|
In going through the Basic Stamp Pbasic manual, the greatest obstacle I can see to implementing the Newton's Method algorithm is in the division step. The manual recommends that division NOT be performed in cases where either numerator or denominator are negative; results can be unpredictable. For the demoninator, cos(x), this is not a problem over the restricted range -pi/2 to +pi/2. However, the numerator can certainly go negative. The additional steps necessary to handle that make the algorithm needlessly complicated and slow - getting back to Dr. Joe's wise advice about time of execution.
The second difficulty comes from the different sizes of the sin function argument and result. SIN takes a byte argument (-127 to +127), and outputs a word result (-32,767 to +32,767). Scaling the word result back down to byte-size to send back through the function at the next iteration could be tricky (i.e., an infinite sink of time trying to work out the programming).
It could be that Jay Lundy's method (which looks to me like a truncated Maclaurin series, or Taylor series about x=0) may actually be more efficient.
Math on a Basic Stamp is definitely not for the faint of heart.
__________________
Leo M.
|