
(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 14 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.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* 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 <= -0.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + ((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(-0.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + 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(-0.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + ((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 -0.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \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) < -0.5Initial program 59.0%
+-commutative59.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.3%
flip-+10.1%
log-div10.1%
add-sqr-sqrt10.2%
fma-def10.6%
+-commutative10.6%
hypot-1-def10.6%
Applied egg-rr10.6%
fma-udef10.2%
+-commutative10.2%
associate--l+56.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 20.5%
*-un-lft-identity20.5%
*-commutative20.5%
log-prod20.5%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt21.2%
+-commutative21.2%
hypot-1-def21.1%
metadata-eval21.1%
Applied egg-rr21.1%
+-rgt-identity21.1%
Simplified21.1%
Taylor expanded in x around 0 100.0%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 43.1%
*-un-lft-identity43.1%
*-commutative43.1%
log-prod43.1%
add-sqr-sqrt43.0%
fabs-sqr43.0%
add-sqr-sqrt43.1%
+-commutative43.1%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
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.10000000149011612)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.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 <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.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(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + 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) 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.10000000149011612)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (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}
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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.100000001Initial program 59.6%
+-commutative59.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.7%
flip-+11.6%
log-div11.6%
add-sqr-sqrt11.6%
fma-def12.1%
+-commutative12.1%
hypot-1-def12.1%
Applied egg-rr12.1%
fma-udef11.6%
+-commutative11.6%
associate--l+56.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 19.3%
*-un-lft-identity19.3%
*-commutative19.3%
log-prod19.3%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt20.0%
+-commutative20.0%
hypot-1-def19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 43.8%
*-un-lft-identity43.8%
*-commutative43.8%
log-prod43.8%
add-sqr-sqrt43.7%
fabs-sqr43.7%
add-sqr-sqrt43.8%
+-commutative43.8%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 x))))) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.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 * (-1.0f / x)))), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.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) * Float32(Float32(-1.0) / x))))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.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) * (single(-1.0) / x))))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.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 + 0.5 \cdot \frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 58.2%
+-commutative58.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.7%
flip-+8.6%
log-div8.6%
add-sqr-sqrt8.6%
fma-def9.1%
+-commutative9.1%
hypot-1-def9.1%
Applied egg-rr9.1%
fma-udef8.6%
+-commutative8.6%
associate--l+55.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.8%
if -10 < x < 0.100000001Initial program 20.5%
Taylor expanded in x around 0 20.6%
fma-def20.6%
unpow220.6%
rem-square-sqrt10.2%
fabs-sqr10.2%
rem-square-sqrt20.1%
log1p-def98.0%
rem-square-sqrt52.3%
fabs-sqr52.3%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 99.2%
if 0.100000001 < x Initial program 43.8%
*-un-lft-identity43.8%
*-commutative43.8%
log-prod43.8%
add-sqr-sqrt43.7%
fabs-sqr43.7%
add-sqr-sqrt43.8%
+-commutative43.8%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.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.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.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.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.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.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 59.6%
+-commutative59.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.7%
flip-+11.6%
log-div11.6%
add-sqr-sqrt11.6%
fma-def12.1%
+-commutative12.1%
hypot-1-def12.1%
Applied egg-rr12.1%
fma-udef11.6%
+-commutative11.6%
associate--l+56.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.100000001 < x < 0.100000001Initial program 19.3%
Taylor expanded in x around 0 20.2%
fma-def20.2%
unpow220.2%
rem-square-sqrt10.4%
fabs-sqr10.4%
rem-square-sqrt19.9%
log1p-def99.0%
rem-square-sqrt53.1%
fabs-sqr53.1%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around 0 99.9%
if 0.100000001 < x Initial program 43.8%
*-un-lft-identity43.8%
*-commutative43.8%
log-prod43.8%
add-sqr-sqrt43.7%
fabs-sqr43.7%
add-sqr-sqrt43.8%
+-commutative43.8%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 x))))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.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 * (-1.0f / x)))), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.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) * Float32(Float32(-1.0) / x))))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.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) * (single(-1.0) / x))))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.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 + 0.5 \cdot \frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 58.2%
+-commutative58.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.7%
flip-+8.6%
log-div8.6%
add-sqr-sqrt8.6%
fma-def9.1%
+-commutative9.1%
hypot-1-def9.1%
Applied egg-rr9.1%
fma-udef8.6%
+-commutative8.6%
associate--l+55.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.8%
if -10 < x < 0.200000003Initial program 21.1%
Taylor expanded in x around 0 20.9%
fma-def20.9%
unpow220.9%
rem-square-sqrt10.6%
fabs-sqr10.6%
rem-square-sqrt20.4%
log1p-def97.6%
rem-square-sqrt52.3%
fabs-sqr52.3%
rem-square-sqrt98.3%
Simplified98.3%
Taylor expanded in x around 0 99.0%
if 0.200000003 < x Initial program 43.1%
Taylor expanded in x around inf 97.3%
associate-*r/97.3%
metadata-eval97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.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((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 58.2%
*-un-lft-identity58.2%
*-commutative58.2%
log-prod58.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.7%
+-commutative9.7%
hypot-1-def9.7%
metadata-eval9.7%
Applied egg-rr9.7%
+-rgt-identity9.7%
Simplified9.7%
Taylor expanded in x around -inf 99.0%
if -10 < x < 0.200000003Initial program 21.1%
Taylor expanded in x around 0 20.9%
fma-def20.9%
unpow220.9%
rem-square-sqrt10.6%
fabs-sqr10.6%
rem-square-sqrt20.4%
log1p-def97.6%
rem-square-sqrt52.3%
fabs-sqr52.3%
rem-square-sqrt98.3%
Simplified98.3%
Taylor expanded in x around 0 99.0%
if 0.200000003 < x Initial program 43.1%
Taylor expanded in x around inf 97.3%
associate-*r/97.3%
metadata-eval97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 2.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / 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(2.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / 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(2.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / 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 2:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 58.2%
*-un-lft-identity58.2%
*-commutative58.2%
log-prod58.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.7%
+-commutative9.7%
hypot-1-def9.7%
metadata-eval9.7%
Applied egg-rr9.7%
+-rgt-identity9.7%
Simplified9.7%
Taylor expanded in x around -inf 99.0%
if -10 < x < 2Initial program 21.7%
Taylor expanded in x around 0 21.1%
fma-def21.1%
unpow221.1%
rem-square-sqrt10.8%
fabs-sqr10.8%
rem-square-sqrt20.5%
log1p-def97.2%
rem-square-sqrt52.2%
fabs-sqr52.2%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
if 2 < x Initial program 42.3%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
metadata-eval98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
Simplified98.0%
Taylor expanded in x around 0 97.4%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -200.0) (copysign 15.333333333333334 x) (if (<= x 2.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -200.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-200.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(2.0)) 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(-200.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(2.0)) 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 -200:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -200Initial program 57.5%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified27.9%
if -200 < x < 2Initial program 22.3%
Taylor expanded in x around 0 21.1%
fma-def21.1%
unpow221.1%
rem-square-sqrt10.7%
fabs-sqr10.7%
rem-square-sqrt20.6%
log1p-def96.7%
rem-square-sqrt51.8%
fabs-sqr51.8%
rem-square-sqrt97.0%
Simplified97.0%
Taylor expanded in x around 0 97.9%
Taylor expanded in x around 0 96.4%
if 2 < x Initial program 42.3%
Taylor expanded in x around inf 96.1%
rem-square-sqrt96.1%
fabs-sqr96.1%
rem-square-sqrt96.1%
Simplified96.1%
Final simplification81.6%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (/ -0.5 x)) x) (if (<= x 2.0) (copysign 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 <= 2.0f) {
tmp = copysignf(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(2.0)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 58.2%
*-un-lft-identity58.2%
*-commutative58.2%
log-prod58.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.7%
+-commutative9.7%
hypot-1-def9.7%
metadata-eval9.7%
Applied egg-rr9.7%
+-rgt-identity9.7%
Simplified9.7%
Taylor expanded in x around -inf 99.0%
if -10 < x < 2Initial program 21.7%
Taylor expanded in x around 0 21.1%
fma-def21.1%
unpow221.1%
rem-square-sqrt10.8%
fabs-sqr10.8%
rem-square-sqrt20.5%
log1p-def97.2%
rem-square-sqrt52.2%
fabs-sqr52.2%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
Taylor expanded in x around 0 97.0%
if 2 < x Initial program 42.3%
Taylor expanded in x around inf 96.1%
rem-square-sqrt96.1%
fabs-sqr96.1%
rem-square-sqrt96.1%
Simplified96.1%
Final simplification97.2%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (/ -0.5 x)) x) (if (<= x 2.0) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / 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(2.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / 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(2.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((single(0.5) / 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 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 58.2%
*-un-lft-identity58.2%
*-commutative58.2%
log-prod58.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.7%
+-commutative9.7%
hypot-1-def9.7%
metadata-eval9.7%
Applied egg-rr9.7%
+-rgt-identity9.7%
Simplified9.7%
Taylor expanded in x around -inf 99.0%
if -10 < x < 2Initial program 21.7%
Taylor expanded in x around 0 21.1%
fma-def21.1%
unpow221.1%
rem-square-sqrt10.8%
fabs-sqr10.8%
rem-square-sqrt20.5%
log1p-def97.2%
rem-square-sqrt52.2%
fabs-sqr52.2%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
Taylor expanded in x around 0 97.0%
if 2 < x Initial program 42.3%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
metadata-eval98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
Simplified98.0%
Taylor expanded in x around 0 97.4%
Final simplification97.6%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign 15.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 58.2%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified27.8%
if -10 < x Initial program 29.2%
Taylor expanded in x around 0 27.8%
log1p-def75.8%
rem-square-sqrt48.2%
fabs-sqr48.2%
rem-square-sqrt75.7%
Simplified75.7%
Final simplification65.2%
(FPCore (x) :precision binary32 (if (<= x -200.0) (copysign 15.333333333333334 x) (if (<= x 10.0) (copysign x x) (copysign 15.333333333333334 x))))
float code(float x) {
float tmp;
if (x <= -200.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 10.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(15.333333333333334f, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-200.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(10.0)) tmp = copysign(x, x); else tmp = copysign(Float32(15.333333333333334), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-200.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(10.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(single(15.333333333333334)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -200:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 10:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\end{array}
\end{array}
if x < -200 or 10 < x Initial program 48.0%
Taylor expanded in x around inf 55.6%
associate-*r/55.6%
metadata-eval55.6%
rem-square-sqrt55.6%
fabs-sqr55.6%
rem-square-sqrt55.6%
Simplified55.6%
Taylor expanded in x around 0 0.8%
Simplified27.1%
if -200 < x < 10Initial program 23.5%
Taylor expanded in x around 0 21.2%
fma-def21.2%
unpow221.2%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt20.8%
log1p-def95.6%
rem-square-sqrt51.4%
fabs-sqr51.4%
rem-square-sqrt96.0%
Simplified96.0%
Taylor expanded in x around 0 96.7%
Taylor expanded in x around 0 95.4%
Final simplification61.8%
(FPCore (x) :precision binary32 (copysign -6.0 x))
float code(float x) {
return copysignf(-6.0f, x);
}
function code(x) return copysign(Float32(-6.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-6.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-6, x\right)
\end{array}
Initial program 35.6%
Taylor expanded in x around inf 30.8%
associate-*r/30.8%
metadata-eval30.8%
rem-square-sqrt30.8%
fabs-sqr30.8%
rem-square-sqrt30.8%
Simplified30.8%
Taylor expanded in x around 0 3.7%
Simplified17.4%
Final simplification17.4%
(FPCore (x) :precision binary32 (copysign 15.333333333333334 x))
float code(float x) {
return copysignf(15.333333333333334f, x);
}
function code(x) return copysign(Float32(15.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(15.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(15.333333333333334, x\right)
\end{array}
Initial program 35.6%
Taylor expanded in x around inf 30.8%
associate-*r/30.8%
metadata-eval30.8%
rem-square-sqrt30.8%
fabs-sqr30.8%
rem-square-sqrt30.8%
Simplified30.8%
Taylor expanded in x around 0 3.3%
Simplified18.7%
Final simplification18.7%
(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 2023257
(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))