
(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 13 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 -0.4000000059604645)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= t_0 0.10000000149011612)
(copysign
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (* x x) -0.044642857142857144)))
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 <= -0.4000000059604645f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * (0.075f + ((x * x) * -0.044642857142857144f))) - 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(-0.4000000059604645)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - 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(Float32(0.075) + Float32(Float32(x * x) * Float32(-0.044642857142857144)))) - 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(-0.4000000059604645)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - 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) + ((x * x) * single(-0.044642857142857144)))) - 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 -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - 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 \left(0.075 + \left(x \cdot x\right) \cdot -0.044642857142857144\right) - 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) < -0.400000006Initial program 54.5%
flip-+8.7%
clear-num8.7%
log-div8.7%
metadata-eval8.7%
+-commutative8.7%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.4%
Applied egg-rr10.3%
neg-sub010.3%
div-sub10.2%
*-rgt-identity10.2%
associate-/l*10.2%
fma-neg10.2%
fma-undefine10.2%
unpow210.2%
associate--r+10.2%
+-inverses10.2%
metadata-eval10.2%
metadata-eval10.2%
*-rgt-identity10.2%
associate-/l*10.2%
fma-undefine10.2%
unpow210.2%
associate--r+51.4%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.2%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 21.9%
add-sqr-sqrt20.3%
pow220.3%
log-pow20.4%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt21.4%
+-commutative21.4%
hypot-1-def21.5%
Applied egg-rr21.5%
Taylor expanded in x around 0 100.0%
unpow2100.0%
Applied egg-rr100.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 52.4%
Taylor expanded in x around 0 52.4%
rem-square-sqrt52.4%
fabs-sqr52.4%
rem-square-sqrt52.4%
metadata-eval52.4%
unpow252.4%
hypot-undefine100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.4000000059604645)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 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 tmp;
if (x <= -0.4000000059604645f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 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) tmp = Float32(0.0) if (x <= Float32(-0.4000000059604645)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= 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) tmp = single(0.0); if (x <= single(-0.4000000059604645)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= 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}
\mathbf{if}\;x \leq -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \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 x < -0.400000006Initial program 54.5%
flip-+8.7%
clear-num8.7%
log-div8.7%
metadata-eval8.7%
+-commutative8.7%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.4%
Applied egg-rr10.3%
neg-sub010.3%
div-sub10.2%
*-rgt-identity10.2%
associate-/l*10.2%
fma-neg10.2%
fma-undefine10.2%
unpow210.2%
associate--r+10.2%
+-inverses10.2%
metadata-eval10.2%
metadata-eval10.2%
*-rgt-identity10.2%
associate-/l*10.2%
fma-undefine10.2%
unpow210.2%
associate--r+51.4%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.2%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
if -0.400000006 < x < 0.100000001Initial program 21.9%
add-sqr-sqrt20.3%
pow220.3%
log-pow20.4%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt21.4%
+-commutative21.4%
hypot-1-def21.5%
Applied egg-rr21.5%
Taylor expanded in x around 0 99.9%
if 0.100000001 < x Initial program 52.4%
Taylor expanded in x around 0 52.4%
rem-square-sqrt52.4%
fabs-sqr52.4%
rem-square-sqrt52.4%
metadata-eval52.4%
unpow252.4%
hypot-undefine100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(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.10000000149011612f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.019999999552965164f) {
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.10000000149011612)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) 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.10000000149011612)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.019999999552965164)) 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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.100000001Initial program 55.1%
+-commutative55.1%
hypot-1-def99.8%
flip-+9.9%
hypot-1-def9.9%
hypot-1-def9.9%
add-sqr-sqrt9.9%
+-commutative9.9%
hypot-1-def9.9%
+-commutative9.9%
div-sub9.8%
Applied egg-rr12.5%
div-sub14.1%
remove-double-neg14.1%
distribute-frac-neg214.1%
neg-sub014.1%
associate--r-14.1%
neg-sub014.1%
+-commutative14.1%
sub-neg14.1%
distribute-frac-neg14.1%
sub-neg14.1%
+-commutative14.1%
distribute-neg-in14.1%
remove-double-neg14.1%
fma-undefine14.1%
unpow214.1%
+-commutative14.1%
associate-+l+52.0%
sub-neg52.0%
+-inverses99.8%
metadata-eval99.8%
Simplified99.8%
if -0.100000001 < x < 0.0199999996Initial program 20.8%
add-sqr-sqrt19.3%
pow219.3%
log-pow19.3%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.3%
+-commutative20.3%
hypot-1-def20.4%
Applied egg-rr20.4%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0199999996 < x Initial program 53.0%
Taylor expanded in x around 0 53.0%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt53.0%
metadata-eval53.0%
unpow253.0%
hypot-undefine99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.019999999552965164)
(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.10000000149011612f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
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.10000000149011612)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.019999999552965164)) 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.10000000149011612)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.019999999552965164)) 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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.100000001Initial program 55.1%
flip-+9.9%
clear-num9.9%
log-div9.9%
metadata-eval9.9%
+-commutative9.9%
hypot-1-def9.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.5%
Applied egg-rr11.5%
neg-sub011.5%
div-sub11.4%
*-rgt-identity11.4%
associate-/l*11.4%
fma-neg11.4%
fma-undefine11.4%
unpow211.4%
associate--r+11.4%
+-inverses11.4%
metadata-eval11.4%
metadata-eval11.4%
*-rgt-identity11.4%
associate-/l*11.4%
fma-undefine11.4%
unpow211.4%
associate--r+52.0%
Simplified99.8%
*-un-lft-identity99.8%
add-sqr-sqrt-0.0%
sqrt-unprod99.8%
sqr-neg99.8%
sqrt-unprod98.1%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -0.100000001 < x < 0.0199999996Initial program 20.8%
add-sqr-sqrt19.3%
pow219.3%
log-pow19.3%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.3%
+-commutative20.3%
hypot-1-def20.4%
Applied egg-rr20.4%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0199999996 < x Initial program 53.0%
Taylor expanded in x around 0 53.0%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt53.0%
metadata-eval53.0%
unpow253.0%
hypot-undefine99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(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.019999999552965164f) {
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.019999999552965164)) 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.019999999552965164)) 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.019999999552965164:\\
\;\;\;\;\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 53.2%
Taylor expanded in x around -inf 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
mul-1-neg99.3%
unsub-neg99.3%
sub-neg99.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.9%
associate-*r/10.9%
metadata-eval10.9%
distribute-neg-frac10.9%
metadata-eval10.9%
Simplified10.9%
Taylor expanded in x around 0 97.7%
if -2 < x < 0.0199999996Initial program 22.5%
add-sqr-sqrt21.1%
pow221.1%
log-pow21.1%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt22.1%
+-commutative22.1%
hypot-1-def22.2%
Applied egg-rr22.2%
Taylor expanded in x around 0 99.0%
distribute-rgt-in99.0%
*-lft-identity99.0%
associate-*l*99.0%
unpow299.0%
unpow399.0%
Simplified99.0%
if 0.0199999996 < x Initial program 53.0%
Taylor expanded in x around 0 53.0%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt53.0%
metadata-eval53.0%
unpow253.0%
hypot-undefine99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.4000000059604645)
(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.4000000059604645f) {
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.4000000059604645)) 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.4000000059604645)) 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.4000000059604645:\\
\;\;\;\;\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 53.2%
Taylor expanded in x around -inf 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
mul-1-neg99.3%
unsub-neg99.3%
sub-neg99.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.9%
associate-*r/10.9%
metadata-eval10.9%
distribute-neg-frac10.9%
metadata-eval10.9%
Simplified10.9%
Taylor expanded in x around 0 97.7%
if -2 < x < 0.400000006Initial program 23.6%
add-sqr-sqrt22.1%
pow222.1%
log-pow22.1%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt23.1%
+-commutative23.1%
hypot-1-def23.2%
Applied egg-rr23.2%
Taylor expanded in x around 0 98.6%
distribute-rgt-in98.6%
*-lft-identity98.6%
associate-*l*98.6%
unpow298.6%
unpow398.6%
Simplified98.6%
if 0.400000006 < x Initial program 51.7%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
rem-square-sqrt98.2%
fabs-sqr98.2%
rem-square-sqrt98.2%
*-inverses98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.4000000059604645) (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.4000000059604645f) {
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.4000000059604645)) 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.4000000059604645)) 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.4000000059604645:\\
\;\;\;\;\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 53.2%
Taylor expanded in x around -inf 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
mul-1-neg99.3%
unsub-neg99.3%
sub-neg99.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.9%
associate-*r/10.9%
metadata-eval10.9%
distribute-neg-frac10.9%
metadata-eval10.9%
Simplified10.9%
Taylor expanded in x around 0 97.7%
if -2 < x < 0.400000006Initial program 23.6%
add-sqr-sqrt22.1%
pow222.1%
log-pow22.1%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt23.1%
+-commutative23.1%
hypot-1-def23.2%
Applied egg-rr23.2%
Taylor expanded in x around 0 97.1%
if 0.400000006 < x Initial program 51.7%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
rem-square-sqrt98.2%
fabs-sqr98.2%
rem-square-sqrt98.2%
*-inverses98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign (log (/ -1.0 x)) x) (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((-1.0f / x)), x);
} else if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(Float32(-1.0) / x)), x); elseif (x <= Float32(0.4000000059604645)) 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(-20.0)) tmp = sign(x) * abs(log((single(-1.0) / x))); elseif (x <= single(0.4000000059604645)) 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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 < -20Initial program 52.5%
Taylor expanded in x around -inf 44.5%
mul-1-neg44.5%
Simplified44.5%
add-sqr-sqrt44.5%
sqrt-unprod44.5%
sqr-neg44.5%
sqrt-unprod-0.0%
add-sqr-sqrt44.5%
frac-2neg44.5%
metadata-eval44.5%
log-div44.5%
metadata-eval44.5%
Applied egg-rr44.5%
neg-sub044.5%
log-rec44.5%
distribute-neg-frac244.5%
distribute-neg-frac44.5%
metadata-eval44.5%
Simplified44.5%
if -20 < x < 0.400000006Initial program 24.2%
add-sqr-sqrt22.7%
pow222.7%
log-pow22.7%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.8%
Applied egg-rr23.8%
Taylor expanded in x around 0 96.6%
if 0.400000006 < x Initial program 51.7%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
rem-square-sqrt98.2%
fabs-sqr98.2%
rem-square-sqrt98.2%
*-inverses98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign (log (- x)) x) (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.4000000059604645)) 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(-20.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.4000000059604645)) 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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 < -20Initial program 52.5%
Taylor expanded in x around -inf 44.5%
neg-mul-144.5%
Simplified44.5%
if -20 < x < 0.400000006Initial program 24.2%
add-sqr-sqrt22.7%
pow222.7%
log-pow22.7%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.8%
Applied egg-rr23.8%
Taylor expanded in x around 0 96.6%
if 0.400000006 < x Initial program 51.7%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
rem-square-sqrt98.2%
fabs-sqr98.2%
rem-square-sqrt98.2%
*-inverses98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x) :precision binary32 (if (<= x -0.5) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -0.5f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.5)) tmp = copysign(log(Float32(-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(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.5Initial program 53.9%
Taylor expanded in x around -inf 44.2%
neg-mul-144.2%
Simplified44.2%
if -0.5 < x Initial program 32.4%
Taylor expanded in x around 0 28.1%
log1p-define77.5%
rem-square-sqrt40.8%
fabs-sqr40.8%
rem-square-sqrt77.5%
Simplified77.5%
(FPCore (x) :precision binary32 (if (<= x 0.4000000059604645) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.4000000059604645)) 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.4000000059604645:\\
\;\;\;\;\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.400000006Initial program 33.7%
add-sqr-sqrt32.7%
pow232.7%
log-pow32.7%
add-sqr-sqrt6.0%
fabs-sqr6.0%
add-sqr-sqrt19.3%
+-commutative19.3%
hypot-1-def19.4%
Applied egg-rr19.4%
Taylor expanded in x around 0 67.8%
if 0.400000006 < x Initial program 51.7%
Taylor expanded in x around 0 44.7%
log1p-define44.7%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt44.7%
Simplified44.7%
(FPCore (x) :precision binary32 (if (<= x 0.4000000059604645) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.4000000059604645)) tmp = copysign(x, x); else tmp = copysign(log(x), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.4000000059604645)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log(x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 0.400000006Initial program 33.7%
add-sqr-sqrt32.7%
pow232.7%
log-pow32.7%
add-sqr-sqrt6.0%
fabs-sqr6.0%
add-sqr-sqrt19.3%
+-commutative19.3%
hypot-1-def19.4%
Applied egg-rr19.4%
Taylor expanded in x around 0 67.8%
if 0.400000006 < x Initial program 51.7%
Taylor expanded in x around inf 44.7%
mul-1-neg44.7%
log-rec44.7%
remove-double-neg44.7%
Simplified44.7%
(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 38.1%
add-sqr-sqrt37.3%
pow237.3%
log-pow37.3%
add-sqr-sqrt17.1%
fabs-sqr17.1%
add-sqr-sqrt27.1%
+-commutative27.1%
hypot-1-def38.9%
Applied egg-rr38.9%
Taylor expanded in x around 0 54.0%
(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 2024144
(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))