Subject: implicit diff & subst problems... /just to you.
From: Evan Cooch
Date: Thu, 06 Oct 2011 12:02:01 -0400
On 10/6/2011 10:32 AM, Richard Fateman wrote:
> Somehow you really seem to be missing the point.
>
> diff(f(x),x) is an expression. If f is "undefined" it is left alone.
>
> substituting a number, say 3, for x in that expression produces
> NONSENSE, namely
> diff(f(3),3).
>
> One cannot compute a derivative with respect to a number.
>
No, but I can evaluate a derivative at a number. A derivative has
heuristic meaning, but is also just an equation. I simply want to
evaluate the equation at a particular value of all the parameters in the
equation. You implicitily differentiate one equation yielding another
equation, which you then evaluate.
y^2+x^2=25
implicit diff of y on x: -x/y
evaluate for x=3, y=2 : -3/2
Thats all I'm interested in doing. In Maple (for example), its a simple as
f:=x^2+^2=25;
implicitdiff(f,y,x);
subs(x=3,y=2,%);
Done -- returns -3/2.
Now, an earlier answer gave me a clue as to how to accomplish this in
Maxima -- it looks (to me) like when I execute the following
--> mat:matrix([0,s_a*m_2,s_a*m_3],[s_o,0,0],[0,s_a,0]);
--> cp:charpoly(mat,lambda);
--> depends(lambda,s_a);
--> deriv:diff(cp,s_a);
--> sol:solve(deriv,'diff(lambda,s_a));
then what Maxima returns for sol is a vector, or some similar construct,
where there is importance to the the LHS and RHS (which appear to be
separately addressable), and that to use subst, you need to tell it to
look/focus on the RHS, and ignore the LHS, where the LHS indicates that
it is a derivative, which is true, but irrelevant to the purpose of
numerically evaluating the function.
(%o9)
['diff(lambda,s_a,1)=(m_2*s_o*lambda+2*m_3*s_a*s_o)/(3*lambda^2-m_2*s_a*s_o)]
My clue (prompted by the earlier email) was noticing that sol is
returned inside [ ]. So, the LHS has a distinct 'meaning', as does the
RHS. I'm only interested in the 'equation' (RHS), so I simply subst
values for all the parameters into the RHS
(%i10)
subst([s_a=0.8,s_o=0.5,m_2=1.2,m_3=1.4,lambda=0.9704],rhs(first(sol)));
(%o10) 0.725893103012548
which is exactly what I was looking for. As Rupert Swarbrick usefully
noted in his reply (which is whee the light bulb started to flicker on
over my head), when Maple does implicit differentiation,
> implicitdiff(cp,lambda,s_a);
2
s_o (m_2 lambda + 3 s_a m_3)
-----------------------------
2
3 lambda - s_o s_a m_2
This doesn't have the left hand dlam/ds_a part, so substitution
actually makes sense.
Exactly -- dlam/ds_a isn't a 'part' of the answer because Maple
basically processes (differentiates) one equation yielding another
equation, which is stateless -- in Maple, an equation doesn't have an
implicit context based on how it was derived. This seems to not be the
case for Maxima, where the LHS (dlam/ds_a in the example), actually has
meaning and context. And which is why subst didn't work when I tried it
initially.
So, my confusion stemmed from the fact the Maple (where I'm coming from)
doesn't 'care' about the source of the expression you're trying to subst
into, whereas Maxima does (more or less).