On Tue, Jul 14, 2009 at 7:51 AM, David Webb <david.webb at noc.soton.ac.uk>wrote:
> ...Instead of having to reconstruct each mathematical expression from
> scratch
> using the new terms, it would be more elegant to replace the term in the
> original expression. I've tried using the 'List' operators to do this, as
> for example, the section says that I should be able to use 'cons' with
> functions. However when I try this I get an error, as in,
> ================================
> (%i1) inflag : true;
> (%o1) true
> (%i2) G : diff(f(x,z),z,1);
> d
> (%o2) -- (f(x, z))
> dz
> (%i3) H : cons(p(x)*q(z),rest(G));
> Attempt to differentiate with respect to a number:
> 1
> ================================
>
> It is obviously trying to evaluate (diff, z, 1), the output from 'rest'.
Yes, that's pretty much correct. Here is what is going on.
Let's just consider the formal function 'f':
rest ( f ( a, b, c, ...) ) => f ( b, c, ...)
That is, it preserves the operator, but discards the first operand
(argument).
So rest( 'diff(x,y,1) ) => 'diff(y,1) which means "differentiate y with
respect to 1", which is meaningless and therefore gives an error during
simplification (not evaluation).
What are you actually trying to do? Perhaps something like rest(args(
'diff(x,y,1) )?
-s