Skip to content
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

Simplify(::Expr) failed #61

Open
DANA-Laboratory opened this issue Jan 25, 2015 · 3 comments
Open

Simplify(::Expr) failed #61

DANA-Laboratory opened this issue Jan 25, 2015 · 3 comments

Comments

@DANA-Laboratory
Copy link

in v0.1.5
simplify can not handle Float64(NaN)
check this code

using calculus 
simplify(:(1-0/0)) 

thanks

@mlubin
Copy link
Collaborator

mlubin commented Jan 26, 2015

If you need this working, feel free to submit a PR. It's not really clear what 0/0 should be simplified to though. NaN is a floating-point value, not a symbolic value.

@johanbluecreek
Copy link
Contributor

I also happen to run into this problem (more exactly, it seems to get stuck indefinitely). To me it looks like it could be due to the loop

while new_ex != ex
  new_ex, ex = simplify(new_ex), new_ex
end

that because of

julia> NaN != NaN
true

should cause an infinite loop. It might be sufficient to change it to a while !(isequal(new_ex, ex)) since

julia> isequal(NaN,NaN)
true

Will try and test this in the next few days and make a PR if it works (unless someone beats me to to it).

@johnmyleswhite
Copy link
Collaborator

That seems reasonable. Please do try that. Such a small change can be made into a PR by just editing the file in GitHub, which will handle everything for you including submitting the PR and running the tests.

johanbluecreek pushed a commit to johanbluecreek/Calculus.jl that referenced this issue Apr 21, 2017
Implementing my suggested sol for Issue JuliaMath#61
johanbluecreek pushed a commit to johanbluecreek/Calculus.jl that referenced this issue Apr 21, 2017
Changed `!=` to use `!isequal()` to not get stuck in infinite loops with NaN.
Non-trivial test also added that verifies this.
johnmyleswhite added a commit that referenced this issue May 6, 2017
Resolving issue #61: Expressions evaluated to NaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants