
(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 10 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.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(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 t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
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) 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.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.4000000059604645)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) 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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.400000006Initial program 66.9%
flip-+8.2%
frac-2neg8.2%
log-div8.2%
Applied egg-rr14.6%
fma-undefine14.2%
unpow214.2%
associate--r+64.6%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0199999996Initial program 19.6%
add-cube-cbrt18.7%
pow318.7%
*-un-lft-identity18.7%
*-un-lft-identity18.7%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt18.9%
+-commutative18.9%
hypot-1-def18.9%
Applied egg-rr18.9%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 61.2%
*-un-lft-identity61.2%
*-commutative61.2%
log-prod61.2%
*-un-lft-identity61.2%
*-un-lft-identity61.2%
add-sqr-sqrt61.2%
fabs-sqr61.2%
add-sqr-sqrt61.2%
+-commutative61.2%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -1.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 <= -1.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(-1.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(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 66.4%
flip-+6.8%
frac-2neg6.8%
log-div6.8%
Applied egg-rr13.3%
fma-undefine12.9%
unpow212.9%
associate--r+64.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.5%
*-commutative97.5%
Simplified97.5%
if -1 < x < 0.0199999996Initial program 20.3%
add-cube-cbrt19.3%
pow319.3%
*-un-lft-identity19.3%
*-un-lft-identity19.3%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
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 61.2%
*-un-lft-identity61.2%
*-commutative61.2%
log-prod61.2%
*-un-lft-identity61.2%
*-un-lft-identity61.2%
add-sqr-sqrt61.2%
fabs-sqr61.2%
add-sqr-sqrt61.2%
+-commutative61.2%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(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.05000000074505806f) {
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.05000000074505806)) 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.05000000074505806)) 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.05000000074505806:\\
\;\;\;\;\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.0500000007Initial program 67.2%
flip-+9.4%
frac-2neg9.4%
log-div9.4%
Applied egg-rr15.7%
fma-undefine15.3%
unpow215.3%
associate--r+65.0%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
if -0.0500000007 < x < 0.0199999996Initial program 19.0%
add-cube-cbrt18.1%
pow318.1%
*-un-lft-identity18.1%
*-un-lft-identity18.1%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt18.3%
+-commutative18.3%
hypot-1-def18.3%
Applied egg-rr18.3%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0199999996 < x Initial program 61.2%
*-un-lft-identity61.2%
*-commutative61.2%
log-prod61.2%
*-un-lft-identity61.2%
*-un-lft-identity61.2%
add-sqr-sqrt61.2%
fabs-sqr61.2%
add-sqr-sqrt61.2%
+-commutative61.2%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.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((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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(Float32(-log(Float32(Float32(0.5) / 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 * 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((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 66.4%
flip-+6.8%
frac-2neg6.8%
log-div6.8%
Applied egg-rr13.3%
fma-undefine12.9%
unpow212.9%
associate--r+64.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.5%
*-commutative97.5%
Simplified97.5%
if -1 < x < 0.0199999996Initial program 20.3%
add-cube-cbrt19.3%
pow319.3%
*-un-lft-identity19.3%
*-un-lft-identity19.3%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
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 61.2%
flip-+10.1%
frac-2neg10.1%
log-div10.1%
Applied egg-rr9.8%
fma-undefine9.8%
unpow29.8%
associate--r+12.8%
+-inverses15.5%
metadata-eval15.5%
metadata-eval15.5%
metadata-eval15.5%
neg-sub015.5%
neg-sub015.5%
associate--r-15.5%
neg-sub015.5%
+-commutative15.5%
sub-neg15.5%
Simplified15.5%
Taylor expanded in x around inf 96.3%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(copysign x x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(x, x); else tmp = copysign(Float32(-log(Float32(Float32(0.5) / 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 * single(-2.0)))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(-log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 66.4%
flip-+6.8%
frac-2neg6.8%
log-div6.8%
Applied egg-rr13.3%
fma-undefine12.9%
unpow212.9%
associate--r+64.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.5%
*-commutative97.5%
Simplified97.5%
if -1 < x < 0.0199999996Initial program 20.3%
add-cube-cbrt19.3%
pow319.3%
*-un-lft-identity19.3%
*-un-lft-identity19.3%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
rem-cube-cbrt20.3%
+-commutative20.3%
Applied egg-rr20.3%
Taylor expanded in x around 0 98.2%
if 0.0199999996 < x Initial program 61.2%
flip-+10.1%
frac-2neg10.1%
log-div10.1%
Applied egg-rr9.8%
fma-undefine9.8%
unpow29.8%
associate--r+12.8%
+-inverses15.5%
metadata-eval15.5%
metadata-eval15.5%
metadata-eval15.5%
neg-sub015.5%
neg-sub015.5%
associate--r-15.5%
neg-sub015.5%
+-commutative15.5%
sub-neg15.5%
Simplified15.5%
Taylor expanded in x around inf 96.3%
Final simplification97.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(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.019999999552965164f) {
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.019999999552965164)) 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.019999999552965164)) 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.019999999552965164:\\
\;\;\;\;\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 66.4%
Taylor expanded in x around -inf 98.6%
mul-1-neg98.6%
distribute-rgt-neg-in98.6%
mul-1-neg98.6%
unsub-neg98.6%
sub-neg98.6%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.5%
associate-*r/10.5%
metadata-eval10.5%
distribute-neg-frac10.5%
metadata-eval10.5%
Simplified10.5%
Taylor expanded in x around 0 97.5%
if -1 < x < 0.0199999996Initial program 20.3%
add-cube-cbrt19.3%
pow319.3%
*-un-lft-identity19.3%
*-un-lft-identity19.3%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
rem-cube-cbrt20.3%
+-commutative20.3%
Applied egg-rr20.3%
Taylor expanded in x around 0 98.2%
if 0.0199999996 < x Initial program 61.2%
add-cube-cbrt61.0%
pow361.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification97.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.019999999552965164)) 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((x * single(-2.0)))); elseif (x <= single(0.019999999552965164)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 66.4%
flip-+6.8%
frac-2neg6.8%
log-div6.8%
Applied egg-rr13.3%
fma-undefine12.9%
unpow212.9%
associate--r+64.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.5%
*-commutative97.5%
Simplified97.5%
if -1 < x < 0.0199999996Initial program 20.3%
add-cube-cbrt19.3%
pow319.3%
*-un-lft-identity19.3%
*-un-lft-identity19.3%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt19.5%
+-commutative19.5%
hypot-1-def19.5%
Applied egg-rr19.5%
rem-cube-cbrt20.3%
+-commutative20.3%
Applied egg-rr20.3%
Taylor expanded in x around 0 98.2%
if 0.0199999996 < x Initial program 61.2%
add-cube-cbrt61.0%
pow361.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification97.2%
(FPCore (x) :precision binary32 (if (<= x 0.019999999552965164) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.019999999552965164f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.019999999552965164)) 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(0.019999999552965164)) 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 0.019999999552965164:\\
\;\;\;\;\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 < 0.0199999996Initial program 36.1%
add-cube-cbrt35.5%
pow335.5%
*-un-lft-identity35.5%
*-un-lft-identity35.5%
add-sqr-sqrt5.2%
fabs-sqr5.2%
add-sqr-sqrt17.1%
+-commutative17.1%
hypot-1-def17.1%
Applied egg-rr17.1%
rem-cube-cbrt17.6%
+-commutative17.6%
Applied egg-rr17.6%
Taylor expanded in x around 0 68.4%
if 0.0199999996 < x Initial program 61.2%
add-cube-cbrt61.0%
pow361.1%
*-un-lft-identity61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.0%
fabs-sqr61.0%
add-sqr-sqrt61.1%
+-commutative61.1%
hypot-1-def98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 95.0%
*-commutative95.0%
Simplified95.0%
Final simplification75.7%
(FPCore (x) :precision binary32 (if (<= x 0.019999999552965164) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.019999999552965164f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.019999999552965164)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.0199999996Initial program 36.1%
add-cube-cbrt35.5%
pow335.5%
*-un-lft-identity35.5%
*-un-lft-identity35.5%
add-sqr-sqrt5.2%
fabs-sqr5.2%
add-sqr-sqrt17.1%
+-commutative17.1%
hypot-1-def17.1%
Applied egg-rr17.1%
rem-cube-cbrt17.6%
+-commutative17.6%
Applied egg-rr17.6%
Taylor expanded in x around 0 68.4%
if 0.0199999996 < x Initial program 61.2%
Taylor expanded in x around 0 43.4%
log1p-define43.4%
rem-square-sqrt43.4%
fabs-sqr43.4%
rem-square-sqrt43.4%
Simplified43.4%
Final simplification61.6%
(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 43.0%
add-cube-cbrt42.5%
pow342.5%
*-un-lft-identity42.5%
*-un-lft-identity42.5%
add-sqr-sqrt20.4%
fabs-sqr20.4%
add-sqr-sqrt29.1%
+-commutative29.1%
hypot-1-def39.3%
Applied egg-rr39.3%
rem-cube-cbrt39.7%
+-commutative39.7%
Applied egg-rr39.7%
Taylor expanded in x around 0 53.1%
Final simplification53.1%
(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 2024077
(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))