Skip to contents

Arithmetic operations for three-velocities

Usage

# S3 method for class '3vel'
Ops(e1, e2)
# S3 method for class '4vel'
Ops(e1, e2)
massage3(u,v)
neg3(u)
prod3(u,v=u)
add3(u,v)
dot3(v,r)

Arguments

e1,e2,u,v

Objects of class “3vel”, three-velocities

r

Scalar value for circle-dot multiplication

Details

The function Ops.3vel() passes unary and binary arithmetic operators “+”, “-” and “*” to the appropriate specialist function.

The most interesting operators are “+” and “*”, which are passed to add3() and dot3() respectively. These are defined, following Ungar, as:

$$ \mathbf{u}+\mathbf{v} = \frac{1}{1+\mathbf{u}\cdot\mathbf{b}/c^2} \left\{ \mathbf{u} + \frac{1}{\gamma_\mathbf{u}}\mathbf{v} + \frac{1}{c^2}\frac{\gamma_\mathbf{u}}{1+\gamma_\mathbf{u}} \left(\mathbf{u}\cdot\mathbf{v}\right)\mathbf{u} \right\} $$

and

$$ r\odot\mathbf{v} = c\tanh\left( r\tanh^{-1}\frac{\left|\left|\mathbf{v}\right|\right|}{c} \right)\frac{\mathbf{v}}{\left|\left|\mathbf{v}\right|\right|} $$

where \(\mathbf{u}\) and \(\mathbf{v}\) are three-vectors and \(r\) a scalar. Function dot3() has special dispensation for zero velocity and does not treat NA entries entirely consistently.

Arithmetic operations, executed via Ops.4vel(), are not defined on four-velocities.

The package is designed so that natural R idiom may be used for three velocity addition, see the examples section.

Value

Returns an object of class 3vel, except for prod3() which returns a numeric vector.

Examples

u <- as.3vel(c(-0.7, 0.1,-0.1))
v <- as.3vel(c( 0.1, 0.2, 0.3))
w <- as.3vel(c( 0.5, 0.2,-0.3))

x <- r3vel(10)   # random three velocities
y <- r3vel(10)   # random three velocities


u+v   # add3(u,v)
#> A vector of three-velocities (speed of light = 1)
#>              x         y         z
#> [1,] -0.648977 0.2557545 0.1246803
u-v   # add3(u,neg3(v))
#> A vector of three-velocities (speed of light = 1)
#>               x           y          z
#> [1,] -0.7434641 -0.03267974 -0.2913943

-v    # neg3(v)
#> A vector of three-velocities (speed of light = 1)
#>         x    y    z
#> [1,] -0.1 -0.2 -0.3

gyr(u,v,w)
#> A vector of three-velocities (speed of light = 1)
#>              x         y          z
#> [1,] 0.5134003 0.2390541 -0.2434611

## package is vectorized:


u+x
#> A vector of three-velocities (speed of light = 1)
#>                 x          y           z
#>  [1,] -0.37813088  0.7164543 -0.14413320
#>  [2,] -0.96917803  0.1213830 -0.13643205
#>  [3,] -0.89948535  0.1233824  0.03639300
#>  [4,] -0.72380488  0.3838240  0.47428504
#>  [5,] -0.71114361  0.2906807 -0.26074149
#>  [6,] -0.44775710 -0.3120654 -0.49728634
#>  [7,] -0.60312719 -0.6954248  0.20761025
#>  [8,] -0.18093716 -0.1923201 -0.13458184
#>  [9,] -0.01122963  0.6288590  0.17949973
#> [10,] -0.78931218 -0.3501581  0.05550188
x+y
#> A vector of three-velocities (speed of light = 1)
#>                x          y           z
#>  [1,]  0.8447803  0.2635985  0.07562038
#>  [2,] -0.8582900  0.3694929 -0.34551186
#>  [3,] -0.3458708 -0.1200680  0.76226856
#>  [4,] -0.1432127  0.1191482  0.88090820
#>  [5,] -0.5801394  0.7018523 -0.17781538
#>  [6,]  0.4690749 -0.5528338 -0.46070785
#>  [7,]  0.1536270 -0.9477491  0.27945350
#>  [8,]  0.3673964 -0.6067629 -0.11334442
#>  [9,]  0.8548057  0.3515789 -0.18818034
#> [10,]  0.5162692 -0.8062846  0.17567527

f <- gyrfun(u,v)
g <- gyrfun(v,u)

f(g(x)) - x    # should be zero by eqn10
#> A vector of three-velocities (speed of light = 1)
#>                   x             y             z
#>  [1,] -6.654321e-16 -4.436214e-16  8.317901e-17
#>  [2,]  1.449847e-15  2.718464e-16  1.812309e-16
#>  [3,]  2.974155e-16  9.559783e-17  1.805737e-16
#>  [4,] -8.776910e-16  1.101416e-15  8.260621e-16
#>  [5,] -3.322553e-16 -1.200673e-16  4.140253e-18
#>  [6,] -3.334777e-16  4.446369e-16  4.446369e-16
#>  [7,] -4.617349e-16  1.846940e-15 -6.926024e-16
#>  [8,] -2.879568e-16  1.799730e-16 -1.968455e-18
#>  [9,] -5.329071e-16  0.000000e+00  2.220446e-16
#> [10,]  1.342252e-17  1.610703e-16  2.684505e-17
g(f(x)) - x
#> A vector of three-velocities (speed of light = 1)
#>                   x             y             z
#>  [1,] -7.393690e-16  4.436214e-16  7.393690e-17
#>  [2,]  5.074466e-15 -2.265387e-16  1.178001e-15
#>  [3,] -8.922464e-16  2.443056e-16  5.098551e-16
#>  [4,] -8.260621e-16  1.239093e-15  1.101416e-15
#>  [5,]  1.749257e-16 -5.382329e-17  1.242076e-16
#>  [6,]  0.000000e+00  1.111592e-16 -5.557961e-17
#>  [7,] -2.308675e-16  9.234698e-16 -2.308675e-16
#>  [8,] -2.879568e-16  1.079838e-16  2.287157e-17
#>  [9,]  0.000000e+00  8.881786e-17 -4.440893e-17
#> [10,] -4.160982e-16  3.221406e-16  1.073802e-16


(u+v) - f(v+u)                     # zero by eqn 10
#> A vector of three-velocities (speed of light = 1)
#>                  x            y            z
#> [1,] -6.132309e-16 1.951189e-16 1.672448e-16
(u+(v+w)) - ((u+v)+f(w))           # zero by eqn 11
#> A vector of three-velocities (speed of light = 1)
#>                  x y             z
#> [1,] -5.469679e-17 0 -5.469679e-18
((u+v)+w) - (u+(v+g(w)))           # zero by eqn 11
#> A vector of three-velocities (speed of light = 1)
#>                 x            y            z
#> [1,] 3.951349e-16 -2.99021e-16 1.975675e-16


## NB, R idiom is unambiguous.  But always always ALWAYS use brackets.

## Ice report in lat 42.n to 41.25n Long 49w to long 50.30w saw much
## heavy pack ice and great number large icebergs also field
## ice.  Weather good clear

## -u+v == (-u) + v == neg3(u) + v == add3(neg3(u),v)

## u+v+w == (u+v)+w == add3(add3(u,v),w)