Another service from Omega

Working with Vectors in Maple


*****


We show here different ways for manipulating vectors with Maple. First you need to load the linear algebra package into your maple session. Most of the commands for computing with vectors are defined in the "linalg" package so it is a good idea to always start with:


> with(linalg):





Notice that I ended the previous command with ":" instead of ";". You may want to experiment and try both ways of ending commands. Do you see the difference?

Next we need to enter some vectors to maple. The command "vector" will do this. Here are several examples:


> v := vector([x,y,z]);


                                v := [ x, y, z ]




The vector is entered as a list and you can access each of its components with v[1], v[2], v[3]. So for example,


> v[1]+v[3]^2;


                                          2
                                     x + z




which is the sum of the first entry of the vector "v" plus the square of its third entry.

If you want a symbolic vector of dimension three you do:


> u := vector(3);


                             u := array(1 .. 3, [])




If you want to see the entries try:


> evalm(u);


                              [ u[1], u[2], u[3] ]




Notice that just typing "u;" doesn't work the way you expect. For example,


> uPlusv := u + v;


                                uPlusv := u + v




does not evaluate. To see the entries you need to use "evalm" which stands for EVALuate as a Matrix. So now


> evalm(uPlusv);


                        [ u[1] + x, u[2] + y, u[3] + z ]




and you get the components of the sum of the two vectors "u" and "v". There is still one more way to use "vector". This is the function form of the "vector" command.


> w := vector(7, i -> i^2-1);


                        w := [ 0, 3, 8, 15, 24, 35, 48 ]




Notice that here, the function is a function of only one variable. The result contains the 'square minus one' of the first seven positive integers.

Multiplication by a scalar is simply done with


> evalm( a*v );


                               [ a x, a y, a z ]




Innerproducts are computed with


> innerprod(v,u);


                            x u[1] + y u[2] + z u[3]




and the angle (in radians) between two vectors is given by


> angle( [1,1] , [0,1] );


                                     1/4 Pi




Notice that it was not necessary to define [1,1] and [0,1] with the vector command. To "convert" to degrees just do:


> convert(",degrees);


                                   45 degrees




or you can pack it all into one line like:


> evalf( convert( angle( [-2,sqrt(2),1] , [2,-1,1] ) , degrees ) );


                              132.9318473 degrees



Homework Problem:

Velocities have both direction and magnitude and so are vectors. The magnitude of a velocity vector is called speed. Suppose that a wind is blowing from the direction N45W at a speed of 50 km/h. (This means that the direction from which the wind blows is 45 degrees west of the northly direction.) A pilot is steering a plane in the direction N60E at an airspeed (speed in still air) of 250 km/h. The true course, or track, of the plane is the direction of the resultant of the velocity vectors of the plane and the wind. The ground speed of the plane is the magnitude of the resultant. Use maple to find the true course and the ground speed of the plane. Answer


Link to the commands in this file
Carlos Rodriguez <carlos@math.albany.edu>
Last modified: Wed Oct 23 09:36:59 EDT 1996