
(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 12 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))
(t_1 (+ (fabs x) 1.0))
(t_2 (pow t_1 2.0)))
(if (<= t_0 -1.0)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.009999999776482582)
(copysign
(fma
-0.041666666666666664
(* (+ (/ 3.0 t_1) (/ 3.0 t_2)) (pow x 4.0))
(fma
0.001388888888888889
(*
(+ (/ 45.0 t_1) (+ (/ 30.0 (pow t_1 3.0)) (/ 45.0 t_2)))
(pow x 6.0))
(fma 0.5 (/ (* x x) t_1) (log1p (fabs x)))))
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 t_1 = fabsf(x) + 1.0f;
float t_2 = powf(t_1, 2.0f);
float tmp;
if (t_0 <= -1.0f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.009999999776482582f) {
tmp = copysignf(fmaf(-0.041666666666666664f, (((3.0f / t_1) + (3.0f / t_2)) * powf(x, 4.0f)), fmaf(0.001388888888888889f, (((45.0f / t_1) + ((30.0f / powf(t_1, 3.0f)) + (45.0f / t_2))) * powf(x, 6.0f)), fmaf(0.5f, ((x * x) / t_1), log1pf(fabsf(x))))), 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) t_1 = Float32(abs(x) + Float32(1.0)) t_2 = t_1 ^ Float32(2.0) tmp = Float32(0.0) if (t_0 <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.009999999776482582)) tmp = copysign(fma(Float32(-0.041666666666666664), Float32(Float32(Float32(Float32(3.0) / t_1) + Float32(Float32(3.0) / t_2)) * (x ^ Float32(4.0))), fma(Float32(0.001388888888888889), Float32(Float32(Float32(Float32(45.0) / t_1) + Float32(Float32(Float32(30.0) / (t_1 ^ Float32(3.0))) + Float32(Float32(45.0) / t_2))) * (x ^ Float32(6.0))), fma(Float32(0.5), Float32(Float32(x * x) / t_1), log1p(abs(x))))), 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)\\
t_1 := \left|x\right| + 1\\
t_2 := {t_1}^{2}\\
\mathbf{if}\;t_0 \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(-0.041666666666666664, \left(\frac{3}{t_1} + \frac{3}{t_2}\right) \cdot {x}^{4}, \mathsf{fma}\left(0.001388888888888889, \left(\frac{45}{t_1} + \left(\frac{30}{{t_1}^{3}} + \frac{45}{t_2}\right)\right) \cdot {x}^{6}, \mathsf{fma}\left(0.5, \frac{x \cdot x}{t_1}, \mathsf{log1p}\left(\left|x\right|\right)\right)\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) 1)))) x) < -1Initial program 50.6%
+-commutative50.6%
hypot-1-def100.0%
Simplified100.0%
flip-+13.6%
div-sub13.7%
pow213.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.7%
pow213.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.8%
hypot-udef4.8%
hypot-udef4.8%
add-sqr-sqrt4.8%
metadata-eval4.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.5%
Applied egg-rr15.5%
unpow215.5%
div-sub19.9%
unpow219.9%
unpow219.9%
unpow219.9%
+-commutative19.9%
associate--r+47.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00999999978Initial program 21.1%
+-commutative21.1%
hypot-1-def21.2%
Simplified21.2%
Taylor expanded in x around 0 22.0%
fma-def22.0%
associate-*r/22.0%
metadata-eval22.0%
associate-*r/22.0%
metadata-eval22.0%
Simplified99.9%
if 0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.05000000074505806)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.009999999776482582)
(copysign (+ x (* -0.16666666666666666 (pow x 3.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.05000000074505806f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.009999999776482582f) {
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) 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.05000000074505806)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.009999999776482582)) 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.05000000074505806)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.009999999776482582)) 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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.009999999776482582:\\
\;\;\;\;\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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.0500000007Initial program 52.9%
+-commutative52.9%
hypot-1-def99.7%
Simplified99.7%
flip-+17.8%
div-sub18.0%
pow218.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt18.0%
pow218.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.9%
hypot-udef6.9%
hypot-udef6.9%
add-sqr-sqrt6.9%
metadata-eval6.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt19.6%
Applied egg-rr19.6%
unpow219.6%
div-sub23.7%
unpow223.7%
unpow223.7%
unpow223.7%
+-commutative23.7%
associate--r+49.7%
+-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
associate-/r*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
sub-neg99.7%
Simplified99.7%
if -0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00999999978Initial program 18.4%
+-commutative18.4%
hypot-1-def18.6%
Simplified18.6%
Taylor expanded in x around 0 18.6%
*-commutative18.6%
unpow218.6%
associate-*l*18.6%
fma-def18.6%
unpow118.6%
sqr-pow8.9%
fabs-sqr8.9%
sqr-pow19.0%
unpow119.0%
Simplified19.0%
Taylor expanded in x around 0 100.0%
if 0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.009999999776482582)
(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 <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.009999999776482582f) {
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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.009999999776482582)) 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.009999999776482582)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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 < -5Initial program 49.2%
+-commutative49.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
associate--l+99.6%
unpow199.6%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow15.6%
unpow115.6%
associate-+r-96.8%
mul-1-neg96.8%
sub-neg96.8%
+-inverses96.8%
neg-sub096.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
if -5 < x < 0.00999999978Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
Simplified22.6%
Taylor expanded in x around 0 20.5%
*-commutative20.5%
unpow220.5%
associate-*l*20.5%
fma-def20.5%
unpow120.5%
sqr-pow8.5%
fabs-sqr8.5%
sqr-pow20.7%
unpow120.7%
Simplified20.7%
Taylor expanded in x around 0 98.2%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Final simplification97.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.009999999776482582)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (+ x (/ 0.5 x)))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + (x + (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(0.009999999776482582)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + Float32(x + 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(0.009999999776482582)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + (x + (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 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 49.2%
+-commutative49.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
associate--l+99.6%
unpow199.6%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow15.6%
unpow115.6%
associate-+r-96.8%
mul-1-neg96.8%
sub-neg96.8%
+-inverses96.8%
neg-sub096.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
if -5 < x < 0.00999999978Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
Simplified22.6%
Taylor expanded in x around 0 20.5%
*-commutative20.5%
unpow220.5%
associate-*l*20.5%
fma-def20.5%
unpow120.5%
sqr-pow8.5%
fabs-sqr8.5%
sqr-pow20.7%
unpow120.7%
Simplified20.7%
Taylor expanded in x around 0 98.2%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 98.3%
associate-+r+98.3%
+-commutative98.3%
+-commutative98.3%
unpow198.3%
sqr-pow98.3%
fabs-sqr98.3%
sqr-pow98.3%
unpow198.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification97.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.009999999776482582)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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 <= 0.009999999776482582f) {
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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.009999999776482582)) 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.009999999776482582)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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 < -5Initial program 49.2%
+-commutative49.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
associate--l+99.6%
unpow199.6%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow15.6%
unpow115.6%
associate-+r-96.8%
mul-1-neg96.8%
sub-neg96.8%
+-inverses96.8%
neg-sub096.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
if -5 < x < 0.00999999978Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
Simplified22.6%
Taylor expanded in x around 0 20.5%
*-commutative20.5%
unpow220.5%
associate-*l*20.5%
fma-def20.5%
unpow120.5%
sqr-pow8.5%
fabs-sqr8.5%
sqr-pow20.7%
unpow120.7%
Simplified20.7%
Taylor expanded in x around 0 98.2%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 98.3%
associate-+r+98.3%
+-commutative98.3%
+-commutative98.3%
unpow198.3%
sqr-pow98.3%
fabs-sqr98.3%
sqr-pow98.3%
unpow198.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
Taylor expanded in x around 0 98.0%
Final simplification97.8%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (if (<= x 0.009999999776482582) (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.009999999776482582f) {
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.009999999776482582)) 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.009999999776482582)) 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.009999999776482582:\\
\;\;\;\;\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 49.2%
+-commutative49.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 43.5%
mul-1-neg43.5%
Simplified43.5%
if -5 < x < 0.00999999978Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
Simplified22.6%
Taylor expanded in x around 0 18.3%
unpow118.3%
sqr-pow7.6%
fabs-sqr7.6%
sqr-pow17.9%
unpow117.9%
Simplified17.9%
Taylor expanded in x around 0 96.5%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 96.6%
unpow196.6%
sqr-pow96.6%
fabs-sqr96.6%
sqr-pow96.6%
unpow196.6%
Simplified96.6%
Final simplification82.0%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.009999999776482582) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 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.009999999776482582)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.009999999776482582)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 49.9%
+-commutative49.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
associate--l+99.0%
unpow199.0%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow16.0%
unpow116.0%
associate-+r-96.1%
mul-1-neg96.1%
sub-neg96.1%
+-inverses96.1%
neg-sub096.1%
associate-*r/96.1%
metadata-eval96.1%
distribute-neg-frac96.1%
metadata-eval96.1%
Simplified96.1%
if -2 < x < 0.00999999978Initial program 21.8%
+-commutative21.8%
hypot-1-def21.9%
Simplified21.9%
Taylor expanded in x around 0 18.2%
unpow118.2%
sqr-pow7.7%
fabs-sqr7.7%
sqr-pow18.1%
unpow118.1%
Simplified18.1%
Taylor expanded in x around 0 97.1%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 96.6%
unpow196.6%
sqr-pow96.6%
fabs-sqr96.6%
sqr-pow96.6%
unpow196.6%
Simplified96.6%
Final simplification96.7%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.009999999776482582)
(copysign x x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / 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.009999999776482582)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.009999999776482582)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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 < -2Initial program 49.9%
+-commutative49.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
associate--l+99.0%
unpow199.0%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow16.0%
unpow116.0%
associate-+r-96.1%
mul-1-neg96.1%
sub-neg96.1%
+-inverses96.1%
neg-sub096.1%
associate-*r/96.1%
metadata-eval96.1%
distribute-neg-frac96.1%
metadata-eval96.1%
Simplified96.1%
if -2 < x < 0.00999999978Initial program 21.8%
+-commutative21.8%
hypot-1-def21.9%
Simplified21.9%
Taylor expanded in x around 0 18.2%
unpow118.2%
sqr-pow7.7%
fabs-sqr7.7%
sqr-pow18.1%
unpow118.1%
Simplified18.1%
Taylor expanded in x around 0 97.1%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 98.3%
associate-+r+98.3%
+-commutative98.3%
+-commutative98.3%
unpow198.3%
sqr-pow98.3%
fabs-sqr98.3%
sqr-pow98.3%
unpow198.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
Taylor expanded in x around 0 98.0%
Final simplification97.0%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) 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 -1:\\
\;\;\;\;\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 < -1Initial program 50.6%
+-commutative50.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 43.0%
mul-1-neg43.0%
Simplified43.0%
if -1 < x Initial program 34.9%
+-commutative34.9%
hypot-1-def50.3%
Simplified50.3%
Taylor expanded in x around 0 27.6%
log1p-def75.3%
unpow175.3%
sqr-pow43.6%
fabs-sqr43.6%
sqr-pow75.3%
unpow175.3%
Simplified75.3%
Final simplification66.2%
(FPCore (x) :precision binary32 (if (<= x 0.009999999776482582) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 0.009999999776482582f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.009999999776482582)) 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.009999999776482582)) 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.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 0.00999999978Initial program 32.5%
+-commutative32.5%
hypot-1-def51.5%
Simplified51.5%
Taylor expanded in x around 0 27.7%
unpow127.7%
sqr-pow4.8%
fabs-sqr4.8%
sqr-pow11.2%
unpow111.2%
Simplified11.2%
Taylor expanded in x around 0 64.9%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 43.6%
mul-1-neg43.6%
log-rec43.6%
remove-double-neg43.6%
Simplified43.6%
Final simplification59.1%
(FPCore (x) :precision binary32 (if (<= x 0.009999999776482582) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.009999999776482582f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.009999999776482582)) 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.009999999776482582:\\
\;\;\;\;\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.00999999978Initial program 32.5%
+-commutative32.5%
hypot-1-def51.5%
Simplified51.5%
Taylor expanded in x around 0 27.7%
unpow127.7%
sqr-pow4.8%
fabs-sqr4.8%
sqr-pow11.2%
unpow111.2%
Simplified11.2%
Taylor expanded in x around 0 64.9%
if 0.00999999978 < x Initial program 58.0%
+-commutative58.0%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around 0 43.6%
log1p-def43.6%
unpow143.6%
sqr-pow43.6%
fabs-sqr43.6%
sqr-pow43.6%
unpow143.6%
Simplified43.6%
Final simplification59.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 39.3%
+-commutative39.3%
hypot-1-def64.2%
Simplified64.2%
Taylor expanded in x around 0 32.0%
unpow132.0%
sqr-pow15.2%
fabs-sqr15.2%
sqr-pow19.9%
unpow119.9%
Simplified19.9%
Taylor expanded in x around 0 50.6%
Final simplification50.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 2023274
(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))