-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improvements to intermediate numerical evaluation #32
Comments
This is due to us including an julia> 2^0.5 * 2^0.5
2.0000000000000004
julia> 2^(0.5 + 0.5)
2.0 Generally,
It seems like the best first steps to solving this larger issue (fixing this specific instance, at least) would be adding conditionals to |
Perhaps there could be an optional argument passed to ie. julia> normalize((@term 2^0.5 * 2^0.5), :EvalNumeric)
2.0000000000000004 |
It seems good to have something in that direction. Since additional arguments to function normalize(ex, rs...; eval::Bool = false)
# ...
end
# true: always evaluate
# false: only evaluate based on EvalRule Also, the evaluation procedure should probably used as a "last resort", only executing when all rules have been exhausted. (e.g. if there is a rule |
Yeah, that'd be nice. Maybe having one mode where all math is done with BigInt and BigFloat to get arbitrary precision would be advantageous as well. This is what most CAS do by default, so it should at least be an option. Another thought is that Rewrite could try and symbolically simplify purely numerical expressions before evaluating them. For instance, normalize(@term 2^0.5 * 2^0.5)
-> normalize(@term 2^(0.5 + 0.5))
-> normalize(@term 2^(1.0))
-> normalize(@term 2)
-> @term 2 I believe this is what Mathematica does as it seems to get In[1]:= NumberForm[2^0.5 2^0.5, 100]
Out[1]= 2. |
We should probably prefer julia> big"2"^0.5 * big"2"^0.5
1.999999999999999999999999999999999999999999999999999999999999999999999999999983 I like the preference towards symbolic rewriting (before considering evaluation); it seems like it should necessarily lead to the most precise results, in contrast with the standard evaluative interpretation provided by Julia. |
The smallest possible length scale in the universe (Planck length) is ~10^-35 meters across whereas the largest known structure in the universe, the Hercules–Corona Borealis Great Wall is 10,000,000,000 ly across or 10^26 meters. Dividing those gives a difference in scale from the largest to smallest lengths in the universe as ~10^61. The above numerical result is correct to one part in 10^77. It's pretty good, but yes, not exact 😛. Would it be a big overhaul to allow symbolic rewriting of numeric expressions? |
No, not at all! In fact, it's already supported! 😀 julia> normalize(@term sin(2)^2 + cos(2)^2)
@term(1)
julia> normalize(@term log(2, 2))
@term(1) Note that those are purely symbolic, since you'd numerically get |
One can do things like
and have the answer simplified but it seems to not with with non-unity exponents:
The text was updated successfully, but these errors were encountered: