Finding the roots of an equation using Newton-Raphson method but I don't know the equation!
Ältere Kommentare anzeigen
Hi all,
This is a challenging problem that I'm having difficulties with.
I've been given a P-code file (protected/hidden MATLAB code) that contains a function f function of two input variables 𝑥, 𝑦.
I'm to use my own my own coding of the Newton-Raphson to find all the roots of 𝑓, i.e. 𝑓(𝑥, 𝑦) = 0, given 𝑥, 𝑦 are real variables defined between [−5, 5]. Hint: The function roots are "special" points (unsure what is meant by that bit).
I can plot the function using the fsurf function:
fsurf(@unknownFunction)
And I can render the following plot:

This shows me that it has four roots.
I have absolutely no idea where to go from here. Every iteration of Newton-Raphson requires me to work out the first derivate of 𝑓(𝑥, 𝑦) (so (𝑓'(𝑥, 𝑦) ) in order to progress which obviously I cannot do due to not knowing the original function.
Can anyone offer me some ideas or support? I'm also a complete novice at MATLAB so detail would be appreciated if possible.
Thank you.
Antworten (1)
Jim Riggs
am 26 Nov. 2020
1 Stimme
You use a numerical approximation for the derivative.
Start at some initial guess for x & y.
take a small step, and compute the change in the function value over deltax and delta y.
These are numerical estimates of df/dx and df/dy.
7 Kommentare
qwerty3
am 26 Nov. 2020
if z = f(x,y), then starting at any point, x0,y0, compute z0 = f(x0, y0)
Then take a small step in one or both directions;
z1 = f(x+dx, y+dy)
now an approximation for the derivative of z at point x,y is given by
dzdx = (z1-z0)/dx (change in z over change in x)
dzdy = (z1-z0)/dy (change in z over change in y)
Now you use these as the function derivatives to implement your Newton Raphson method.
Also, looking at the function surface plot, it looks loke the zero points are local minima, which means that the slope is zero at these points, so you will need to guard against division by zero in your method. (It's always a good practice to guard againt division by zero in any code.)
Walter Roberson
am 26 Nov. 2020
Note that this will not be Newton-Raphson method -- that method requires that you have the actual derivative available to you.
James Tursa
am 27 Nov. 2020
@Jim Riggs: I think you need to separate your dx and dy calculations. E.g.,
z0 = f(x0, y0)
zx = f(x0+dx, y0)
zy = f(x0, y0+dy)
now an approximation for the derivatives of z at point x,y is given by
dzdx = (zx-z0)/dx (change in z over change in x)
dzdy = (zy-z0)/dy (change in z over change in y)
James Tursa
am 27 Nov. 2020
Also, finding local minima of a function is not the same thing as finding roots of a function. What is the actual goal here?
Jim Riggs
am 27 Nov. 2020
Yes, separating out dx and dy is probably more correct.
Kategorien
Mehr zu Newton-Raphson Method finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!