next up previous
Next: Operations On Vector Up: OPERATIONS ON VECTORS Previous: OPERATIONS ON VECTORS

Vector Operations

The vector operations are in the linalg package.

with(linalg):            load linalg package - once each Maple session
a := vector( [2,3,7] );  b:=vector( [-3,4,2] );       defines vectors a,b
dotprod(a,b);                    dot product of a and b
lena := sqrt( dotprod(a,a) );    length of a is sqrt(a.a)
crossprod(a,b);                  crossproduct of a and b
c := evalm( 3*a-b/2 );           evaluate 3a-b/2                    
c[1]; c[2]; c[3];                the 1st, 2nd, 3rd entries of c
The last two commands are worth noting. See what happens if you drop the evalm.

To differentiate or integrate a vector function we must integrate or differentiate each term of the vector. Whenever a command has to be applied to each term of a vector then the map command is used. e.g.

r := vector( [sin(t), t+cos(t), t*sin(2*t)] );
rp := map( diff, r, t );            compute r' i.e. dr/dt
junk := map( int, r, t=0..Pi/2 );   compute integral of r for t=0..Pi/2
As a use of the above tools we consider the following question.
Given , the trajectory of a particle, determine the tangent vector T, the normal vector N, the curvature at time t, and the distance covered by the particle in the period 0<t<3.

r := vector( [t^2, t, 3*t] );
rp := map( diff, r, t );          dr/dt
speed := sqrt( dotprod(rp,rp) );  speed = ||dr/dt||
tang := evalm( rp/speed );        T = tang = dr/dt / ||dr/dt||
dist := int( speed, t=0..3 );     dist covered in t=0..3. Note map not
evalf( dist, 5 );                 used because speed is not a vector    
Tp := map( diff, tang, t );       Tp = dT/dt
kN := evalm( Tp/speed );          This is curvature*N     
kN := map( simplify, kN );        simplify each term of k*N
k := sqrt( dotprod(kN,kN) );      curvature
k := simplify(k);
N := evalm( kN/k );               Normal vector
map( simplify, N, assume=real );  simplify assuming sqrt is real
Remark: In Maple, if ever your vector calculations do not work as you think they should, then check whether you have used evalm in the appropriate places.



Peter Monk
Tue Aug 29 14:41:29 EDT 1995