Re: nan

Peter Rockett via gnuplot-info <[email protected]> Wed, 2 Nov 2022 09:04:35 +0000
Newsgroups gmane.comp.graphics.gnuplot.user
Message-ID <[email protected]>
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
> [email protected]
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info


_______________________________________________
gnuplot-info mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info