Newton's Method for systems

15 ビュー (過去 30 日間)
Mel Hernandez
Mel Hernandez 2018 年 4 月 6 日
コメント済み: Mel Hernandez 2018 年 4 月 7 日

I'm trying to figure out what step 3 means in the picture attached. I know it's finding the Jacobian, but I don't understand what that means in 'Matlab code.' Also, if possible, is my code correct so far? This is what I have so far:

 function [x,ERR,k] = newtonMethod(f,j,x,Nmax,tol)
 % Inputs:
 %number of equations and unknowns, x0 = initial guess, Nmax = max iterations, 
 %tol =tolerance
 % Outputs: 
 %x = solution, ERR = error estimation, k = iterations
 %Step 1
 k = 1; ERR = 1; Niter = 50; x=x0; %tol = 10e-10;
 %Step 2
 while (k < Niter)
    %Step 3 - Compute F(x), J(x)
    %Step 4 - Solve for y s.t. J(x)*y = -F(x) using y = J\-F
    y = J(x)\(-F(x));
    %Step 5 - Set x = x + y
    x = x + y;
    %ERR
    ERR = norm(y,'inf');
    %Step 6
    if (ERR < tol)
        fprintf('convergent')
        break
    end
   %Step 7
    k = k+1;
 end
 end
  2 件のコメント
James Tursa
James Tursa 2018 年 4 月 6 日
How are you given f? Is it a function handle? Did the instructor tell you to use numerical difference methods to approximate the Jacobian?
Mel Hernandez
Mel Hernandez 2018 年 4 月 7 日
I believe we're supposed to input what f is, the system of equations. And the instructor didn't say. I didn't know if it would be better to do it in matlab (using jacobian command) or to do it by hand then say what it is as J. I'm just trying to understand Step 3.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by