
(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 12 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 -1.0)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.30000001192092896)
(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 <= -1.0f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.30000001192092896f) {
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(-1.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.30000001192092896)) 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(-1.0)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.30000001192092896)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.30000001192092896:\\
\;\;\;\;\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) < -1Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
+-commutative50.1%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
flip-+10.9%
unpow210.9%
div-sub9.4%
hypot-udef9.6%
metadata-eval9.6%
unpow29.6%
hypot-udef8.9%
metadata-eval8.9%
unpow28.9%
add-sqr-sqrt9.8%
+-commutative9.8%
Applied egg-rr9.8%
div-sub13.1%
associate--r+46.7%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/r*98.7%
neg-mul-198.7%
neg-sub098.7%
associate--r-98.7%
neg-sub098.7%
+-commutative98.7%
sub-neg98.7%
Simplified98.7%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.300000012Initial program 20.3%
*-un-lft-identity20.3%
*-commutative20.3%
log-prod20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt10.6%
fabs-sqr10.6%
add-sqr-sqrt20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 100.0%
if 0.300000012 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 67.1%
*-un-lft-identity67.1%
*-commutative67.1%
log-prod67.1%
+-commutative67.1%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.05000000074505806)
(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.10000000149011612f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.05000000074505806f) {
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.10000000149011612)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.05000000074505806)) 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.10000000149011612)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.05000000074505806)) 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.05000000074505806:\\
\;\;\;\;\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.100000001Initial program 50.7%
*-un-lft-identity50.7%
*-commutative50.7%
log-prod50.7%
+-commutative50.7%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.9%
metadata-eval13.9%
Applied egg-rr13.9%
+-rgt-identity13.9%
Simplified13.9%
flip-+11.9%
unpow211.9%
div-sub10.4%
hypot-udef10.6%
metadata-eval10.6%
unpow210.6%
hypot-udef9.9%
metadata-eval9.9%
unpow29.9%
add-sqr-sqrt10.9%
+-commutative10.9%
Applied egg-rr10.9%
div-sub14.1%
associate--r+47.3%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/r*98.7%
neg-mul-198.7%
neg-sub098.7%
associate--r-98.7%
neg-sub098.7%
+-commutative98.7%
sub-neg98.7%
Simplified98.7%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0500000007Initial program 18.9%
*-un-lft-identity18.9%
*-commutative18.9%
log-prod18.9%
+-commutative18.9%
hypot-1-def18.9%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt18.9%
metadata-eval18.9%
Applied egg-rr18.9%
+-rgt-identity18.9%
Simplified18.9%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 67.5%
*-un-lft-identity67.5%
*-commutative67.5%
log-prod67.5%
+-commutative67.5%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(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 <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.05000000074505806f) {
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(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.05000000074505806)) 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(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.05000000074505806)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 < -1Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
+-commutative50.1%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 0.0500000007Initial program 19.6%
*-un-lft-identity19.6%
*-commutative19.6%
log-prod19.6%
+-commutative19.6%
hypot-1-def19.6%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt19.6%
metadata-eval19.6%
Applied egg-rr19.6%
+-rgt-identity19.6%
Simplified19.6%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
Simplified99.7%
if 0.0500000007 < x Initial program 67.5%
*-un-lft-identity67.5%
*-commutative67.5%
log-prod67.5%
+-commutative67.5%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(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((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.05000000074505806f) {
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(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) 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((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.05000000074505806)) 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(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 50.7%
*-un-lft-identity50.7%
*-commutative50.7%
log-prod50.7%
+-commutative50.7%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.9%
metadata-eval13.9%
Applied egg-rr13.9%
+-rgt-identity13.9%
Simplified13.9%
flip-+11.9%
unpow211.9%
div-sub10.4%
hypot-udef10.6%
metadata-eval10.6%
unpow210.6%
hypot-udef9.9%
metadata-eval9.9%
unpow29.9%
add-sqr-sqrt10.9%
+-commutative10.9%
Applied egg-rr10.9%
div-sub14.1%
associate--r+47.3%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
associate-/r*98.7%
neg-mul-198.7%
neg-sub098.7%
associate--r-98.7%
neg-sub098.7%
+-commutative98.7%
sub-neg98.7%
Simplified98.7%
if -0.100000001 < x < 0.0500000007Initial program 18.9%
*-un-lft-identity18.9%
*-commutative18.9%
log-prod18.9%
+-commutative18.9%
hypot-1-def18.9%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt18.9%
metadata-eval18.9%
Applied egg-rr18.9%
+-rgt-identity18.9%
Simplified18.9%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.0500000007 < x Initial program 67.5%
*-un-lft-identity67.5%
*-commutative67.5%
log-prod67.5%
+-commutative67.5%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.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(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.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(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\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(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
+-commutative50.1%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 1Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
+-commutative21.8%
hypot-1-def21.8%
add-sqr-sqrt12.3%
fabs-sqr12.3%
add-sqr-sqrt21.8%
metadata-eval21.8%
Applied egg-rr21.8%
+-rgt-identity21.8%
Simplified21.8%
Taylor expanded in x around 0 98.4%
*-commutative98.4%
Simplified98.4%
if 1 < x Initial program 66.2%
*-un-lft-identity66.2%
*-commutative66.2%
log-prod66.2%
+-commutative66.2%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 96.6%
Final simplification97.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.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((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(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((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\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(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
+-commutative50.1%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 1Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
+-commutative21.8%
hypot-1-def21.8%
add-sqr-sqrt12.3%
fabs-sqr12.3%
add-sqr-sqrt21.8%
metadata-eval21.8%
Applied egg-rr21.8%
+-rgt-identity21.8%
Simplified21.8%
Taylor expanded in x around 0 98.4%
*-commutative98.4%
Simplified98.4%
if 1 < x Initial program 66.2%
*-un-lft-identity66.2%
*-commutative66.2%
log-prod66.2%
+-commutative66.2%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 95.6%
*-commutative95.6%
Simplified95.6%
Final simplification97.3%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign (log (- x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf(-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(-20.0)) tmp = copysign(log(Float32(-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(-20.0)) tmp = sign(x) * abs(log(-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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-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 < -20Initial program 48.8%
Taylor expanded in x around -inf 98.7%
sub-neg98.7%
neg-mul-198.7%
unsub-neg98.7%
associate-*r/98.7%
metadata-eval98.7%
distribute-neg-frac98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around inf 44.6%
neg-mul-144.6%
Simplified44.6%
if -20 < x < 1Initial program 23.2%
*-un-lft-identity23.2%
*-commutative23.2%
log-prod23.2%
+-commutative23.2%
hypot-1-def23.2%
add-sqr-sqrt12.1%
fabs-sqr12.1%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
+-rgt-identity23.2%
Simplified23.2%
Taylor expanded in x around 0 95.9%
if 1 < x Initial program 66.2%
*-un-lft-identity66.2%
*-commutative66.2%
log-prod66.2%
+-commutative66.2%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 95.6%
*-commutative95.6%
Simplified95.6%
Final simplification80.7%
(FPCore (x) :precision binary32 (if (<= x -1.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 <= -1.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(-1.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(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 50.1%
*-un-lft-identity50.1%
*-commutative50.1%
log-prod50.1%
+-commutative50.1%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
metadata-eval12.9%
Applied egg-rr12.9%
+-rgt-identity12.9%
Simplified12.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 1Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
+-commutative21.8%
hypot-1-def21.8%
add-sqr-sqrt12.3%
fabs-sqr12.3%
add-sqr-sqrt21.8%
metadata-eval21.8%
Applied egg-rr21.8%
+-rgt-identity21.8%
Simplified21.8%
Taylor expanded in x around 0 97.0%
if 1 < x Initial program 66.2%
*-un-lft-identity66.2%
*-commutative66.2%
log-prod66.2%
+-commutative66.2%
hypot-1-def98.7%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 95.6%
*-commutative95.6%
Simplified95.6%
Final simplification96.7%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 50.1%
Taylor expanded in x around -inf 97.5%
sub-neg97.5%
neg-mul-197.5%
unsub-neg97.5%
associate-*r/97.5%
metadata-eval97.5%
distribute-neg-frac97.5%
metadata-eval97.5%
Simplified97.5%
Taylor expanded in x around inf 44.1%
neg-mul-144.1%
Simplified44.1%
if -1 < x Initial program 39.7%
Taylor expanded in x around 0 28.3%
+-commutative28.3%
*-un-lft-identity28.3%
log-prod28.3%
metadata-eval28.3%
log1p-udef73.6%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt73.6%
Applied egg-rr73.6%
+-lft-identity73.6%
Simplified73.6%
Final simplification64.7%
(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.7%
*-un-lft-identity34.7%
*-commutative34.7%
log-prod34.7%
+-commutative34.7%
hypot-1-def54.7%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt19.4%
metadata-eval19.4%
Applied egg-rr19.4%
+-rgt-identity19.4%
Simplified19.4%
Taylor expanded in x around 0 60.7%
if 4 < x Initial program 64.8%
Taylor expanded in x around inf 44.0%
mul-1-neg44.0%
log-rec44.0%
remove-double-neg44.0%
Simplified44.0%
Final simplification56.2%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 2Initial program 34.4%
*-un-lft-identity34.4%
*-commutative34.4%
log-prod34.4%
+-commutative34.4%
hypot-1-def54.5%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt18.9%
metadata-eval18.9%
Applied egg-rr18.9%
+-rgt-identity18.9%
Simplified18.9%
Taylor expanded in x around 0 60.9%
if 2 < x Initial program 65.3%
Taylor expanded in x around 0 43.8%
+-commutative43.8%
*-un-lft-identity43.8%
log-prod43.8%
metadata-eval43.8%
log1p-udef43.8%
add-sqr-sqrt43.8%
fabs-sqr43.8%
add-sqr-sqrt43.8%
Applied egg-rr43.8%
+-lft-identity43.8%
Simplified43.8%
Final simplification56.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 42.8%
*-un-lft-identity42.8%
*-commutative42.8%
log-prod42.8%
+-commutative42.8%
hypot-1-def66.6%
add-sqr-sqrt32.9%
fabs-sqr32.9%
add-sqr-sqrt40.7%
metadata-eval40.7%
Applied egg-rr40.7%
+-rgt-identity40.7%
Simplified40.7%
Taylor expanded in x around 0 47.5%
Final simplification47.5%
(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 2023312
(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))