Question: Multivariable functions f(x1,x2,x3)

Hi!

I am trying to convert expressions into functions, but the expressions have many variables x1, x2, x3.....xn.
The reason I am doing this is because I am hoping that differentiating functions in a large jacobian with large multivariable functions will go faster with functions than expressions. If it doesn't go faster then let me know.

What I am trying to do in a simplified code,

xv:=Vector(2,symbol=x):
f[1]:=x[1]+x[2];
f[2]:=x[1]-x[2];

f[1]:=unapply(f[1],[xv[1],xv[2]]);

Diff(f[1],x[1]);



                          f1:=x[1] + x[2]
                          f2:=x[1] - x[2]
f1:=(x_1, x_2) -> x_1 + x_2
                            d        
                          ------ f[1]
                           dx[1]     

 

 

How can I get this to work? And is it worth it?

Please Wait...