MATLAB Answers

# Finding the roots of an equation using Newton-Raphson method but I don't know the equation!

18 views (last 30 days)
qwerty3 on 26 Nov 2020
Commented: Jim Riggs on 27 Nov 2020
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 have uploaded the P-code containing the unknown function here.
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.
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (1)

Jim Riggs on 26 Nov 2020
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 CommentsShowHide 6 older comments
Jim Riggs on 27 Nov 2020
Yes, separating out dx and dy is probably more correct.

Sign in to comment.

R2020b

### Community Treasure Hunt

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

Start Hunting!