
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -2.0)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.009999999776482582)
(copysign
(+
(* -0.16666666666666666 (* x (* x x)))
(+ (* 0.075 (pow x 5.0)) (+ x (* -0.044642857142857144 (pow x 7.0)))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -2.0f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.009999999776482582f) {
tmp = copysignf(((-0.16666666666666666f * (x * (x * x))) + ((0.075f * powf(x, 5.0f)) + (x + (-0.044642857142857144f * powf(x, 7.0f))))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.009999999776482582)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + Float32(x + Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0)))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-2.0)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.009999999776482582)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x * (x * x))) + ((single(0.075) * (x ^ single(5.0))) + (x + (single(-0.044642857142857144) * (x ^ single(7.0))))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right) + \left(0.075 \cdot {x}^{5} + \left(x + -0.044642857142857144 \cdot {x}^{7}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -2Initial program 42.4%
+-commutative42.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
flip-+5.3%
log-div5.3%
add-sqr-sqrt5.3%
fma-def5.3%
+-commutative5.3%
hypot-1-def5.3%
Applied egg-rr5.3%
fma-udef5.3%
+-commutative5.3%
associate--l+38.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00999999978Initial program 19.9%
*-un-lft-identity19.9%
*-commutative19.9%
log-prod19.9%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
metadata-eval19.8%
Applied egg-rr19.8%
+-rgt-identity19.8%
Simplified19.8%
Taylor expanded in x around 0 100.0%
unpow3100.0%
Applied egg-rr100.0%
if 0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 49.2%
*-un-lft-identity49.2%
*-commutative49.2%
log-prod49.2%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.009999999776482582)
(copysign
(+ (* -0.16666666666666666 (* x (* x x))) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf(((-0.16666666666666666f * (x * (x * x))) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.009999999776482582)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.009999999776482582)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x * (x * x))) + (x + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right) + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 42.4%
+-commutative42.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
flip-+5.3%
log-div5.3%
add-sqr-sqrt5.3%
fma-def5.3%
+-commutative5.3%
hypot-1-def5.3%
Applied egg-rr5.3%
fma-udef5.3%
+-commutative5.3%
associate--l+38.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.9%
*-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
if -10 < x < 0.00999999978Initial program 19.9%
*-un-lft-identity19.9%
*-commutative19.9%
log-prod19.9%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
metadata-eval19.8%
Applied egg-rr19.8%
+-rgt-identity19.8%
Simplified19.8%
Taylor expanded in x around 0 99.8%
unpow3100.0%
Applied egg-rr99.8%
if 0.00999999978 < x Initial program 49.2%
*-un-lft-identity49.2%
*-commutative49.2%
log-prod49.2%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.009999999776482582)
(copysign
(+ (* -0.16666666666666666 (* x (* x x))) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf(((-0.16666666666666666f * (x * (x * x))) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.009999999776482582)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.009999999776482582)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x * (x * x))) + (x + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right) + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 44.0%
+-commutative44.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.0%
flip-+8.0%
log-div7.9%
add-sqr-sqrt8.0%
fma-def8.0%
+-commutative8.0%
hypot-1-def8.0%
Applied egg-rr8.0%
fma-udef8.0%
+-commutative8.0%
associate--l+40.2%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.100000001 < x < 0.00999999978Initial program 18.7%
*-un-lft-identity18.7%
*-commutative18.7%
log-prod18.7%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt18.7%
+-commutative18.7%
hypot-1-def18.7%
metadata-eval18.7%
Applied egg-rr18.7%
+-rgt-identity18.7%
Simplified18.7%
Taylor expanded in x around 0 100.0%
unpow3100.0%
Applied egg-rr100.0%
if 0.00999999978 < x Initial program 49.2%
*-un-lft-identity49.2%
*-commutative49.2%
log-prod49.2%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.009999999776482582)
(copysign
(+ (* -0.16666666666666666 (* x (* x x))) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf(((-0.16666666666666666f * (x * (x * x))) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.009999999776482582)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.009999999776482582)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x * (x * x))) + (x + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right) + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 44.0%
+-commutative44.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.0%
flip-+8.0%
add-sqr-sqrt8.0%
fma-def8.0%
+-commutative8.0%
hypot-1-def8.0%
Applied egg-rr8.0%
fma-udef8.0%
+-commutative8.0%
associate--l+40.2%
+-inverses99.9%
metadata-eval99.9%
Simplified99.9%
if -0.100000001 < x < 0.00999999978Initial program 18.7%
*-un-lft-identity18.7%
*-commutative18.7%
log-prod18.7%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt18.7%
+-commutative18.7%
hypot-1-def18.7%
metadata-eval18.7%
Applied egg-rr18.7%
+-rgt-identity18.7%
Simplified18.7%
Taylor expanded in x around 0 100.0%
unpow3100.0%
Applied egg-rr100.0%
if 0.00999999978 < x Initial program 49.2%
*-un-lft-identity49.2%
*-commutative49.2%
log-prod49.2%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.5)
(copysign
(+ (* -0.16666666666666666 (* x (* x x))) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.5f) {
tmp = copysignf(((-0.16666666666666666f * (x * (x * x))) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.5)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x * (x * x))) + (x + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right) + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 42.4%
+-commutative42.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
flip-+5.3%
log-div5.3%
add-sqr-sqrt5.3%
fma-def5.3%
+-commutative5.3%
hypot-1-def5.3%
Applied egg-rr5.3%
fma-udef5.3%
+-commutative5.3%
associate--l+38.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.9%
*-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
if -10 < x < 0.5Initial program 20.5%
*-un-lft-identity20.5%
*-commutative20.5%
log-prod20.5%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.4%
metadata-eval20.4%
Applied egg-rr20.4%
+-rgt-identity20.4%
Simplified20.4%
Taylor expanded in x around 0 99.5%
unpow399.8%
Applied egg-rr99.5%
if 0.5 < x Initial program 48.3%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.1%
Simplified98.1%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (* x (* x x)))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * (x * (x * x)))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x * (x * x))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 42.4%
*-un-lft-identity42.4%
*-commutative42.4%
log-prod42.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
+-commutative8.5%
hypot-1-def8.5%
metadata-eval8.5%
Applied egg-rr8.5%
+-rgt-identity8.5%
Simplified8.5%
Taylor expanded in x around -inf 99.3%
if -10 < x < 0.5Initial program 20.5%
*-un-lft-identity20.5%
*-commutative20.5%
log-prod20.5%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.4%
metadata-eval20.4%
Applied egg-rr20.4%
+-rgt-identity20.4%
Simplified20.4%
Taylor expanded in x around 0 99.2%
unpow399.8%
Applied egg-rr99.2%
if 0.5 < x Initial program 48.3%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.1%
Simplified98.1%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (* x (* x x)))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * (x * (x * x)))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x * (x * x))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 42.4%
+-commutative42.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
flip-+5.3%
log-div5.3%
add-sqr-sqrt5.3%
fma-def5.3%
+-commutative5.3%
hypot-1-def5.3%
Applied egg-rr5.3%
fma-udef5.3%
+-commutative5.3%
associate--l+38.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.9%
*-commutative99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
if -10 < x < 0.5Initial program 20.5%
*-un-lft-identity20.5%
*-commutative20.5%
log-prod20.5%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.4%
metadata-eval20.4%
Applied egg-rr20.4%
+-rgt-identity20.4%
Simplified20.4%
Taylor expanded in x around 0 99.2%
unpow399.8%
Applied egg-rr99.2%
if 0.5 < x Initial program 48.3%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.1%
Simplified98.1%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (* x (* x x)))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * (x * (x * x)))), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x)))), x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x * (x * x))))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 42.4%
*-un-lft-identity42.4%
*-commutative42.4%
log-prod42.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.5%
+-commutative8.5%
hypot-1-def8.5%
metadata-eval8.5%
Applied egg-rr8.5%
+-rgt-identity8.5%
Simplified8.5%
Taylor expanded in x around -inf 99.3%
if -10 < x < 0.5Initial program 20.5%
*-un-lft-identity20.5%
*-commutative20.5%
log-prod20.5%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt20.4%
+-commutative20.4%
hypot-1-def20.4%
metadata-eval20.4%
Applied egg-rr20.4%
+-rgt-identity20.4%
Simplified20.4%
Taylor expanded in x around 0 99.2%
unpow399.8%
Applied egg-rr99.2%
if 0.5 < x Initial program 48.3%
Taylor expanded in x around inf 96.8%
rem-square-sqrt96.7%
fabs-sqr96.7%
rem-square-sqrt96.8%
Simplified96.8%
Final simplification98.6%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 27.7%
*-un-lft-identity27.7%
*-commutative27.7%
log-prod27.7%
add-sqr-sqrt6.5%
fabs-sqr6.5%
add-sqr-sqrt16.5%
+-commutative16.5%
hypot-1-def16.5%
metadata-eval16.5%
Applied egg-rr16.5%
+-rgt-identity16.5%
Simplified16.5%
Taylor expanded in x around 0 69.1%
if 0.5 < x Initial program 48.3%
Taylor expanded in x around inf 96.8%
rem-square-sqrt96.7%
fabs-sqr96.7%
rem-square-sqrt96.8%
Simplified96.8%
Final simplification75.4%
(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 28.0%
*-un-lft-identity28.0%
*-commutative28.0%
log-prod28.0%
add-sqr-sqrt6.9%
fabs-sqr6.9%
add-sqr-sqrt16.9%
+-commutative16.9%
hypot-1-def16.9%
metadata-eval16.9%
Applied egg-rr16.9%
+-rgt-identity16.9%
Simplified16.9%
Taylor expanded in x around 0 68.9%
if 1.5 < x Initial program 47.4%
Taylor expanded in x around 0 44.3%
log1p-def44.3%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt44.3%
Simplified44.3%
Final simplification63.4%
(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 32.4%
*-un-lft-identity32.4%
*-commutative32.4%
log-prod32.4%
add-sqr-sqrt15.9%
fabs-sqr15.9%
add-sqr-sqrt23.7%
+-commutative23.7%
hypot-1-def35.4%
metadata-eval35.4%
Applied egg-rr35.4%
+-rgt-identity35.4%
Simplified35.4%
Taylor expanded in x around 0 56.1%
Final simplification56.1%
(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 2023263
(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))