Non-variable 2nd argument to DIFF:



Your legendre_root function, used in

            x : legendre_root(order,i),

returns a number, e.g.:

(%i46) legendre_root(4,0);
                              sqrt(15 - 2 sqrt(30))
(%o46)                      - ---------------------
                                    sqrt(35)

This number is then supplied as the function argument xi:

            sum : sum + (w * func(x))),

to your anonymous (lambda) function. The function then calls diff() with xi
as its second argument, i.e., it tries to differentiate with respect to a
number, as opposed to a variable:

(%i47) diff(phi1(xi)*A(xi,t),%);

Non-variable 2nd argument to diff:
errexp1
 -- an error.  Quitting.  To debug this try debugmode(true);



Viktor
 

-----Original Message-----
From: maxima-admin@math.utexas.edu [mailto:maxima-admin at math] On
Behalf Of Angus Leeming
Sent: Wednesday, May 11, 2005 10:25 AM
To: maxima@math.utexas.edu
Subject: Non-variable 2nd argument to DIFF:

Hello,

I'm a newbie who is trying to write a function that accepts a function in
its 
argument list. Unfortunately, I'm failing, so:

/* Function to perform the numerical integration */
quad(order,func):=
    block([sum, x, w],
        sum:0,
        for i:0 thru order-1 do (
            x : legendre_root(order,i),
            w : gauss_legendre_weight(order,i),
            sum : sum + (w * func(x))),
        return(sum)
    )$

Ai11(xi):=phi1(xi)*V1*diff(phi1(xi)*A(xi,t),xi);
A11q:quad(4,lambda([xi],Ai11(xi)));

(%i336)             A11q : quad(4, LAMBDA([XI], Ai11(XI)))
Non-variable 2nd argument to DIFF:
ERREXP1

I can see what the problem is, but I have no idea about how to fix it. Any 
clues? (Full script attached.)

Regards,
Angus