
(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 8 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 (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (+ (+ (log 2.0) (/ 0.25 (pow x 2.0))) (log 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((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.019999999552965164f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(((logf(2.0f) + (0.25f / powf(x, 2.0f))) + logf(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(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(Float32(Float32(log(Float32(2.0)) + Float32(Float32(0.25) / (x ^ Float32(2.0)))) + log(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((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.019999999552965164)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(((log(single(2.0)) + (single(0.25) / (x ^ single(2.0)))) + log(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(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\left(\log 2 + \frac{0.25}{{x}^{2}}\right) + \log x, 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.200000003Initial program 49.5%
Taylor expanded in x around 0 49.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
metadata-eval-0.0%
unpow2-0.0%
hypot-undefine-0.0%
rem-square-sqrt12.1%
Simplified12.1%
+-commutative12.1%
flip-+8.8%
hypot-undefine10.0%
metadata-eval10.0%
unpow210.0%
hypot-undefine8.3%
metadata-eval8.3%
unpow28.3%
add-sqr-sqrt10.3%
+-commutative10.3%
unpow210.3%
Applied egg-rr10.3%
sub-neg10.3%
+-commutative10.3%
associate-+l+46.0%
sub-neg46.0%
+-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0199999996Initial program 17.5%
Taylor expanded in x around 0 18.5%
+-commutative18.5%
fma-define18.5%
+-commutative18.5%
rem-square-sqrt10.5%
fabs-sqr10.5%
rem-square-sqrt18.5%
log1p-define99.7%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt99.9%
Simplified99.9%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
Applied egg-rr100.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 55.3%
Taylor expanded in x around 0 55.3%
rem-square-sqrt55.3%
fabs-sqr55.3%
metadata-eval55.3%
unpow255.3%
hypot-undefine98.6%
rem-square-sqrt98.5%
Simplified98.5%
Taylor expanded in x around inf 99.1%
+-commutative99.1%
mul-1-neg99.1%
log-rec99.1%
remove-double-neg99.1%
associate-+r+99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.009999999776482582)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ (fabs 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((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.009999999776482582f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((fabsf(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(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.009999999776482582)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(abs(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((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.009999999776482582)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log((abs(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(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \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.200000003Initial program 49.5%
Taylor expanded in x around 0 49.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
metadata-eval-0.0%
unpow2-0.0%
hypot-undefine-0.0%
rem-square-sqrt12.1%
Simplified12.1%
+-commutative12.1%
flip-+8.8%
hypot-undefine10.0%
metadata-eval10.0%
unpow210.0%
hypot-undefine8.3%
metadata-eval8.3%
unpow28.3%
add-sqr-sqrt10.3%
+-commutative10.3%
unpow210.3%
Applied egg-rr10.3%
sub-neg10.3%
+-commutative10.3%
associate-+l+46.0%
sub-neg46.0%
+-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00999999978Initial program 16.9%
Taylor expanded in x around 0 18.0%
+-commutative18.0%
fma-define18.0%
+-commutative18.0%
rem-square-sqrt9.8%
fabs-sqr9.8%
rem-square-sqrt17.9%
log1p-define99.8%
rem-square-sqrt52.7%
fabs-sqr52.7%
rem-square-sqrt100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
Applied egg-rr100.0%
if 0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 55.9%
+-commutative55.9%
hypot-1-def98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.009999999776482582)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) 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.009999999776482582f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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.20000000298023224)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.009999999776482582)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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.20000000298023224)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.009999999776482582)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\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 49.5%
Taylor expanded in x around 0 49.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
metadata-eval-0.0%
unpow2-0.0%
hypot-undefine-0.0%
rem-square-sqrt12.1%
Simplified12.1%
+-commutative12.1%
flip-+8.8%
hypot-undefine10.0%
metadata-eval10.0%
unpow210.0%
hypot-undefine8.3%
metadata-eval8.3%
unpow28.3%
add-sqr-sqrt10.3%
+-commutative10.3%
unpow210.3%
Applied egg-rr10.3%
sub-neg10.3%
+-commutative10.3%
associate-+l+46.0%
sub-neg46.0%
+-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -0.200000003 < x < 0.00999999978Initial program 16.9%
Taylor expanded in x around 0 18.0%
+-commutative18.0%
fma-define18.0%
+-commutative18.0%
rem-square-sqrt9.8%
fabs-sqr9.8%
rem-square-sqrt17.9%
log1p-define99.8%
rem-square-sqrt52.7%
fabs-sqr52.7%
rem-square-sqrt100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
unpow2100.0%
Applied egg-rr100.0%
if 0.00999999978 < x Initial program 55.9%
Taylor expanded in x around 0 55.9%
rem-square-sqrt55.9%
fabs-sqr55.9%
metadata-eval55.9%
unpow255.9%
hypot-undefine98.5%
rem-square-sqrt98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ (- E) x)) x)
(if (<= x 0.009999999776482582)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-((float) M_E) / x)), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf((x * (1.0f + ((x * x) * -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(-5.0)) tmp = copysign(log(Float32(Float32(-Float32(exp(1))) / x)), x); elseif (x <= Float32(0.009999999776482582)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-5.0)) tmp = sign(x) * abs(log((-single(2.71828182845904523536) / x))); elseif (x <= single(0.009999999776482582)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-e}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\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 < -5Initial program 48.7%
Taylor expanded in x around -inf 48.3%
distribute-lft-out48.3%
Simplified48.3%
add-sqr-sqrt48.3%
sqrt-unprod48.3%
mul-1-neg48.3%
mul-1-neg48.3%
sqr-neg48.3%
sqrt-unprod-0.0%
add-sqr-sqrt48.3%
add-log-exp48.3%
sum-log48.3%
add-sqr-sqrt-0.0%
add-sqr-sqrt48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt40.4%
*-inverses40.4%
Applied egg-rr40.4%
associate-*l/40.4%
mul-1-neg40.4%
Simplified40.4%
if -5 < x < 0.00999999978Initial program 17.5%
Taylor expanded in x around 0 18.3%
+-commutative18.3%
fma-define18.3%
+-commutative18.3%
rem-square-sqrt9.8%
fabs-sqr9.8%
rem-square-sqrt18.1%
log1p-define99.3%
rem-square-sqrt52.3%
fabs-sqr52.3%
rem-square-sqrt99.6%
Simplified99.6%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
if 0.00999999978 < x Initial program 55.9%
Taylor expanded in x around 0 55.9%
rem-square-sqrt55.9%
fabs-sqr55.9%
metadata-eval55.9%
unpow255.9%
hypot-undefine98.5%
rem-square-sqrt98.5%
Simplified98.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ (- E) x)) x)
(if (<= x 0.019999999552965164)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (+ 1.0 (log x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-((float) M_E) / x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf((1.0f + logf(x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-Float32(exp(1))) / x)), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(Float32(Float32(1.0) + 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((-single(2.71828182845904523536) / x))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs((single(1.0) + log(x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-e}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \log x, x\right)\\
\end{array}
\end{array}
if x < -5Initial program 48.7%
Taylor expanded in x around -inf 48.3%
distribute-lft-out48.3%
Simplified48.3%
add-sqr-sqrt48.3%
sqrt-unprod48.3%
mul-1-neg48.3%
mul-1-neg48.3%
sqr-neg48.3%
sqrt-unprod-0.0%
add-sqr-sqrt48.3%
add-log-exp48.3%
sum-log48.3%
add-sqr-sqrt-0.0%
add-sqr-sqrt48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt40.4%
*-inverses40.4%
Applied egg-rr40.4%
associate-*l/40.4%
mul-1-neg40.4%
Simplified40.4%
if -5 < x < 0.0199999996Initial program 18.1%
Taylor expanded in x around 0 18.8%
+-commutative18.8%
fma-define18.8%
+-commutative18.8%
rem-square-sqrt10.4%
fabs-sqr10.4%
rem-square-sqrt18.6%
log1p-define99.2%
rem-square-sqrt52.6%
fabs-sqr52.6%
rem-square-sqrt99.5%
Simplified99.5%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
if 0.0199999996 < x Initial program 55.3%
Taylor expanded in x around inf 48.3%
+-commutative48.3%
rem-square-sqrt48.3%
fabs-sqr48.3%
rem-square-sqrt48.3%
mul-1-neg48.3%
log-rec48.3%
remove-double-neg48.3%
Simplified48.3%
Taylor expanded in x around 0 48.3%
(FPCore (x) :precision binary32 (if (<= x 0.019999999552965164) (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x) (copysign (+ 1.0 (log x)) x)))
float code(float x) {
float tmp;
if (x <= 0.019999999552965164f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf((1.0f + logf(x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(Float32(Float32(1.0) + log(x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs((single(1.0) + log(x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \log x, x\right)\\
\end{array}
\end{array}
if x < 0.0199999996Initial program 28.2%
Taylor expanded in x around 0 16.0%
+-commutative16.0%
fma-define16.0%
+-commutative16.0%
rem-square-sqrt7.0%
fabs-sqr7.0%
rem-square-sqrt15.9%
log1p-define70.1%
rem-square-sqrt35.3%
fabs-sqr35.3%
rem-square-sqrt66.8%
Simplified66.8%
Taylor expanded in x around 0 69.6%
*-commutative69.6%
Simplified69.6%
unpow269.6%
Applied egg-rr69.6%
if 0.0199999996 < x Initial program 55.3%
Taylor expanded in x around inf 48.3%
+-commutative48.3%
rem-square-sqrt48.3%
fabs-sqr48.3%
rem-square-sqrt48.3%
mul-1-neg48.3%
log-rec48.3%
remove-double-neg48.3%
Simplified48.3%
Taylor expanded in x around 0 48.3%
(FPCore (x) :precision binary32 (if (<= x 0.019999999552965164) (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x) (copysign (log (* x E)) x)))
float code(float x) {
float tmp;
if (x <= 0.019999999552965164f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * ((float) M_E))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log(Float32(x * Float32(exp(1)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); else tmp = sign(x) * abs(log((x * single(2.71828182845904523536)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot e\right), x\right)\\
\end{array}
\end{array}
if x < 0.0199999996Initial program 28.2%
Taylor expanded in x around 0 16.0%
+-commutative16.0%
fma-define16.0%
+-commutative16.0%
rem-square-sqrt7.0%
fabs-sqr7.0%
rem-square-sqrt15.9%
log1p-define70.1%
rem-square-sqrt35.3%
fabs-sqr35.3%
rem-square-sqrt66.8%
Simplified66.8%
Taylor expanded in x around 0 69.6%
*-commutative69.6%
Simplified69.6%
unpow269.6%
Applied egg-rr69.6%
if 0.0199999996 < x Initial program 55.3%
Taylor expanded in x around inf 48.3%
+-commutative48.3%
rem-square-sqrt48.3%
fabs-sqr48.3%
rem-square-sqrt48.3%
mul-1-neg48.3%
log-rec48.3%
remove-double-neg48.3%
Simplified48.3%
add-log-exp46.9%
*-inverses46.9%
+-commutative46.9%
exp-sum46.9%
add-exp-log46.9%
exp-1-e46.9%
Applied egg-rr46.9%
(FPCore (x) :precision binary32 (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x))
float code(float x) {
return copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
}
function code(x) return copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x) end
function tmp = code(x) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)
\end{array}
Initial program 35.3%
Taylor expanded in x around 0 14.6%
+-commutative14.6%
fma-define14.6%
+-commutative14.6%
rem-square-sqrt7.9%
fabs-sqr7.9%
rem-square-sqrt14.5%
log1p-define54.5%
rem-square-sqrt28.8%
fabs-sqr28.8%
rem-square-sqrt52.1%
Simplified52.1%
Taylor expanded in x around 0 53.4%
*-commutative53.4%
Simplified53.4%
unpow253.4%
Applied egg-rr53.4%
(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 2024179
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))