
(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 -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+ x (* (fma (pow x 2.0) 0.075 -0.16666666666666666) (pow x 3.0)))
x)
(copysign (* 2.0 (log (sqrt (+ x (hypot 1.0 x))))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x + (fmaf(powf(x, 2.0f), 0.075f, -0.16666666666666666f) * powf(x, 3.0f))), x);
} else {
tmp = copysignf((2.0f * logf(sqrtf((x + hypotf(1.0f, x))))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(fma((x ^ Float32(2.0)), Float32(0.075), Float32(-0.16666666666666666)) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(Float32(2.0) * log(sqrt(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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + \mathsf{fma}\left({x}^{2}, 0.075, -0.16666666666666666\right) \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{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) #s(literal 1 binary32))))) x) < -0.100000001Initial program 57.2%
flip-+7.9%
frac-2neg7.9%
log-div7.9%
pow27.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.9%
add-sqr-sqrt7.5%
fma-define7.2%
Applied egg-rr13.0%
neg-sub013.0%
associate--r-13.0%
neg-sub013.0%
+-commutative13.0%
fma-undefine13.5%
unpow213.5%
+-commutative13.5%
associate-+l+54.3%
sub-neg54.3%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 18.5%
*-un-lft-identity18.5%
*-commutative18.5%
log-prod18.5%
+-commutative18.5%
hypot-1-def18.4%
add-sqr-sqrt10.9%
fabs-sqr10.9%
add-sqr-sqrt18.6%
metadata-eval18.6%
Applied egg-rr18.6%
+-rgt-identity18.6%
Simplified18.6%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
fmm-def100.0%
metadata-eval100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 48.3%
add-sqr-sqrt48.3%
pow248.3%
log-pow48.4%
*-un-lft-identity48.4%
*-un-lft-identity48.4%
add-sqr-sqrt48.5%
fabs-sqr48.5%
add-sqr-sqrt48.4%
+-commutative48.4%
hypot-1-def100.0%
Applied egg-rr100.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.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (* 2.0 (log (sqrt (+ x (hypot 1.0 x))))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf((2.0f * logf(sqrtf((x + hypotf(1.0f, x))))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(Float32(Float32(2.0) * log(sqrt(Float32(x + hypot(Float32(1.0), x))))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.10000000149011612)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs((single(2.0) * log(sqrt((x + hypot(single(1.0), x)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{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) #s(literal 1 binary32))))) x) < -0.100000001Initial program 57.2%
flip-+7.9%
frac-2neg7.9%
log-div7.9%
pow27.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.9%
add-sqr-sqrt7.5%
fma-define7.2%
Applied egg-rr13.0%
neg-sub013.0%
associate--r-13.0%
neg-sub013.0%
+-commutative13.0%
fma-undefine13.5%
unpow213.5%
+-commutative13.5%
associate-+l+54.3%
sub-neg54.3%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 18.5%
*-un-lft-identity18.5%
*-commutative18.5%
log-prod18.5%
+-commutative18.5%
hypot-1-def18.4%
add-sqr-sqrt10.9%
fabs-sqr10.9%
add-sqr-sqrt18.6%
metadata-eval18.6%
Applied egg-rr18.6%
+-rgt-identity18.6%
Simplified18.6%
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 48.3%
add-sqr-sqrt48.3%
pow248.3%
log-pow48.4%
*-un-lft-identity48.4%
*-un-lft-identity48.4%
add-sqr-sqrt48.5%
fabs-sqr48.5%
add-sqr-sqrt48.4%
+-commutative48.4%
hypot-1-def100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\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 x < -0.100000001Initial program 57.2%
flip-+7.9%
frac-2neg7.9%
log-div7.9%
pow27.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.9%
add-sqr-sqrt7.5%
fma-define7.2%
Applied egg-rr13.0%
neg-sub013.0%
associate--r-13.0%
neg-sub013.0%
+-commutative13.0%
fma-undefine13.5%
unpow213.5%
+-commutative13.5%
associate-+l+54.3%
sub-neg54.3%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.100000001 < x < 0.100000001Initial program 18.5%
*-un-lft-identity18.5%
*-commutative18.5%
log-prod18.5%
+-commutative18.5%
hypot-1-def18.4%
add-sqr-sqrt10.9%
fabs-sqr10.9%
add-sqr-sqrt18.6%
metadata-eval18.6%
Applied egg-rr18.6%
+-rgt-identity18.6%
Simplified18.6%
Taylor expanded in x around 0 100.0%
if 0.100000001 < x Initial program 48.3%
*-un-lft-identity48.3%
*-commutative48.3%
log-prod48.3%
+-commutative48.3%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.1%
*-un-lft-identity56.1%
*-commutative56.1%
log-prod56.1%
+-commutative56.1%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
metadata-eval10.4%
Applied egg-rr10.4%
+-rgt-identity10.4%
Simplified10.4%
Taylor expanded in x around -inf 99.2%
clear-num99.2%
log-div99.2%
metadata-eval99.2%
div-inv99.2%
metadata-eval99.2%
Applied egg-rr99.2%
neg-sub099.2%
Simplified99.2%
if -10 < x < 0.0199999996Initial program 18.5%
*-un-lft-identity18.5%
*-commutative18.5%
log-prod18.5%
+-commutative18.5%
hypot-1-def18.5%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt18.8%
metadata-eval18.8%
Applied egg-rr18.8%
+-rgt-identity18.8%
Simplified18.8%
Taylor expanded in x around 0 99.4%
distribute-rgt-in99.4%
*-lft-identity99.4%
associate-*l*99.4%
unpow299.4%
unpow399.4%
Simplified99.4%
if 0.0199999996 < x Initial program 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
+-commutative50.0%
hypot-1-def99.6%
add-sqr-sqrt99.5%
fabs-sqr99.5%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 57.2%
flip-+7.9%
frac-2neg7.9%
log-div7.9%
pow27.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.9%
add-sqr-sqrt7.5%
fma-define7.2%
Applied egg-rr13.0%
neg-sub013.0%
associate--r-13.0%
neg-sub013.0%
+-commutative13.0%
fma-undefine13.5%
unpow213.5%
+-commutative13.5%
associate-+l+54.3%
sub-neg54.3%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.100000001 < x < 0.0199999996Initial program 17.4%
*-un-lft-identity17.4%
*-commutative17.4%
log-prod17.4%
+-commutative17.4%
hypot-1-def17.4%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt17.6%
metadata-eval17.6%
Applied egg-rr17.6%
+-rgt-identity17.6%
Simplified17.6%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
+-commutative50.0%
hypot-1-def99.6%
add-sqr-sqrt99.5%
fabs-sqr99.5%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (- (log (* x -2.0))) 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 <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-10.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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(-10.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -10Initial program 56.1%
*-un-lft-identity56.1%
*-commutative56.1%
log-prod56.1%
+-commutative56.1%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
metadata-eval10.4%
Applied egg-rr10.4%
+-rgt-identity10.4%
Simplified10.4%
Taylor expanded in x around -inf 99.2%
clear-num99.2%
log-div99.2%
metadata-eval99.2%
div-inv99.2%
metadata-eval99.2%
Applied egg-rr99.2%
neg-sub099.2%
Simplified99.2%
if -10 < x < 1Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
+-commutative20.7%
hypot-1-def20.6%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt20.9%
metadata-eval20.9%
Applied egg-rr20.9%
+-rgt-identity20.9%
Simplified20.9%
Taylor expanded in x around 0 98.5%
distribute-rgt-in98.5%
*-lft-identity98.5%
associate-*l*98.5%
unpow298.5%
unpow398.5%
Simplified98.5%
if 1 < x Initial program 46.2%
*-un-lft-identity46.2%
*-commutative46.2%
log-prod46.2%
+-commutative46.2%
hypot-1-def100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x) :precision binary32 (if (<= x -10.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 <= -10.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(-10.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(-10.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 -10:\\
\;\;\;\;\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 < -10Initial program 56.1%
*-un-lft-identity56.1%
*-commutative56.1%
log-prod56.1%
+-commutative56.1%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
metadata-eval10.4%
Applied egg-rr10.4%
+-rgt-identity10.4%
Simplified10.4%
Taylor expanded in x around -inf 99.2%
if -10 < x < 1Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
+-commutative20.7%
hypot-1-def20.6%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt20.9%
metadata-eval20.9%
Applied egg-rr20.9%
+-rgt-identity20.9%
Simplified20.9%
Taylor expanded in x around 0 97.1%
if 1 < x Initial program 46.2%
*-un-lft-identity46.2%
*-commutative46.2%
log-prod46.2%
+-commutative46.2%
hypot-1-def100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-10.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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(-10.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -10Initial program 56.1%
*-un-lft-identity56.1%
*-commutative56.1%
log-prod56.1%
+-commutative56.1%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.4%
metadata-eval10.4%
Applied egg-rr10.4%
+-rgt-identity10.4%
Simplified10.4%
Taylor expanded in x around -inf 99.2%
clear-num99.2%
log-div99.2%
metadata-eval99.2%
div-inv99.2%
metadata-eval99.2%
Applied egg-rr99.2%
neg-sub099.2%
Simplified99.2%
if -10 < x < 1Initial program 20.7%
*-un-lft-identity20.7%
*-commutative20.7%
log-prod20.7%
+-commutative20.7%
hypot-1-def20.6%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt20.9%
metadata-eval20.9%
Applied egg-rr20.9%
+-rgt-identity20.9%
Simplified20.9%
Taylor expanded in x around 0 97.1%
if 1 < x Initial program 46.2%
*-un-lft-identity46.2%
*-commutative46.2%
log-prod46.2%
+-commutative46.2%
hypot-1-def100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification97.9%
(FPCore (x) :precision binary32 (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(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(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(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 31.8%
*-un-lft-identity31.8%
*-commutative31.8%
log-prod31.8%
+-commutative31.8%
hypot-1-def45.7%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt17.6%
metadata-eval17.6%
Applied egg-rr17.6%
+-rgt-identity17.6%
Simplified17.6%
Taylor expanded in x around 0 69.9%
if 1 < x Initial program 46.2%
*-un-lft-identity46.2%
*-commutative46.2%
log-prod46.2%
+-commutative46.2%
hypot-1-def100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
Final simplification75.2%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.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(1.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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 1Initial program 31.8%
*-un-lft-identity31.8%
*-commutative31.8%
log-prod31.8%
+-commutative31.8%
hypot-1-def45.7%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt17.6%
metadata-eval17.6%
Applied egg-rr17.6%
+-rgt-identity17.6%
Simplified17.6%
Taylor expanded in x around 0 69.9%
if 1 < x Initial program 46.2%
Taylor expanded in x around inf 45.1%
mul-1-neg45.1%
log-rec45.1%
remove-double-neg45.1%
Simplified45.1%
Final simplification65.3%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 31.8%
*-un-lft-identity31.8%
*-commutative31.8%
log-prod31.8%
+-commutative31.8%
hypot-1-def45.7%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt17.6%
metadata-eval17.6%
Applied egg-rr17.6%
+-rgt-identity17.6%
Simplified17.6%
Taylor expanded in x around 0 69.9%
if 1 < x Initial program 46.2%
Taylor expanded in x around 0 45.1%
log1p-define45.1%
rem-square-sqrt45.1%
fabs-sqr45.1%
rem-square-sqrt45.1%
Simplified45.1%
Final simplification65.3%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 34.5%
*-un-lft-identity34.5%
*-commutative34.5%
log-prod34.5%
+-commutative34.5%
hypot-1-def55.7%
add-sqr-sqrt25.0%
fabs-sqr25.0%
add-sqr-sqrt32.7%
metadata-eval32.7%
Applied egg-rr32.7%
+-rgt-identity32.7%
Simplified32.7%
Taylor expanded in x around 0 59.0%
Final simplification59.0%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024112
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(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))