Fixed point iteration to find the roots of 0=x-tan(x)

AI Thread Summary
The discussion focuses on using fixed point iteration to find the roots of the equation 0 = x - tan(x). The user initially rearranged the equation to x = arctan(x) for convergence but struggled with the implementation in MATLAB, particularly with the iteration logic and understanding how to find multiple roots. It was clarified that the roots of x = tan(x) are not periodic like tan(x) itself, and the user was advised to use the relationship x = nπ + θ to find roots within specific intervals. The conversation emphasized the need for careful selection of initial guesses and the importance of using the arctan function for convergence, as the derivative of tan(x) does not guarantee stability in fixed point iterations. Ultimately, the user was guided to refine their approach to effectively locate the positive roots of the equation.
  • #51
That algorithm doesn't converge. I just took your code from post #17; it stopped after 50 iterations because it failed to converge.

Look at it this way: \tan x \approx x(1 - x^2/3) for small x. All setting x=\arctan(x) does when x gets even close to zero is to scale x by a factor that is nearly equal to 1.
 
Physics news on Phys.org
  • #52
After rewriting it so that x_new... line is now x_new= atan (pi + x_old) it converged within 6 iterations. So is that just a fluke then? It is giving me the correct number to find the roots though.
I don't follow post #51 at all I'm sorry.
 
Back
Top