clue needed on using results of previous computations
Subject: clue needed on using results of previous computations
From: Stavros Macrakis
Date: Thu, 5 Sep 2002 13:57:18 -0400
Rich--
Solve returns equations rather than expressions because sometimes it
does not get a fully explicit solution. For example:
solve(f(x)-3=2*f(x),x)
=>
[ f(x) = -3 ]
--------------
I think the way I would do your problem is as follows:
expr: x*x + 5*g*x /* No reason to define as an equation with y
*/
dexpr: diff(expr1,x) /* No reason to define a function f */
sols: solve(dexpr1=0,x)
=>
[ x = -5*g/2 ]
/* Verify that solutions are explicit by eye */
vals: map(rhs,sols); /* Preserves multiple solutions */
plot2d(vals,[g,0,10])
or, more concisely:
plot2d(map(rhs,solve(diff(EXPR,x),x)),[g,0,10])
if you're confident that the solutions will be explicit.
Of course, whether this makes sense in the general case depends on how
you want to generalize....
-s