
(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 15 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))
(t_1 (+ (fabs x) 1.0))
(t_2 (pow t_1 2.0)))
(if (<= t_0 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(fma
(* -0.125 (+ (/ 1.0 t_1) (/ 1.0 t_2)))
(pow x 4.0)
(fma
(*
0.001388888888888889
(+ (/ 45.0 t_1) (+ (/ 30.0 (pow t_1 3.0)) (/ 45.0 t_2))))
(pow x 6.0)
(fma 0.5 (/ x (/ t_1 x)) (log1p (fabs x)))))
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 t_1 = fabsf(x) + 1.0f;
float t_2 = powf(t_1, 2.0f);
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf(fmaf((-0.125f * ((1.0f / t_1) + (1.0f / t_2))), powf(x, 4.0f), fmaf((0.001388888888888889f * ((45.0f / t_1) + ((30.0f / powf(t_1, 3.0f)) + (45.0f / t_2)))), powf(x, 6.0f), fmaf(0.5f, (x / (t_1 / x)), log1pf(fabsf(x))))), 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) t_1 = Float32(abs(x) + Float32(1.0)) t_2 = t_1 ^ Float32(2.0) tmp = Float32(0.0) if (t_0 <= Float32(-0.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(fma(Float32(Float32(-0.125) * Float32(Float32(Float32(1.0) / t_1) + Float32(Float32(1.0) / t_2))), (x ^ Float32(4.0)), fma(Float32(Float32(0.001388888888888889) * Float32(Float32(Float32(45.0) / t_1) + Float32(Float32(Float32(30.0) / (t_1 ^ Float32(3.0))) + Float32(Float32(45.0) / t_2)))), (x ^ Float32(6.0)), fma(Float32(0.5), Float32(x / Float32(t_1 / x)), log1p(abs(x))))), 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)\\
t_1 := \left|x\right| + 1\\
t_2 := {t_1}^{2}\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\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(\mathsf{fma}\left(-0.125 \cdot \left(\frac{1}{t_1} + \frac{1}{t_2}\right), {x}^{4}, \mathsf{fma}\left(0.001388888888888889 \cdot \left(\frac{45}{t_1} + \left(\frac{30}{{t_1}^{3}} + \frac{45}{t_2}\right)\right), {x}^{6}, \mathsf{fma}\left(0.5, \frac{x}{\frac{t_1}{x}}, \mathsf{log1p}\left(\left|x\right|\right)\right)\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.200000003Initial program 51.1%
+-commutative51.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.9%
flip-+14.5%
log-div14.6%
add-sqr-sqrt16.0%
fma-def16.0%
+-commutative16.0%
hypot-1-def16.1%
Applied egg-rr16.1%
fma-udef16.1%
+-commutative16.1%
associate--l+47.8%
+-inverses97.3%
metadata-eval97.3%
metadata-eval97.3%
neg-sub097.3%
Simplified97.3%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 19.6%
Taylor expanded in x around 0 20.5%
associate-*r*20.5%
fma-def20.5%
Simplified100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt50.0%
+-commutative50.0%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(t_1 (pow (+ x 1.0) 2.0)))
(if (<= t_0 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(fma
(* -0.041666666666666664 (+ (/ 3.0 (+ x 1.0)) (/ 3.0 t_1)))
(pow x 4.0)
(fma
(*
0.001388888888888889
(+
(/ 45.0 t_1)
(+ (/ 45.0 (+ x 1.0)) (/ 30.0 (pow (+ x 1.0) 3.0)))))
(pow x 6.0)
(fma 0.5 (/ (* x x) (+ x 1.0)) (log1p x))))
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 t_1 = powf((x + 1.0f), 2.0f);
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf(fmaf((-0.041666666666666664f * ((3.0f / (x + 1.0f)) + (3.0f / t_1))), powf(x, 4.0f), fmaf((0.001388888888888889f * ((45.0f / t_1) + ((45.0f / (x + 1.0f)) + (30.0f / powf((x + 1.0f), 3.0f))))), powf(x, 6.0f), fmaf(0.5f, ((x * x) / (x + 1.0f)), log1pf(x)))), 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) t_1 = Float32(x + Float32(1.0)) ^ Float32(2.0) tmp = Float32(0.0) if (t_0 <= Float32(-0.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(fma(Float32(Float32(-0.041666666666666664) * Float32(Float32(Float32(3.0) / Float32(x + Float32(1.0))) + Float32(Float32(3.0) / t_1))), (x ^ Float32(4.0)), fma(Float32(Float32(0.001388888888888889) * Float32(Float32(Float32(45.0) / t_1) + Float32(Float32(Float32(45.0) / Float32(x + Float32(1.0))) + Float32(Float32(30.0) / (Float32(x + Float32(1.0)) ^ Float32(3.0)))))), (x ^ Float32(6.0)), fma(Float32(0.5), Float32(Float32(x * x) / Float32(x + Float32(1.0))), log1p(x)))), 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)\\
t_1 := {\left(x + 1\right)}^{2}\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\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(\mathsf{fma}\left(-0.041666666666666664 \cdot \left(\frac{3}{x + 1} + \frac{3}{t_1}\right), {x}^{4}, \mathsf{fma}\left(0.001388888888888889 \cdot \left(\frac{45}{t_1} + \left(\frac{45}{x + 1} + \frac{30}{{\left(x + 1\right)}^{3}}\right)\right), {x}^{6}, \mathsf{fma}\left(0.5, \frac{x \cdot x}{x + 1}, \mathsf{log1p}\left(x\right)\right)\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.200000003Initial program 51.1%
+-commutative51.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.9%
flip-+14.5%
log-div14.6%
add-sqr-sqrt16.0%
fma-def16.0%
+-commutative16.0%
hypot-1-def16.1%
Applied egg-rr16.1%
fma-udef16.1%
+-commutative16.1%
associate--l+47.8%
+-inverses97.3%
metadata-eval97.3%
metadata-eval97.3%
neg-sub097.3%
Simplified97.3%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 19.6%
Taylor expanded in x around 0 20.5%
Simplified99.9%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt50.0%
+-commutative50.0%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(t_1 (+ (fabs x) 1.0)))
(if (<= t_0 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(fma
(* -0.125 (+ (/ 1.0 t_1) (/ 1.0 (pow t_1 2.0))))
(pow x 4.0)
(fma 0.5 (/ x (/ t_1 x)) (log1p (fabs x))))
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 t_1 = fabsf(x) + 1.0f;
float tmp;
if (t_0 <= -0.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf(fmaf((-0.125f * ((1.0f / t_1) + (1.0f / powf(t_1, 2.0f)))), powf(x, 4.0f), fmaf(0.5f, (x / (t_1 / x)), log1pf(fabsf(x)))), 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) t_1 = Float32(abs(x) + Float32(1.0)) tmp = Float32(0.0) if (t_0 <= Float32(-0.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(fma(Float32(Float32(-0.125) * Float32(Float32(Float32(1.0) / t_1) + Float32(Float32(1.0) / (t_1 ^ Float32(2.0))))), (x ^ Float32(4.0)), fma(Float32(0.5), Float32(x / Float32(t_1 / x)), log1p(abs(x)))), 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)\\
t_1 := \left|x\right| + 1\\
\mathbf{if}\;t_0 \leq -0.20000000298023224:\\
\;\;\;\;\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(\mathsf{fma}\left(-0.125 \cdot \left(\frac{1}{t_1} + \frac{1}{{t_1}^{2}}\right), {x}^{4}, \mathsf{fma}\left(0.5, \frac{x}{\frac{t_1}{x}}, \mathsf{log1p}\left(\left|x\right|\right)\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.200000003Initial program 51.1%
+-commutative51.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.9%
flip-+14.5%
log-div14.6%
add-sqr-sqrt16.0%
fma-def16.0%
+-commutative16.0%
hypot-1-def16.1%
Applied egg-rr16.1%
fma-udef16.1%
+-commutative16.1%
associate--l+47.8%
+-inverses97.3%
metadata-eval97.3%
metadata-eval97.3%
neg-sub097.3%
Simplified97.3%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 19.6%
Taylor expanded in x around 0 20.5%
associate-*r*20.5%
fma-def20.5%
distribute-lft-out20.5%
associate-*r*20.5%
metadata-eval20.5%
fma-def20.5%
unpow220.5%
associate-/l*20.5%
log1p-def99.9%
Simplified99.9%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt50.0%
+-commutative50.0%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.0020000000949949026)
(copysign (+ x (* -0.16666666666666666 (pow x 3.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.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 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) 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.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= 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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.0500000007Initial program 51.7%
+-commutative51.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt18.9%
flip-+15.6%
log-div15.6%
add-sqr-sqrt17.1%
fma-def17.1%
+-commutative17.1%
hypot-1-def17.1%
Applied egg-rr17.1%
fma-udef17.1%
+-commutative17.1%
associate--l+48.4%
+-inverses97.2%
metadata-eval97.2%
metadata-eval97.2%
neg-sub097.2%
Simplified97.2%
if -0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00200000009Initial program 18.5%
Taylor expanded in x around 0 18.5%
fma-def18.5%
unpow218.5%
rem-square-sqrt9.6%
fabs-sqr9.6%
rem-square-sqrt18.9%
Simplified18.9%
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 50.9%
*-un-lft-identity50.9%
*-commutative50.9%
log-prod50.9%
add-sqr-sqrt51.0%
fabs-sqr51.0%
add-sqr-sqrt50.9%
+-commutative50.9%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (- x x) (/ 0.5 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(((x - x) - (0.5f / 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(Float32(x - x) - 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 + 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(((x - x) - (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 + 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 - x\right) - \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 + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.8%
Taylor expanded in x around -inf 94.0%
neg-mul-194.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt94.9%
sub-neg94.9%
associate-*r/94.9%
metadata-eval94.9%
Simplified94.9%
if -1 < x < 0.00200000009Initial program 20.2%
Taylor expanded in x around 0 19.3%
fma-def19.3%
unpow219.3%
rem-square-sqrt9.3%
fabs-sqr9.3%
rem-square-sqrt19.7%
Simplified19.7%
Taylor expanded in x around 0 99.2%
if 0.00200000009 < x Initial program 50.9%
*-un-lft-identity50.9%
*-commutative50.9%
log-prod50.9%
add-sqr-sqrt51.0%
fabs-sqr51.0%
add-sqr-sqrt50.9%
+-commutative50.9%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (/ -1.0 x))) x)
(if (<= x 1.0)
(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 <= -2.0f) {
tmp = copysignf(-logf((-1.0f / 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 + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / 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(Float32(0.5) / x) + 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(-1.0) / 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) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{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} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 49.0%
Taylor expanded in x around -inf 44.2%
mul-1-neg44.2%
Simplified44.2%
if -2 < x < 1Initial program 22.8%
Taylor expanded in x around 0 20.4%
fma-def20.4%
unpow220.4%
rem-square-sqrt10.5%
fabs-sqr10.5%
rem-square-sqrt20.7%
Simplified20.7%
Taylor expanded in x around 0 97.6%
if 1 < x Initial program 46.8%
Taylor expanded in x around inf 98.3%
associate-*r/98.3%
metadata-eval98.3%
rem-square-sqrt98.3%
fabs-sqr98.3%
rem-square-sqrt98.3%
Simplified98.3%
Final simplification83.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (- x x) (/ 0.5 x))) x)
(if (<= x 1.0)
(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 <= -1.0f) {
tmp = copysignf(logf(((x - x) - (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 + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(x - x) - 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(Float32(0.5) / x) + 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(log(((x - x) - (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) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(x - x\right) - \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} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.8%
Taylor expanded in x around -inf 94.0%
neg-mul-194.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt94.9%
sub-neg94.9%
associate-*r/94.9%
metadata-eval94.9%
Simplified94.9%
if -1 < x < 1Initial program 22.3%
Taylor expanded in x around 0 20.2%
fma-def20.2%
unpow220.2%
rem-square-sqrt10.6%
fabs-sqr10.6%
rem-square-sqrt20.6%
Simplified20.6%
Taylor expanded in x around 0 98.1%
if 1 < x Initial program 46.8%
Taylor expanded in x around inf 98.3%
associate-*r/98.3%
metadata-eval98.3%
rem-square-sqrt98.3%
fabs-sqr98.3%
rem-square-sqrt98.3%
Simplified98.3%
Final simplification97.3%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (/ -1.0 x))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / 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 + 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(-1.0) / 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 + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{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 + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 49.0%
Taylor expanded in x around -inf 44.2%
mul-1-neg44.2%
Simplified44.2%
if -2 < x < 1Initial program 22.8%
Taylor expanded in x around 0 20.4%
fma-def20.4%
unpow220.4%
rem-square-sqrt10.5%
fabs-sqr10.5%
rem-square-sqrt20.7%
Simplified20.7%
Taylor expanded in x around 0 97.6%
if 1 < x Initial program 46.8%
Taylor expanded in x around inf 96.5%
rem-square-sqrt96.5%
fabs-sqr96.5%
rem-square-sqrt96.5%
Simplified96.5%
Final simplification83.2%
(FPCore (x) :precision binary32 (if (<= x -50.0) (copysign 15.333333333333334 x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(15.333333333333334f, 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(-50.0)) tmp = copysign(Float32(15.333333333333334), 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(-50.0)) tmp = sign(x) * abs(single(15.333333333333334)); 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 -50:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, 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 < -50Initial program 45.1%
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.0%
if -50 < x < 1Initial program 25.4%
Taylor expanded in x around 0 18.9%
log1p-def91.1%
rem-square-sqrt49.4%
fabs-sqr49.4%
rem-square-sqrt89.7%
Simplified89.7%
Taylor expanded in x around 0 94.0%
if 1 < x Initial program 46.8%
Taylor expanded in x around inf 96.5%
rem-square-sqrt96.5%
fabs-sqr96.5%
rem-square-sqrt96.5%
Simplified96.5%
Final simplification77.9%
(FPCore (x) :precision binary32 (if (<= x -3.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -3.0f) {
tmp = copysignf(-logf((-1.0f / 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(-3.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / 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(-3.0)) tmp = sign(x) * abs(-log((single(-1.0) / 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 -3:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{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 < -3Initial program 47.5%
Taylor expanded in x around -inf 44.7%
mul-1-neg44.7%
Simplified44.7%
if -3 < x < 1Initial program 23.9%
Taylor expanded in x around 0 18.7%
log1p-def92.3%
rem-square-sqrt50.5%
fabs-sqr50.5%
rem-square-sqrt91.6%
Simplified91.6%
Taylor expanded in x around 0 95.4%
if 1 < x Initial program 46.8%
Taylor expanded in x around inf 96.5%
rem-square-sqrt96.5%
fabs-sqr96.5%
rem-square-sqrt96.5%
Simplified96.5%
Final simplification82.5%
(FPCore (x) :precision binary32 (if (<= x -50.0) (copysign 15.333333333333334 x) (if (<= x 2.0) (copysign x x) (copysign (log x) x))))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-50.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(2.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(-50.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)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < -50Initial program 45.1%
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.0%
if -50 < x < 2Initial program 25.9%
Taylor expanded in x around 0 19.0%
log1p-def90.7%
rem-square-sqrt49.3%
fabs-sqr49.3%
rem-square-sqrt89.4%
Simplified89.4%
Taylor expanded in x around 0 93.6%
if 2 < x Initial program 45.5%
Taylor expanded in x around inf 44.8%
mul-1-neg44.8%
log-rec44.8%
remove-double-neg44.8%
Simplified44.8%
Final simplification69.0%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign 15.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 49.8%
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%
Simplified26.6%
if -1 < x Initial program 28.1%
Taylor expanded in x around 0 24.5%
log1p-def82.0%
rem-square-sqrt49.9%
fabs-sqr49.9%
rem-square-sqrt82.0%
Simplified82.0%
Final simplification67.1%
(FPCore (x) :precision binary32 (if (<= x -50.0) (copysign 15.333333333333334 x) (copysign x x)))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(x, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-50.0)) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-50.0)) tmp = sign(x) * abs(single(15.333333333333334)); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -50Initial program 45.1%
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.0%
if -50 < x Initial program 30.3%
Taylor expanded in x around 0 24.8%
log1p-def80.5%
rem-square-sqrt48.3%
fabs-sqr48.3%
rem-square-sqrt79.4%
Simplified79.4%
Taylor expanded in x around 0 75.1%
Final simplification63.3%
(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 33.9%
Taylor expanded in x around inf 20.0%
associate-*r/20.0%
metadata-eval20.0%
rem-square-sqrt20.0%
fabs-sqr20.0%
rem-square-sqrt20.0%
Simplified20.0%
Taylor expanded in x around 0 3.7%
Simplified16.3%
Final simplification16.3%
(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 33.9%
Taylor expanded in x around inf 20.0%
associate-*r/20.0%
metadata-eval20.0%
rem-square-sqrt20.0%
fabs-sqr20.0%
rem-square-sqrt20.0%
Simplified20.0%
Taylor expanded in x around 0 3.4%
Simplified17.3%
Final simplification17.3%
(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 2023182
(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))