
(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 15 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%
clear-num6.5%
log-div6.5%
metadata-eval6.5%
+-commutative6.5%
hypot-1-def6.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.4%
Applied egg-rr10.1%
neg-sub010.1%
div-sub10.1%
*-rgt-identity10.1%
associate-/l*10.1%
*-rgt-identity10.1%
associate-/l*10.1%
fma-undefine9.5%
unpow29.5%
associate--r+10.2%
+-inverses10.2%
metadata-eval10.2%
metadata-eval10.2%
*-commutative10.2%
neg-mul-110.2%
fma-undefine9.5%
unpow29.5%
associate--r+57.1%
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%
add-sqr-sqrt17.4%
pow217.4%
log-pow17.7%
+-commutative17.7%
hypot-1-def17.7%
+-commutative17.7%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt17.9%
Applied egg-rr17.9%
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%
+-commutative56.6%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 56.6%
rem-square-sqrt56.6%
fabs-sqr56.6%
metadata-eval56.6%
unpow256.6%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(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%
clear-num7.9%
log-div7.8%
metadata-eval7.8%
+-commutative7.8%
hypot-1-def7.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.8%
Applied egg-rr11.4%
neg-sub011.4%
div-sub11.4%
*-rgt-identity11.4%
associate-/l*11.4%
*-rgt-identity11.4%
associate-/l*11.4%
fma-undefine10.9%
unpow210.9%
associate--r+11.5%
+-inverses11.5%
metadata-eval11.5%
metadata-eval11.5%
*-commutative11.5%
neg-mul-111.5%
fma-undefine10.9%
unpow210.9%
associate--r+57.7%
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%
add-sqr-sqrt16.9%
pow216.9%
log-pow17.1%
+-commutative17.1%
hypot-1-def17.1%
+-commutative17.1%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt17.3%
Applied egg-rr17.3%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.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%
+-commutative56.6%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 56.6%
rem-square-sqrt56.6%
fabs-sqr56.6%
metadata-eval56.6%
unpow256.6%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(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%
Taylor expanded in x around -inf 98.2%
mul-1-neg98.2%
distribute-rgt-neg-in98.2%
mul-1-neg98.2%
unsub-neg98.2%
/-rgt-identity98.2%
/-rgt-identity98.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
associate-*r/10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.9%
if -5 < x < 0.0199999996Initial program 19.2%
add-sqr-sqrt18.0%
pow218.0%
log-pow18.3%
+-commutative18.3%
hypot-1-def18.3%
+-commutative18.3%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt18.5%
Applied egg-rr18.5%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0199999996 < x Initial program 56.6%
+-commutative56.6%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 56.6%
rem-square-sqrt56.6%
fabs-sqr56.6%
metadata-eval56.6%
unpow256.6%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(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%
Taylor expanded in x around -inf 98.2%
mul-1-neg98.2%
distribute-rgt-neg-in98.2%
mul-1-neg98.2%
unsub-neg98.2%
/-rgt-identity98.2%
/-rgt-identity98.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
associate-*r/10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.9%
if -5 < x < 1Initial program 21.6%
add-sqr-sqrt20.5%
pow220.5%
log-pow20.7%
+-commutative20.7%
hypot-1-def20.7%
+-commutative20.7%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt20.9%
Applied egg-rr20.9%
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%
+-commutative97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
*-inverses97.2%
metadata-eval97.2%
Simplified97.2%
(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%
Taylor expanded in x around -inf 98.2%
mul-1-neg98.2%
distribute-rgt-neg-in98.2%
mul-1-neg98.2%
unsub-neg98.2%
/-rgt-identity98.2%
/-rgt-identity98.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
associate-*r/10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.9%
if -5 < x < 1Initial program 21.6%
add-sqr-sqrt20.5%
pow220.5%
log-pow20.7%
+-commutative20.7%
hypot-1-def20.7%
+-commutative20.7%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt20.9%
Applied egg-rr20.9%
Taylor expanded in x around 0 97.9%
distribute-lft-in97.9%
*-rgt-identity97.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%
+-commutative97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
*-inverses97.2%
metadata-eval97.2%
Simplified97.2%
(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%
Taylor expanded in x around -inf 98.2%
mul-1-neg98.2%
distribute-rgt-neg-in98.2%
mul-1-neg98.2%
unsub-neg98.2%
/-rgt-identity98.2%
/-rgt-identity98.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
associate-*r/10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.9%
if -5 < x < 1Initial program 21.6%
Taylor expanded in x around 0 18.2%
log1p-define94.0%
rem-square-sqrt47.8%
fabs-sqr47.8%
rem-square-sqrt94.0%
Simplified94.0%
Taylor expanded in x around 0 97.0%
if 1 < x Initial program 54.0%
Taylor expanded in x around inf 97.2%
+-commutative97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
*-inverses97.2%
metadata-eval97.2%
Simplified97.2%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (* x -2.0)) 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((x * -2.0f)), 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(x * Float32(-2.0))), 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((x * single(-2.0)))); 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(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 \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 59.3%
Taylor expanded in x around -inf 97.5%
neg-mul-197.5%
Simplified97.5%
+-commutative97.5%
neg-sub097.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.4%
associate-+l-6.4%
sub-neg6.4%
add-sqr-sqrt9.3%
sqrt-unprod3.6%
sqr-neg3.6%
sqrt-unprod-0.0%
add-sqr-sqrt97.5%
Applied egg-rr97.5%
neg-sub097.5%
count-297.5%
*-commutative97.5%
distribute-rgt-neg-in97.5%
metadata-eval97.5%
Simplified97.5%
if -5 < x < 1Initial program 21.6%
Taylor expanded in x around 0 18.2%
log1p-define94.0%
rem-square-sqrt47.8%
fabs-sqr47.8%
rem-square-sqrt94.0%
Simplified94.0%
Taylor expanded in x around 0 97.0%
if 1 < x Initial program 54.0%
Taylor expanded in x around inf 97.2%
+-commutative97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
*-inverses97.2%
metadata-eval97.2%
Simplified97.2%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (* x -2.0)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 59.3%
Taylor expanded in x around -inf 97.5%
neg-mul-197.5%
Simplified97.5%
+-commutative97.5%
neg-sub097.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.4%
associate-+l-6.4%
sub-neg6.4%
add-sqr-sqrt9.3%
sqrt-unprod3.6%
sqr-neg3.6%
sqrt-unprod-0.0%
add-sqr-sqrt97.5%
Applied egg-rr97.5%
neg-sub097.5%
count-297.5%
*-commutative97.5%
distribute-rgt-neg-in97.5%
metadata-eval97.5%
Simplified97.5%
if -5 < x Initial program 32.1%
Taylor expanded in x around 0 26.6%
log1p-define77.8%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt77.8%
Simplified77.8%
(FPCore (x) :precision binary32 (if (<= x -5.0) (pow (copysign -2.0 -2.0) 3.0) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = powf(copysignf(-2.0f, -2.0f), 3.0f);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-2.0), Float32(-2.0)) ^ Float32(3.0); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;{\left(\mathsf{copysign}\left(-2, -2\right)\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 59.3%
Taylor expanded in x around 0 44.1%
log1p-define44.1%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Applied egg-rr25.7%
if -5 < x Initial program 32.1%
Taylor expanded in x around 0 26.6%
log1p-define77.8%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt77.8%
Simplified77.8%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign 4.0 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(4.0f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(4.0), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(4, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 59.3%
Taylor expanded in x around 0 44.1%
log1p-define44.1%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Applied egg-rr23.5%
if -5 < x Initial program 32.1%
Taylor expanded in x around 0 26.6%
log1p-define77.8%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt77.8%
Simplified77.8%
(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 26.6%
log1p-define77.8%
rem-square-sqrt32.4%
fabs-sqr32.4%
rem-square-sqrt63.6%
Simplified63.6%
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%
(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 30.9%
log1p-define69.6%
rem-square-sqrt35.3%
fabs-sqr35.3%
rem-square-sqrt58.9%
Simplified58.9%
Taylor expanded in x around 0 55.2%
(FPCore (x) :precision binary32 (copysign 4.0 x))
float code(float x) {
return copysignf(4.0f, x);
}
function code(x) return copysign(Float32(4.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(4.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(4, x\right)
\end{array}
Initial program 38.7%
Taylor expanded in x around 0 30.9%
log1p-define69.6%
rem-square-sqrt35.3%
fabs-sqr35.3%
rem-square-sqrt58.9%
Simplified58.9%
Applied egg-rr16.9%
(FPCore (x) :precision binary32 (copysign 2.0 x))
float code(float x) {
return copysignf(2.0f, x);
}
function code(x) return copysign(Float32(2.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(2.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(2, x\right)
\end{array}
Initial program 38.7%
Taylor expanded in x around 0 30.9%
log1p-define69.6%
rem-square-sqrt35.3%
fabs-sqr35.3%
rem-square-sqrt58.9%
Simplified58.9%
Applied egg-rr16.2%
(FPCore (x) :precision binary32 (copysign 1.5 x))
float code(float x) {
return copysignf(1.5f, x);
}
function code(x) return copysign(Float32(1.5), x) end
function tmp = code(x) tmp = sign(x) * abs(single(1.5)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(1.5, x\right)
\end{array}
Initial program 38.7%
Taylor expanded in x around 0 30.9%
log1p-define69.6%
rem-square-sqrt35.3%
fabs-sqr35.3%
rem-square-sqrt58.9%
Simplified58.9%
Applied egg-rr16.0%
(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
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))