Finding Jacobian matrix for a similar set of equations

12 views (last 30 days)
Hello ,
I want to form a jacobian matrix for a case where i have multiple equations of the same form, e.g. 10 functions F1i of form xi - yi - 1 and similarly 10 of form F2i = xi^2 + yi^2 -1 .
I ultimately want to solve multiple such sets of similar equations using the newton raphson method.
Edit :
I would potentially like to use loops for the equations from say i = 1 : n
  3 Comments
Parthsarthi
Parthsarthi on 30 Mar 2024
Thank you for the response. I am actually looking as to how I could club all the i's from 1 to n , in one vector and them find a jacobian based on it.
Sam Chak
Sam Chak on 30 Mar 2024
Now that you have the Jacobian, could you please demonstrate how you intend to solve this simple problem using the Newton-Raphson method in MATLAB code?
syms x y
F1 = x - y - 1;
F2 = x^2 + y^2 - 1;
eqn = [F1; F2];
J = jacobian(eqn, [x, y])
J = 

Sign in to comment.

Answers (2)

prabhat kumar sharma
prabhat kumar sharma on 14 Apr 2024
Hello Parthsarthi,
I understand that you're looking to solve your system of nonlinear equations using the Newton-Raphson method. For illustrative purposes, let's assume you're dealing with two equations, though this method can be extended to handle more equations and variables.
First, let's define the system of equations and their Jacobian matrix as you have begun. To solve the system using the Newton-Raphson method, you will need an initial guess for the values of x and y. Then, iteratively update these values using the Newton-Raphson formula until convergence is achieved.
For a clearer understanding and potential solution to your issue, you can refer to this MATLAB answer:
I hope this helps!

Nipun
Nipun on 16 Apr 2024
Hi Parthsarthi,
I understand that you want to generalize a system of equations with different orders in a matrix to find the roots using an iterative Newton-Ralphson method. Based on the shared information, I see that you want to first calculate the Jacobian of the generalized matrix and then use the result to iteratively solve for roots.
Bases on the shared information, I assume all coefficients to be 1 and each "x_i" (respectively "y_i") represents a different variable. Since the coefficients are same, a solution to "F11" is same as solution to "F1n" (similar case holds for "F2i").
You can create the Jacobian as follows in MATLAB:
syms x y
F1 = x - y - 1;
F2 = x^2 + y^2 - 1;
eqn = [F1; F2];
J = jacobian(eqn, [x, y])
J =
For more information on "solving equations using symbolic math" in MATLAB, refer to the following MathWorks documentation:
If you intend to create a column vector of "F1i" and a separate column vector for "F2i" with varying "i", use the following MATLAB script:
n = 10;
xi = sym('x', [1 10])
yi = sym('y', [1 10])
F1i = xi - yi - 1;
F2i = xi.^2 + yi.^2 - 1;
J1i = jacobian(F1i, [xi, yi])
J2i = jacobian(F2i, [xi, yi])
xi =
yi =
J1i =
J2i =
Hope this helps.
Regards,
Nipun

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!