Azzera filtri
Azzera filtri

How can i generate solution using Newton Raphson Method for two equations and two unknowns?

6 visualizzazioni (ultimi 30 giorni)
hello,
i have a specific two equiations,How can i solve it using Newton Raphson? I'm waiting your solutions.. Thanks..
My Unknows - Ht and Hs
and Equations
F1 = -24818293809749471470110210071781/618970019642690137449562112/Hs^2+56127954443102947/5070602400912917605986812821504*Hs^(31/10)+69817699429225617/5070602400912917605986812821504*Hs^(41/10)/Ht+488723896004579319/50706024009129176059868128215040000*Hs^(41/10)-3058826600166217/38685626227668133590597632*Ht^(7/2)/Hs^2
F2 = -24818293809749471470110210071781/618970019642690137449562112/Ht^2-6844872493061335/2535301200456458802993406410752*Hs^(51/10)/Ht^2+21411786201163519/77371252455336267181195264*Ht^(5/2)/Hs+15294133000831085/77371252455336267181195264*Ht^(3/2)+149882503408144633/773712524553362671811952640000*Ht^(5/2)
F1=F2=0

Risposta accettata

Jose Jeremias Caballero
Jose Jeremias Caballero il 4 Gen 2013
Modificato: Jose Jeremias Caballero il 4 Gen 2013
clear all
xo=[1;1] ;
syms Hs Ht
fname=[-24818293809749471470110210071781/618970019642690137449562112/Hs^2+56127954443102947/5070602400912917605986812821504*Hs^(31/10)+69817699429225617/5070602400912917605986812821504*Hs^(41/10)/Ht+488723896004579319/50706024009129176059868128215040000*Hs^(41/10)-3058826600166217/38685626227668133590597632*Ht^(7/2)/Hs^2;
-24818293809749471470110210071781/618970019642690137449562112/Ht^2-6844872493061335/2535301200456458802993406410752*Hs^(51/10)/Ht^2+21411786201163519/77371252455336267181195264*Ht^(5/2)/Hs+15294133000831085/77371252455336267181195264*Ht^(3/2)+149882503408144633/773712524553362671811952640000*Ht^(5/2)];
fprima=jacobian(fname);
epsilon=1.e-10;
maxiter = 30;
iter = 1;
f=inline(fname);
jf=inline(fprima);
error=norm(f(xo(1),xo(2)),2);
fprintf('error=%12.8f\n', error);
while error >= epsilon
fxo=f(xo(1),xo(2));
fpxo=jf(xo(1),xo(2));
x1=xo-inv(fpxo)*fxo;
fx1=f(x1(1),x1(2));
error =norm((fx1),2);%abs(x1-xo);
fprintf(' Iter %2d raiz x=(%14.9f,%14.9f) f(x)=(%14.9f,%14.9f)\n',....
iter,x1(1),x1(2),fx1(1),fx1(2));
if iter > maxiter
fprintf(' Numero maximo de iteraciones excedido \n');
return;
end
xo=x1;
iter=iter+1;
end
>> newton_no_lineal6
error=56704.47127790
Iter 1 raiz x=( 1.500000000, 1.500000000) f(x)=(-17820.496072977,-17820.496072976)
Iter 2 raiz x=( 2.250000000, 2.250000000) f(x)=(-7920.220476879,-7920.220476878)
Iter 3 raiz x=( 3.375000000, 3.375000000) f(x)=(-3520.097989724,-3520.097989722)
Iter 4 raiz x=( 5.062500000, 5.062500000) f(x)=(-1564.487995433,-1564.487995429)
Iter 5 raiz x=( 7.593750000, 7.593750000) f(x)=(-695.327997971,-695.327997964)
Iter 6 raiz x=(11.390625000,11.390625000) f(x)=(-309.034665766,-309.034665753)
Iter 7 raiz x=(17.085937500,17.085937499) f(x)=(-137.348740343,-137.348740319)
Iter 8 raiz x=(25.628906251,25.628906245) f(x)=(-61.043884601,-61.043884556)
Iter 9 raiz x=(38.443359380,38.443359345) f(x)=(-27.130615386,-27.130615304)
Iter 10 raiz x=(57.665039089,57.665038875) f(x)=(-12.058051294,-12.058051145)
Iter 11 raiz x=(86.497558734,86.497557421) f(x)=(-5.359133922,-5.359133654)
Iter 12 raiz x=(129.746338461,129.746330553) f(x)=(-2.381837293,-2.381836830)
Iter 13 raiz x=(194.619506764,194.619460801) f(x)=(-1.058594233,-1.058593495)
Iter 14 raiz x=(291.929215406,291.928970728) f(x)=(-0.470485703,-0.470484782)
Iter 15 raiz x=(437.893057946,437.892068219) f(x)=(-0.209102094,-0.209102089)
Iter 16 raiz x=(656.828605705,656.829417680) f(x)=(-0.092923475,-0.092930148)
Iter 17 raiz x=(985.092863735,985.190897241) f(x)=(-0.041255886,-0.041295170)
Iter 18 raiz x=(1475.601083927,1477.477525723) f(x)=(-0.018158964,-0.018342676)
Iter 19 raiz x=(2185.973217318,2214.614063849) f(x)=(-0.007368823,-0.008140098)
Iter 20 raiz x=(2978.831798434,3311.018843590) f(x)=(-0.001468628,-0.003567531)
Iter 21 raiz x=(3237.673222434,4798.257751022) f(x)=( 0.000044466,-0.001324202)
Iter 22 raiz x=(3266.256502071,6105.062691525) f(x)=( 0.000016511,-0.000231066)
Iter 23 raiz x=(3271.625295853,6423.950137805) f(x)=(-0.000000200,-0.000004419)
Iter 24 raiz x=(3271.808886987,6430.293417109) f(x)=(-0.000000000,-0.000000001)
Iter 25 raiz x=(3271.808955701,6430.295270011) f(x)=(-0.000000000,-0.000000000)

Più risposte (1)

Akash Nambiar
Akash Nambiar il 1 Apr 2022
% Program Code of Newton-Raphson Method in MATLAB
a=input('Enter the function in the form of variable x:','s');
x(1)=input('Enter Initial Guess:');
error=input('Enter allowed Error:');
f=inline(a)
dif=diff(sym(a));
d=inline(dif);
for i=1:100
x(i+1)=x(i)-((f(x(i))/d(x(i))));
err(i)=abs((x(i+1)-x(i))/x(i));
if err(i)<error
break
end
end
root=x(i)

Community Treasure Hunt

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

Start Hunting!

Translated by