andygrove opened a new issue, #434:
URL: https://github.com/apache/datafusion-spark/issues/434

   ## Summary
   
   `log1p` (added in #344) computes its result with `f64::ln_1p` 
(`crates/spark/src/function/math/log1p.rs`), which calls the platform libm. 
Spark uses `java.lang.StrictMath.log1p`, which the Java spec requires to return 
exactly fdlibm's results.
   
   The two can differ in the last bit, and the difference depends on the 
platform. #334 measured this for `ln`, `log10` and `log2`: Rust's platform libm 
differs from fdlibm on about 2% of inputs (about 5% for `log10`), and 
differently on macOS and Linux. `log1p` probably behaves the same way, but this 
has not been measured for `log1p` on `main`.
   
   ## Why `libm` is not enough
   
   The `libm` crate follows musl, which simplified fdlibm's final steps and 
rounds differently. #359 uses `libm` for `expm1` because it matched Spark's 
results on the cases tested there. #334 found that musl's logs do not match 
fdlibm, so `log1p` likely needs a direct translation of fdlibm's `s_log1p.c` 
instead.
   
   ## Proposed fix
   
   #334 adds `math/fdlibm.rs`, a translation of fdlibm 5.3's `e_log.c`, 
`e_log10.c` and `s_log1p.c`, and moves `log1p` onto it. Once that lands, this 
issue can be closed. Until then, `log1p` on `main` may differ from Spark in the 
last bit on some inputs.
   
   Raised by @coderfender in review of #359.
   
   ---
   _This issue was drafted by an LLM (Claude) from the review discussion and 
the code, and reviewed before filing; please verify the claims against Spark._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to