MATLAB: How to create a jacobian matrix for newton methods using multiple variables

jacobianmultiple variablesnewton-ralphson

I am trying to create a jacobian matrix using the equations
f1= x^2 +2x+2y^2-26 and f2=2x^3-y^2+4y-19
I haven't seen other codes that use more of the same variable (x^2, 2x) per equation, usually it's one x and one y variable. Does anyone have any advice or ideas on how to create the matrix?

Best Answer

If you have the symbolic toolbox, then
syms x y
f1 = x^2 +2*x+2*y^2-26
f2 = 2*x^3-y^2+4*y-19
jacobian([f1, f2], [x,y])
If you do not have the symbolic toolbox then you will need to do the computations the usual way,
[diff(f1,x), diff(f1, y); diff(f2, x), diff(f2, y)]