
(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 11 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.20000000298023224)
(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 (+ (+ 1.0 (log (+ x (hypot 1.0 x)))) -1.0) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.20000000298023224f) {
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(((1.0f + logf((x + hypotf(1.0f, x)))) + -1.0f), 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.20000000298023224)) tmp = copysign(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(Float32(Float32(Float32(1.0) + log(Float32(x + hypot(Float32(1.0), x)))) + Float32(-1.0)), 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.20000000298023224)) 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(((single(1.0) + log((x + hypot(single(1.0), x)))) + single(-1.0))); 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.20000000298023224:\\
\;\;\;\;\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(\left(1 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right) + -1, x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.200000003Initial program 52.4%
+-commutative52.4%
hypot-1-def100.0%
Simplified100.0%
flip-+7.8%
div-sub7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.8%
hypot-udef2.8%
hypot-udef2.8%
add-sqr-sqrt2.8%
metadata-eval2.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
Applied egg-rr10.4%
div-sub12.6%
+-commutative12.6%
associate--r+49.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%
add-sqr-sqrt-0.0%
pow1/2-0.0%
pow1/2-0.0%
pow-prod-down100.0%
log-rec100.0%
log-rec100.0%
sqr-neg100.0%
pow1100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
unpow1/2100.0%
unpow2100.0%
rem-sqrt-square100.0%
unpow1100.0%
sqr-pow98.6%
fabs-sqr98.6%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 18.4%
+-commutative18.4%
hypot-1-def18.4%
Simplified18.4%
*-un-lft-identity18.4%
log-prod18.4%
metadata-eval18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt18.8%
Applied egg-rr18.8%
+-lft-identity18.8%
Simplified18.8%
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 54.5%
+-commutative54.5%
hypot-1-def99.9%
Simplified99.9%
expm1-log1p-u97.4%
expm1-udef97.3%
log1p-udef97.4%
add-exp-log100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (+ 1.0 (log (+ x (hypot 1.0 x)))) -1.0) x))))
float code(float x) {
float tmp;
if (x <= -0.20000000298023224f) {
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(((1.0f + logf((x + hypotf(1.0f, x)))) + -1.0f), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.20000000298023224)) 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(Float32(Float32(Float32(1.0) + log(Float32(x + hypot(Float32(1.0), x)))) + Float32(-1.0)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.20000000298023224)) 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(((single(1.0) + log((x + hypot(single(1.0), x)))) + single(-1.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.20000000298023224:\\
\;\;\;\;\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(\left(1 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right) + -1, x\right)\\
\end{array}
\end{array}
if x < -0.200000003Initial program 52.4%
+-commutative52.4%
hypot-1-def100.0%
Simplified100.0%
flip-+7.8%
div-sub7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.8%
hypot-udef2.8%
hypot-udef2.8%
add-sqr-sqrt2.8%
metadata-eval2.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
Applied egg-rr10.4%
div-sub12.6%
+-commutative12.6%
associate--r+49.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%
add-sqr-sqrt-0.0%
pow1/2-0.0%
pow1/2-0.0%
pow-prod-down100.0%
log-rec100.0%
log-rec100.0%
sqr-neg100.0%
pow1100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
unpow1/2100.0%
unpow2100.0%
rem-sqrt-square100.0%
unpow1100.0%
sqr-pow98.6%
fabs-sqr98.6%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
if -0.200000003 < x < 0.0199999996Initial program 18.4%
+-commutative18.4%
hypot-1-def18.4%
Simplified18.4%
*-un-lft-identity18.4%
log-prod18.4%
metadata-eval18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt18.8%
Applied egg-rr18.8%
+-lft-identity18.8%
Simplified18.8%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 54.5%
+-commutative54.5%
hypot-1-def99.9%
Simplified99.9%
expm1-log1p-u97.4%
expm1-udef97.3%
log1p-udef97.4%
add-exp-log100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -5.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 <= -5.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(-5.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(-5.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 -5:\\
\;\;\;\;\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 < -5Initial program 51.6%
+-commutative51.6%
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-pow11.1%
unpow111.1%
associate-+r-98.1%
mul-1-neg98.1%
sub-neg98.1%
+-inverses98.1%
neg-sub098.1%
associate-*r/98.1%
metadata-eval98.1%
distribute-neg-frac98.1%
metadata-eval98.1%
Simplified98.1%
if -5 < x < 0.0199999996Initial program 19.0%
+-commutative19.0%
hypot-1-def19.0%
Simplified19.0%
*-un-lft-identity19.0%
log-prod19.0%
metadata-eval19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt19.4%
Applied egg-rr19.4%
+-lft-identity19.4%
Simplified19.4%
Taylor expanded in x around 0 99.6%
if 0.0199999996 < x Initial program 54.5%
+-commutative54.5%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
log-prod99.9%
metadata-eval99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(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.20000000298023224f) {
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.20000000298023224)) 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.20000000298023224)) 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.20000000298023224:\\
\;\;\;\;\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.200000003Initial program 52.4%
+-commutative52.4%
hypot-1-def100.0%
Simplified100.0%
flip-+7.8%
div-sub7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.8%
hypot-udef2.8%
hypot-udef2.8%
add-sqr-sqrt2.8%
metadata-eval2.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
Applied egg-rr10.4%
div-sub12.6%
+-commutative12.6%
associate--r+49.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%
add-sqr-sqrt-0.0%
pow1/2-0.0%
pow1/2-0.0%
pow-prod-down100.0%
log-rec100.0%
log-rec100.0%
sqr-neg100.0%
pow1100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
unpow1/2100.0%
unpow2100.0%
rem-sqrt-square100.0%
unpow1100.0%
sqr-pow98.6%
fabs-sqr98.6%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
if -0.200000003 < x < 0.0199999996Initial program 18.4%
+-commutative18.4%
hypot-1-def18.4%
Simplified18.4%
*-un-lft-identity18.4%
log-prod18.4%
metadata-eval18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt18.8%
Applied egg-rr18.8%
+-lft-identity18.8%
Simplified18.8%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 54.5%
+-commutative54.5%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
log-prod99.9%
metadata-eval99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(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.5f) {
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.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(x + 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.5)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 51.6%
+-commutative51.6%
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-pow11.1%
unpow111.1%
associate-+r-98.1%
mul-1-neg98.1%
sub-neg98.1%
+-inverses98.1%
neg-sub098.1%
associate-*r/98.1%
metadata-eval98.1%
distribute-neg-frac98.1%
metadata-eval98.1%
Simplified98.1%
if -5 < x < 0.5Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
*-un-lft-identity19.6%
log-prod19.6%
metadata-eval19.6%
*-un-lft-identity19.6%
*-un-lft-identity19.6%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
+-lft-identity20.0%
Simplified20.0%
Taylor expanded in x around 0 99.3%
if 0.5 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
associate-+l+100.0%
unpow1100.0%
sqr-pow100.0%
fabs-sqr100.0%
sqr-pow100.0%
unpow1100.0%
+-commutative100.0%
associate-+r+100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + 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.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), 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((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + 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.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 51.6%
+-commutative51.6%
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-pow11.1%
unpow111.1%
associate-+r-98.1%
mul-1-neg98.1%
sub-neg98.1%
+-inverses98.1%
neg-sub098.1%
associate-*r/98.1%
metadata-eval98.1%
distribute-neg-frac98.1%
metadata-eval98.1%
Simplified98.1%
if -5 < x < 0.5Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
*-un-lft-identity19.6%
log-prod19.6%
metadata-eval19.6%
*-un-lft-identity19.6%
*-un-lft-identity19.6%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
+-lft-identity20.0%
Simplified20.0%
Taylor expanded in x around 0 99.3%
if 0.5 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
unpow199.3%
sqr-pow99.3%
fabs-sqr99.3%
sqr-pow99.3%
unpow199.3%
Simplified99.3%
Final simplification99.0%
(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 51.6%
+-commutative51.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.5%
mul-1-neg44.5%
Simplified44.5%
if -5 < x < 0.5Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
*-un-lft-identity19.6%
log-prod19.6%
metadata-eval19.6%
*-un-lft-identity19.6%
*-un-lft-identity19.6%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
+-lft-identity20.0%
Simplified20.0%
Taylor expanded in x around 0 98.6%
if 0.5 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
unpow199.3%
sqr-pow99.3%
fabs-sqr99.3%
sqr-pow99.3%
unpow199.3%
Simplified99.3%
Final simplification86.5%
(FPCore (x) :precision binary32 (if (<= x -5.0) (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 <= -5.0f) {
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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + 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.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(\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 < -5Initial program 51.6%
+-commutative51.6%
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-pow11.1%
unpow111.1%
associate-+r-98.1%
mul-1-neg98.1%
sub-neg98.1%
+-inverses98.1%
neg-sub098.1%
associate-*r/98.1%
metadata-eval98.1%
distribute-neg-frac98.1%
metadata-eval98.1%
Simplified98.1%
if -5 < x < 0.5Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
*-un-lft-identity19.6%
log-prod19.6%
metadata-eval19.6%
*-un-lft-identity19.6%
*-un-lft-identity19.6%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
+-lft-identity20.0%
Simplified20.0%
Taylor expanded in x around 0 98.6%
if 0.5 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
unpow199.3%
sqr-pow99.3%
fabs-sqr99.3%
sqr-pow99.3%
unpow199.3%
Simplified99.3%
Final simplification98.6%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.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 -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 < -5Initial program 51.6%
+-commutative51.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.5%
mul-1-neg44.5%
Simplified44.5%
if -5 < x Initial program 31.5%
+-commutative31.5%
hypot-1-def47.6%
Simplified47.6%
Taylor expanded in x around 0 27.3%
log1p-def77.8%
unpow177.8%
sqr-pow46.1%
fabs-sqr46.1%
sqr-pow77.8%
unpow177.8%
Simplified77.8%
Final simplification70.3%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 29.5%
+-commutative29.5%
hypot-1-def44.5%
Simplified44.5%
*-un-lft-identity44.5%
log-prod44.5%
metadata-eval44.5%
*-un-lft-identity44.5%
*-un-lft-identity44.5%
add-sqr-sqrt6.5%
fabs-sqr6.5%
add-sqr-sqrt17.5%
Applied egg-rr17.5%
+-lft-identity17.5%
Simplified17.5%
Taylor expanded in x around 0 71.4%
if 0.5 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 44.9%
log1p-def44.9%
unpow144.9%
sqr-pow44.9%
fabs-sqr44.9%
sqr-pow44.9%
unpow144.9%
Simplified44.9%
Final simplification64.2%
(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 36.1%
+-commutative36.1%
hypot-1-def59.5%
Simplified59.5%
*-un-lft-identity59.5%
log-prod59.5%
metadata-eval59.5%
*-un-lft-identity59.5%
*-un-lft-identity59.5%
add-sqr-sqrt31.7%
fabs-sqr31.7%
add-sqr-sqrt39.8%
Applied egg-rr39.8%
+-lft-identity39.8%
Simplified39.8%
Taylor expanded in x around 0 55.0%
Final simplification55.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 2023293
(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))