This Fexl program demonstrates using a fixpoint function to solve various equations. The function (fixpoint f x) iterates function f repeatedly, starting from an initial value x, until it reaches a value equal to the previous value.

# Compute the fixpoint of function f starting with initial value x. \fixpoint= (\f @\loop\x \y=(f x) eq x y y; loop y ) \solve= (\label\f\x say ["Solve "label" starting at "x"."] say ["The solution is "(fixpoint f x)"."] nl ) ( \try=(solve "x=(x+1)^(1/5)" (\x ^ (+ x 1) 0.2)) # Does not converge for negative starting points. try 0 try 5.8 ) ( \try=(solve "x=1/(2x+1)" (\x / 1 (+ 1 (* 2 x)))) try -5.8 try -1.01 try -1 say "^^^ AHA! -1 is the only starting value which leads to -1." nl try -0.99 try 0 try 2.6 try 4 try 587 )The output is:

Solve x=(x+1)^(1/5) starting at 0. The solution is 1.16730397826142. Solve x=(x+1)^(1/5) starting at 5.8. The solution is 1.16730397826142. Solve x=1/(2x+1) starting at -5.8. The solution is 0.5. Solve x=1/(2x+1) starting at -1.01. The solution is 0.5. Solve x=1/(2x+1) starting at -1. The solution is -1. ^^^ AHA! -1 is the only starting value which leads to -1. Solve x=1/(2x+1) starting at -0.99. The solution is 0.5. Solve x=1/(2x+1) starting at 0. The solution is 0.5. Solve x=1/(2x+1) starting at 2.6. The solution is 0.5. Solve x=1/(2x+1) starting at 4. The solution is 0.5. Solve x=1/(2x+1) starting at 587. The solution is 0.5.