-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: special: algorithmic Error in ratevl
in cephes/polevl.h
#20697
Comments
ratevl
in cephes/polevl.h
Hi @ZhibingSun , as a small ask, could you edit your post to enclose equations in backticks (this symbol `)? That should make it easier to read! (Or you can use $ signs for LaTeX too). cc @steppi |
Hi, I have updated my post as required, and thanks for letting me know that I can enclose equations and use LaTex. Please let me know if I need to provide more information. |
Thanks for the bug report @ZhibingSun! It looks like this error goes back to when this function was first introduced. It seems no one noticed before you because
Would you like submit a pull request with the fix? |
Yes, I would love to contribute. Could you give me some guidance of how to submit a pull request? |
Great! Start with the Contributor quickstart in the Developer documentation, and then check out the Development workflow section. That should be enough to get started. |
I followed |
Are you on windows or Linux? I suggesting trying to compile a really simple test program (c.f. hello world) to see if the compiler actually works. |
I am on M1 mac Ventura 13.6.6. |
How did you install gfortran? I've found homebrew to work. |
I installed it from here. |
Running that command doesn't necessarily mean that the compiler works. Try compiling and running a test program. |
I use Mac M1 and had the same error message. I worked around it by executing the following before export LIBRARY_PATH="$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" This works for me because after I upgraded XCode, some of the environment variables are not correctly set. Btw, after the config error message, there should be somewhere that shows you a detailed error log. In that log it explains exactly why it “couldn’t compile Fortran program”. For me it was unable to “-lSystem”. |
These two lines from http://scipy.github.io/devdocs/building/index.html#system-level-dependencies were enough for me. |
I am a PhD candidate in Applied Math from the University of Waterloo. I was investigating some numerical issues in my research when I found an algorithmic error for the function$\cfrac{P(x)}{Q(x)}$ , where $P(x)$ and $Q(x)$ are polynomials of order $M$ and $N$ respectively. For $|x| > 1$ , $P(x)$ and $Q(x)$ are evaluated by $\cfrac{1}{x}$ instead of $x$ , using Horner's method as referenced on $f_2(x) = a_2 x^2 + a_1 x + a_0$ be a second order polynomial. If $|x| > 1$ , then the polynomial is evaluated in reverse order as polynomial in $\cfrac{1}{x}$ .$\cfrac{f_2(x)}{x^2} = a_2 + a_1 \cdot\cfrac{1}{x} + a_0 \cdot\cfrac{1}{x^2} = (a_0 \cdot\cfrac{1}{x} + a_1)\cdot \cfrac{1}{x} + a_2$ , thus $f_2(x) = ((a_0\cdot \cfrac{1}{x} + a_1)\cdot\cfrac{1}{x} + a_2) \cdot x^2$ . In the code, $P(x) = num\textunderscore ans \cdot x^M$ , $Q(x) = denom\textunderscore ans \cdot x^N$ , thus $\cfrac{P(x)}{Q(x)} = \cfrac{num\textunderscore ans}{denom\textunderscore ans}\cdot x^{M - N}$ , and $i$ on $M - N$ , not $N - M$ .$P(x)$ and $Q(x)$ to have the same order so that it's not an issue there. As on
ratevl
inscipy / scipy / special / cephes / polevl.h
. It appears online 158
, which should bei = M - N;
instead ofi = N - M;
. Here I give a brief explanation of what the function does and why there is a bug.The function
ratevl
online 118
evaluates a rational functionline 55
.Here I give a simple example to illustrate. Let
That is,
line 158
should beIn the boost implementation as referenced on
line 55
, it pre-processed to requireline 60
, I believe the piece of code for the functionratevl
is rewritten instead of copying from the reference directly, which is likely to be a reason for this error.The text was updated successfully, but these errors were encountered: