I'm new to maxima. And I have two questions:

1. Question I have a little problem with computing vector's magnitude. Now I'm using such form as


This code looks very ugly.

2. Question I thought vector cross product is expressed like a~b. but Maxima says ~ is not an infix operator


3 Answers 3


As far as I know, there is no built-in function to calculate a vector's magnitude, but you can easily define your own:

(%i1) norm(x) := sqrt(x . x)$
(%i2) norm([1, 1]);
(%o2)                               sqrt(2)

The cross product operator ~ is only available after loading 'vect':

(%i1) load("vect")$
(%i2) [1, 2, 3] ~ [2, 3, 4];
(%o2)                        [1, 2, 3] ~ [2, 3, 4]
(%i3) express(%);
(%o3)                            [- 1, 2, - 1]

If you don't mind using lists as vectors a very simple solution would be functions::

cross(u, v) := [u[2] * v[3] - v[2] * u[3], v[1] * u[3] - u[1] * v[3], u[1] * v[2] - v[1] * u[2]]$
dot(u, v) := u[1] * v[1] + u[2] * v[2] + u[3] * v[3]$
norm(u) := sqrt(dot(u, u))$

this is not an ideal nor safe solution but a concise one.


well, I didn't like the vec library, so I decided to write my own functions. here it goes:

/*this function gets 3 values as elements of a 3D vector and gives a (3,1) column matrix as the representation of the vector */

/*this function gets a (3,1) column matrix as representation of a 3D vector and delivers a scalar as the magnitude of the vector*/
vecmag(vecmag_tempvar_V1):= block(


/*this function calculates the vector/cross product of the vector on the left on the vector on the right*/

crosprod(crosprod_temvar_V1,crosprod_temvar_V2):= block(

I have also been working on a maxima library for rigitd body dynamics, specially robotic applications using screw theory in particular. you may find it at github.com/Foadfs/RMaxima.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .