[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion |
Date: |
Sat, 16 Apr 2022 16:58:25 -0400 (EDT) |
Follow-up Comment #5, bug #62321 (project octave):
I have check with WolframAlpha
<https://www.wolframalpha.com/input?i2d=true&i=Ai%5C%2840%29-0.464938443651899%5C%2841%29>
(this computes `Ai(V(1, 1))`) and SciPy, and it is `Q` in [comment #3 comment
#3] that is true and `P` that is false.
I am not that well verse in C++, so I might be wrong. From the C++ code in
[comment #3 comment #3], I do not understand the use of the `tmp` variable. If
I understand correctly, when we call the Airy function `airy(0, z)` it first
computes the scaled version and since we want the "unscaled" version it goes
into this bloc and multiply the complex scale result `ar + i*ai` by the
complex scale factor `expz = rexpz + i*iexpz`. So, it is just a multiplication
of two complex numbers, and we could rewrite this bloc as
if (! scaled)
{
Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z));
double rexpz = expz.real ();
double iexpz = expz.imag ();
ar = ar*rexpz - ai*iexpz;
ai = ar*iexpz + ai*rexpz;
}
I also remark the same pattern in
*
[https://hg.savannah.gnu.org/hgweb/octave/file/30f7f409861a/liboctave/numeric/lo-specfun.cc#l146];
*
[https://hg.savannah.gnu.org/hgweb/octave/file/30f7f409861a/liboctave/numeric/lo-specfun.cc#l216];
*
[https://hg.savannah.gnu.org/hgweb/octave/file/30f7f409861a/liboctave/numeric/lo-specfun.cc#l1392];
*
[https://hg.savannah.gnu.org/hgweb/octave/file/30f7f409861a/liboctave/numeric/lo-specfun.cc#l1462].
For the last two, the value `expz` is the exponential of a real value, so it
is a real number, and we should be able to reduce the bloc to
if (! scaled)
{
double expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z))));
ar = ar*expz;
ai = ai*expz;
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62321>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, anonymous, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion,
anonymous <=
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/16
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, anonymous, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/17
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, anonymous, 2022/04/18
- [Octave-bug-tracker] [bug #62321] Wrong result for Airy funtion, Arun Giridhar, 2022/04/18