Help writhe a fixed point algorithm

1 view (last 30 days)
Write a matlab program, for a given fixed point equation, x=g(x), runs the fixed point algorithm xnew = g(xold) until either two consecutive approximation to the root are close enough (tolerance 10^-10), or divergence is determined.
The equation I will be using is xnew = ((x*e^(x/20))/arctan(x) where x = xold.
I am new to matlab and need some help writing the program. My book wont be here for another week and I need this done by teusday.

Accepted Answer

Roger Stafford
Roger Stafford on 19 Sep 2014
This problem is ideal for using matlab's 'while' function. You can read the details about it at:
http://www.mathworks.com/help/matlab/ref/while.html
You have three main steps to perform in the while loop. A) If the absolute value of the difference between xnew and xold is greater than your tolerance, continue into the loop. B) Copy xnew into xold. C) Compute a new xnew from xold using your formula.
Additional considerations. 1) When you first enter the loop make sure xnew has the initial value you wish to start with. 2) Also when first entering make sure xold is different enough to pass the test. 3) You need to add some kind of counting scheme into the above so that if you haven't converged after a certain maximum number of iterations, you will nevertheless drop out of the while loop. You don't want it continuing to execute the while loop forever. (I'll leave that detail to you.)
I hope the above will get you started, (missing book notwithstanding.)

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!