Thread: Hypergeometric functions

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    4

    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. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    aa = -1/(3*w)
    dd = -pow(a, -3*w)*(1-omegam)/omegam;
    Is a different from aa?

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    4
    Quote Originally Posted by zacs7 View Post
    Is a different from aa?
    Yes a it's different to aa...and both are define in main

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote 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. #5
    Registered User
    Join Date
    May 2007
    Posts
    4
    Quote Originally Posted by zacs7 View Post
    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. #6
    Registered User
    Join Date
    May 2007
    Posts
    58
    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)

    so your code would be


    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= %1.3e, bb = %1.3e, cc = %1.3e y dd = %1.3e\n", aa, bb, cc, dd);

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    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% related to passing incorrect data to the function (as Govalant said)

  8. #8
    Registered User
    Join Date
    May 2007
    Posts
    4
    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 :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM