Closed waruyama closed 2 years ago
The pseudocode in the Wikipedia article "... assumes the initial values of ya and yb ... satisfy ya < 0 < yb ...", which is consistent with the plots to the right of this text. This assumption simplifies the code for updating the bracketing interval. More generally, we need to be able to handle cases where ya > 0 > yb, which is what the multiplication by the sign does.
Thank you. My ya and yb did not satisfy this condition, that's why the implementation failed. So we can leave the Wikipedia article as it is and only do the multiplication in the code.
I just learned about ITP yesterday and tried an implementation that is based on Wikipedia's pseudocode implementation of the algorithm.
It says:
In your implementation you multiply
yITP
with the sign ofyb
in the conditions:I do not understand the algorithm, but changing the conditions to multiply
yitp
with the sign ofyb
(or simplyyb
) made the implementation work. Also, I know from other algorithms (like Regula Falsi) that this multiplication is done in the conditions.Since you seem to have deep understanding of the ITP method, my question would be if you can confirm that there is an error in the algorithm in the Wikipedia article.