LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newton Raphson zero finder optimization

I have been using successfully the Newton Raphson Zero Finder vi. Using the routine that I attach to the message. I am trying to find the x value that makes the solution to equation (1) zero:

 

x + ((b*c*x)/(1+c*x)) - (d) - ((b*c*d)/(1+c*d)) - a = 0     (equation 1)

 

Unfortunately, when I use real values of the parameters d and a, which are very small numbers, the Newton Raphson Zero finder.vi cannot provide accurate enough results, could you help me to optimise this function to find my solution?

 

a= 2e-9

c=7.8e6

b=1e-6

d=2e-8

 

0 Kudos
Message 1 of 4
(1,887 Views)

This can be a little tricky given the mixture of large and small values. I would suggest:

1. Tighten the values of h and accuracy. Try h=1E-12 and accuracy=1E-16.

2. Use the VI reference version of Newton Raphson Zero Finder.vi. This will allow you control of the numerics and order of execution when evaluating your function.

3. In the model function (the f(x) input to the NRZF VI) try using extended precision for all constants and coerce the x input to be extended precision instead of double precision. 

4. View the f(zero) output of the zero finder. This should be the same as your formula node output, but due to the possible difference in the order of execution and arithmetic precision they may be different. 

 

-Jim

0 Kudos
Message 2 of 4
(1,841 Views)

Dear Jim,

 

Thanks for fast reply, unfortunately, I do not know how to implement the  Newton Raphson Zero Finder.vi.. I was using the Newton Raphson Zero Finder.vi. (formula), because, this tool appeared previously in the Labview Forum:

 

https://forums.ni.com/t5/LabVIEW/using-newton-raphsson-zero-finder/td-p/967858?profile.language=en

 

https://forums.ni.com/t5/LabVIEW/Error-with-Newton-Raphson-zero-finder/m-p/4036116#M1157886

 

https://forums.ni.com/t5/LabVIEW/How-to-build-an-equation-with-variables/td-p/1172035

 

Could you add an example?

 

By the way, I increased the precision of my zero (from the Newton Raphson Zero Finder (formula)), by increasing the precision from 6 to 15 of the Number to Fractional String tool (see attached file).

 

Regards,

 

David

0 Kudos
Message 3 of 4
(1,822 Views)

David,

On your block diagram you should see a selector at the bottom of the Newton Raphson Zero Finder.vi that shows "NR Zero Finder: formula". You can click on this and select "NR Zero Finder: VI". Instead of inputting your equation as a string you can now pass a VI reference to Newton Raphson Zero Finder.vi that evaluates your equation. I have attached an example of this equation VI. 

 

Also, please be careful about naming your VI to have the same name as the VI that you are calling. The polymorphic VI that is being called on your diagram has the same name, but is also part of a project library so the qualified name is different. It is very easy to make a mistake or become confused.

-Jim

0 Kudos
Message 4 of 4
(1,811 Views)