Search code examples
maximawxmaxima

How to properly substitute a value to the variable used in formula in wxMaxima?


I calculated a velocity vector and its module from the equations of motion of a point in wxMaxima:

x:3*sin(4*t);
y:2*cos(4*t);
r:[x,y];
v:diff(r,t,1);
v_mod:sqrt(v.v);

Now I would like to calculate the velocity for t=5. How can I do this? When I add (t) and := everywhere, like this:

x(t):=3*sin(4*t);
y(t):=2*cos(4*t);
r(t):=[x(t),y(t)];
v(t):=diff(r(t),t,1);
v_mod(t):=sqrt(v(t).v(t));

and then add this line at the end:

v_mod(5);

I get the following error:

diff: second argument must be a variable; found 5

What am I doing wrong here?


Solution

  • The problem is that when you say v(5), you're getting diff(<something>, 5) and Maxima is complaining about that.

    Try v(t) := at(diff(r(u), u), u = t) -- i.e., differentiate wrt a dummy variable u, and then evaluate that derivative at u equal to the argument t.

    There are other ways to go about it. If at doesn't work for you, we can try something else.