|Re: hp 35s not very impressive (WP 34S solutions)|
Message #55 Posted by Walter B on 30 Aug 2012, 8:15 a.m.,
in response to message #54 by Valentin Albillo
OK, I plotted the equation y = sin(x + cos(x)) - 1 and found its root at pi/2 is the maximum of this function. So, in an attempt to cure the problem, I modified the equation slightly:
y = sin(x + cos(x)) - 1 + d with d << 1.
I solved it for different values of d (stored in R00). These are the results for DBLON, taking 0 and pi as first guesses and setting the display to ALL 00 (edit: I added the results of a second run with 1 and 2 as first guesses):
d x_root(0, pi) x_root(1, 2)
1e-3 2,22036201033 2,22036201033
1e-6 1,77490289682 1,77490289682
1e-7 1,70980074769 1,70980074769
1e-8 1,6654825901 1,6654825901
1e-9 1,63530016132 -29,7806263746
1e-10 1,61474064464 1,52685200895
1e-11 no root found 1,57079703157 -8840433,65927
1e-12 no root found 1,57079639727 1,59119295725
1e-15 no root found 1,57079632687 -4,71883892102
1e-18 no root found 1,57079632679 (= pi/2 + 7e-14) -10579,2744561
1e-21 no root found 1,57079632679 (= pi/2 + 7e-17)
1e-24 no root found 1,57079632679 (= pi/2 + 7e-20)
1e-27 no root found 1,57079632679 (= pi/2 + 7e-23)
1e-30 no root found 1,57079632679 (= pi/2 + 7e-26)
1e-33 no root found 1,57079632679 (= pi/2 + 7e-29)
Just checked the HP15C Owner's Handbook, Appendix D. The function given by Valentin doesn't fulfill the conditions stated on p.221f there. Although that's not explaining why the algorithm seems to fail, it shows at least that other folks may have had problems, too, with such functions.
Let's take a closer look to the last case solved properly and the first case apparently going banana (d = 1e-8 and d = 1e-9 for the initial estimates 1 and 2):
SLV returns for d = 1e-8: x= 1,6654825901, y-x= 9,44475624443e-14, z= 0
and returns for d = 1e-9: x= -29,7806263746, y= 4,22728651914, z= 0.
Despite of the strange result, it's fully correct. The function Valentin gave us is periodic. It has an infinite number of roots. And the neighborhood of each root is extremely ill-conditioned. Close to the roots, the function runs almost horizontally. So any search algorithm working with the tangent to the curve will become unstable, i.e. the next sample point may be far off and another root will be found (remember: there is an infinite number of them).
OK, and what's to be learned? Do not throw anything you don't know in any automatic device :-)
Edited to merge two postings.
Edited: 31 Aug 2012, 6:38 a.m. after one or more responses were posted