Created
April 2, 2020 14:59
-
-
Save johnmyleswhite/39f42e57618ee83b10c51499d94bc461 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fixed_point(f, x0) | |
x, x_old = f(x0), x0 | |
n = 1 | |
while x !== x_old | |
x, x_old = f(x), x | |
n += 1 | |
end | |
(x, n) | |
end | |
fixed_point(x -> 0.1 * x, 1.0) | |
fixed_point(x -> 10.0 * x, 1.0) | |
fixed_point(x -> exp(x), 1.0) | |
fixed_point(x -> x + 1.0, 1.0e16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment