
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (powf(x, 3.0f) * -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(-1.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * 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(-1.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 52.4%
Taylor expanded in x around -inf 98.1%
neg-mul-198.1%
unsub-neg98.1%
Simplified98.1%
if -1 < x < 0.0199999996Initial program 22.0%
Taylor expanded in x around 0 22.6%
+-commutative22.6%
fma-def22.6%
unpow222.6%
associate-/l*22.6%
rem-square-sqrt11.4%
fabs-sqr11.4%
rem-square-sqrt22.3%
log1p-def99.0%
rem-square-sqrt53.5%
fabs-sqr53.5%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
Simplified99.8%
if 0.0199999996 < x Initial program 59.6%
*-un-lft-identity59.6%
*-commutative59.6%
log-prod59.6%
add-sqr-sqrt59.6%
fabs-sqr59.6%
add-sqr-sqrt59.6%
+-commutative59.6%
hypot-1-def99.6%
metadata-eval99.6%
Applied egg-rr99.6%
+-rgt-identity99.6%
Simplified99.6%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<=
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
-0.009999999776482582)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -0.009999999776482582f) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(-0.009999999776482582)) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\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.00999999978Initial program 53.7%
+-commutative53.7%
hypot-1-def99.7%
Simplified99.7%
if -0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 34.8%
*-un-lft-identity34.8%
*-commutative34.8%
log-prod34.8%
add-sqr-sqrt28.5%
fabs-sqr28.5%
add-sqr-sqrt34.8%
+-commutative34.8%
hypot-1-def49.2%
metadata-eval49.2%
Applied egg-rr49.2%
+-rgt-identity49.2%
Simplified49.2%
log1p-expm1-u49.2%
expm1-udef49.2%
add-exp-log49.2%
Applied egg-rr49.2%
associate--l+97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -200.0) (copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (x <= -200.0f) {
tmp = copysignf(logf(((fabsf(x) - x) + (-0.5f / x))), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-200.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) + Float32(Float32(-0.5) / x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -200:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -200Initial program 50.8%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
if -200 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
add-sqr-sqrt27.9%
fabs-sqr27.9%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def50.1%
metadata-eval50.1%
Applied egg-rr50.1%
+-rgt-identity50.1%
Simplified50.1%
log1p-expm1-u50.1%
expm1-udef50.1%
add-exp-log50.1%
Applied egg-rr50.1%
associate--l+97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -200.0) (copysign (log (- (fabs x) x)) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (x <= -200.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-200.0)) tmp = copysign(log(Float32(abs(x) - x)), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -200:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -200Initial program 50.8%
Taylor expanded in x around -inf 99.8%
neg-mul-199.8%
unsub-neg99.8%
Simplified99.8%
if -200 < x Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
add-sqr-sqrt27.9%
fabs-sqr27.9%
add-sqr-sqrt36.0%
+-commutative36.0%
hypot-1-def50.1%
metadata-eval50.1%
Applied egg-rr50.1%
+-rgt-identity50.1%
Simplified50.1%
log1p-expm1-u50.1%
expm1-udef50.1%
add-exp-log50.1%
Applied egg-rr50.1%
associate--l+97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(abs(x) - x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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((abs(x) - x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 52.4%
Taylor expanded in x around -inf 98.1%
neg-mul-198.1%
unsub-neg98.1%
Simplified98.1%
if -1 < x < 0.200000003Initial program 23.6%
Taylor expanded in x around 0 23.6%
+-commutative23.6%
fma-def23.6%
unpow223.6%
associate-/l*23.6%
rem-square-sqrt12.6%
fabs-sqr12.6%
rem-square-sqrt23.2%
log1p-def98.1%
rem-square-sqrt53.7%
fabs-sqr53.7%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 0.200000003 < x Initial program 58.1%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
+-commutative99.5%
associate-+l+99.5%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt99.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (/ -0.5 x) (- x x))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(((-0.5f / x) + (x - x))), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(Float32(-0.5) / x) + Float32(x - x))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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(((single(-0.5) / x) + (x - x)))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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(\frac{-0.5}{x} + \left(x - x\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 52.4%
Taylor expanded in x around -inf 98.9%
associate--l+98.9%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.5%
sub-neg9.5%
associate-+r+98.0%
neg-mul-198.0%
sub-neg98.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < x < 0.200000003Initial program 23.6%
Taylor expanded in x around 0 23.6%
+-commutative23.6%
fma-def23.6%
unpow223.6%
associate-/l*23.6%
rem-square-sqrt12.6%
fabs-sqr12.6%
rem-square-sqrt23.2%
log1p-def98.1%
rem-square-sqrt53.7%
fabs-sqr53.7%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 0.200000003 < x Initial program 58.1%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
+-commutative99.5%
associate-+l+99.5%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt99.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (/ -1.0 x))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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(-5.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 51.6%
Taylor expanded in x around -inf 44.6%
mul-1-neg44.6%
Simplified44.6%
if -5 < x < 0.200000003Initial program 24.2%
Taylor expanded in x around 0 23.6%
+-commutative23.6%
fma-def23.6%
unpow223.6%
associate-/l*23.6%
rem-square-sqrt12.5%
fabs-sqr12.5%
rem-square-sqrt23.3%
log1p-def97.7%
rem-square-sqrt53.3%
fabs-sqr53.3%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
if 0.200000003 < x Initial program 58.1%
Taylor expanded in x around inf 98.4%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.4%
Simplified98.4%
Final simplification86.4%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (/ -0.5 x) (- x x))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(((-0.5f / x) + (x - x))), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(Float32(-0.5) / x) + Float32(x - x))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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(-1.0)) tmp = sign(x) * abs(log(((single(-0.5) / x) + (x - x)))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x} + \left(x - x\right)\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 52.4%
Taylor expanded in x around -inf 98.9%
associate--l+98.9%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.5%
sub-neg9.5%
associate-+r+98.0%
neg-mul-198.0%
sub-neg98.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < x < 0.200000003Initial program 23.6%
Taylor expanded in x around 0 23.6%
+-commutative23.6%
fma-def23.6%
unpow223.6%
associate-/l*23.6%
rem-square-sqrt12.6%
fabs-sqr12.6%
rem-square-sqrt23.2%
log1p-def98.1%
rem-square-sqrt53.7%
fabs-sqr53.7%
rem-square-sqrt98.6%
Simplified98.6%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 0.200000003 < x Initial program 58.1%
Taylor expanded in x around inf 98.4%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.4%
Simplified98.4%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (/ -1.0 x))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* (* x x) -0.5)) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + ((x * x) * -0.5f)), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(x * x) * Float32(-0.5))), 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(-5.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((x * x) * single(-0.5)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(x \cdot x\right) \cdot -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 51.6%
Taylor expanded in x around -inf 44.6%
mul-1-neg44.6%
Simplified44.6%
if -5 < x < 0.200000003Initial program 24.2%
Taylor expanded in x around 0 21.0%
rem-square-sqrt11.0%
fabs-sqr11.0%
rem-square-sqrt20.9%
Simplified20.9%
Taylor expanded in x around 0 93.5%
*-commutative93.5%
unpow293.5%
Simplified93.5%
if 0.200000003 < x Initial program 58.1%
Taylor expanded in x around inf 98.4%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.4%
Simplified98.4%
Final simplification83.7%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign (+ x (* (* x x) -0.5)) x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
tmp = copysignf((x + ((x * x) * -0.5f)), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(x * x) * Float32(-0.5))), 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(0.20000000298023224)) tmp = sign(x) * abs((x + ((x * x) * single(-0.5)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(x \cdot x\right) \cdot -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 0.200000003Initial program 32.6%
Taylor expanded in x around 0 28.3%
rem-square-sqrt7.6%
fabs-sqr7.6%
rem-square-sqrt14.5%
Simplified14.5%
Taylor expanded in x around 0 67.4%
*-commutative67.4%
unpow267.4%
Simplified67.4%
if 0.200000003 < x Initial program 58.1%
Taylor expanded in x around inf 98.4%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.4%
Simplified98.4%
Final simplification75.5%
(FPCore (x) :precision binary32 (copysign (log1p x) x))
float code(float x) {
return copysignf(log1pf(x), x);
}
function code(x) return copysign(log1p(x), x) end
\begin{array}{l}
\\
\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)
\end{array}
Initial program 39.3%
Taylor expanded in x around 0 32.5%
log1p-def69.6%
rem-square-sqrt37.8%
fabs-sqr37.8%
rem-square-sqrt59.4%
Simplified59.4%
Final simplification59.4%
(FPCore (x) :precision binary32 (copysign (+ x (* (* x x) -0.5)) x))
float code(float x) {
return copysignf((x + ((x * x) * -0.5f)), x);
}
function code(x) return copysign(Float32(x + Float32(Float32(x * x) * Float32(-0.5))), x) end
function tmp = code(x) tmp = sign(x) * abs((x + ((x * x) * single(-0.5)))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x + \left(x \cdot x\right) \cdot -0.5, x\right)
\end{array}
Initial program 39.3%
Taylor expanded in x around 0 32.5%
rem-square-sqrt17.3%
fabs-sqr17.3%
rem-square-sqrt22.3%
Simplified22.3%
Taylor expanded in x around 0 52.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
Final simplification52.0%
(FPCore (x) :precision binary32 (copysign (* x 0.5) x))
float code(float x) {
return copysignf((x * 0.5f), x);
}
function code(x) return copysign(Float32(x * Float32(0.5)), x) end
function tmp = code(x) tmp = sign(x) * abs((x * single(0.5))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x \cdot 0.5, x\right)
\end{array}
Initial program 39.3%
Taylor expanded in x around 0 17.2%
+-commutative17.2%
fma-def17.2%
unpow217.2%
associate-/l*17.5%
rem-square-sqrt9.3%
fabs-sqr9.3%
rem-square-sqrt17.4%
log1p-def55.4%
rem-square-sqrt30.2%
fabs-sqr30.2%
rem-square-sqrt53.0%
Simplified53.0%
Taylor expanded in x around inf 19.9%
*-commutative19.9%
Simplified19.9%
Final simplification19.9%
(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 2023278
(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))