
(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 10 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
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+
x
(*
(pow x 3.0)
(fma
(pow x 2.0)
(fma (pow x 2.0) -0.044642857142857144 0.075)
-0.16666666666666666)))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x + (powf(x, 3.0f) * fmaf(powf(x, 2.0f), fmaf(powf(x, 2.0f), -0.044642857142857144f, 0.075f), -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * fma((x ^ Float32(2.0)), fma((x ^ Float32(2.0)), Float32(-0.044642857142857144), Float32(0.075)), Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot \mathsf{fma}\left({x}^{2}, \mathsf{fma}\left({x}^{2}, -0.044642857142857144, 0.075\right), -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\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) < -2Initial program 49.1%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
mul-1-neg96.6%
unsub-neg96.6%
sub-neg96.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.8%
associate-*r/10.8%
metadata-eval10.8%
distribute-neg-frac10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in x around 0 98.2%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 23.0%
add-exp-log23.0%
+-commutative23.0%
hypot-1-def23.2%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt13.6%
Applied egg-rr13.6%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
fma-neg100.0%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
metadata-eval100.0%
Simplified100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 63.8%
+-commutative63.8%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 63.8%
rem-square-sqrt63.8%
fabs-sqr63.8%
metadata-eval63.8%
unpow263.8%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 0.10000000149011612)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (t_0 <= single(0.10000000149011612)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\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) < -2Initial program 49.1%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
mul-1-neg96.6%
unsub-neg96.6%
sub-neg96.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.8%
associate-*r/10.8%
metadata-eval10.8%
distribute-neg-frac10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in x around 0 98.2%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 23.0%
add-exp-log23.0%
+-commutative23.0%
hypot-1-def23.2%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt13.6%
Applied egg-rr13.6%
Taylor expanded in x around 0 99.9%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 63.8%
+-commutative63.8%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 63.8%
rem-square-sqrt63.8%
fabs-sqr63.8%
metadata-eval63.8%
unpow263.8%
hypot-undefine99.9%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.03999999910593033f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.03999999910593033)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.1%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
mul-1-neg96.6%
unsub-neg96.6%
sub-neg96.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.8%
associate-*r/10.8%
metadata-eval10.8%
distribute-neg-frac10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in x around 0 98.2%
if -5 < x < 0.0399999991Initial program 22.4%
add-exp-log22.4%
+-commutative22.4%
hypot-1-def22.6%
add-sqr-sqrt8.4%
fabs-sqr8.4%
add-sqr-sqrt12.9%
Applied egg-rr12.9%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if 0.0399999991 < x Initial program 64.2%
add-sqr-sqrt64.2%
pow264.2%
+-commutative64.2%
hypot-1-def99.7%
Applied egg-rr99.7%
log1p-expm1-u99.7%
expm1-undefine99.7%
add-exp-log99.7%
unpow299.7%
add-sqr-sqrt99.8%
add-sqr-sqrt99.7%
fabs-sqr99.7%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
associate-+l+100.0%
Simplified100.0%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.03999999910593033)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.03999999910593033f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.03999999910593033)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.03999999910593033)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), 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 < -5Initial program 49.1%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
mul-1-neg96.6%
unsub-neg96.6%
sub-neg96.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.8%
associate-*r/10.8%
metadata-eval10.8%
distribute-neg-frac10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in x around 0 98.2%
if -5 < x < 0.0399999991Initial program 22.4%
add-exp-log22.4%
+-commutative22.4%
hypot-1-def22.6%
add-sqr-sqrt8.4%
fabs-sqr8.4%
add-sqr-sqrt12.9%
Applied egg-rr12.9%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
if 0.0399999991 < x Initial program 64.2%
+-commutative64.2%
hypot-1-def99.8%
Simplified99.8%
Taylor expanded in x around 0 64.2%
rem-square-sqrt64.2%
fabs-sqr64.2%
metadata-eval64.2%
unpow264.2%
hypot-undefine99.7%
rem-square-sqrt99.8%
Simplified99.8%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(Float32(-log(Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(-log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.1%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
mul-1-neg96.6%
unsub-neg96.6%
sub-neg96.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.8%
associate-*r/10.8%
metadata-eval10.8%
distribute-neg-frac10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in x around 0 98.2%
if -5 < x < 1Initial program 24.9%
add-exp-log24.9%
+-commutative24.9%
hypot-1-def25.1%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt15.7%
Applied egg-rr15.7%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.2%
Applied egg-rr98.2%
if 1 < x Initial program 62.3%
flip-+18.0%
clear-num18.0%
log-div18.0%
metadata-eval18.0%
+-commutative18.0%
hypot-1-def17.6%
add-sqr-sqrt17.5%
fabs-sqr17.5%
add-sqr-sqrt17.6%
Applied egg-rr17.8%
neg-sub017.8%
div-sub17.9%
*-rgt-identity17.9%
associate-/l*17.9%
*-rgt-identity17.9%
associate-/l*17.9%
fma-undefine17.9%
unpow217.9%
associate--r+17.6%
+-inverses17.6%
metadata-eval17.6%
metadata-eval17.6%
*-commutative17.6%
neg-mul-117.6%
fma-undefine17.6%
unpow217.6%
associate--r+20.2%
Simplified22.8%
Taylor expanded in x around inf 93.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.1%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
*-commutative96.6%
distribute-rgt-neg-in96.6%
mul-1-neg96.6%
unsub-neg96.6%
sub-neg96.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.8%
associate-*r/10.8%
metadata-eval10.8%
distribute-neg-frac10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in x around 0 98.2%
if -5 < x < 1Initial program 24.9%
add-exp-log24.9%
+-commutative24.9%
hypot-1-def25.1%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt15.7%
Applied egg-rr15.7%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.2%
Applied egg-rr98.2%
if 1 < x Initial program 62.3%
Taylor expanded in x around inf 93.4%
rem-square-sqrt93.4%
fabs-sqr93.4%
rem-square-sqrt93.4%
*-inverses93.4%
metadata-eval93.4%
Simplified93.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign -1.0 x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-1.0f, x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-1.0), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), 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(-5.0)) tmp = sign(x) * abs(single(-1.0)); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(-1, x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.1%
Taylor expanded in x around -inf 48.2%
distribute-lft-out48.2%
Simplified48.2%
Taylor expanded in x around 0 20.9%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt20.9%
*-inverses20.9%
metadata-eval20.9%
Simplified20.9%
if -5 < x < 1Initial program 24.9%
add-exp-log24.9%
+-commutative24.9%
hypot-1-def25.1%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt15.7%
Applied egg-rr15.7%
Taylor expanded in x around 0 98.2%
*-commutative98.2%
Simplified98.2%
unpow298.2%
Applied egg-rr98.2%
if 1 < x Initial program 62.3%
Taylor expanded in x around inf 93.4%
rem-square-sqrt93.4%
fabs-sqr93.4%
rem-square-sqrt93.4%
*-inverses93.4%
metadata-eval93.4%
Simplified93.4%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign -1.0 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-1.0f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-1.0), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(-1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.1%
Taylor expanded in x around -inf 48.2%
distribute-lft-out48.2%
Simplified48.2%
Taylor expanded in x around 0 20.9%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt20.9%
*-inverses20.9%
metadata-eval20.9%
Simplified20.9%
if -5 < x Initial program 38.4%
Taylor expanded in x around 0 28.2%
log1p-define74.1%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt74.1%
Simplified74.1%
(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 41.3%
Taylor expanded in x around 0 32.7%
log1p-define66.0%
rem-square-sqrt32.5%
fabs-sqr32.5%
rem-square-sqrt53.9%
Simplified53.9%
Taylor expanded in x around 0 51.3%
(FPCore (x) :precision binary32 (copysign -1.0 x))
float code(float x) {
return copysignf(-1.0f, x);
}
function code(x) return copysign(Float32(-1.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-1.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-1, x\right)
\end{array}
Initial program 41.3%
Taylor expanded in x around -inf 15.7%
distribute-lft-out15.7%
Simplified15.7%
Taylor expanded in x around 0 16.6%
rem-square-sqrt8.3%
fabs-sqr8.3%
rem-square-sqrt16.6%
*-inverses16.6%
metadata-eval16.6%
Simplified16.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 2024118
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))