09-01-2009 04:41 PM
Hi all,
I am trying to use the Newton Raphson zero solver to solve an equation, however, I am having a problem.
Even if I just set the program to say solve the function cos(x) - 0.3 = 0 I receive NaN as my result. Similar problems occur with log/ln/acosh..etc.
Ironically, everything involving the sin function does work (sin, sinh, etc).
Limit for the above cos(x) - .3 example is set to between -10 to 10. Accuracy and others are left empty.
I am completely confused as to why such a problem exists?
Does anyone have any advice?
09-01-2009 05:00 PM
My advice to you is to not use the Newton-Raphson root finder. NR is a very useful method in many cases with one notable exception. 1D cases where the derivative is evaluated numerically. For 2D problems, it is a real winner (due mostly to lack of competition), in 1D in is acceptable when you can efficiently evaluate the derivative. Unfortunately, the VI that ships with LV is for the one case where NR is a bad idea. If I remember correctly, even the secant method is much improved, and far less suceptible to roundoff error. I recommend that you go next door and use the Ridder's Zero finder.
That said, in your case you are just entering bad values for the start and stop. Try something closer to a known root like 0 to 2 for the start and try again. You have to do some work to bracket your zero. I didn't test it, but I'll wager Kudos.
Convergence of the simple Newton's method is explored here.
09-01-2009 05:42 PM
Sorry, I guess I did not clearly explain my problem. Regardless of if I use Riddlers or N-R I am unable to obtain any result for any higher order function other than sin. Any cos/cot/cosh/ln/log etc will produce a solution of NaN. If I use the equation cos(x) + 1 and start at 3 I still receive a result of NaN.
Has anyone had an issue like this before? It seems as if t he cos() etc functions are not being recognized by labview itself.
09-01-2009 06:01 PM - edited 09-01-2009 06:02 PM