defining functions of s variables



On Tue, Jan 08, 2008 at 09:25:40AM -0600, Barton Willis wrote:
> Welcome to Maxima. Here is a function that sums its arguments
> 
> [... snip explanation ...]

Barton,

Thanks for the explanation.  In the meanwhile, I had also found
that I can indeed do something like:


(%i1) f([x]) := product(x[i]^i, i, 1, length(x));
                                       i
(%o1)               f([x]) := product(x , i, 1, length(x))
                                       i
(%i2) f(1, 2, 3);
(%o2)                                 108


But now I want to go one step further and be able to calculate partial
derivatives for an arbitrary s-dimensional function (as it is defined by
the user in his command for defining f([x])).  And this is where I'm stuck.

Take the dimension of x to be three, then the function as I define it
above is:

f(x) = x[1]^1 * x[2]^2 * x[3]^3

and then i want to be able to calculate for example the first partial
derivative to x[1], being:

x[2]^2 * x[3]^3

However, if I try

(%i3) diff(f(x), x[1], 1);
(%o3)                                  0
(%i4) diff(f([x]), x[1], 1);
(%o4)                                 [0]

These results are not what I expect them to be...
I want to be able to do this for whatever partial derivative I need and
for whatever function I a user defines, so not only for the above example
as I have given it.

Any help welcome!
Bart

-- 
	"Share what you know.  Learn what you don't."