
(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 10 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.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign
(+ x (* (pow x 3.0) (fma (pow x 2.0) 0.075 -0.16666666666666666)))
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.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
tmp = copysignf((x + (powf(x, 3.0f) * fmaf(powf(x, 2.0f), 0.075f, -0.16666666666666666f))), 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.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * fma((x ^ Float32(2.0)), Float32(0.075), Float32(-0.16666666666666666)))), 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.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot \mathsf{fma}\left({x}^{2}, 0.075, -0.16666666666666666\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) #s(literal 1 binary32))))) x) < -0.400000006Initial program 59.9%
flip-+6.5%
frac-2neg6.5%
log-div6.5%
Applied egg-rr13.1%
neg-sub013.1%
associate--r-13.1%
neg-sub013.1%
+-commutative13.1%
fma-undefine12.6%
unpow212.6%
+-commutative12.6%
associate-+l+57.1%
sub-neg57.1%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
neg-sub098.5%
associate--r-98.5%
neg-sub098.5%
+-commutative98.5%
sub-neg98.5%
Simplified98.5%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0199999996Initial program 18.5%
*-un-lft-identity18.5%
*-commutative18.5%
log-prod18.5%
*-un-lft-identity18.5%
*-un-lft-identity18.5%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt18.6%
+-commutative18.6%
hypot-1-def18.6%
metadata-eval18.6%
Applied egg-rr18.6%
+-rgt-identity18.6%
Simplified18.6%
Taylor expanded in x around 0 99.9%
distribute-lft-in100.0%
*-rgt-identity100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
*-commutative100.0%
fmm-def100.0%
metadata-eval100.0%
Simplified100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 56.6%
*-un-lft-identity56.6%
*-commutative56.6%
log-prod56.6%
*-un-lft-identity56.6%
*-un-lft-identity56.6%
add-sqr-sqrt56.6%
fabs-sqr56.6%
add-sqr-sqrt56.6%
+-commutative56.6%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) 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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
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) 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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) 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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + {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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.100000001Initial program 60.5%
flip-+7.9%
frac-2neg7.9%
log-div7.8%
Applied egg-rr14.3%
neg-sub014.3%
associate--r-14.3%
neg-sub014.3%
+-commutative14.3%
fma-undefine13.9%
unpow213.9%
+-commutative13.9%
associate-+l+57.7%
sub-neg57.7%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
neg-sub098.5%
associate--r-98.5%
neg-sub098.5%
+-commutative98.5%
sub-neg98.5%
Simplified98.5%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0199999996Initial program 17.9%
Taylor expanded in x around 0 19.0%
+-commutative19.0%
fma-define19.0%
rem-square-sqrt10.1%
fabs-sqr10.1%
rem-square-sqrt19.0%
log1p-define99.8%
rem-square-sqrt50.5%
fabs-sqr50.5%
rem-square-sqrt99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 56.6%
*-un-lft-identity56.6%
*-commutative56.6%
log-prod56.6%
*-un-lft-identity56.6%
*-un-lft-identity56.6%
add-sqr-sqrt56.6%
fabs-sqr56.6%
add-sqr-sqrt56.6%
+-commutative56.6%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(copysign (* x (+ 1.0 (* (pow x 2.0) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot -0.16666666666666666\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 x < -5Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.8%
metadata-eval10.8%
Applied egg-rr10.8%
+-rgt-identity10.8%
Simplified10.8%
Taylor expanded in x around -inf 98.9%
if -5 < x < 0.0199999996Initial program 19.2%
Taylor expanded in x around 0 19.5%
+-commutative19.5%
fma-define19.5%
rem-square-sqrt10.0%
fabs-sqr10.0%
rem-square-sqrt19.3%
log1p-define98.8%
rem-square-sqrt49.7%
fabs-sqr49.7%
rem-square-sqrt99.1%
Simplified99.1%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0199999996 < x Initial program 56.6%
*-un-lft-identity56.6%
*-commutative56.6%
log-prod56.6%
*-un-lft-identity56.6%
*-un-lft-identity56.6%
add-sqr-sqrt56.6%
fabs-sqr56.6%
add-sqr-sqrt56.6%
+-commutative56.6%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (* x (+ 1.0 (* (pow x 2.0) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.8%
metadata-eval10.8%
Applied egg-rr10.8%
+-rgt-identity10.8%
Simplified10.8%
Taylor expanded in x around -inf 98.9%
if -5 < x < 1Initial program 21.6%
Taylor expanded in x around 0 20.3%
+-commutative20.3%
fma-define20.3%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt20.0%
log1p-define97.2%
rem-square-sqrt49.5%
fabs-sqr49.5%
rem-square-sqrt97.4%
Simplified97.4%
Taylor expanded in x around 0 97.9%
*-commutative97.9%
Simplified97.9%
if 1 < x Initial program 54.0%
Taylor expanded in x around inf 97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
Simplified97.2%
*-un-lft-identity97.2%
log-prod97.2%
metadata-eval97.2%
*-inverses97.2%
metadata-eval97.2%
Applied egg-rr97.2%
+-lft-identity97.2%
Simplified97.2%
Final simplification98.0%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -5Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.8%
metadata-eval10.8%
Applied egg-rr10.8%
+-rgt-identity10.8%
Simplified10.8%
Taylor expanded in x around -inf 98.9%
if -5 < x < 1Initial program 21.6%
Taylor expanded in x around 0 20.3%
+-commutative20.3%
fma-define20.3%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt20.0%
log1p-define97.2%
rem-square-sqrt49.5%
fabs-sqr49.5%
rem-square-sqrt97.4%
Simplified97.4%
Taylor expanded in x around 0 97.9%
distribute-rgt-in97.9%
*-lft-identity97.9%
*-commutative97.9%
*-commutative97.9%
associate-*r*97.9%
unpow297.9%
cube-mult97.9%
Simplified97.9%
if 1 < x Initial program 54.0%
Taylor expanded in x around inf 97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
Simplified97.2%
*-un-lft-identity97.2%
log-prod97.2%
metadata-eval97.2%
*-inverses97.2%
metadata-eval97.2%
Applied egg-rr97.2%
+-lft-identity97.2%
Simplified97.2%
Final simplification98.0%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-5.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 * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -5Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.8%
+-commutative10.8%
hypot-1-def10.8%
metadata-eval10.8%
Applied egg-rr10.8%
+-rgt-identity10.8%
Simplified10.8%
Taylor expanded in x around -inf 98.9%
if -5 < x < 1Initial program 21.6%
Taylor expanded in x around 0 20.3%
+-commutative20.3%
fma-define20.3%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt20.0%
log1p-define97.2%
rem-square-sqrt49.5%
fabs-sqr49.5%
rem-square-sqrt97.4%
Simplified97.4%
Taylor expanded in x around 0 97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in x around 0 97.0%
if 1 < x Initial program 54.0%
Taylor expanded in x around inf 97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
Simplified97.2%
*-un-lft-identity97.2%
log-prod97.2%
metadata-eval97.2%
*-inverses97.2%
metadata-eval97.2%
Applied egg-rr97.2%
+-lft-identity97.2%
Simplified97.2%
Final simplification97.5%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
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(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(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 33.7%
Taylor expanded in x around 0 17.2%
+-commutative17.2%
fma-define17.2%
rem-square-sqrt7.5%
fabs-sqr7.5%
rem-square-sqrt17.1%
log1p-define69.5%
rem-square-sqrt33.6%
fabs-sqr33.6%
rem-square-sqrt66.1%
Simplified66.1%
Taylor expanded in x around 0 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in x around 0 69.5%
if 1 < x Initial program 54.0%
Taylor expanded in x around inf 97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
Simplified97.2%
*-un-lft-identity97.2%
log-prod97.2%
metadata-eval97.2%
*-inverses97.2%
metadata-eval97.2%
Applied egg-rr97.2%
+-lft-identity97.2%
Simplified97.2%
Final simplification76.3%
(FPCore (x) :precision binary32 (if (<= x 4.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 4.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(4.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(4.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 4:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 4Initial program 34.0%
Taylor expanded in x around 0 17.3%
+-commutative17.3%
fma-define17.3%
rem-square-sqrt7.6%
fabs-sqr7.6%
rem-square-sqrt17.2%
log1p-define69.3%
rem-square-sqrt33.6%
fabs-sqr33.6%
rem-square-sqrt65.9%
Simplified65.9%
Taylor expanded in x around 0 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in x around 0 69.3%
if 4 < x Initial program 53.2%
Taylor expanded in x around inf 44.2%
mul-1-neg44.2%
log-rec44.2%
remove-double-neg44.2%
Simplified44.2%
Final simplification63.2%
(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 33.7%
Taylor expanded in x around 0 17.2%
+-commutative17.2%
fma-define17.2%
rem-square-sqrt7.5%
fabs-sqr7.5%
rem-square-sqrt17.1%
log1p-define69.5%
rem-square-sqrt33.6%
fabs-sqr33.6%
rem-square-sqrt66.1%
Simplified66.1%
Taylor expanded in x around 0 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in x around 0 69.5%
if 1 < x Initial program 54.0%
Taylor expanded in x around 0 44.0%
log1p-define44.0%
rem-square-sqrt44.0%
fabs-sqr44.0%
rem-square-sqrt44.0%
Simplified44.0%
Final simplification63.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 38.7%
Taylor expanded in x around 0 15.7%
+-commutative15.7%
fma-define15.7%
rem-square-sqrt8.3%
fabs-sqr8.3%
rem-square-sqrt15.6%
log1p-define55.1%
rem-square-sqrt28.0%
fabs-sqr28.0%
rem-square-sqrt52.5%
Simplified52.5%
Taylor expanded in x around 0 54.0%
*-commutative54.0%
Simplified54.0%
Taylor expanded in x around 0 55.2%
Final simplification55.2%
(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 2024131
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(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))