# How To First Evaluate A Differential Equation And Then To Input The Function Parameters?

I have two functions:

f1[x1_,x2_] := 2x1*x2
f2[x1_,x2_] := x1+x2*x1


and I would like to compute this matrix (linearization of the system), but the differentials should first be taken and then the x1, x2 input should be applied. How do I do it?

I tried:

m[x1_, x2_] := {{D[f1[x1, x2], x1],
D[f1[x1, x2], x2]}, {D[f2[x1, x2], x1], D[f2[x1, x2], x2]}}


but it does not work...

EDIT: The documentation was not very clear to me, so for people who also need a bit of help to understand the difference of "Set" and "Set Delay" :

The function definition without ":" before the "=" (Set) evaluates the function a first time and the output is assigned to m[x1_,x2_], so if you input values they are feed into the already-differentiated equations.

If now, you use ":" before the "=", (Set Delay), it evaluates the function when it is needed, hence it will evaluate the function only when values for x1 and x2 are set, hence it will not work, since one cannot differentiate a function with respect to 5 (a numerical value for example).

• You are using double [[ ]] on your definition of m. Should be single [ ] for a function definition. Commented Oct 16, 2016 at 8:37
• Thanks. Did not see that, but still does not work, since I first want to calculate the differential and then input the x1 and x2 values. Commented Oct 16, 2016 at 8:41

f1[x1_, x2_] = 2 x1*x2;
f2[x1_, x2_] = x1 + x2*x1;


{{2 x2, 2 x1}, {1 + x2, x1}}

m[1, 2]
{{4, 2}, {3, 1}}


Edit

To answer your question in the comment: Look up in the documention Set' and 'SetDelayed' . Note the two examples:

1.)

f1[x1_, x2_] := 2 x1*x2;
f2[x1_, x2_] := x1 + x2*x1;

{{2 x2, 2 x1}, {1 + x2, x1}}
m[1, 2]
{{4, 2}, {3, 1}}


2.)

f1[x1_, x2_] := 2 x1*x2;
f2[x1_, x2_] := x1 + x2*x1;
`