Skip to content

Commit

Permalink
Decrease the allowed tolerance for cbrt
Browse files Browse the repository at this point in the history
With the correctly rounded implementation, we can reduce the ULP
requirement for `cbrt` to zero. There is still an override required for
`i586` because of the imprecise FMA.
  • Loading branch information
tgross35 committed Jan 25, 2025
1 parent d622bf8 commit f453c3e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/libm-test/src/precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
| Bn::Trunc => 0,

// Operations that aren't required to be exact, but our implementations are.
Bn::Cbrt if ctx.fn_ident != Id::Cbrt => 0,
Bn::Cbrt => 0,

// Bessel functions have large inaccuracies.
Bn::J0 | Bn::J1 | Bn::Y0 | Bn::Y1 | Bn::Jn | Bn::Yn => 8_000_000,
Expand All @@ -54,7 +54,6 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
Bn::Atan => 1,
Bn::Atan2 => 2,
Bn::Atanh => 2,
Bn::Cbrt => 1,
Bn::Cos => 1,
Bn::Cosh => 1,
Bn::Erf => 1,
Expand Down Expand Up @@ -92,6 +91,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
}

match ctx.fn_ident {
Id::Cbrt => ulp = 2,
// FIXME(#401): musl has an incorrect result here.
Id::Fdim => ulp = 2,
Id::Sincosf => ulp = 500,
Expand Down Expand Up @@ -119,6 +119,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {

Id::Asinh => ulp = 3,
Id::Asinhf => ulp = 3,
Id::Cbrt => ulp = 1,
Id::Exp10 | Id::Exp10f => ulp = 1_000_000,
Id::Exp2 | Id::Exp2f => ulp = 10_000_000,
Id::Log1p | Id::Log1pf => ulp = 2,
Expand Down

0 comments on commit f453c3e

Please sign in to comment.