(log x 10) vs (/ (log x) (log 10)
Describe the bug
Let x
be a double-float
. Then(log x 10d0)
produces different
results from (/ (log x) (log 10d0))
for some values of x
.
It would be nice if they returned the same answer.
To Reproduce
Steps to reproduce the behavior:
- Evaluate
(log 1d3 10)
3.0d0
- Evaluate
(/ (log 1d3) (log 10d0))
2.9999999999999996d0
- Ideally both would return 3d0
Expected behavior
While the difference is acceptable, it would be rather nice if cmucl
could convert (/ (log x) (log 10))
to (log x 10)
. The latter
works better because we convert (log x 10)
to a call to log10 from
fdlibm which is produces more accurate results.
Desktop (please complete the following information):
- OS: All
Additional context
I think this would require adjusting the deftransform for /
to
recognize that it's dividing two log forms and the second log form
must have an argument that is equal to 10. This is further
complicated by numeric contagion. This makes it fairly complex
because we want to be sure (/ (log x) (log 10))
uses a single
precision value for (log 10)
. Maybe only apply the transform if x
and 10 have the same numeric precision?