Newton method , student need help.

1 Ansicht (letzte 30 Tage)
Thierry Gelinas
Thierry Gelinas am 10 Apr. 2015
Kommentiert: Torsten am 22 Nov. 2023
Hi , I know there's a lot of subjects on this but I didn't find what I'm looking for... This is my problem: I have create this code and it works perfectly well :
fonc=inline('fonction');
dfonc=inline('derivée de la fonction');
x=0.8;
;xn=0;
eps=1e-6;
k=0;
fprintf(' k x_k f(x_k) \n');
fprintf('%4d %12.4e %12.4e \n',k, x,fonc(x));
k=k+1;
while abs(x-xn) > eps & k < 20
xn=x;
x=x-fonc(x)/dfonc(x);
fprintf('%4d %12.4e %12.4e \n',k, x,fonc(x));
k=k+1;
end
In this case fonction = x^4-1.3*x^3-2.97*x^2+5.929*x-2.662 and dérivée de la fonction is 4*x^3-3.9*x^2-5.94*x+5.929
k x_k f(x_k)
0 8.0000e-01 -7.5600e-02
1 9.0370e-01 -2.1963e-02
2 9.7064e-01 -6.4300e-03
3 1.0144e+00 -1.8908e-03
4 1.0432e+00 -5.5753e-04
5 1.0623e+00 -1.6467e-04
6 1.0749e+00 -4.8691e-05
7 1.0833e+00 -1.4407e-05
8 1.0889e+00 -4.2649e-06
9 1.0926e+00 -1.2629e-06
10 1.0951e+00 -3.7405e-07
...
29 1.1000e+00 0.0000e+00
My problem is that I have to add a new thing to the table that would be create by this fonction:
abs((xn2-xn)/(xn-x)) and I don't know how to do it... I really need help.
It should be looking like this
k x_k f(x_k) |En+1/En|
0 8.0000e-01 -7.5600e-02 0,645515911
1 9.0370e-01 -2.1963e-02 0,653719749
2 9.7064e-01 -6.4300e-03 0,658135283
3 1.0144e+00 -1.8908e-03 0,663194444
4 1.0432e+00 -5.5753e-04 0,659685864
5 1.0623e+00 -1.6467e-04 ...
6 1.0749e+00 -4.8691e-05 ...
7 1.0833e+00 -1.4407e-05 ...
8 1.0889e+00 -4.2649e-06 ...
9 1.0926e+00 -1.2629e-06 ...
10 1.0951e+00 -3.7405e-07 ...
11 1.0967e+00 -1.1080e-07 ...
Thank you. ( by the way , english is not my native language so I'm sorry for all the mistakes I may have made. )

Antworten (1)

Dendani
Dendani am 22 Nov. 2023
i need the solution of this fonction méthode of newton and secante X^2-7y+5 X^3+6x^2-xy+4
  1 Kommentar
Torsten
Torsten am 22 Nov. 2023
You have a system of 2 equations in 2 unknowns.
I've never heard that the secant method is used for systems of equations.
If you don't succeed or you are not keen on programming Newton's method on your own, I suggest a google search " MATLAB & Newton's method". There should be a lot of hits.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by