Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug in Horner's scheme #78

Closed
aytekinar opened this issue Dec 1, 2016 · 2 comments
Closed

Bug in Horner's scheme #78

aytekinar opened this issue Dec 1, 2016 · 2 comments

Comments

@aytekinar
Copy link

Description

Horner's scheme as it is implemented now gives wrong results.

Observed Behaviour

julia> using Polynomials
julia> p1 = Poly([Inf, Inf])
Poly(Inf + Infx)
julia> p1(Inf)
NaN
julia> p1(-Inf)
NaN
julia> p1(0)
NaN
julia> p2 = Poly([0, Inf])
Poly(Infx)
julia> p2(-Inf)
NaN

Desired Behaviour

julia> using Polynomials
julia> p1 = Poly([Inf, Inf])
Poly(Inf + Infx)
julia> p1(Inf)
Inf
julia> p1(-Inf)
NaN
julia> p1(0)
NaN
julia> p2 = Poly([0, Inf])
Poly(Infx)
julia> p2(-Inf)
-Inf
@aytekinar
Copy link
Author

Moreover, without the bugfix, we currently have

julia> using Polynomials
julia> p = Poly([1])
Poly(1)
julia> p(Inf)
NaN
julia> p(NaN)
NaN

both of which should give 1.0, I suppose, as the polynomial is a constant polynomial.

@aytekinar aytekinar mentioned this issue Dec 2, 2016
@jverzani
Copy link
Member

jverzani commented Dec 2, 2016

Yes, this is how SymPy handles these cases.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants