
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 63.3%
flip-+11.5%
frac-2neg11.5%
log-div11.5%
Applied egg-rr18.4%
fma-undefine18.4%
unpow218.4%
associate--r+60.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
Simplified99.9%
if -0.0500000007 < x < 0.0500000007Initial program 20.3%
Taylor expanded in x around 0 20.3%
+-commutative20.3%
fma-define20.3%
rem-square-sqrt9.7%
fabs-sqr9.7%
rem-square-sqrt20.9%
Simplified20.9%
Taylor expanded in x around 0 99.8%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0500000007 < x Initial program 64.1%
*-un-lft-identity64.1%
*-commutative64.1%
log-prod64.1%
+-commutative64.1%
hypot-1-def99.5%
add-sqr-sqrt99.5%
fabs-sqr99.5%
add-sqr-sqrt99.5%
metadata-eval99.5%
Applied egg-rr99.5%
+-rgt-identity99.5%
Simplified99.5%
(FPCore (x)
:precision binary32
(if (<=
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
-0.019999999552965164)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -0.019999999552965164f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(-0.019999999552965164)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.0199999996Initial program 64.1%
flip-+13.9%
frac-2neg13.9%
log-div13.7%
Applied egg-rr20.5%
fma-undefine20.5%
unpow220.5%
associate--r+61.7%
+-inverses99.5%
metadata-eval99.5%
metadata-eval99.5%
metadata-eval99.5%
neg-sub099.5%
associate--r-99.5%
neg-sub099.5%
+-commutative99.5%
sub-neg99.5%
neg-sub099.5%
Simplified99.5%
if -0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 34.8%
expm1-log1p-u34.4%
expm1-undefine34.4%
*-un-lft-identity34.4%
*-un-lft-identity34.4%
add-sqr-sqrt28.3%
fabs-sqr28.3%
add-sqr-sqrt34.8%
+-commutative34.8%
hypot-1-def46.6%
Applied egg-rr46.6%
expm1-define46.7%
Simplified46.7%
expm1-log1p-u47.5%
log1p-expm1-u47.5%
log1p-undefine47.5%
expm1-undefine47.5%
add-exp-log47.5%
Applied egg-rr47.5%
log1p-define47.5%
associate--l+98.2%
Simplified98.2%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.2%
Taylor expanded in x around -inf 97.2%
neg-mul-197.2%
Simplified97.2%
if -2 < x < 0.0500000007Initial program 21.5%
Taylor expanded in x around 0 20.9%
+-commutative20.9%
fma-define20.9%
rem-square-sqrt9.5%
fabs-sqr9.5%
rem-square-sqrt21.4%
Simplified21.4%
Taylor expanded in x around 0 99.3%
distribute-rgt-in99.4%
*-lft-identity99.4%
associate-*l*99.4%
unpow299.4%
unpow399.4%
Simplified99.4%
if 0.0500000007 < x Initial program 64.1%
*-un-lft-identity64.1%
*-commutative64.1%
log-prod64.1%
+-commutative64.1%
hypot-1-def99.5%
add-sqr-sqrt99.5%
fabs-sqr99.5%
add-sqr-sqrt99.5%
metadata-eval99.5%
Applied egg-rr99.5%
+-rgt-identity99.5%
Simplified99.5%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.2%
Taylor expanded in x around -inf 99.1%
mul-1-neg99.1%
distribute-rgt-neg-in99.1%
mul-1-neg99.1%
unsub-neg99.1%
sub-neg99.1%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.8%
associate-*r/12.8%
metadata-eval12.8%
distribute-neg-frac12.8%
metadata-eval12.8%
Simplified12.8%
Taylor expanded in x around 0 97.2%
if -2 < x < 0.0500000007Initial program 21.5%
Taylor expanded in x around 0 20.9%
+-commutative20.9%
fma-define20.9%
rem-square-sqrt9.5%
fabs-sqr9.5%
rem-square-sqrt21.4%
Simplified21.4%
Taylor expanded in x around 0 99.3%
distribute-rgt-in99.4%
*-lft-identity99.4%
associate-*l*99.4%
unpow299.4%
unpow399.4%
Simplified99.4%
if 0.0500000007 < x Initial program 64.1%
*-un-lft-identity64.1%
*-commutative64.1%
log-prod64.1%
+-commutative64.1%
hypot-1-def99.5%
add-sqr-sqrt99.5%
fabs-sqr99.5%
add-sqr-sqrt99.5%
metadata-eval99.5%
Applied egg-rr99.5%
+-rgt-identity99.5%
Simplified99.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.2%
Taylor expanded in x around -inf 99.1%
mul-1-neg99.1%
distribute-rgt-neg-in99.1%
mul-1-neg99.1%
unsub-neg99.1%
sub-neg99.1%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.8%
associate-*r/12.8%
metadata-eval12.8%
distribute-neg-frac12.8%
metadata-eval12.8%
Simplified12.8%
Taylor expanded in x around 0 97.2%
if -2 < x < 0.5Initial program 24.2%
Taylor expanded in x around 0 22.5%
+-commutative22.5%
fma-define22.5%
rem-square-sqrt11.6%
fabs-sqr11.6%
rem-square-sqrt23.0%
Simplified23.0%
Taylor expanded in x around 0 98.4%
distribute-rgt-in98.4%
*-lft-identity98.4%
associate-*l*98.4%
unpow298.4%
unpow398.4%
Simplified98.4%
if 0.5 < x Initial program 61.6%
+-commutative61.6%
hypot-1-def99.9%
flip-+10.1%
hypot-1-def10.0%
hypot-1-def9.4%
add-sqr-sqrt9.9%
+-commutative9.9%
hypot-1-def9.2%
+-commutative9.2%
div-sub9.4%
Applied egg-rr10.0%
div-sub9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.2%
Taylor expanded in x around -inf 99.1%
mul-1-neg99.1%
distribute-rgt-neg-in99.1%
mul-1-neg99.1%
unsub-neg99.1%
sub-neg99.1%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.8%
associate-*r/12.8%
metadata-eval12.8%
distribute-neg-frac12.8%
metadata-eval12.8%
Simplified12.8%
Taylor expanded in x around 0 97.2%
if -2 < x < 0.5Initial program 24.2%
Taylor expanded in x around 0 22.5%
+-commutative22.5%
fma-define22.5%
rem-square-sqrt11.6%
fabs-sqr11.6%
rem-square-sqrt23.0%
Simplified23.0%
Taylor expanded in x around 0 95.7%
if 0.5 < x Initial program 61.6%
+-commutative61.6%
hypot-1-def99.9%
flip-+10.1%
hypot-1-def10.0%
hypot-1-def9.4%
add-sqr-sqrt9.9%
+-commutative9.9%
hypot-1-def9.2%
+-commutative9.2%
div-sub9.4%
Applied egg-rr10.0%
div-sub9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 36.3%
Taylor expanded in x around 0 21.6%
+-commutative21.6%
fma-define21.6%
rem-square-sqrt7.9%
fabs-sqr7.9%
rem-square-sqrt22.0%
Simplified22.0%
Taylor expanded in x around 0 69.2%
if 0.5 < x Initial program 61.6%
+-commutative61.6%
hypot-1-def99.9%
flip-+10.1%
hypot-1-def10.0%
hypot-1-def9.4%
add-sqr-sqrt9.9%
+-commutative9.9%
hypot-1-def9.2%
+-commutative9.2%
div-sub9.4%
Applied egg-rr10.0%
div-sub9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 36.3%
Taylor expanded in x around 0 21.6%
+-commutative21.6%
fma-define21.6%
rem-square-sqrt7.9%
fabs-sqr7.9%
rem-square-sqrt22.0%
Simplified22.0%
Taylor expanded in x around 0 69.2%
if 0.5 < x Initial program 61.6%
Taylor expanded in x around 0 43.9%
log1p-define43.9%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt43.9%
Simplified43.9%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 42.3%
Taylor expanded in x around 0 21.2%
+-commutative21.2%
fma-define21.2%
rem-square-sqrt10.7%
fabs-sqr10.7%
rem-square-sqrt21.4%
Simplified21.4%
Taylor expanded in x around 0 55.6%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024119
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))) x)
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))