# How do I create a Jacobian matrix for a large system of equations?

I would like to create a Jacobian matrix using the simplified functions below:

f1[a_,b_,c_]:= a^2 + b^2
f2[a_,b_,c_]:= c/2
f3[a_,b_,c_]:= b^3


I say simplified because in the actual code that I'm working on, there are 14 functions and hence 14 variables defined for each function, all defined as f1,f2,...f14. Because of the large size, I wanted to get an idea about how I could implement the following code on the wolfram site possibly using iteration:

JacobianMatrix[f_List?VectorQ, x_List] :=
Outer[D, f, x] /; Equal @@ (Dimensions /@ {f, x})



Here is way to iterate over a list of functions applying each function to the same sequence of variables.

funcs = {f1, f2, f3};
vars = {x, y, z};
h = Table[g @@ Sequence@vars, {g, funcs}];
JacobianMatrix[h, vars]


A more compact way to get the Jacobian matrix is

Outer[D, Through[funcs @@ Sequence@vars], vars]

• I get an error. For funcs, would I have to do {f1[a_,b_,c_],f2[a_,b_,c_],f3[a_,b_,c_]}? – K.M Apr 27 '19 at 21:31
• The underscore (Blank) is used to define functions, but not in when evaluating the functions. So, no, don't use Blank in your argument list, or in your list of variables. You may need to do something like ClearAll on your functions and/or variables. Or you may want to quit the kernel and then re-evaluate your notebook. Please describe the error in more detail. Do you mean it doesn't work with the 3 example functions, or it doesn't work with your 14 actual functions? Does it fail on one function in particular? Can you add any of your functions to the question? – LouisB Apr 27 '19 at 21:59