
(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 13 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.20000000298023224)
(copysign (log (fma (pow (cbrt x) 2.0) (fabs (cbrt x)) (hypot 1.0 x))) x)
(if (<= t_0 0.0020000000949949026)
(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.20000000298023224f) {
tmp = copysignf(logf(fmaf(powf(cbrtf(x), 2.0f), fabsf(cbrtf(x)), hypotf(1.0f, x))), x);
} else if (t_0 <= 0.0020000000949949026f) {
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.20000000298023224)) tmp = copysign(log(fma((cbrt(x) ^ Float32(2.0)), abs(cbrt(x)), hypot(Float32(1.0), x))), x); elseif (t_0 <= Float32(0.0020000000949949026)) 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
\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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{fma}\left({\left(\sqrt[3]{x}\right)}^{2}, \left|\sqrt[3]{x}\right|, \mathsf{hypot}\left(1, x\right)\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.0020000000949949026:\\
\;\;\;\;\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.200000003Initial program 48.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
sqrt-prod48.8%
add-cube-cbrt48.7%
sqrt-prod48.7%
fma-def48.7%
Applied egg-rr76.6%
metadata-eval76.6%
pow-sqr76.6%
rem-sqrt-square100.0%
unpow2100.0%
rem-sqrt-square100.0%
unpow2100.0%
fabs-sqr100.0%
unpow2100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00200000009Initial program 18.9%
*-un-lft-identity18.9%
*-commutative18.9%
log-prod18.9%
*-un-lft-identity18.9%
*-un-lft-identity18.9%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt19.1%
+-commutative19.1%
hypot-1-def19.1%
metadata-eval19.1%
Applied egg-rr19.1%
+-rgt-identity19.1%
Simplified19.1%
Taylor expanded in x around 0 100.0%
if 0.00200000009 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.0020000000949949026)
(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.20000000298023224f) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else if (t_0 <= 0.0020000000949949026f) {
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.20000000298023224)) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); elseif (t_0 <= Float32(0.0020000000949949026)) 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.20000000298023224)) tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); elseif (t_0 <= single(0.0020000000949949026)) 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.0020000000949949026:\\
\;\;\;\;\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.200000003Initial program 48.8%
+-commutative48.8%
hypot-1-def99.9%
Simplified99.9%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00200000009Initial program 18.9%
*-un-lft-identity18.9%
*-commutative18.9%
log-prod18.9%
*-un-lft-identity18.9%
*-un-lft-identity18.9%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt19.1%
+-commutative19.1%
hypot-1-def19.1%
metadata-eval19.1%
Applied egg-rr19.1%
+-rgt-identity19.1%
Simplified19.1%
Taylor expanded in x around 0 100.0%
if 0.00200000009 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.0020000000949949026)
(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 tmp;
if (x <= -0.20000000298023224f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.0020000000949949026f) {
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) tmp = Float32(0.0) if (x <= Float32(-0.20000000298023224)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.0020000000949949026)) 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) tmp = single(0.0); if (x <= single(-0.20000000298023224)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.0020000000949949026)) 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}
\mathbf{if}\;x \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\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 x < -0.200000003Initial program 48.8%
*-un-lft-identity48.8%
*-commutative48.8%
log-prod48.8%
*-un-lft-identity48.8%
*-un-lft-identity48.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.3%
+-commutative16.3%
hypot-1-def15.9%
metadata-eval15.9%
Applied egg-rr15.9%
+-rgt-identity15.9%
Simplified15.9%
flip-+12.0%
unpow212.0%
div-sub12.0%
hypot-udef12.9%
metadata-eval12.9%
unpow212.9%
hypot-udef12.8%
metadata-eval12.8%
unpow212.8%
add-sqr-sqrt13.3%
+-commutative13.3%
Applied egg-rr13.3%
div-sub14.9%
*-rgt-identity14.9%
associate-*r/14.9%
associate--r+45.1%
+-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
associate-/r*99.7%
metadata-eval99.7%
+-inverses45.1%
associate--r+14.9%
neg-mul-114.9%
neg-mul-114.9%
distribute-frac-neg14.9%
neg-sub014.9%
Simplified99.7%
if -0.200000003 < x < 0.00200000009Initial program 18.9%
*-un-lft-identity18.9%
*-commutative18.9%
log-prod18.9%
*-un-lft-identity18.9%
*-un-lft-identity18.9%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt19.1%
+-commutative19.1%
hypot-1-def19.1%
metadata-eval19.1%
Applied egg-rr19.1%
+-rgt-identity19.1%
Simplified19.1%
Taylor expanded in x around 0 100.0%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.0020000000949949026)
(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((fabsf(x) - x)), x);
} else if (x <= 0.0020000000949949026f) {
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(abs(x) - x)), x); elseif (x <= Float32(0.0020000000949949026)) 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((abs(x) - x))); elseif (x <= single(0.0020000000949949026)) 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(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\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 47.2%
Taylor expanded in x around -inf 96.9%
neg-mul-196.9%
unsub-neg96.9%
Simplified96.9%
if -1 < x < 0.00200000009Initial program 20.0%
*-un-lft-identity20.0%
*-commutative20.0%
log-prod20.0%
*-un-lft-identity20.0%
*-un-lft-identity20.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.2%
+-commutative20.2%
hypot-1-def20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 99.3%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.0020000000949949026)
(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.05000000074505806f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.0020000000949949026f) {
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.05000000074505806)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.0020000000949949026)) 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.05000000074505806)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.0020000000949949026)) 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\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.0500000007Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.5%
+-commutative17.5%
hypot-1-def17.0%
metadata-eval17.0%
Applied egg-rr17.0%
+-rgt-identity17.0%
Simplified17.0%
flip-+13.1%
unpow213.1%
div-sub13.2%
hypot-udef14.0%
metadata-eval14.0%
unpow214.0%
hypot-udef14.0%
metadata-eval14.0%
unpow214.0%
add-sqr-sqrt14.4%
+-commutative14.4%
Applied egg-rr14.4%
div-sub16.0%
*-rgt-identity16.0%
associate-*r/16.0%
associate--r+45.7%
+-inverses99.6%
metadata-eval99.6%
metadata-eval99.6%
associate-/r*99.6%
metadata-eval99.6%
+-inverses45.7%
associate--r+16.0%
neg-mul-116.0%
neg-mul-116.0%
distribute-frac-neg16.0%
neg-sub016.0%
Simplified99.6%
if -0.0500000007 < x < 0.00200000009Initial program 18.4%
*-un-lft-identity18.4%
*-commutative18.4%
log-prod18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt18.6%
+-commutative18.6%
hypot-1-def18.6%
metadata-eval18.6%
Applied egg-rr18.6%
+-rgt-identity18.6%
Simplified18.6%
Taylor expanded in x around 0 100.0%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.0020000000949949026)
(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((fabsf(x) - x)), x);
} else if (x <= 0.0020000000949949026f) {
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(abs(x) - x)), x); elseif (x <= Float32(0.0020000000949949026)) 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((abs(x) - x))); elseif (x <= single(0.0020000000949949026)) 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(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\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 47.2%
Taylor expanded in x around -inf 96.9%
neg-mul-196.9%
unsub-neg96.9%
Simplified96.9%
if -1 < x < 0.00200000009Initial program 20.0%
*-un-lft-identity20.0%
*-commutative20.0%
log-prod20.0%
*-un-lft-identity20.0%
*-un-lft-identity20.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.2%
+-commutative20.2%
hypot-1-def20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 99.3%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.0020000000949949026)
(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 <= 0.0020000000949949026f) {
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(0.0020000000949949026)) 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(0.0020000000949949026)) 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 0.0020000000949949026:\\
\;\;\;\;\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 47.2%
*-un-lft-identity47.2%
*-commutative47.2%
log-prod47.2%
*-un-lft-identity47.2%
*-un-lft-identity47.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.7%
+-commutative13.7%
hypot-1-def13.3%
metadata-eval13.3%
Applied egg-rr13.3%
+-rgt-identity13.3%
Simplified13.3%
Taylor expanded in x around -inf 96.9%
if -1 < x < 0.00200000009Initial program 20.0%
*-un-lft-identity20.0%
*-commutative20.0%
log-prod20.0%
*-un-lft-identity20.0%
*-un-lft-identity20.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.2%
+-commutative20.2%
hypot-1-def20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 99.3%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.8%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.0020000000949949026)
(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 <= 0.0020000000949949026f) {
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(0.0020000000949949026)) 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(0.0020000000949949026)) 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 0.0020000000949949026:\\
\;\;\;\;\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 47.2%
*-un-lft-identity47.2%
*-commutative47.2%
log-prod47.2%
*-un-lft-identity47.2%
*-un-lft-identity47.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.7%
+-commutative13.7%
hypot-1-def13.3%
metadata-eval13.3%
Applied egg-rr13.3%
+-rgt-identity13.3%
Simplified13.3%
Taylor expanded in x around -inf 96.9%
if -1 < x < 0.00200000009Initial program 20.0%
*-un-lft-identity20.0%
*-commutative20.0%
log-prod20.0%
*-un-lft-identity20.0%
*-un-lft-identity20.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.2%
+-commutative20.2%
hypot-1-def20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 99.3%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- x)) x)
(if (<= x 0.0020000000949949026)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.0020000000949949026f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.0020000000949949026)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.0020000000949949026)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 45.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
sqrt-prod45.4%
add-cube-cbrt45.4%
sqrt-prod45.4%
fma-def45.4%
Applied egg-rr75.1%
metadata-eval75.1%
pow-sqr75.1%
rem-sqrt-square100.0%
unpow2100.0%
rem-sqrt-square100.0%
unpow2100.0%
fabs-sqr100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.6%
neg-mul-144.6%
Simplified44.6%
if -5 < x < 0.00200000009Initial program 21.2%
*-un-lft-identity21.2%
*-commutative21.2%
log-prod21.2%
*-un-lft-identity21.2%
*-un-lft-identity21.2%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt21.4%
+-commutative21.4%
hypot-1-def21.4%
metadata-eval21.4%
Applied egg-rr21.4%
+-rgt-identity21.4%
Simplified21.4%
Taylor expanded in x around 0 97.4%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
*-commutative98.8%
Simplified98.8%
Final simplification85.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.0020000000949949026)
(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 <= 0.0020000000949949026f) {
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(0.0020000000949949026)) 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(0.0020000000949949026)) 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 0.0020000000949949026:\\
\;\;\;\;\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 47.2%
*-un-lft-identity47.2%
*-commutative47.2%
log-prod47.2%
*-un-lft-identity47.2%
*-un-lft-identity47.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.7%
+-commutative13.7%
hypot-1-def13.3%
metadata-eval13.3%
Applied egg-rr13.3%
+-rgt-identity13.3%
Simplified13.3%
Taylor expanded in x around -inf 96.9%
if -1 < x < 0.00200000009Initial program 20.0%
*-un-lft-identity20.0%
*-commutative20.0%
log-prod20.0%
*-un-lft-identity20.0%
*-un-lft-identity20.0%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt20.2%
+-commutative20.2%
hypot-1-def20.3%
metadata-eval20.3%
Applied egg-rr20.3%
+-rgt-identity20.3%
Simplified20.3%
Taylor expanded in x around 0 98.4%
if 0.00200000009 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.1%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (if (<= x 0.0020000000949949026) (copysign x x) (copysign (log x) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.0020000000949949026f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.0020000000949949026)) 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(-5.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.0020000000949949026)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < -5Initial program 45.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
sqrt-prod45.4%
add-cube-cbrt45.4%
sqrt-prod45.4%
fma-def45.4%
Applied egg-rr75.1%
metadata-eval75.1%
pow-sqr75.1%
rem-sqrt-square100.0%
unpow2100.0%
rem-sqrt-square100.0%
unpow2100.0%
fabs-sqr100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.6%
neg-mul-144.6%
Simplified44.6%
if -5 < x < 0.00200000009Initial program 21.2%
*-un-lft-identity21.2%
*-commutative21.2%
log-prod21.2%
*-un-lft-identity21.2%
*-un-lft-identity21.2%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt21.4%
+-commutative21.4%
hypot-1-def21.4%
metadata-eval21.4%
Applied egg-rr21.4%
+-rgt-identity21.4%
Simplified21.4%
Taylor expanded in x around 0 97.4%
if 0.00200000009 < x Initial program 36.0%
Taylor expanded in x around inf 45.1%
mul-1-neg45.1%
log-rec45.1%
remove-double-neg45.1%
Simplified45.1%
Final simplification73.4%
(FPCore (x) :precision binary32 (if (<= x 0.0020000000949949026) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 0.0020000000949949026f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.0020000000949949026)) 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(0.0020000000949949026)) 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 0.0020000000949949026:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 0.00200000009Initial program 28.5%
*-un-lft-identity28.5%
*-commutative28.5%
log-prod28.5%
*-un-lft-identity28.5%
*-un-lft-identity28.5%
add-sqr-sqrt5.9%
fabs-sqr5.9%
add-sqr-sqrt18.2%
+-commutative18.2%
hypot-1-def18.1%
metadata-eval18.1%
Applied egg-rr18.1%
+-rgt-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 71.3%
if 0.00200000009 < x Initial program 36.0%
Taylor expanded in x around inf 45.1%
mul-1-neg45.1%
log-rec45.1%
remove-double-neg45.1%
Simplified45.1%
Final simplification65.5%
(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 30.2%
*-un-lft-identity30.2%
*-commutative30.2%
log-prod30.2%
*-un-lft-identity30.2%
*-un-lft-identity30.2%
add-sqr-sqrt12.6%
fabs-sqr12.6%
add-sqr-sqrt22.2%
+-commutative22.2%
hypot-1-def36.3%
metadata-eval36.3%
Applied egg-rr36.3%
+-rgt-identity36.3%
Simplified36.3%
Taylor expanded in x around 0 57.7%
Final simplification57.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 2024040
(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))