# Hypergeometric functions

This is a discussion on Hypergeometric functions within the C Programming forums, part of the General Programming Boards category; Hi everyone: I've been working with hypergeometric series for the last couple of days, and after found a C-function to ...

1. ## Hypergeometric functions

Hi everyone:
I've been working with hypergeometric series for the last couple of days, and after found a C-function to do this type of mathematical determination, and ensure that the limits of the function and the anomalies weren't include in the calculus..I found the next mess:

gsl: hyperg_2F1.c:640: ERROR: domain error
Default GSL error handler invoked.
Abort
and the lines in my code are:

aa = -1/(3*w);
bb = (w-1)/(3*w);
cc = 1-(5/(6*w));
dd = -pow(a, -3*w)*(1-omegam)/omegam;
printf("valor de aa= %1.3e, bb = %1.3e, cc = %1.3e y dd = %1.3e\n", aa, bb, cc, dd);
/*lingro = gsl_sf_hyperg_2F1 (aa, bb, cc, -pow(a, -3*w)*(1-omegam)/omegam );*/
lingro = 1.0;
where w = -1...And I evaluated the function (with mathematica) and the result should be 1.

If anyone know wich it's the problem...I really appreciate your help :-)

2. aa = -1/(3*w)
dd = -pow(a, -3*w)*(1-omegam)/omegam;
Is a different from aa?

3. Originally Posted by zacs7
Is a different from aa?
Yes a it's different to aa...and both are define in main

4. Originally Posted by pow usage
If base is negative and exponent is not an integral value, or if base is zero and exponent is negative, a domain error occurs, setting the global variable errno to the value EDOM.
ensure pow(a... isn't negative, and the exponent is an integral (ie not 1/3)

5. Originally Posted by zacs7
ensure pow(a... isn't negative, and the exponent is an integral (ie not 1/3)
Hi again, I checked this before to post :-(, and even print the values of aa, bb, cc, dd to ensure that this variables are correct evaluates... I hink I have some problem in the hypergeometric function..but I'vent used this function before, and I don't have any idea about which it's the problem and how solve it.

but thanks

6. Make sure that aa,bb ,cc and all others are of type float.

Since in C, if you do 5/2 it evaluates to 2.
but 5.0/2 = 2.5

Also, change every numeric constant and add a .0 (so the type changes to a float)

Code:
```aa = -1.0/(3.0*w);
bb = (w-1.0)/(3.0*w);
cc = 1.0-(5.0/(6.0*w));
dd = -pow(a, -3.0*w)*(1.0-omegam)/omegam;
printf("valor de aa= &#37;1.3e, bb = %1.3e, cc = %1.3e y dd = %1.3e\n", aa, bb, cc, dd);```

7. In order to remain completly correct, you should add .0f

ie,
Code:
`aa = -1.0f / (3.0f * w);`
Also adding some whitespace between your operators so it's readable. Your problem is 99&#37; related to passing incorrect data to the function (as Govalant said)

8. Hi again!
Well I solve partially the troubles with the hypergeometric function....but I found that I can evaluate the function only with a parameter i.e

gsl_sf_hyperg_2F1 (aa, bb, cc, w )
But when I tried to do with:

g
sl_sf_hyperg_2F1 (aa, bb, cc, -pow(a, -3*w)*(1-omegam)/omegam )
I found a mistake and the abort the process.

Y tried to pre-declare the variable
f = -pow(a, -3*w)*(1-omegam)/omegam
And make gsl_sf_hyperg_2F1 (aa, bb, cc, f )
But this didn't work

Have anyone some idea to how solve this? I've been programming in C since a couple of months and I don't have enought experience to solve this....

Thanks :-)