
(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 14 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.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), 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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.075) * (x ^ Float32(5.0))))), 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.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0)))))); 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\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) 1)))) x) < -0.100000001Initial program 56.0%
+-commutative56.0%
hypot-1-def99.8%
Simplified99.8%
flip-+11.8%
frac-2neg11.8%
log-div11.9%
Applied egg-rr17.0%
sub-neg17.0%
sub-neg17.0%
fma-undefine16.6%
unpow216.6%
associate--r+53.0%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 23.4%
+-commutative23.4%
hypot-1-def23.7%
Simplified23.7%
flip-+23.1%
div-sub23.5%
pow223.5%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt23.5%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt21.9%
Applied egg-rr23.5%
div-sub23.4%
fma-undefine23.4%
unpow223.4%
associate--r+23.6%
+-inverses23.6%
metadata-eval23.6%
metadata-eval23.6%
associate-/r*23.6%
neg-mul-123.6%
sub-neg23.6%
+-commutative23.6%
distribute-neg-in23.6%
remove-double-neg23.6%
sub-neg23.6%
Simplified23.6%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 62.6%
+-commutative62.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
*-commutative98.6%
log-prod98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 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 <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) + (0.5f * (-1.0f / 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(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) + Float32(Float32(0.5) * Float32(Float32(-1.0) / 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(-1.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) + (single(0.5) * (single(-1.0) / 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 + 0.5 \cdot \frac{-1}{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 < -1Initial program 54.7%
+-commutative54.7%
hypot-1-def99.9%
Simplified99.9%
flip-+9.0%
frac-2neg9.0%
log-div9.0%
Applied egg-rr14.4%
sub-neg14.4%
sub-neg14.4%
fma-undefine14.0%
unpow214.0%
associate--r+51.6%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.0%
if -1 < x < 0.0199999996Initial program 24.5%
+-commutative24.5%
hypot-1-def24.8%
Simplified24.8%
Taylor expanded in x around 0 24.3%
+-commutative24.3%
fma-define24.3%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt23.2%
log1p-define96.8%
rem-square-sqrt40.4%
fabs-sqr40.4%
rem-square-sqrt98.1%
Simplified98.1%
Taylor expanded in x around 0 99.2%
if 0.0199999996 < x Initial program 62.6%
+-commutative62.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
*-commutative98.6%
log-prod98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -0.029999999329447746)
(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.029999999329447746f) {
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.029999999329447746)) tmp = copysign(Float32(-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.029999999329447746)) 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.029999999329447746:\\
\;\;\;\;\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.0299999993Initial program 57.8%
+-commutative57.8%
hypot-1-def99.6%
Simplified99.6%
flip-+15.4%
frac-2neg15.4%
log-div15.4%
Applied egg-rr20.4%
sub-neg20.4%
sub-neg20.4%
fma-undefine20.0%
unpow220.0%
associate--r+55.0%
+-inverses99.6%
metadata-eval99.6%
metadata-eval99.6%
metadata-eval99.6%
neg-sub099.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-in99.6%
remove-double-neg99.6%
sub-neg99.6%
Simplified99.6%
if -0.0299999993 < x < 0.0199999996Initial program 21.7%
+-commutative21.7%
hypot-1-def22.0%
Simplified22.0%
Taylor expanded in x around 0 22.7%
+-commutative22.7%
fma-define22.7%
rem-square-sqrt11.4%
fabs-sqr11.4%
rem-square-sqrt22.3%
log1p-define98.9%
rem-square-sqrt42.0%
fabs-sqr42.0%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 62.6%
+-commutative62.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
*-commutative98.6%
log-prod98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.5)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); 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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 53.2%
+-commutative53.2%
hypot-1-def99.9%
Simplified99.9%
flip-+6.0%
frac-2neg6.0%
log-div6.0%
Applied egg-rr11.6%
sub-neg11.6%
sub-neg11.6%
fma-undefine11.1%
unpow211.1%
associate--r+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 98.1%
if -1.5 < x < 0.5Initial program 26.2%
+-commutative26.2%
hypot-1-def26.5%
Simplified26.5%
Taylor expanded in x around 0 24.6%
+-commutative24.6%
fma-define24.6%
rem-square-sqrt11.1%
fabs-sqr11.1%
rem-square-sqrt23.4%
log1p-define95.4%
rem-square-sqrt39.9%
fabs-sqr39.9%
rem-square-sqrt96.2%
Simplified96.2%
Taylor expanded in x around 0 97.9%
if 0.5 < x Initial program 62.0%
+-commutative62.0%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
associate-+r+97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 x))))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) + (0.5f * (-1.0f / x)))), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) + Float32(Float32(0.5) * Float32(Float32(-1.0) / 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(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) + (single(0.5) * (single(-1.0) / x))))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 + 0.5 \cdot \frac{-1}{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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 54.7%
+-commutative54.7%
hypot-1-def99.9%
Simplified99.9%
flip-+9.0%
frac-2neg9.0%
log-div9.0%
Applied egg-rr14.4%
sub-neg14.4%
sub-neg14.4%
fma-undefine14.0%
unpow214.0%
associate--r+51.6%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.0%
if -1 < x < 0.5Initial program 25.1%
+-commutative25.1%
hypot-1-def25.3%
Simplified25.3%
Taylor expanded in x around 0 24.4%
+-commutative24.4%
fma-define24.4%
rem-square-sqrt11.3%
fabs-sqr11.3%
rem-square-sqrt23.4%
log1p-define96.5%
rem-square-sqrt40.5%
fabs-sqr40.5%
rem-square-sqrt97.7%
Simplified97.7%
Taylor expanded in x around 0 98.8%
if 0.5 < x Initial program 62.0%
+-commutative62.0%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
associate-+r+97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + 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(-x)); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 52.4%
+-commutative52.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 44.3%
mul-1-neg44.3%
Simplified44.3%
if -5 < x < 0.5Initial program 26.7%
+-commutative26.7%
hypot-1-def27.0%
Simplified27.0%
Taylor expanded in x around 0 24.7%
+-commutative24.7%
fma-define24.7%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt23.4%
log1p-define94.9%
rem-square-sqrt39.6%
fabs-sqr39.6%
rem-square-sqrt95.5%
Simplified95.5%
Taylor expanded in x around 0 97.4%
Taylor expanded in x around 0 95.1%
if 0.5 < x Initial program 62.0%
+-commutative62.0%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.0%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.0%
Simplified97.0%
Final simplification84.3%
(FPCore (x) :precision binary32 (if (<= x -1.5) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.5)) 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 + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;\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 + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 53.2%
+-commutative53.2%
hypot-1-def99.9%
Simplified99.9%
flip-+6.0%
div-sub5.9%
pow25.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.3%
Applied egg-rr8.6%
div-sub11.6%
fma-undefine11.2%
unpow211.2%
associate--r+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 98.0%
if -1.5 < x < 0.5Initial program 26.2%
+-commutative26.2%
hypot-1-def26.5%
Simplified26.5%
Taylor expanded in x around 0 24.6%
+-commutative24.6%
fma-define24.6%
rem-square-sqrt11.1%
fabs-sqr11.1%
rem-square-sqrt23.4%
log1p-define95.4%
rem-square-sqrt39.9%
fabs-sqr39.9%
rem-square-sqrt96.2%
Simplified96.2%
Taylor expanded in x around 0 97.9%
Taylor expanded in x around 0 95.6%
if 0.5 < x Initial program 62.0%
+-commutative62.0%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.0%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.0%
Simplified97.0%
Final simplification96.5%
(FPCore (x) :precision binary32 (if (<= x -1.5) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.5)) 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((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 53.2%
+-commutative53.2%
hypot-1-def99.9%
Simplified99.9%
flip-+6.0%
div-sub5.9%
pow25.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.3%
Applied egg-rr8.6%
div-sub11.6%
fma-undefine11.2%
unpow211.2%
associate--r+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 98.0%
if -1.5 < x < 0.5Initial program 26.2%
+-commutative26.2%
hypot-1-def26.5%
Simplified26.5%
Taylor expanded in x around 0 24.6%
+-commutative24.6%
fma-define24.6%
rem-square-sqrt11.1%
fabs-sqr11.1%
rem-square-sqrt23.4%
log1p-define95.4%
rem-square-sqrt39.9%
fabs-sqr39.9%
rem-square-sqrt96.2%
Simplified96.2%
Taylor expanded in x around 0 97.9%
Taylor expanded in x around 0 95.6%
if 0.5 < x Initial program 62.0%
+-commutative62.0%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
associate-+r+97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
Final simplification96.8%
(FPCore (x) :precision binary32 (if (<= x -1.5) (copysign (- (log (* x -2.0))) x) (if (<= x 0.5) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.5)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); 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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 53.2%
+-commutative53.2%
hypot-1-def99.9%
Simplified99.9%
flip-+6.0%
frac-2neg6.0%
log-div6.0%
Applied egg-rr11.6%
sub-neg11.6%
sub-neg11.6%
fma-undefine11.1%
unpow211.1%
associate--r+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 98.1%
if -1.5 < x < 0.5Initial program 26.2%
+-commutative26.2%
hypot-1-def26.5%
Simplified26.5%
Taylor expanded in x around 0 24.6%
+-commutative24.6%
fma-define24.6%
rem-square-sqrt11.1%
fabs-sqr11.1%
rem-square-sqrt23.4%
log1p-define95.4%
rem-square-sqrt39.9%
fabs-sqr39.9%
rem-square-sqrt96.2%
Simplified96.2%
Taylor expanded in x around 0 97.9%
Taylor expanded in x around 0 95.6%
if 0.5 < x Initial program 62.0%
+-commutative62.0%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
associate-+r+97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
Final simplification96.9%
(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 55.4%
+-commutative55.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 43.1%
mul-1-neg43.1%
Simplified43.1%
if -0.5 < x Initial program 36.8%
+-commutative36.8%
hypot-1-def49.0%
Simplified49.0%
Taylor expanded in x around 0 28.0%
log1p-define76.3%
rem-square-sqrt39.6%
fabs-sqr39.6%
rem-square-sqrt76.3%
Simplified76.3%
Final simplification68.4%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign 14.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(14.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(14.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 54.7%
+-commutative54.7%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 5.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
associate-+r+-0.0%
associate-*r/-0.0%
metadata-eval-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified26.5%
if -1 < x Initial program 37.1%
+-commutative37.1%
hypot-1-def49.2%
Simplified49.2%
Taylor expanded in x around 0 28.0%
log1p-define76.1%
rem-square-sqrt39.4%
fabs-sqr39.4%
rem-square-sqrt76.0%
Simplified76.0%
Final simplification64.4%
(FPCore (x) :precision binary32 (if (or (<= x -200.0) (not (<= x 4.0))) (copysign 14.333333333333334 x) (copysign x x)))
float code(float x) {
float tmp;
if ((x <= -200.0f) || !(x <= 4.0f)) {
tmp = copysignf(14.333333333333334f, x);
} else {
tmp = copysignf(x, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if ((x <= Float32(-200.0)) || !(x <= Float32(4.0))) tmp = copysign(Float32(14.333333333333334), x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if ((x <= single(-200.0)) || ~((x <= single(4.0)))) tmp = sign(x) * abs(single(14.333333333333334)); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -200 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -200 or 4 < x Initial program 56.8%
+-commutative56.8%
hypot-1-def99.2%
Simplified99.2%
Taylor expanded in x around inf 55.0%
rem-square-sqrt52.1%
fabs-sqr52.1%
rem-square-sqrt52.1%
associate-+r+52.1%
associate-*r/52.1%
metadata-eval52.1%
Simplified52.1%
Taylor expanded in x around 0 1.1%
Simplified27.2%
if -200 < x < 4Initial program 27.8%
+-commutative27.8%
hypot-1-def28.0%
Simplified28.0%
Taylor expanded in x around 0 24.8%
+-commutative24.8%
fma-define24.8%
rem-square-sqrt11.1%
fabs-sqr11.1%
rem-square-sqrt23.6%
log1p-define94.1%
rem-square-sqrt39.2%
fabs-sqr39.2%
rem-square-sqrt94.4%
Simplified94.4%
Taylor expanded in x around 0 96.3%
Taylor expanded in x around 0 94.1%
Final simplification63.0%
(FPCore (x) :precision binary32 (copysign -7.0 x))
float code(float x) {
return copysignf(-7.0f, x);
}
function code(x) return copysign(Float32(-7.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-7.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-7, x\right)
\end{array}
Initial program 41.2%
+-commutative41.2%
hypot-1-def61.1%
Simplified61.1%
Taylor expanded in x around inf 28.2%
rem-square-sqrt26.9%
fabs-sqr26.9%
rem-square-sqrt26.9%
associate-+r+26.9%
associate-*r/26.9%
metadata-eval26.9%
Simplified26.9%
Taylor expanded in x around 0 3.6%
Simplified17.7%
Final simplification17.7%
(FPCore (x) :precision binary32 (copysign 14.333333333333334 x))
float code(float x) {
return copysignf(14.333333333333334f, x);
}
function code(x) return copysign(Float32(14.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(14.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(14.333333333333334, x\right)
\end{array}
Initial program 41.2%
+-commutative41.2%
hypot-1-def61.1%
Simplified61.1%
Taylor expanded in x around inf 28.2%
rem-square-sqrt26.9%
fabs-sqr26.9%
rem-square-sqrt26.9%
associate-+r+26.9%
associate-*r/26.9%
metadata-eval26.9%
Simplified26.9%
Taylor expanded in x around 0 3.0%
Simplified18.5%
Final simplification18.5%
(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 2024043
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:herbie-target
(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))