LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Gauss Hypergeometric Function not returning value

Solved!
Go to solution

I need to evaluate the Gauss Hypergeometric  function (Mathematic > Elementary > Hypergeometric Functions > Gauss Function.vi) for the following constants:

 

a=11/6

b= 1/6

c= 5/6

 

for various values of x, all of which are negative.  One value of x is -4.  When I execute a VI with this function, it returns NAN.  I'm not sure what is going on as the help file states the function is defined from neg. Infinity to 1.  A condition is placed on it being defined specifically at 1 which I am not interested in. 

 

We have used a MATLAB script node within Labview to successfully calculate these values.  I know some other programs can only calculate the function for |x| < 1, but the help file in Labview claims it doesn't have this limitation as is the case with Matlab.  Can anyone else confirms this problem or am I just overlooking something?  

0 Kudos
Message 1 of 8
(4,238 Views)

I suspect the LabVIEW documentation is wrong.  The Gauss Hypergeometric function has a convergent solution for (complex) |z| < 1, and can converge for [z] = 1 if the coefficients a, b, and c obey the right conditions.  So a value of x = -4 may well not converge, returning NaN.

0 Kudos
Message 2 of 8
(4,215 Views)

You can use the ODE solver to get the value over a wider range of values.  I have done this for a different function, but I have tried to adapt it for the Hypergeometric function.  I do not have Mathematica to test on this machine, so you can try it and let me know if it works.  It is a fairly standard method, you can read about the details in books like Numerical Recipes.

 

Let me know if this works.  (By the way, this version returns complex values)

 

 

0 Kudos
Message 3 of 8
(4,204 Views)

I guess it would help if I actually added the type cast to return the complex value of the hypergeometric function.  Here is the fixed version.

 

 

0 Kudos
Message 4 of 8
(4,188 Views)
Solution
Accepted by Jeff2

It would also help to check with Mathematica to verify that I did not make stupid calculus mistakes....

 

Third time is a charm.

 

 

Message 5 of 8
(4,174 Views)

I've tested it with a few values and compared them to the output of the MATLAB node and they are the same to about 5 decimal places.  I'll try to run them both through a loop with a range of values and attach the values for comparison.  Thanks a lot for the response and the VI.

 

 

0 Kudos
Message 6 of 8
(4,167 Views)

If you unhide the simulation parameter controls you can probably decrease the tolerances and squeeze out a couple of more decimal places without too much of a time hit.  5 is not too bad of a starting point.  When the series solution converges, the result should be good to machine precision.

0 Kudos
Message 7 of 8
(4,164 Views)

Attached are the values from -1 to -1000 for comparison.  Your ODE solver took 2.31813 seconds in Labview to process these values as compared to the Matlab node which took 44.8476.  So it's considerably faster.  Thanks for the help. Time was becoming an issue since we are using this to curve fit with multiple iterations.  

Message 8 of 8
(4,098 Views)