mgaido91 opened a new pull request, #54676:
URL: https://github.com/apache/spark/pull/54676

   ### What changes were proposed in this pull request?
   
   As mentioned in https://issues.apache.org/jira/browse/SPARK-55557, for large 
values (namely, larger than the square root of `Double.MAX:_VALUE`) the `asinh` 
and `acosh` functions return Infinity, due to overflow. This happens because of 
the `x * x` operation in the formula to compute them. However, for such large 
numbers, the expression can be simplified. Indeed, `x +\- 1` for such large 
numbers has no effect, since the precision is not enough to be sensitive to 
this operaiton. Hence, `log(x + sqrt(x * x +/- 1))` can be written as `log(2x) 
= (log(2) + log(x))` in such cases.
   
   
   ### Why are the changes needed?
   
   Current code overflows and returns Infinity for asinh and acosh for large 
values.
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, SQL with asinh and acosh with large values do not return infinity 
anymore. For large negative values as input of acosh, `NaN` is returned.
   
   
   ### How was this patch tested?
   
   Added UTs.
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.
   


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