|
From: Patrick D. <pd...@gm...> - 2022-11-01 21:54:11
|
Hello, Setting fcn(x,g,G)=-imag(1/(x+I*g)*faddeeva(x/G) plot [-30:30] fcn(x,0.01,1) provides nan from values less than -27.28 and more than 27.28 There is not reason for that The value are small, but not very small slightly less than -0.0007586274478 Any idea? Thank =========================================================================== Patrick DUPRÉ | | email: pd...@gm... Laboratoire interdisciplinaire Carnot de Bourgogne 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE Tel: +33 (0)380395988 | | Room# D114A =========================================================================== |
|
From: Ethan M. <eam...@gm...> - 2022-11-02 01:02:44
|
On Tuesday, 1 November 2022 14:54:01 PDT Patrick Dupre wrote:
> Hello,
>
> Setting
> fcn(x,g,G)=-imag(1/(x+I*g)*faddeeva(x/G)
>
> plot [-30:30] fcn(x,0.01,1)
>
> provides
> nan from values less than -27.28 and more than 27.28
> There is not reason for that
> The value are small, but not very small
> slightly less than
> -0.0007586274478
>
> Any idea?
Good question.
Something in the cerf library is setting a range error (ERANGE)
"Math result not representable". Possibly this is due to
underflow of the real component, which we could ignore, but that is
only speculation at this point. Note the result
gnuplot> print faddeeva(27.)
{2.50797207889417e-317, 0.0209102719931009}
which indicates that the real component has reached the smallest
representable IEEE double float value.
I will investigate further.
Ethan
>
> Thank
> ===========================================================================
> Patrick DUPRÉ | | email: pd...@gm...
> Laboratoire interdisciplinaire Carnot de Bourgogne
> 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
> Tel: +33 (0)380395988 | | Room# D114A
> ===========================================================================
>
>
>
> _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
|
|
From: Ethan M. <eam...@gm...> - 2022-11-02 05:02:16
|
Underflow confirmed.
The Faddeeva function is exp(-z^2) * erfc(-i*z)
Calculation of exp(-z^2) underflows to zero at about z = 27.
Gnuplot's own exp function knows to ignore the floating point
exception that is generated and just return zero.
But the implementation used by the Faddeeva function in libcerf
doesn't do this. It leaves the ERANGE error active.
I don't have an immediate fix for this in gnuplot.
The libcerf library does provide a separate function
im_w_of_x(x) that would calculate the imaginary part
without triggering an underflow, but that only helps if
the calling program already knows there will be an underflow
and calls the special case instead of the generic routine.
Gnuplot doesn't currently know to do this.
Ethan
On Tuesday, 1 November 2022 18:02:33 PDT Ethan Merritt wrote:
> On Tuesday, 1 November 2022 14:54:01 PDT Patrick Dupre wrote:
> > Hello,
> >
> > Setting
> > fcn(x,g,G)=-imag(1/(x+I*g)*faddeeva(x/G)
> >
> > plot [-30:30] fcn(x,0.01,1)
> >
> > provides
> > nan from values less than -27.28 and more than 27.28
> > There is not reason for that
> > The value are small, but not very small
> > slightly less than
> > -0.0007586274478
> >
> > Any idea?
>
> Good question.
> Something in the cerf library is setting a range error (ERANGE)
> "Math result not representable". Possibly this is due to
> underflow of the real component, which we could ignore, but that is
> only speculation at this point. Note the result
> gnuplot> print faddeeva(27.)
> {2.50797207889417e-317, 0.0209102719931009}
> which indicates that the real component has reached the smallest
> representable IEEE double float value.
>
> I will investigate further.
>
> Ethan
>
|
|
From: Peter R. <p.r...@sh...> - 2022-11-02 09:31:09
|
Ummm.... Would the OP's problem be more elegantly solved with a small
Python script. Or even using Excel to pre-process the data file?
(Reinhart & Rogoff notwithstanding...)
Peter
On 02/11/2022 05:02, Ethan Merritt wrote:
> Underflow confirmed.
>
> The Faddeeva function is exp(-z^2) * erfc(-i*z)
>
> Calculation of exp(-z^2) underflows to zero at about z = 27.
> Gnuplot's own exp function knows to ignore the floating point
> exception that is generated and just return zero.
> But the implementation used by the Faddeeva function in libcerf
> doesn't do this. It leaves the ERANGE error active.
>
> I don't have an immediate fix for this in gnuplot.
>
> The libcerf library does provide a separate function
> im_w_of_x(x) that would calculate the imaginary part
> without triggering an underflow, but that only helps if
> the calling program already knows there will be an underflow
> and calls the special case instead of the generic routine.
> Gnuplot doesn't currently know to do this.
>
> Ethan
>
>
> On Tuesday, 1 November 2022 18:02:33 PDT Ethan Merritt wrote:
>> On Tuesday, 1 November 2022 14:54:01 PDT Patrick Dupre wrote:
>>> Hello,
>>>
>>> Setting
>>> fcn(x,g,G)=-imag(1/(x+I*g)*faddeeva(x/G)
>>>
>>> plot [-30:30] fcn(x,0.01,1)
>>>
>>> provides
>>> nan from values less than -27.28 and more than 27.28
>>> There is not reason for that
>>> The value are small, but not very small
>>> slightly less than
>>> -0.0007586274478
>>>
>>> Any idea?
>>> Good question.
>>> Something in the cerf library is setting a range error (ERANGE)
>>> "Math result not representable". Possibly this is due to
>>> underflow of the real component, which we could ignore, but that is
>>> only speculation at this point. Note the result
>>> gnuplot> print faddeeva(27.)
>>> {2.50797207889417e-317, 0.0209102719931009}
>>> which indicates that the real component has reached the smallest
>>> representable IEEE double float value.
>>>
>>> I will investigate further.
>>>
>>> Ethan
>>>
>
>
>
>
> _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
|
|
From: Dan H. <dan...@ph...> - 2022-11-03 00:10:09
|
On Tue, 1 Nov 2022, Ethan Merritt wrote: > I don't have an immediate fix for this in gnuplot. My Gnuplot was compiled without libcerf support, so I can't test it, but why not do myfaddeeva(z) = exp(-z**2.0+log(1.0-erfi(-z)/(-I))) ? |