C code generation



> I tried something like this:
> R11: ev(diff(x1, x0, 1), [x0=0,x0p=0,y0=0,y0p=0,delta=0]);
> and maxima said Non-variable second argument to diff.
>
> I split this into two commands with intermediate storage of the
> derviative and it worked fine.

The "ev" command (a pseudo-function) evaluates its first argument with
the given variables set to the given values.  So what the 'diff' command
sees is diff(x1,0,1), hence the error message.

In general, "ev" and other pseudo-functions (which don't evaluate their
arguments in the usual way) can be tricky to use.

The "at" function is probably what you want here:

   at(diff(y^2/x^3,x),[x=2,y=3]) => -27/16

You can see the difference by tracing the DIFF function:

(C1) trace(diff)$

(C2) ev(diff(log(x)/(1-x*y),x),[x=1,y=1/2]);

   1 Enter DIFF [0, 1]
   Non-variable 2nd argument to DIFF:
   1
   -- an error.

(C3) at(diff(y^2/x^3,x),[x=2,y=3]);

                 2
                y
  1 Enter DIFF [--, x]
                 3
                x
                    2
                 3 y
  1 Exit DIFF  - ----
                   4
                  x

                   27
(D3)             - --
                   16