clue needed on using results of previous computations
Subject: clue needed on using results of previous computations
From: Rich Drewes
Date: Wed, 4 Sep 2002 21:21:42 -0700 (PDT)
Hello,
I am making a dogged effort to use Maxima in a graduate math class,
despite the bias toward Maple and Mathematica. I have had some success
but I am having great problems doing a couple of things that seem trivial
in Maple. I think this is because I just lack one crucial clue, and
hopefully someone out there can help me out.
Here is one problem I am having. Take a function, e.g.:
y=x*x + 5*g*x;
Say I want to plot x and g that maximizes y. So, differentiate the
function with respect to y, set equal to 0, and plot the x and g that
satisfy that equation. Sounds simple, and in Maple it is, but in Maxima I
can't get past some conceptual hurdle. Let's try this in Maxima:
eq1: y(x, g):=x*x + 5*g*x;
and that works. We can differentiate with respect to x just fine:
diff(y(x, g), x);
which gives 2 x + 5 g as we expect. So set this =0 and solve for x:
eq2:solve(diff(y(x, g), x) = 0, x);
This gives us a result of x=-5*g/2 as it should. However, and this is
where my conceptual problem arises, Maxima seems to treat that result
as (forgive my terminology) an 'equation' rather than a 'function',
and further manipulation is therefore difficult. We can examine eq2:
eq2;
and that does spit back x=-5*g/2. But how can we plot this? How can
we differentiate it further, with respect to g say? For example,
plot2d(x, [g, 0, 10]);
fails, saying that the 'function ~a is undefined', whatever that is.
Nor does:
plot2d(eq2, [g, 0, 10]);
work. I can use ev() to evaluate this equation at some g, for example:
ev(eq2, g:5);
does what you would expect. I could do an explicit redifinition by typing
this in:
f(g):=-(5*g)/2;
and then this plot works:
plot2d(f(g), [g, 0, 10]);
But that's a pain in general. I also can't differentiate this again:
diff(eq2, g);
since that returns the nonsensical "0=-5/2" rather than something
symbolically reasonable like dx/dg=-5/2, where dx/dg can be referenced
symbolically in another computation. (Interestingly, if I do a
"depends(f, g)" and then do the "diff(eq2, g)", I do get the result
dx/dg=-5/2, but I still cannot reference the dx/dg result in other
computations as a symbol . . .)
I guess the clearest statement of my conceptual problem is this: whereas
Maple's results seem to be treated in the same class as the stuff you type
in directly, and these results are trivial to manipulate further and
combine with other equations, in Maxima the results of operations seem to
be treated as equations rather than functions, and they become difficult
to manipulate further and I quickly get into the position of having to
redefine functions explicitly by typing it back in as above, which is
obviously a waste of time.
Does this make sense to anyone?
Thanks,
Rich