Calculus.jl icon indicating copy to clipboard operation
Calculus.jl copied to clipboard

Simplify(::Expr) failed

Open DANA-Laboratory opened this issue 10 years ago • 3 comments

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

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

thanks

DANA-Laboratory avatar Jan 25 '15 12:01 DANA-Laboratory

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.

mlubin avatar Jan 26 '15 01:01 mlubin

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).

johanbluecreek avatar Apr 21 '17 14:04 johanbluecreek

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.

johnmyleswhite avatar Apr 21 '17 14:04 johnmyleswhite