![]() % Following the steps you provided and the Newton-Raphson for one variable: % it instead of working with symbolic variables. So it is computationally much more efficient to use fun and jacobian are function handles to the equations and % Here we take advantage of MATLAB syntax to easily implement our % nonlinear system of equations F, with jacobian J, given an initial % This function uses the Newton-Raphson method to find a root for the Let's use it to code our Newton-Raphson: function x = newton(fun,jacobian,x0) Your logic for the Newton-Raphson is correct. Create a function to calculate the Jacobian as a function of the variables. The functions are simple, so you can do it manually. The Newton-Raphson algorithm requires the evaluation of the Jacobian. This creates the column-vector function F as a function of the variables x1 (x) and x2 (y). The provided system of nonlinear equations can be written in vector form as: function fx = F(x)įx = zeros(2,1) % pre-allocate to create a column-vector I will also slightly change some of the notation you provided so you can fully see the MATLAB easy to use syntax. ![]() I will not solve the entirety of the problem, as you said it appears your Gauss-Seidel is working. Your problem is to couple the Newton-Raphson and the Gauss-Seidel solvers.
0 Comments
Leave a Reply. |