
(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.5)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(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(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.10000000149011612f) {
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(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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
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.5)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.10000000149011612)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (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.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.10000000149011612:\\
\;\;\;\;\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 53.9%
+-commutative53.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.8%
add-sqr-sqrt7.9%
fma-def7.8%
+-commutative7.8%
hypot-1-def7.8%
Applied egg-rr7.8%
fma-udef7.9%
+-commutative7.9%
associate--l+50.8%
+-inverses99.9%
metadata-eval99.9%
Simplified99.9%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 23.7%
*-un-lft-identity23.7%
*-commutative23.7%
log-prod23.7%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt24.2%
+-commutative24.2%
hypot-1-def24.2%
metadata-eval24.2%
Applied egg-rr24.2%
+-rgt-identity24.2%
Simplified24.2%
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 55.0%
*-un-lft-identity55.0%
*-commutative55.0%
log-prod55.0%
add-sqr-sqrt55.0%
fabs-sqr55.0%
add-sqr-sqrt55.0%
+-commutative55.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.04500000178813934)
(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.04500000178813934f) {
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.04500000178813934)) 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.04500000178813934)) 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.04500000178813934:\\
\;\;\;\;\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 53.2%
+-commutative53.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.7%
flip-+6.3%
log-div6.3%
add-sqr-sqrt6.3%
fma-def6.3%
+-commutative6.3%
hypot-1-def6.3%
Applied egg-rr6.3%
fma-udef6.3%
+-commutative6.3%
associate--l+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.2%
*-commutative99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
if -1 < x < 0.0450000018Initial program 23.2%
Taylor expanded in x around 0 23.4%
fma-def23.4%
unpow223.4%
rem-square-sqrt10.4%
fabs-sqr10.4%
rem-square-sqrt23.1%
log1p-def98.5%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt98.7%
Simplified98.7%
Taylor expanded in x around 0 99.4%
if 0.0450000018 < x Initial program 55.9%
*-un-lft-identity55.9%
*-commutative55.9%
log-prod55.9%
add-sqr-sqrt55.9%
fabs-sqr55.9%
add-sqr-sqrt55.9%
+-commutative55.9%
hypot-1-def99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.04500000178813934)
(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.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.04500000178813934f) {
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.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.04500000178813934)) 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.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.04500000178813934)) 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.04500000178813934:\\
\;\;\;\;\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.0500000007Initial program 54.6%
+-commutative54.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.5%
flip-+9.2%
log-div9.3%
add-sqr-sqrt9.2%
fma-def9.3%
+-commutative9.3%
hypot-1-def9.3%
Applied egg-rr9.3%
fma-udef9.2%
+-commutative9.2%
associate--l+51.5%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.0500000007 < x < 0.0450000018Initial program 21.9%
Taylor expanded in x around 0 22.8%
fma-def22.8%
unpow222.8%
rem-square-sqrt10.6%
fabs-sqr10.6%
rem-square-sqrt22.8%
log1p-def99.6%
rem-square-sqrt45.0%
fabs-sqr45.0%
rem-square-sqrt99.6%
Simplified99.6%
Taylor expanded in x around 0 100.0%
if 0.0450000018 < x Initial program 55.9%
*-un-lft-identity55.9%
*-commutative55.9%
log-prod55.9%
add-sqr-sqrt55.9%
fabs-sqr55.9%
add-sqr-sqrt55.9%
+-commutative55.9%
hypot-1-def99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.0)
(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)), x);
} else if (x <= 1.0f) {
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(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) 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)))); elseif (x <= single(1.0)) 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\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 53.2%
+-commutative53.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.7%
flip-+6.3%
log-div6.3%
add-sqr-sqrt6.3%
fma-def6.3%
+-commutative6.3%
hypot-1-def6.3%
Applied egg-rr6.3%
fma-udef6.3%
+-commutative6.3%
associate--l+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.0%
*-commutative99.0%
Simplified99.0%
if -1 < x < 1Initial program 24.9%
Taylor expanded in x around 0 24.3%
fma-def24.3%
unpow224.3%
rem-square-sqrt11.7%
fabs-sqr11.7%
rem-square-sqrt24.0%
log1p-def97.6%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.7%
if 1 < x Initial program 54.5%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
rem-square-sqrt99.0%
fabs-sqr99.0%
rem-square-sqrt99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.0)
(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 <= 1.0f) {
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(1.0)) 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(1.0)) 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 1:\\
\;\;\;\;\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 53.2%
+-commutative53.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.7%
flip-+6.3%
log-div6.3%
add-sqr-sqrt6.3%
fma-def6.3%
+-commutative6.3%
hypot-1-def6.3%
Applied egg-rr6.3%
fma-udef6.3%
+-commutative6.3%
associate--l+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.2%
*-commutative99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
if -1 < x < 1Initial program 24.9%
Taylor expanded in x around 0 24.3%
fma-def24.3%
unpow224.3%
rem-square-sqrt11.7%
fabs-sqr11.7%
rem-square-sqrt24.0%
log1p-def97.6%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.7%
if 1 < x Initial program 54.5%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
rem-square-sqrt99.0%
fabs-sqr99.0%
rem-square-sqrt99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
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.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) 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.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(1.0)) 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:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -1Initial program 53.2%
+-commutative53.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.7%
flip-+6.3%
log-div6.3%
add-sqr-sqrt6.3%
fma-def6.3%
+-commutative6.3%
hypot-1-def6.3%
Applied egg-rr6.3%
fma-udef6.3%
+-commutative6.3%
associate--l+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.0%
*-commutative99.0%
Simplified99.0%
if -1 < x < 1Initial program 24.9%
Taylor expanded in x around 0 24.3%
fma-def24.3%
unpow224.3%
rem-square-sqrt11.7%
fabs-sqr11.7%
rem-square-sqrt24.0%
log1p-def97.6%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.7%
if 1 < x Initial program 54.5%
Taylor expanded in x around inf 96.3%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt96.3%
Simplified96.3%
Final simplification98.1%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 53.2%
*-un-lft-identity53.2%
*-commutative53.2%
log-prod53.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.7%
+-commutative8.7%
hypot-1-def8.7%
metadata-eval8.7%
Applied egg-rr8.7%
+-rgt-identity8.7%
Simplified8.7%
Taylor expanded in x around -inf 98.9%
if -1 < x < 1Initial program 24.9%
*-un-lft-identity24.9%
*-commutative24.9%
log-prod24.9%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt25.4%
+-commutative25.4%
hypot-1-def25.4%
metadata-eval25.4%
Applied egg-rr25.4%
+-rgt-identity25.4%
Simplified25.4%
Taylor expanded in x around 0 97.4%
if 1 < x Initial program 54.5%
Taylor expanded in x around inf 96.3%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt96.3%
Simplified96.3%
Final simplification97.4%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) 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.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(1.0)) 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:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 53.2%
+-commutative53.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.7%
flip-+6.3%
log-div6.3%
add-sqr-sqrt6.3%
fma-def6.3%
+-commutative6.3%
hypot-1-def6.3%
Applied egg-rr6.3%
fma-udef6.3%
+-commutative6.3%
associate--l+49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.0%
*-commutative99.0%
Simplified99.0%
if -1 < x < 1Initial program 24.9%
*-un-lft-identity24.9%
*-commutative24.9%
log-prod24.9%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt25.4%
+-commutative25.4%
hypot-1-def25.4%
metadata-eval25.4%
Applied egg-rr25.4%
+-rgt-identity25.4%
Simplified25.4%
Taylor expanded in x around 0 97.4%
if 1 < x Initial program 54.5%
Taylor expanded in x around inf 96.3%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt96.3%
Simplified96.3%
Final simplification97.4%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) 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.0)) 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:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 34.3%
*-un-lft-identity34.3%
*-commutative34.3%
log-prod34.3%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 68.5%
if 1 < x Initial program 54.5%
Taylor expanded in x around inf 96.3%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt96.3%
Simplified96.3%
Final simplification76.8%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 34.3%
*-un-lft-identity34.3%
*-commutative34.3%
log-prod34.3%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 68.5%
if 1 < x Initial program 54.5%
Taylor expanded in x around 0 44.3%
log1p-def44.3%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt44.3%
Simplified44.3%
Final simplification61.3%
(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 40.3%
*-un-lft-identity40.3%
*-commutative40.3%
log-prod40.3%
add-sqr-sqrt21.8%
fabs-sqr21.8%
add-sqr-sqrt30.1%
+-commutative30.1%
hypot-1-def43.6%
metadata-eval43.6%
Applied egg-rr43.6%
+-rgt-identity43.6%
Simplified43.6%
Taylor expanded in x around 0 51.6%
Final simplification51.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 2023196
(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))