how to substitute known values




On Tue, 5 Apr 2011, Barton Willis wrote:

< 
< -----maxima-bounces at math.utexas.edu wrote: -----
< 
< >depends(x,t);
< >depends(y,t);
< >c(t):=sqrt(x^2+y^2);
< >diff(c(t),t);
< >
< >...?I?want?to?substitute?specific?values?of?x,?y,?dx/dt,?and?dy/dt?into
< >the?resulting?expression?for?dc/dt. What?is?the?simplest?way?to?do?that?
< 
< The function subst can do this, but it's tricky:
< 
< OK:
<   (%i21) subst([diff(x,t) = 5, diff(y,t)=7, x = 3, y = 4], diff(sqrt(x^2+y^2),t));
<   (%o21) 43/5
< 
< Not OK:
< 
<  (%i16) subst([x=3, y=4, diff(x,t) = 5, diff(y,t)=7], diff(sqrt(x^2+y^2),t));
<  (%o16) 0
< 
< In the last calculation, the substitution x = 3, causes diff(x,t) --> diff(3,t) --> 0.
< The user documentation for 'subst' does say that the substitutions are made from left
< to right.
 
 I think the function you want is psubst.

 psubst([x=3, y=4, diff(x,t) = 5, diff(y,t)=7], diff(sqrt(x^2+y^2),t));

 should do what you want.

 Leo
-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.