Michael's answer is good, but it does the differentiation everytime g(x)
is called. (Also, normally you see it wrapped in a block
statement to ensure that y
is properly localized).
There is a way to force the RHS to evaluate at the time of definition
and with the general x
.
The syntax is
(%i1) f(x) := 2*x^4;
4
(%o1) f(x) := 2 x
(%i2) g(x) := ''(diff(f(x), x) - 8);
3
(%o2) g(x) := 8 x - 8
(%i3) g(0);
(%o3) - 8
Compare with the block construct:
(%i4) h(x) := block([y], subst([y = x], diff(f(y), y) - 8));
(%o4) h(x) := block([y], subst([y = x], diff(f(y), y) - 8))
(%i5) h(0);
(%o5) - 8
Notice (%o4) which shows that the RHS is unevaluated.
Ref: http://www.math.utexas.edu/pipermail/maxima/2007/004706.html