Root-Finder Utility for f(M) = a1cos(M)sin2(M) + a2cos2(M)sin2(M) + a3
This page contains a routine that numerically finds roots of the equation presented above on the interval specified by the user.
Shampine, L. F. (SNLA) and H. A. Watts (SNLA)
"FZERO, A Root-solving Code" Report SC-TM-70-631
"Finding a Zero by Means of Successive Linear Interpolation"
"Constructive Aspects of the Fundamental Theorem of Algebra"
edited by B. Dejon and P. Henrici
The utility posted on this page is based on the program "FZERO.F", written by L. F. Shampine (SNLA) and H. A. Watts (SNLA), based upon a method by T. J. Dekker.
"FZERO.F" is part of the SLATEC library of programs, and its original code (written in FORTRAN) can be viewed there.
To increase the flexibility of this utility, the user is given fields into which values must be entered for the constants a1, a2, and a3. If any of the three terms in this equation is not required, just enter 0's for the appropriate a constant(s).
In addition to the a values, the user must enter a range, [b, c], over which a zero will be sought for this function. These values represent time variables, from which M is calculated as M = (2πt)/T. T is the period of the motion, which must be entered by the user as well.
The user should ensure that a zero is included on this interval before entering these values. In other words, the sign of f(b) should not be the same as the sign of f(c). If f(M) does not change sign over the specified interval, a message box pops up stating this feature and then drops out of the routine--no further action is taken. The user must try again, entering b and c values such that f(M) changes sign over the interval.
Even before using this utility, some observations may be made:
If a1 and a2 are 0, but a3 is non-zero, the function is a straight line and does not have a root.
If a3 is zero, but a1 or a2--or both--is non-zero, the function has roots at m(π/2), where m is a non-zero integer.
IMPORTANT: Note the Error Code returned.
Enter the a values for the function.
Error Code = 1: The zero is within the requested tolerance (on the order of Machine Epsilon), the interval has collapsed to the requested tolerance, the function changes sign over the interval, and the function decreased in magnitude as the interval collapsed.
Error Code = 2: A zero has been found, but the interval has not collapsed to the requested tolerance.
Error Code = 3: MAXIT (200) function evaluations. The solution may be meaningless. Check it.