Solving a system with Newton's method in matlab?
4 ビュー (過去 30 日間)
古いコメントを表示
I have the following system to solve with Newton's method in matlab:

I tried with two variables but I need to solve the system to get the roots a_i and a_j. for i,j=1.2....N (N=1000)
function [a,F,itr] = newtonsys(Ffun,Jfun,a0,B,L,tol ,nmax)
itr= 0; err = tol + 1; a = a0;
while err >= tol & itr< nmax
J =Jfun(a,B,L);
F =Ffun(a,B,L);
delta = - J\F;
a = a + delta;
err = norm(delta,inf);
itr = itr+ 1;
end
return
function F=Ffun(a,B,L)
F(1 ,1) =a(1)*tan(a(1))-B*(1-L*(a(1).^2+a(2).^2));
F(2 ,1) =a(2)*tan(a(2))-B*(1-L*(a(1).^2+a(2).^2));
return
function J=Jfun(a,B,L)
J(1 ,1) =tan(a(1))+a(1)*( tan(a(1)).^2+1); J(1 ,2) = 2*B*L*a(2);
J(2 ,1) =2*B*L*a(1); J(2 ,2) =tan(a(2))+a(2)*( tan(a(2)).^2+1);
return
clc
a0=[10;10]; tol=1e-5; nmax=10000; B=0.1; L=0.1;
[a,F,itr]= newtonsys(@Ffun,@Jfun,a0,B,L,tol,nmax)
I'm a newbie, somebody please help me. thanks a lot advance!
7 件のコメント
Torsten
2023 年 1 月 4 日
編集済み: Torsten
2023 年 1 月 4 日
it is not an exercise, it is one of my projects and I arrived at this (solution , and the roots equation )
Then you must have made a mistake.
As already stated, all alpha_i arbitrary and equal is a solution. And I don't see how you could impose the condition that they should be different for a nonlinear solver.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


