assignment question




On Mon, 25 Jan 2010, Robert Herczegh wrote:

< Hello:
< 
< Why doesn't the second assignment work? I want g(x):=x; how do I do that?
< 
< (%i1)    f(x):=x^2;
< (%o1)   f(x):=x^2
< (%i2)    g(x):=diff(f(x),x);
< (%o2)   g(x):=diff(f(x),x)
< 
< Thanks,
< Robert
 
This is on the faq, but here's a simple explanation:

g(x):=foo(x);

says, apply the transformation foo to x.

What you want to do is apply a transformation to f(x), and
have that expression define the transformation of x.

Here are 2 ways;

define(g(x),diff(f(x),x));  /* f(x) has been  defined */

or

diff(f(x),x);
g(x):=''%;

Leo

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