Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Math Resources > Mathematics Software Discussion
Reply
 
Thread Tools Display Modes
  #1  
Old October 27th, 2009, 11:25 PM
Newbie
 
Join Date: Oct 2009
Posts: 1
Country:
Thanks: 0
Thanked 0 Times in 0 Posts
eleigh1103 is on a distinguished road
Default Newtons method for matlab

Ok so im trying to write a code for matlab and this is what i have so far:


function N = newton(f,x,a,m)

x=g;
numguess = 1;
x1 = g-(f(g)/(d(g));
numguess = 1+ numguess;
while numguess <m || (abs(x1-x))>=a
x1=x;
x2=x-(f(g))/d(g));
numguess = numguess +1;
end

if abs(x1-x)<=a
disp('You have hit the accuracy')
else
disp('You have reached the max number of guess')
end


*** the inputs have to be the function, and initial guess for the solution, desired accuracy and the max number of iterations allowed.
The user has to input the function as a symbolic function and use the symbolic toolbox to calculate the derivative.

**It has to iterate until the absolute value of the difference between the last two iterations is less than the desired tolerance/accuracy or
the maximum number of iterations have been reached. The output of your
function is the LAST iterate.
Reply With Quote
Advertisement
 
  #2  
Old October 28th, 2009, 05:42 PM
Member
 
Join Date: Mar 2007
Posts: 104
Country:
Thanks: 17
Thanked 14 Times in 14 Posts
elbarto is on a distinguished road
Default

Is there a question in there? Looking at your code, it appears that d(g) is undefined? I dont have MATLAB on this machine so cant test your code right now.

Elbarto
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 08:16 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.