
(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.5)
(copysign (- (log1p (+ (- (hypot 1.0 x) x) -1.0))) x)
(if (<= t_0 0.009999999776482582)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 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.5f) {
tmp = copysignf(-log1pf(((hypotf(1.0f, x) - x) + -1.0f)), x);
} else if (t_0 <= 0.009999999776482582f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (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.5)) tmp = copysign(Float32(-log1p(Float32(Float32(hypot(Float32(1.0), x) - x) + Float32(-1.0)))), x); elseif (t_0 <= Float32(0.009999999776482582)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + 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
\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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) - x\right) + -1\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 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.5Initial program 59.5%
+-commutative59.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt19.4%
flip-+19.6%
log-div19.5%
add-sqr-sqrt20.7%
fma-def20.7%
+-commutative20.7%
hypot-1-def20.7%
Applied egg-rr20.7%
fma-udef20.6%
+-commutative20.6%
associate--l+56.7%
+-inverses98.3%
metadata-eval98.3%
metadata-eval98.3%
neg-sub098.3%
Simplified98.3%
log1p-expm1-u98.3%
expm1-udef98.3%
add-exp-log98.4%
Applied egg-rr98.4%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00999999978Initial program 20.5%
add-cube-cbrt19.7%
pow319.7%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
Applied egg-rr19.8%
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 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
add-sqr-sqrt60.5%
fabs-sqr60.5%
add-sqr-sqrt60.5%
+-commutative60.5%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -0.05999999865889549)
(copysign (- (log1p (+ (- (hypot 1.0 x) x) -1.0))) 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 <= -0.05999999865889549f) {
tmp = copysignf(-log1pf(((hypotf(1.0f, x) - x) + -1.0f)), 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(-0.05999999865889549)) tmp = copysign(Float32(-log1p(Float32(Float32(hypot(Float32(1.0), x) - x) + Float32(-1.0)))), 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
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05999999865889549:\\
\;\;\;\;\mathsf{copysign}\left(-\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) - x\right) + -1\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 < -0.0599999987Initial program 60.0%
+-commutative60.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt20.5%
flip-+20.7%
log-div20.6%
add-sqr-sqrt21.7%
fma-def21.7%
+-commutative21.7%
hypot-1-def21.7%
Applied egg-rr21.7%
fma-udef21.7%
+-commutative21.7%
associate--l+57.2%
+-inverses98.2%
metadata-eval98.2%
metadata-eval98.2%
neg-sub098.2%
Simplified98.2%
log1p-expm1-u98.2%
expm1-udef98.2%
add-exp-log98.2%
Applied egg-rr98.2%
if -0.0599999987 < x < 0.00999999978Initial program 20.0%
Taylor expanded in x around 0 21.0%
fma-def21.0%
unpow221.0%
rem-square-sqrt9.7%
fabs-sqr9.7%
rem-square-sqrt20.9%
log1p-def99.2%
rem-square-sqrt49.5%
fabs-sqr49.5%
rem-square-sqrt99.7%
Simplified99.7%
Taylor expanded in x around 0 99.9%
if 0.00999999978 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
add-sqr-sqrt60.5%
fabs-sqr60.5%
add-sqr-sqrt60.5%
+-commutative60.5%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 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 <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (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(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - 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(-1.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \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 < -1Initial program 58.9%
+-commutative58.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt18.2%
flip-+18.3%
log-div18.3%
add-sqr-sqrt19.5%
fma-def19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
fma-udef19.4%
+-commutative19.4%
associate--l+56.1%
+-inverses98.3%
metadata-eval98.3%
metadata-eval98.3%
neg-sub098.3%
Simplified98.3%
Taylor expanded in x around -inf 96.0%
*-commutative96.0%
associate-*r/96.0%
metadata-eval96.0%
Simplified96.0%
if -1 < x < 0.00999999978Initial program 21.1%
Taylor expanded in x around 0 21.4%
fma-def21.4%
unpow221.4%
rem-square-sqrt9.5%
fabs-sqr9.5%
rem-square-sqrt21.2%
log1p-def98.3%
rem-square-sqrt48.8%
fabs-sqr48.8%
rem-square-sqrt98.9%
Simplified98.9%
Taylor expanded in x around 0 99.4%
if 0.00999999978 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
add-sqr-sqrt60.5%
fabs-sqr60.5%
add-sqr-sqrt60.5%
+-commutative60.5%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -0.05999999865889549)
(copysign (- (log (- (hypot 1.0 x) 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 <= -0.05999999865889549f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - 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(-0.05999999865889549)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - 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(-0.05999999865889549)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - 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 -0.05999999865889549:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - 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 < -0.0599999987Initial program 60.0%
+-commutative60.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt20.5%
flip-+20.7%
log-div20.6%
add-sqr-sqrt21.7%
fma-def21.7%
+-commutative21.7%
hypot-1-def21.7%
Applied egg-rr21.7%
fma-udef21.7%
+-commutative21.7%
associate--l+57.2%
+-inverses98.2%
metadata-eval98.2%
metadata-eval98.2%
neg-sub098.2%
Simplified98.2%
if -0.0599999987 < x < 0.00999999978Initial program 20.0%
Taylor expanded in x around 0 21.0%
fma-def21.0%
unpow221.0%
rem-square-sqrt9.7%
fabs-sqr9.7%
rem-square-sqrt20.9%
log1p-def99.2%
rem-square-sqrt49.5%
fabs-sqr49.5%
rem-square-sqrt99.7%
Simplified99.7%
Taylor expanded in x around 0 99.9%
if 0.00999999978 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
add-sqr-sqrt60.5%
fabs-sqr60.5%
add-sqr-sqrt60.5%
+-commutative60.5%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ 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 + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (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(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + 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 + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (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 + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 58.3%
Taylor expanded in x around -inf 96.8%
neg-mul-196.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt95.9%
sub-neg95.9%
associate-*r/95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div95.9%
Simplified95.9%
if -1.5 < x < 0.5Initial program 22.2%
Taylor expanded in x around 0 21.8%
fma-def21.8%
unpow221.8%
rem-square-sqrt9.8%
fabs-sqr9.8%
rem-square-sqrt21.4%
log1p-def97.4%
rem-square-sqrt48.4%
fabs-sqr48.4%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.6%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around inf 96.7%
associate-*r/96.7%
metadata-eval96.7%
rem-square-sqrt96.7%
fabs-sqr96.7%
rem-square-sqrt96.7%
Simplified96.7%
Final simplification97.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / 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 + 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) / 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(Float32(0.5) / x) + Float32(x + 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) / 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) + (x + 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 - \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(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 58.9%
+-commutative58.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt18.2%
flip-+18.3%
log-div18.3%
add-sqr-sqrt19.5%
fma-def19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
fma-udef19.4%
+-commutative19.4%
associate--l+56.1%
+-inverses98.3%
metadata-eval98.3%
metadata-eval98.3%
neg-sub098.3%
Simplified98.3%
Taylor expanded in x around -inf 96.0%
*-commutative96.0%
associate-*r/96.0%
metadata-eval96.0%
Simplified96.0%
if -1 < x < 0.5Initial program 21.7%
Taylor expanded in x around 0 21.7%
fma-def21.7%
unpow221.7%
rem-square-sqrt9.8%
fabs-sqr9.8%
rem-square-sqrt21.4%
log1p-def97.9%
rem-square-sqrt48.8%
fabs-sqr48.8%
rem-square-sqrt98.5%
Simplified98.5%
Taylor expanded in x around 0 99.1%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around inf 96.7%
associate-*r/96.7%
metadata-eval96.7%
rem-square-sqrt96.7%
fabs-sqr96.7%
rem-square-sqrt96.7%
Simplified96.7%
Final simplification97.8%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(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 <= -1.5f) {
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(-1.5)) 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(-1.5)) 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 -1.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 < -1.5Initial program 58.3%
Taylor expanded in x around -inf 96.8%
neg-mul-196.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt95.9%
sub-neg95.9%
associate-*r/95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div95.9%
Simplified95.9%
if -1.5 < x < 0.5Initial program 22.2%
Taylor expanded in x around 0 21.8%
fma-def21.8%
unpow221.8%
rem-square-sqrt9.8%
fabs-sqr9.8%
rem-square-sqrt21.4%
log1p-def97.4%
rem-square-sqrt48.4%
fabs-sqr48.4%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.6%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around inf 93.5%
rem-square-sqrt93.5%
fabs-sqr93.5%
rem-square-sqrt93.5%
Simplified93.5%
Final simplification96.8%
(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 58.3%
Taylor expanded in x around -inf 96.8%
neg-mul-196.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt95.9%
sub-neg95.9%
associate-*r/95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div95.9%
Simplified95.9%
if -1.5 < x < 0.5Initial program 22.2%
Taylor expanded in x around 0 19.3%
rem-square-sqrt8.6%
fabs-sqr8.6%
rem-square-sqrt19.3%
Simplified19.3%
Taylor expanded in x around 0 97.5%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around inf 93.5%
rem-square-sqrt93.5%
fabs-sqr93.5%
rem-square-sqrt93.5%
Simplified93.5%
Final simplification96.2%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 1.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + Float32(1.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + single(1.0)))); end tmp_2 = 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(\log \left(x + 1\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 33.6%
Taylor expanded in x around 0 27.1%
rem-square-sqrt5.9%
fabs-sqr5.9%
rem-square-sqrt13.2%
Simplified13.2%
Taylor expanded in x around 0 70.6%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around 0 43.4%
rem-square-sqrt43.4%
fabs-sqr43.4%
rem-square-sqrt43.4%
Simplified43.4%
Final simplification64.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
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(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(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 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 < 0.5Initial program 33.6%
Taylor expanded in x around 0 27.1%
rem-square-sqrt5.9%
fabs-sqr5.9%
rem-square-sqrt13.2%
Simplified13.2%
Taylor expanded in x around 0 70.6%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around inf 93.5%
rem-square-sqrt93.5%
fabs-sqr93.5%
rem-square-sqrt93.5%
Simplified93.5%
Final simplification75.6%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) 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(2.0)) 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 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 2Initial program 34.6%
Taylor expanded in x around 0 27.2%
rem-square-sqrt6.3%
fabs-sqr6.3%
rem-square-sqrt13.5%
Simplified13.5%
Taylor expanded in x around 0 70.0%
if 2 < x Initial program 57.6%
Taylor expanded in x around inf 43.9%
mul-1-neg43.9%
log-rec43.9%
remove-double-neg43.9%
Simplified43.9%
Final simplification64.6%
(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 33.6%
Taylor expanded in x around 0 27.1%
rem-square-sqrt5.9%
fabs-sqr5.9%
rem-square-sqrt13.2%
Simplified13.2%
Taylor expanded in x around 0 70.6%
if 0.5 < x Initial program 59.9%
Taylor expanded in x around 0 43.4%
log1p-def43.4%
rem-square-sqrt43.4%
fabs-sqr43.4%
rem-square-sqrt43.4%
Simplified43.4%
Final simplification64.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 39.3%
Taylor expanded in x around 0 30.6%
rem-square-sqrt14.1%
fabs-sqr14.1%
rem-square-sqrt19.8%
Simplified19.8%
Taylor expanded in x around 0 57.9%
Final simplification57.9%
(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 2023240
(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))