
(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
(if (<= x -0.05000000074505806)
(copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x)
(if (<= x 0.10000000149011612)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(logf((-1.0f / (x - hypotf(1.0f, x)))), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), 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(log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), 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((single(-1.0) / (x - hypot(single(1.0), x))))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); 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(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, 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 55.7%
flip-+9.2%
clear-num9.2%
log-rec9.2%
+-commutative9.2%
hypot-1-def9.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
sqr-abs8.5%
add-sqr-sqrt11.2%
+-commutative11.2%
Applied egg-rr11.2%
Taylor expanded in x around 0 99.8%
clear-num99.8%
log-rec99.8%
Applied egg-rr99.8%
if -0.0500000007 < x < 0.100000001Initial program 19.3%
flip-+19.3%
clear-num19.2%
log-rec19.6%
+-commutative19.6%
hypot-1-def19.6%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt19.4%
sqr-abs19.4%
add-sqr-sqrt19.6%
+-commutative19.6%
Applied egg-rr19.6%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
Simplified99.9%
if 0.100000001 < x Initial program 54.6%
*-un-lft-identity54.6%
*-commutative54.6%
log-prod54.6%
add-sqr-sqrt54.6%
fabs-sqr54.6%
add-sqr-sqrt54.6%
+-commutative54.6%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.8%
(FPCore (x) :precision binary32 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -1.0) (copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x) (copysign (log1p (+ x (+ -1.0 (hypot 1.0 x)))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -1.0f) {
tmp = copysignf(logf((-1.0f / (x - hypotf(1.0f, x)))), x);
} else {
tmp = copysignf(log1pf((x + (-1.0f + hypotf(1.0f, x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-1.0) / Float32(x - hypot(Float32(1.0), x)))), x); else tmp = copysign(log1p(Float32(x + Float32(Float32(-1.0) + hypot(Float32(1.0), x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(-1 + \mathsf{hypot}\left(1, x\right)\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 55.2%
flip-+8.0%
clear-num8.0%
log-rec8.0%
+-commutative8.0%
hypot-1-def8.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.3%
sqr-abs7.3%
add-sqr-sqrt10.1%
+-commutative10.1%
Applied egg-rr10.1%
Taylor expanded in x around 0 99.9%
clear-num99.9%
log-rec100.0%
Applied egg-rr100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 29.9%
*-un-lft-identity29.9%
*-commutative29.9%
log-prod29.9%
add-sqr-sqrt23.9%
fabs-sqr23.9%
add-sqr-sqrt30.0%
+-commutative30.0%
hypot-1-def42.9%
metadata-eval42.9%
Applied egg-rr42.9%
log1p-expm1-u42.9%
expm1-udef42.9%
add-exp-log42.9%
Applied egg-rr42.9%
associate--l+98.2%
Simplified98.2%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) 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.10000000149011612f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), 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.10000000149011612)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), 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.10000000149011612)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, 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 55.7%
flip-+9.2%
clear-num9.2%
log-rec9.2%
+-commutative9.2%
hypot-1-def9.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
sqr-abs8.5%
add-sqr-sqrt11.2%
+-commutative11.2%
Applied egg-rr11.2%
Taylor expanded in x around 0 99.8%
*-un-lft-identity99.8%
log-prod99.8%
metadata-eval99.8%
frac-2neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
Applied egg-rr99.8%
+-lft-identity99.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
Simplified99.8%
if -0.0500000007 < x < 0.100000001Initial program 19.3%
flip-+19.3%
clear-num19.2%
log-rec19.6%
+-commutative19.6%
hypot-1-def19.6%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt19.4%
sqr-abs19.4%
add-sqr-sqrt19.6%
+-commutative19.6%
Applied egg-rr19.6%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
*-commutative99.9%
Simplified99.9%
if 0.100000001 < x Initial program 54.6%
*-un-lft-identity54.6%
*-commutative54.6%
log-prod54.6%
add-sqr-sqrt54.6%
fabs-sqr54.6%
add-sqr-sqrt54.6%
+-commutative54.6%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.8%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.5)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 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.5f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (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.5)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(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.5)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (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.5:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 55.7%
flip-+9.2%
clear-num9.2%
log-rec9.2%
+-commutative9.2%
hypot-1-def9.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
sqr-abs8.5%
add-sqr-sqrt11.2%
+-commutative11.2%
Applied egg-rr11.2%
Taylor expanded in x around 0 99.8%
*-un-lft-identity99.8%
log-prod99.8%
metadata-eval99.8%
frac-2neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
Applied egg-rr99.8%
+-lft-identity99.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
Simplified99.8%
if -0.0500000007 < x < 0.5Initial program 21.6%
flip-+21.5%
clear-num21.5%
log-rec21.9%
+-commutative21.9%
hypot-1-def21.8%
add-sqr-sqrt14.2%
fabs-sqr14.2%
add-sqr-sqrt21.6%
sqr-abs21.6%
add-sqr-sqrt21.8%
+-commutative21.8%
Applied egg-rr21.8%
Taylor expanded in x around 0 99.5%
Taylor expanded in x around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
*-commutative99.0%
Simplified99.0%
if 0.5 < x Initial program 51.3%
*-un-lft-identity51.3%
*-commutative51.3%
log-prod51.3%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt51.3%
+-commutative51.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 99.3%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / 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(0.5)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(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((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 55.2%
*-un-lft-identity55.2%
*-commutative55.2%
log-prod55.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.3%
+-commutative13.3%
hypot-1-def13.3%
metadata-eval13.3%
Applied egg-rr13.3%
Taylor expanded in x around -inf 97.1%
if -1 < x < 0.5Initial program 22.1%
flip-+22.0%
clear-num22.0%
log-rec22.4%
+-commutative22.4%
hypot-1-def22.3%
add-sqr-sqrt14.1%
fabs-sqr14.1%
add-sqr-sqrt22.1%
sqr-abs22.1%
add-sqr-sqrt22.3%
+-commutative22.3%
Applied egg-rr22.3%
Taylor expanded in x around 0 99.5%
Taylor expanded in x around 0 98.9%
mul-1-neg98.9%
unsub-neg98.9%
*-commutative98.9%
Simplified98.9%
if 0.5 < x Initial program 51.3%
*-un-lft-identity51.3%
*-commutative51.3%
log-prod51.3%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt51.3%
+-commutative51.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 99.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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(0.5)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), 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(0.5)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log((x * single(2.0)))); 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 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 55.2%
*-un-lft-identity55.2%
*-commutative55.2%
log-prod55.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.3%
+-commutative13.3%
hypot-1-def13.3%
metadata-eval13.3%
Applied egg-rr13.3%
Taylor expanded in x around -inf 97.1%
if -1 < x < 0.5Initial program 22.1%
flip-+22.0%
clear-num22.0%
log-rec22.4%
+-commutative22.4%
hypot-1-def22.3%
add-sqr-sqrt14.1%
fabs-sqr14.1%
add-sqr-sqrt22.1%
sqr-abs22.1%
add-sqr-sqrt22.3%
+-commutative22.3%
Applied egg-rr22.3%
Taylor expanded in x around 0 99.5%
Taylor expanded in x around 0 98.9%
mul-1-neg98.9%
unsub-neg98.9%
*-commutative98.9%
Simplified98.9%
if 0.5 < x Initial program 51.3%
*-un-lft-identity51.3%
*-commutative51.3%
log-prod51.3%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt51.3%
+-commutative51.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 98.1%
*-commutative98.1%
Simplified98.1%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 0.5) (copysign x x) (copysign (- (log (/ 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(-logf((1.0f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(Float32(-log(Float32(Float32(1.0) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(-log((single(1.0) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 54.6%
Taylor expanded in x around -inf 44.1%
if -10 < x < 0.5Initial program 22.6%
flip-+22.6%
clear-num22.5%
log-rec22.9%
+-commutative22.9%
hypot-1-def22.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt22.7%
sqr-abs22.7%
add-sqr-sqrt22.9%
+-commutative22.9%
Applied egg-rr22.9%
Taylor expanded in x around 0 97.0%
neg-mul-197.0%
Simplified97.0%
if 0.5 < x Initial program 51.3%
Taylor expanded in x around inf 44.4%
Final simplification72.7%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 54.6%
Taylor expanded in x around -inf 44.1%
if -10 < x < 0.5Initial program 22.6%
flip-+22.6%
clear-num22.5%
log-rec22.9%
+-commutative22.9%
hypot-1-def22.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt22.7%
sqr-abs22.7%
add-sqr-sqrt22.9%
+-commutative22.9%
Applied egg-rr22.9%
Taylor expanded in x around 0 97.0%
neg-mul-197.0%
Simplified97.0%
if 0.5 < x Initial program 51.3%
*-un-lft-identity51.3%
*-commutative51.3%
log-prod51.3%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt51.3%
+-commutative51.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 98.1%
*-commutative98.1%
Simplified98.1%
Final simplification83.2%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), 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(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); 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 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 55.2%
*-un-lft-identity55.2%
*-commutative55.2%
log-prod55.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.3%
+-commutative13.3%
hypot-1-def13.3%
metadata-eval13.3%
Applied egg-rr13.3%
Taylor expanded in x around -inf 97.1%
if -1 < x < 0.5Initial program 22.1%
flip-+22.0%
clear-num22.0%
log-rec22.4%
+-commutative22.4%
hypot-1-def22.3%
add-sqr-sqrt14.1%
fabs-sqr14.1%
add-sqr-sqrt22.1%
sqr-abs22.1%
add-sqr-sqrt22.3%
+-commutative22.3%
Applied egg-rr22.3%
Taylor expanded in x around 0 97.5%
neg-mul-197.5%
Simplified97.5%
if 0.5 < x Initial program 51.3%
*-un-lft-identity51.3%
*-commutative51.3%
log-prod51.3%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt51.3%
+-commutative51.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 98.1%
*-commutative98.1%
Simplified98.1%
Final simplification97.5%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 0.5) (copysign x x) (copysign (log x) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(0.5)) 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(-10.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(0.5)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < -10Initial program 54.6%
Taylor expanded in x around -inf 44.1%
if -10 < x < 0.5Initial program 22.6%
flip-+22.6%
clear-num22.5%
log-rec22.9%
+-commutative22.9%
hypot-1-def22.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt22.7%
sqr-abs22.7%
add-sqr-sqrt22.9%
+-commutative22.9%
Applied egg-rr22.9%
Taylor expanded in x around 0 97.0%
neg-mul-197.0%
Simplified97.0%
if 0.5 < x Initial program 51.3%
Taylor expanded in x around inf 44.4%
Taylor expanded in x around 0 44.4%
neg-mul-144.4%
Simplified44.4%
Final simplification72.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) 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.5)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 33.2%
flip-+17.3%
clear-num17.3%
log-rec17.6%
+-commutative17.6%
hypot-1-def17.5%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt17.2%
sqr-abs17.2%
add-sqr-sqrt18.2%
+-commutative18.2%
Applied egg-rr18.2%
Taylor expanded in x around 0 68.7%
neg-mul-168.7%
Simplified68.7%
if 0.5 < x Initial program 51.3%
Taylor expanded in x around inf 44.4%
Taylor expanded in x around 0 44.4%
neg-mul-144.4%
Simplified44.4%
Final simplification64.0%
(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.7%
flip-+14.9%
clear-num14.8%
log-rec15.0%
+-commutative15.0%
hypot-1-def15.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt14.7%
sqr-abs14.7%
add-sqr-sqrt15.6%
+-commutative15.6%
Applied egg-rr15.6%
Taylor expanded in x around 0 57.4%
neg-mul-157.4%
Simplified57.4%
Final simplification57.4%
(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 2023189
(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))