
(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 -0.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+
x
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* -0.044642857142857144 (pow x 7.0)) (* 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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + ((-0.044642857142857144f * powf(x, 7.0f)) + (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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0))) + 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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(-0.044642857142857144) * (x ^ single(7.0))) + (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.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(x + \left(-0.16666666666666666 \cdot {x}^{3} + \left(-0.044642857142857144 \cdot {x}^{7} + 0.075 \cdot {x}^{5}\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 50.9%
+-commutative50.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.4%
flip-+14.8%
log-div14.8%
add-sqr-sqrt18.2%
fma-def18.2%
+-commutative18.2%
hypot-1-def18.2%
Applied egg-rr18.2%
fma-udef18.2%
+-commutative18.2%
associate--l+47.4%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 21.1%
*-un-lft-identity21.1%
*-commutative21.1%
log-prod21.1%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt21.1%
+-commutative21.1%
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 42.2%
*-un-lft-identity42.2%
*-commutative42.2%
log-prod42.2%
add-sqr-sqrt42.1%
fabs-sqr42.1%
add-sqr-sqrt42.2%
+-commutative42.2%
hypot-1-def98.3%
metadata-eval98.3%
Applied egg-rr98.3%
+-rgt-identity98.3%
Simplified98.3%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.15000000596046448)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 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.15000000596046448f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (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.15000000596046448)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + 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.15000000596046448)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (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.15000000596046448:\\
\;\;\;\;\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 + \left(-0.16666666666666666 \cdot {x}^{3} + 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.150000006Initial program 51.6%
+-commutative51.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt18.6%
flip-+16.0%
log-div16.0%
add-sqr-sqrt19.4%
fma-def19.4%
+-commutative19.4%
hypot-1-def19.3%
Applied egg-rr19.3%
fma-udef19.3%
+-commutative19.3%
associate--l+48.2%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
Simplified99.8%
if -0.150000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 20.1%
*-un-lft-identity20.1%
*-commutative20.1%
log-prod20.1%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt20.1%
+-commutative20.1%
hypot-1-def20.1%
metadata-eval20.1%
Applied egg-rr20.1%
+-rgt-identity20.1%
Simplified20.1%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < (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.1%
fabs-sqr43.1%
add-sqr-sqrt43.1%
+-commutative43.1%
hypot-1-def98.2%
metadata-eval98.2%
Applied egg-rr98.2%
+-rgt-identity98.2%
Simplified98.2%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.019999999552965164f) {
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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.019999999552965164)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.019999999552965164)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 < -2Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.0%
+-commutative16.0%
hypot-1-def16.1%
metadata-eval16.1%
Applied egg-rr16.1%
+-rgt-identity16.1%
Simplified16.1%
Taylor expanded in x around -inf 96.2%
if -2 < x < 0.0199999996Initial program 21.1%
*-un-lft-identity21.1%
*-commutative21.1%
log-prod21.1%
add-sqr-sqrt8.4%
fabs-sqr8.4%
add-sqr-sqrt21.2%
+-commutative21.2%
hypot-1-def21.2%
metadata-eval21.2%
Applied egg-rr21.2%
+-rgt-identity21.2%
Simplified21.2%
Taylor expanded in x around 0 99.2%
if 0.0199999996 < x Initial program 43.1%
*-un-lft-identity43.1%
*-commutative43.1%
log-prod43.1%
add-sqr-sqrt43.1%
fabs-sqr43.1%
add-sqr-sqrt43.1%
+-commutative43.1%
hypot-1-def98.2%
metadata-eval98.2%
Applied egg-rr98.2%
+-rgt-identity98.2%
Simplified98.2%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(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.019999999552965164f) {
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.019999999552965164)) 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.019999999552965164)) 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.019999999552965164:\\
\;\;\;\;\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 52.2%
+-commutative52.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt19.8%
flip-+17.2%
log-div17.2%
add-sqr-sqrt20.5%
fma-def20.5%
+-commutative20.5%
hypot-1-def20.5%
Applied egg-rr20.5%
fma-udef20.5%
+-commutative20.5%
associate--l+48.9%
+-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
neg-sub099.7%
Simplified99.7%
if -0.100000001 < x < 0.0199999996Initial program 19.5%
*-un-lft-identity19.5%
*-commutative19.5%
log-prod19.5%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt19.6%
+-commutative19.6%
hypot-1-def19.6%
metadata-eval19.6%
Applied egg-rr19.6%
+-rgt-identity19.6%
Simplified19.6%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 43.1%
*-un-lft-identity43.1%
*-commutative43.1%
log-prod43.1%
add-sqr-sqrt43.1%
fabs-sqr43.1%
add-sqr-sqrt43.1%
+-commutative43.1%
hypot-1-def98.2%
metadata-eval98.2%
Applied egg-rr98.2%
+-rgt-identity98.2%
Simplified98.2%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -2Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.0%
+-commutative16.0%
hypot-1-def16.1%
metadata-eval16.1%
Applied egg-rr16.1%
+-rgt-identity16.1%
Simplified16.1%
Taylor expanded in x around -inf 96.2%
if -2 < x < 1Initial program 22.8%
*-un-lft-identity22.8%
*-commutative22.8%
log-prod22.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt22.8%
+-commutative22.8%
hypot-1-def22.8%
metadata-eval22.8%
Applied egg-rr22.8%
+-rgt-identity22.8%
Simplified22.8%
Taylor expanded in x around 0 98.4%
if 1 < x Initial program 40.0%
Taylor expanded in x around inf 97.7%
+-commutative97.7%
+-commutative97.7%
associate-+l+97.7%
associate-*r/97.7%
metadata-eval97.7%
rem-square-sqrt97.7%
fabs-sqr97.7%
rem-square-sqrt97.7%
Simplified97.7%
Taylor expanded in x around 0 98.5%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.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 + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.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 -2:\\
\;\;\;\;\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 + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.0%
+-commutative16.0%
hypot-1-def16.1%
metadata-eval16.1%
Applied egg-rr16.1%
+-rgt-identity16.1%
Simplified16.1%
Taylor expanded in x around -inf 96.2%
if -2 < x < 1Initial program 22.8%
*-un-lft-identity22.8%
*-commutative22.8%
log-prod22.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt22.8%
+-commutative22.8%
hypot-1-def22.8%
metadata-eval22.8%
Applied egg-rr22.8%
+-rgt-identity22.8%
Simplified22.8%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 40.0%
Taylor expanded in x around inf 96.7%
rem-square-sqrt96.7%
fabs-sqr96.7%
rem-square-sqrt96.7%
Simplified96.7%
Final simplification96.6%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.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(-2.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((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.0%
+-commutative16.0%
hypot-1-def16.1%
metadata-eval16.1%
Applied egg-rr16.1%
+-rgt-identity16.1%
Simplified16.1%
Taylor expanded in x around -inf 96.2%
if -2 < x < 1Initial program 22.8%
*-un-lft-identity22.8%
*-commutative22.8%
log-prod22.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt22.8%
+-commutative22.8%
hypot-1-def22.8%
metadata-eval22.8%
Applied egg-rr22.8%
+-rgt-identity22.8%
Simplified22.8%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 40.0%
Taylor expanded in x around inf 97.7%
+-commutative97.7%
+-commutative97.7%
associate-+l+97.7%
associate-*r/97.7%
metadata-eval97.7%
rem-square-sqrt97.7%
fabs-sqr97.7%
rem-square-sqrt97.7%
Simplified97.7%
Taylor expanded in x around 0 98.5%
Final simplification97.0%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), 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 + x)), 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 + x))); 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 + x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 30.8%
*-un-lft-identity30.8%
*-commutative30.8%
log-prod30.8%
add-sqr-sqrt7.2%
fabs-sqr7.2%
add-sqr-sqrt20.8%
+-commutative20.8%
hypot-1-def20.8%
metadata-eval20.8%
Applied egg-rr20.8%
+-rgt-identity20.8%
Simplified20.8%
Taylor expanded in x around 0 71.6%
if 1 < x Initial program 40.0%
Taylor expanded in x around inf 96.7%
rem-square-sqrt96.7%
fabs-sqr96.7%
rem-square-sqrt96.7%
Simplified96.7%
Final simplification76.8%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign -1.0 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-1.0f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-1.0), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 50.1%
Taylor expanded in x around inf 6.4%
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%
Simplified21.2%
if -2 < x Initial program 27.4%
Taylor expanded in x around 0 25.6%
log1p-def80.0%
rem-square-sqrt41.1%
fabs-sqr41.1%
rem-square-sqrt80.0%
Simplified80.0%
Final simplification66.2%
(FPCore (x) :precision binary32 (copysign -1.0 x))
float code(float x) {
return copysignf(-1.0f, x);
}
function code(x) return copysign(Float32(-1.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-1.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-1, x\right)
\end{array}
Initial program 32.7%
Taylor expanded in x around inf 25.6%
rem-square-sqrt22.7%
fabs-sqr22.7%
rem-square-sqrt22.7%
Simplified22.7%
Taylor expanded in x around 0 23.0%
Simplified15.3%
Final simplification15.3%
(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.7%
*-un-lft-identity32.7%
*-commutative32.7%
log-prod32.7%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt24.8%
+-commutative24.8%
hypot-1-def36.8%
metadata-eval36.8%
Applied egg-rr36.8%
+-rgt-identity36.8%
Simplified36.8%
Taylor expanded in x around 0 59.0%
Final simplification59.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 2023271
(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))