[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Computation of gsl_sf_hyperg_1F1 fails for some values

From: Sam Mason
Subject: Re: [Help-gsl] Computation of gsl_sf_hyperg_1F1 fails for some values
Date: Fri, 10 May 2013 11:43:35 +0100

On 10 May 2013 10:43, Daniel Schury <address@hidden> wrote:
> "double part22 = gsl_sf_hyperg_1F1(-p/2.0, 1.0/2.0,
> - -1.0/2.0*((E1-x)/dE)^2.0);"

In this case; in C the ^ operator is a bitwise xor and doesn't raise
things to a power.

Is that double negation really needed? Seems redundant, or am I
missing something?

> This works for most values, but fails for some. With p = 2.09, E1 = 8, x
> = 26.8 and dE = 0.5 my program crashes.

You be better off reporting the actual values of a, b and x that
caused the program to crash.  When you printed these out you may
notice that something strange is happening.

> Can somebody confirm this problem maybe on a different platform or has
> an idea how to trace the problem?

Fixing the code to actually square things works for me in Linux with
GSL v1.15, but gives back a *very* large number: 3.2e301.  Mathematica
gives the same value, so at least they're both consistent.

I'd break things down to debug it.  I.e. create some more variables to
save the values of a, b, x, then use printf to display them—or use a
debugger.  You should then be able to see you're getting strange
things going on before calling the hypergeometric function.

It seems strange that your compiler isn't complaining about the xor!  GCC does.

Hope that helps!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]