MATLAB Matlab Newton-Raphsons method

  • Thread starter Dukefool
  • Start date
My objective is to create an applicator for the Matlab Newton-Raphsons method using only a function handle, the initial value and the number of iterations desired. I'm extremely new to Matlab and programming so bare with me for being programming deficient. My question is when making a loop, how can you take the value made from x1 onto x2? For example if I wanted to approximate x2-5 with 6 iterations at the initial value of 100, how would I be able to take the value from x5 onto x6?

Here's what I have right now. I know it is absolutely wrong.
function y = mynewton(f,a,n)
syms x
x(0)=a;
df=diff(f(x),n);
for i=1:n
x=x(i-1)-f(x(i-1))/diff(f(x),i-1)
end
y=x
 

Want to reply to this thread?

"Matlab Newton-Raphsons method" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top