Newton-raphson method with vectors as functions, and derivative
9 views (last 30 days)
Show older comments
I am during the last stage of an assignment, in which i have to use the newton-raphson iterative method to find the root of a polynom, where the polynom is given by a derivative of a vector where n+1= the length of the original vector. To make things more clear, i have something like this-
vector[a1 a2 a3 a4 a5 a6]
i need to derive it once to get the polynom i need to work with, so the first deriving function i thought of is-
for i=2:1:n+1
der1(i-1)=(vector(i)*n-1*(x^(n-2)))
and to use newton raphson i will need to derive again, so-
for i=2:1:n
der2(i-1)=(der1(i)*n-1*(x^(n-2)))
These two loops will give vectors, and summing these vectors would give the actual functions f (der1) and it's derivative (der2). From this point the newton raphson method itself is obvious, just choose an initial guess and let it start running.
On paper it all looks good, but i am far from sure that this is actually a correct process. If anyone can give his opinion if this is ok, or if anyone has a better idea- i will appreciate any input. Thanks.
(just to be clear about it- i am a complete matlab noob, and we were given a few assignments without instructions on how to work with matlab, so i have to learn as i go)
0 Comments
Answers (1)
Torsten
on 25 Jun 2015
help polyval
help polyder
Best wishes
Torsten.
3 Comments
Torsten
on 26 Jun 2015
And I gave you a very specific answer:
If your polynomial is given by a vector
p = [3 2 1];
you can get its first and second derivatives by
derp = polyder(p);
der2p = polyder(derp);
and you can evaluate the polynomial and its first and second derivatives with polyval (e.g. at x=1.0):
y=polyval(p,1.0);
yder=polyval(derp,1.0);
yder2=poyval(der2p,1.0);
Best wishes
Torsten.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!