
(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 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -4.0) (copysign (log (- (/ 0.125 (pow x 3.0)) (/ 0.5 x))) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -4.0f) {
tmp = copysignf(logf(((0.125f / powf(x, 3.0f)) - (0.5f / x))), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), 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(-4.0)) tmp = copysign(log(Float32(Float32(Float32(0.125) / (x ^ Float32(3.0))) - Float32(Float32(0.5) / x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), 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 -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.125}{{x}^{3}} - \frac{0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\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) < -4Initial program 46.8%
+-commutative46.8%
hypot-1-def98.6%
Simplified98.6%
+-lft-identity98.6%
+-commutative98.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.5%
Applied egg-rr10.5%
Taylor expanded in x around -inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if -4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 32.5%
+-commutative32.5%
hypot-1-def48.3%
Simplified48.3%
log1p-expm1-u48.3%
expm1-udef48.3%
add-exp-log48.3%
associate--l+97.7%
add-sqr-sqrt63.1%
fabs-sqr63.1%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
Final simplification98.2%
(FPCore (x) :precision binary32 (if (<= x -50.0) (copysign (log (/ -0.5 x)) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-50.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -50Initial program 45.1%
+-commutative45.1%
hypot-1-def98.5%
Simplified98.5%
+-lft-identity98.5%
+-commutative98.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
Applied egg-rr8.5%
Taylor expanded in x around -inf 99.4%
if -50 < x Initial program 33.2%
+-commutative33.2%
hypot-1-def48.9%
Simplified48.9%
log1p-expm1-u48.9%
expm1-udef48.9%
add-exp-log48.9%
associate--l+97.7%
add-sqr-sqrt62.4%
fabs-sqr62.4%
add-sqr-sqrt97.3%
Applied egg-rr97.3%
Final simplification97.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(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.05000000074505806f) {
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.05000000074505806)) 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.05000000074505806)) 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.05000000074505806:\\
\;\;\;\;\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 48.3%
+-commutative48.3%
hypot-1-def98.6%
Simplified98.6%
+-lft-identity98.6%
+-commutative98.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
Applied egg-rr13.0%
Taylor expanded in x around -inf 97.0%
if -1 < x < 0.0500000007Initial program 22.8%
+-commutative22.8%
hypot-1-def23.0%
Simplified23.0%
Taylor expanded in x around 0 21.9%
*-un-lft-identity21.9%
log-prod21.9%
metadata-eval21.9%
+-commutative21.9%
log1p-def98.6%
+-commutative98.6%
fma-def98.6%
add-sqr-sqrt48.2%
fabs-sqr48.2%
add-sqr-sqrt98.4%
Applied egg-rr98.4%
+-rgt-identity98.4%
fma-udef98.4%
*-commutative98.4%
fma-udef98.4%
Simplified98.4%
Taylor expanded in x around 0 98.8%
if 0.0500000007 < x Initial program 50.9%
+-commutative50.9%
hypot-1-def99.9%
Simplified99.9%
+-lft-identity99.9%
+-commutative99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 96.7%
Final simplification97.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.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 <= 1.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(1.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(1.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 1.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 48.3%
+-commutative48.3%
hypot-1-def98.6%
Simplified98.6%
+-lft-identity98.6%
+-commutative98.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
Applied egg-rr13.0%
Taylor expanded in x around -inf 97.0%
if -1 < x < 1.5Initial program 23.4%
+-commutative23.4%
hypot-1-def23.5%
Simplified23.5%
Taylor expanded in x around 0 22.0%
*-un-lft-identity22.0%
log-prod22.0%
metadata-eval22.0%
+-commutative22.0%
log1p-def98.1%
+-commutative98.1%
fma-def98.1%
add-sqr-sqrt48.1%
fabs-sqr48.1%
add-sqr-sqrt98.0%
Applied egg-rr98.0%
+-rgt-identity98.0%
fma-udef98.0%
*-commutative98.0%
fma-udef98.0%
Simplified98.0%
Taylor expanded in x around 0 98.3%
if 1.5 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 6.4%
*-un-lft-identity6.4%
log-prod6.4%
metadata-eval6.4%
+-commutative6.4%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt6.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt96.0%
mul-1-neg96.0%
neg-fabs96.0%
add-sqr-sqrt96.0%
fabs-sqr96.0%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
+-rgt-identity96.0%
count-296.0%
*-commutative96.0%
Simplified96.0%
Final simplification97.4%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (- x)) x) (if (<= x 1.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.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(-2.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.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(-2.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(1.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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1.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 < -2Initial program 47.5%
+-commutative47.5%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around -inf 44.8%
if -2 < x < 1.5Initial program 24.0%
+-commutative24.0%
hypot-1-def24.1%
Simplified24.1%
Taylor expanded in x around 0 22.1%
*-un-lft-identity22.1%
log-prod22.1%
metadata-eval22.1%
+-commutative22.1%
log1p-def97.7%
+-commutative97.7%
fma-def97.7%
add-sqr-sqrt47.8%
fabs-sqr47.8%
add-sqr-sqrt97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
fma-udef97.4%
*-commutative97.4%
fma-udef97.4%
Simplified97.4%
Taylor expanded in x around 0 96.8%
if 1.5 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 6.4%
*-un-lft-identity6.4%
log-prod6.4%
metadata-eval6.4%
+-commutative6.4%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt6.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt96.0%
mul-1-neg96.0%
neg-fabs96.0%
add-sqr-sqrt96.0%
fabs-sqr96.0%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
+-rgt-identity96.0%
count-296.0%
*-commutative96.0%
Simplified96.0%
Final simplification83.2%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 1.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 1.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(-2.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(1.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(-2.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(1.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 -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.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 < -2Initial program 47.5%
+-commutative47.5%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around -inf 96.5%
Taylor expanded in x around -inf 44.8%
mul-1-neg44.8%
Simplified44.8%
if -2 < x < 1.5Initial program 24.0%
+-commutative24.0%
hypot-1-def24.1%
Simplified24.1%
Taylor expanded in x around 0 22.1%
*-un-lft-identity22.1%
log-prod22.1%
metadata-eval22.1%
+-commutative22.1%
log1p-def97.7%
+-commutative97.7%
fma-def97.7%
add-sqr-sqrt47.8%
fabs-sqr47.8%
add-sqr-sqrt97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
fma-udef97.4%
*-commutative97.4%
fma-udef97.4%
Simplified97.4%
Taylor expanded in x around 0 96.8%
if 1.5 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 6.4%
*-un-lft-identity6.4%
log-prod6.4%
metadata-eval6.4%
+-commutative6.4%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt6.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt96.0%
mul-1-neg96.0%
neg-fabs96.0%
add-sqr-sqrt96.0%
fabs-sqr96.0%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
+-rgt-identity96.0%
count-296.0%
*-commutative96.0%
Simplified96.0%
Final simplification83.2%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.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 <= 1.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(1.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(1.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 1.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 48.3%
+-commutative48.3%
hypot-1-def98.6%
Simplified98.6%
+-lft-identity98.6%
+-commutative98.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
Applied egg-rr13.0%
Taylor expanded in x around -inf 97.0%
if -1 < x < 1.5Initial program 23.4%
+-commutative23.4%
hypot-1-def23.5%
Simplified23.5%
Taylor expanded in x around 0 22.0%
*-un-lft-identity22.0%
log-prod22.0%
metadata-eval22.0%
+-commutative22.0%
log1p-def98.1%
+-commutative98.1%
fma-def98.1%
add-sqr-sqrt48.1%
fabs-sqr48.1%
add-sqr-sqrt98.0%
Applied egg-rr98.0%
+-rgt-identity98.0%
fma-udef98.0%
*-commutative98.0%
fma-udef98.0%
Simplified98.0%
Taylor expanded in x around 0 97.3%
if 1.5 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 6.4%
*-un-lft-identity6.4%
log-prod6.4%
metadata-eval6.4%
+-commutative6.4%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt6.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt96.0%
mul-1-neg96.0%
neg-fabs96.0%
add-sqr-sqrt96.0%
fabs-sqr96.0%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
+-rgt-identity96.0%
count-296.0%
*-commutative96.0%
Simplified96.0%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x -0.5) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -0.5f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.5)) 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 -0.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 < -0.5Initial program 49.7%
+-commutative49.7%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around -inf 44.1%
if -0.5 < x Initial program 31.1%
+-commutative31.1%
hypot-1-def47.3%
Simplified47.3%
Taylor expanded in x around 0 27.6%
Simplified78.1%
log1p-def27.6%
*-un-lft-identity27.6%
log-prod27.6%
metadata-eval27.6%
+-commutative27.6%
log1p-def78.1%
add-sqr-sqrt45.7%
fabs-sqr45.7%
add-sqr-sqrt78.1%
Applied egg-rr78.1%
+-rgt-identity78.1%
Simplified78.1%
Final simplification68.9%
(FPCore (x) :precision binary32 (if (<= x 5.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 5.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(5.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(5.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 5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 5Initial program 32.9%
+-commutative32.9%
hypot-1-def50.0%
Simplified50.0%
Taylor expanded in x around 0 20.4%
*-un-lft-identity20.4%
log-prod20.4%
metadata-eval20.4%
+-commutative20.4%
log1p-def69.7%
+-commutative69.7%
fma-def69.7%
add-sqr-sqrt31.7%
fabs-sqr31.7%
add-sqr-sqrt69.6%
Applied egg-rr69.6%
+-rgt-identity69.6%
fma-udef69.6%
*-commutative69.6%
fma-udef69.6%
Simplified69.6%
Taylor expanded in x around 0 67.2%
if 5 < x Initial program 47.5%
+-commutative47.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 44.7%
Final simplification62.2%
(FPCore (x) :precision binary32 (if (<= x 1.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.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 1.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 < 1.5Initial program 31.9%
+-commutative31.9%
hypot-1-def49.2%
Simplified49.2%
Taylor expanded in x around 0 20.2%
*-un-lft-identity20.2%
log-prod20.2%
metadata-eval20.2%
+-commutative20.2%
log1p-def70.3%
+-commutative70.3%
fma-def70.3%
add-sqr-sqrt31.7%
fabs-sqr31.7%
add-sqr-sqrt70.1%
Applied egg-rr70.1%
+-rgt-identity70.1%
fma-udef70.1%
*-commutative70.1%
fma-udef70.1%
Simplified70.1%
Taylor expanded in x around 0 67.8%
if 1.5 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 44.1%
Simplified44.1%
log1p-def44.1%
*-un-lft-identity44.1%
log-prod44.1%
metadata-eval44.1%
+-commutative44.1%
log1p-def44.1%
add-sqr-sqrt44.1%
fabs-sqr44.1%
add-sqr-sqrt44.1%
Applied egg-rr44.1%
+-rgt-identity44.1%
Simplified44.1%
Final simplification62.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-def61.1%
Simplified61.1%
Taylor expanded in x around 0 19.5%
*-un-lft-identity19.5%
log-prod19.5%
metadata-eval19.5%
+-commutative19.5%
log1p-def57.8%
+-commutative57.8%
fma-def57.8%
add-sqr-sqrt28.3%
fabs-sqr28.3%
add-sqr-sqrt57.7%
Applied egg-rr57.7%
+-rgt-identity57.7%
fma-udef57.7%
*-commutative57.7%
fma-udef57.7%
Simplified57.7%
Taylor expanded in x around 0 54.6%
Final simplification54.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 2023326
(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))