Stopping an iteration when values get close together?

Alasdair shared this question 3 years ago
Needs Answer

I'm doing a little numerical work, and I can create an iteration and run it, either in the spreadsheet view or else with IterationList. However, I'd like to run it until consecutive values reach a certain closeness (or after a fixed number of iterations, whichever comes first).

Thus a command something like

IterationsUntil(f, x0, n, eps)

will run an iteration x <- f(x) until either n steps, or until two consecutive values differ in absolute value by eps. It could be used as


Does this mean writing a Custom Tool using JavaScript, or is there an easier way?


Comments (2)


Please post your .ggb file


Thank you - but I don't have a ggb file yet - I'm not up to that stage! I was hoping for some pointers to information which would enable me to write such a function myself. I have done some JavaScript programming, so that doesn't worry me. If there is any documentation about adding your own JavaScript function to GeoGebra, I'd love to know of it!

© 2023 International GeoGebra Institute