I want to take the directional derivative of the function omega at the point p in the direction V:
omega:x*y*z*z;
p:[2,3,-1];
V:[1,2,3];
p2:p+t*V;
sp:[x=p[1],y=p[2],z=p[3]];
sp2:[x=p2[1],y=p2[2],z=p2[3]];
deltaomega:subst(sp2,omega)-subst(sp,omega);
slope:ratsimp(deltaomega/t);
gVomega:limit(slope,t,0);
This works, but the two substitutions seem a bit hacky. Is there a better way to say 'evaluate omega at p and p+t*V'?
I know there are better ways of doing this! I want to be able to do it from first principles (because I have more complicated versions in mind for which there are no built ins).
I can see at least two ways to do it; we can probably find others as well.
(%i1) omega (x, y, z) := x * y * z^2 $
(%i2) p : [2, 3, -1] $
(%i3) V : [1, 2, 3] $
(%i4) p2 : p + t * V $
(%i5) deltaomega : apply (omega, p2) - apply (omega, p);
2
(%o5) (t + 2) (2 t + 3) (3 t - 1) - 6
... and then the rest is the same. Or define omega
so its argument is a list:
(%i1) omega (p) := p[1] * p[2] * p[3]^2 $
(%i2) p : [2, 3, -1] $
(%i3) V : [1, 2, 3] $
(%i4) p2 : p + t * V $
(%i5) deltaomega : omega (p2) - omega (p);
2
(%o5) (t + 2) (2 t + 3) (3 t - 1) - 6
Notice that in both cases I've defined omega
as a function.