
(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 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -5.0) (copysign (log (/ -0.5 x)) x) (copysign (log1p (+ x (* x (/ x (+ 1.0 (hypot 1.0 x)))))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else {
tmp = copysignf(log1pf((x + (x * (x / (1.0f + hypotf(1.0f, x)))))), 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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); else tmp = copysign(log1p(Float32(x + Float32(x * Float32(x / Float32(Float32(1.0) + hypot(Float32(1.0), x)))))), 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + x \cdot \frac{x}{1 + \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) < -5Initial program 60.1%
Taylor expanded in x around -inf 97.9%
mul-1-neg97.9%
*-commutative97.9%
distribute-rgt-neg-in97.9%
mul-1-neg97.9%
unsub-neg97.9%
sub-neg97.9%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.4%
associate-*r/9.4%
metadata-eval9.4%
distribute-neg-frac9.4%
metadata-eval9.4%
Simplified9.4%
Taylor expanded in x around 0 99.9%
if -5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 40.4%
add-log-exp22.0%
*-un-lft-identity22.0%
log-prod22.0%
metadata-eval22.0%
add-log-exp40.4%
add-sqr-sqrt31.2%
fabs-sqr31.2%
add-sqr-sqrt40.3%
Applied egg-rr40.3%
+-lft-identity40.3%
+-commutative40.3%
hypot-1-def56.6%
pow156.6%
metadata-eval56.6%
pow-pow26.2%
log1p-expm1-u26.2%
expm1-undefine26.2%
pow-pow56.6%
metadata-eval56.6%
pow156.6%
add-exp-log56.5%
Applied egg-rr56.5%
associate--l+97.3%
Simplified97.3%
flip--81.1%
div-inv81.1%
metadata-eval81.1%
sub-neg81.1%
hypot-undefine81.1%
hypot-undefine80.9%
metadata-eval80.9%
metadata-eval80.9%
add-sqr-sqrt81.3%
pow281.3%
metadata-eval81.3%
+-commutative81.3%
Applied egg-rr81.3%
associate-*r/81.3%
*-rgt-identity81.3%
+-commutative81.3%
associate-+l+83.5%
metadata-eval83.5%
Simplified83.5%
+-rgt-identity83.5%
unpow283.5%
associate-/l*99.6%
Applied egg-rr99.6%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 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 <= -0.20000000298023224f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, 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(-0.20000000298023224)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), 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(-0.20000000298023224)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), 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 -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, 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 < -0.200000003Initial program 64.4%
+-commutative64.4%
hypot-1-def98.0%
flip-+13.0%
hypot-1-def12.7%
hypot-1-def11.1%
add-sqr-sqrt12.7%
+-commutative12.7%
hypot-1-def11.2%
+-commutative11.2%
div-sub11.2%
Applied egg-rr15.8%
div-sub19.5%
remove-double-neg19.5%
distribute-neg-frac219.5%
distribute-frac-neg19.5%
neg-sub019.5%
associate--r-19.5%
neg-sub019.5%
+-commutative19.5%
fma-undefine19.5%
unpow219.5%
+-commutative19.5%
associate-+l+62.1%
sub-neg62.1%
+-inverses98.1%
metadata-eval98.1%
neg-sub098.1%
associate--r-98.1%
neg-sub098.1%
+-commutative98.1%
sub-neg98.1%
Simplified98.1%
if -0.200000003 < x < 0.0199999996Initial program 23.8%
add-log-exp23.8%
*-un-lft-identity23.8%
log-prod23.8%
metadata-eval23.8%
add-log-exp23.8%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt24.2%
Applied egg-rr24.2%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 59.7%
Taylor expanded in x around 0 59.7%
rem-square-sqrt59.7%
fabs-sqr59.7%
metadata-eval59.7%
unpow259.7%
hypot-undefine99.7%
rem-square-sqrt99.8%
Simplified99.8%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (log (- (hypot 1.0 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 <= -0.20000000298023224f) {
tmp = copysignf(logf((hypotf(1.0f, 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(-0.20000000298023224)) tmp = copysign(log(Float32(hypot(Float32(1.0), 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(-0.20000000298023224)) tmp = sign(x) * abs(log((hypot(single(1.0), 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 -0.20000000298023224:\\
\;\;\;\;\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 + {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 < -0.200000003Initial program 64.4%
+-commutative64.4%
hypot-1-def98.0%
Simplified98.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
sqrt-prod64.5%
pow1/264.5%
add-cbrt-cube27.4%
pow1/327.4%
pow-pow27.4%
pow327.5%
pow227.5%
pow-pow27.5%
metadata-eval27.5%
metadata-eval27.5%
Applied egg-rr27.5%
Taylor expanded in x around -inf 64.4%
metadata-eval64.4%
unpow264.4%
hypot-undefine98.0%
metadata-eval98.0%
pow-base-198.0%
*-lft-identity98.0%
cancel-sign-sub-inv98.0%
*-lft-identity98.0%
Simplified98.0%
if -0.200000003 < x < 0.0199999996Initial program 23.8%
add-log-exp23.8%
*-un-lft-identity23.8%
log-prod23.8%
metadata-eval23.8%
add-log-exp23.8%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt24.2%
Applied egg-rr24.2%
Taylor expanded in x around 0 100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 59.7%
Taylor expanded in x around 0 59.7%
rem-square-sqrt59.7%
fabs-sqr59.7%
metadata-eval59.7%
unpow259.7%
hypot-undefine99.7%
rem-square-sqrt99.8%
Simplified99.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 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((-0.5f / 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(Float32(-0.5) / 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((single(-0.5) / 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(\frac{-0.5}{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 63.8%
Taylor expanded in x around -inf 95.8%
mul-1-neg95.8%
*-commutative95.8%
distribute-rgt-neg-in95.8%
mul-1-neg95.8%
unsub-neg95.8%
sub-neg95.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.7%
associate-*r/13.7%
metadata-eval13.7%
distribute-neg-frac13.7%
metadata-eval13.7%
Simplified13.7%
Taylor expanded in x around 0 95.5%
if -1 < x < 0.0199999996Initial program 24.4%
add-log-exp24.4%
*-un-lft-identity24.4%
log-prod24.4%
metadata-eval24.4%
add-log-exp24.4%
add-sqr-sqrt12.6%
fabs-sqr12.6%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
Taylor expanded in x around 0 99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
*-commutative99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
Simplified99.7%
if 0.0199999996 < x Initial program 59.7%
Taylor expanded in x around 0 59.7%
rem-square-sqrt59.7%
fabs-sqr59.7%
metadata-eval59.7%
unpow259.7%
hypot-undefine99.7%
rem-square-sqrt99.8%
Simplified99.8%
(FPCore (x) :precision binary32 (if (<= x -500.0) (copysign (log (/ -0.5 x)) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (x <= -500.0f) {
tmp = copysignf(logf((-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(-500.0)) tmp = copysign(log(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 -500:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\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 < -500Initial program 60.1%
Taylor expanded in x around -inf 97.9%
mul-1-neg97.9%
*-commutative97.9%
distribute-rgt-neg-in97.9%
mul-1-neg97.9%
unsub-neg97.9%
sub-neg97.9%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt9.4%
associate-*r/9.4%
metadata-eval9.4%
distribute-neg-frac9.4%
metadata-eval9.4%
Simplified9.4%
Taylor expanded in x around 0 99.9%
if -500 < x Initial program 40.4%
add-log-exp22.0%
*-un-lft-identity22.0%
log-prod22.0%
metadata-eval22.0%
add-log-exp40.4%
add-sqr-sqrt31.2%
fabs-sqr31.2%
add-sqr-sqrt40.3%
Applied egg-rr40.3%
+-lft-identity40.3%
+-commutative40.3%
hypot-1-def56.6%
pow156.6%
metadata-eval56.6%
pow-pow26.2%
log1p-expm1-u26.2%
expm1-undefine26.2%
pow-pow56.6%
metadata-eval56.6%
pow156.6%
add-exp-log56.5%
Applied egg-rr56.5%
associate--l+97.3%
Simplified97.3%
Final simplification97.7%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(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((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 63.8%
Taylor expanded in x around -inf 95.8%
mul-1-neg95.8%
*-commutative95.8%
distribute-rgt-neg-in95.8%
mul-1-neg95.8%
unsub-neg95.8%
sub-neg95.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.7%
associate-*r/13.7%
metadata-eval13.7%
distribute-neg-frac13.7%
metadata-eval13.7%
Simplified13.7%
Taylor expanded in x around 0 95.5%
if -1 < x < 0.5Initial program 26.1%
add-log-exp26.0%
*-un-lft-identity26.0%
log-prod26.0%
metadata-eval26.0%
add-log-exp26.1%
add-sqr-sqrt14.6%
fabs-sqr14.6%
add-sqr-sqrt26.5%
Applied egg-rr26.5%
Taylor expanded in x around 0 99.1%
distribute-lft-in99.1%
*-rgt-identity99.1%
*-commutative99.1%
associate-*r*99.1%
unpow299.1%
cube-mult99.1%
Simplified99.1%
if 0.5 < x Initial program 58.4%
Taylor expanded in x around -inf 5.6%
mul-1-neg5.6%
*-commutative5.6%
distribute-rgt-neg-in5.6%
mul-1-neg5.6%
unsub-neg5.6%
sub-neg5.6%
rem-square-sqrt8.1%
fabs-sqr8.1%
rem-square-sqrt5.6%
associate-*r/5.6%
metadata-eval5.6%
distribute-neg-frac5.6%
metadata-eval5.6%
Simplified5.6%
metadata-eval5.6%
add-sqr-sqrt5.6%
sqrt-prod5.6%
sqr-neg5.6%
sqrt-unprod-0.0%
add-sqr-sqrt11.9%
frac-2neg11.9%
div-inv11.9%
metadata-eval11.9%
cancel-sign-sub-inv11.9%
div-inv11.9%
Applied egg-rr11.9%
Taylor expanded in x around 0 97.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), 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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(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((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 63.8%
Taylor expanded in x around -inf 95.8%
mul-1-neg95.8%
*-commutative95.8%
distribute-rgt-neg-in95.8%
mul-1-neg95.8%
unsub-neg95.8%
sub-neg95.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.7%
associate-*r/13.7%
metadata-eval13.7%
distribute-neg-frac13.7%
metadata-eval13.7%
Simplified13.7%
Taylor expanded in x around 0 95.5%
if -1 < x < 0.5Initial program 26.1%
add-log-exp26.0%
*-un-lft-identity26.0%
log-prod26.0%
metadata-eval26.0%
add-log-exp26.1%
add-sqr-sqrt14.6%
fabs-sqr14.6%
add-sqr-sqrt26.5%
Applied egg-rr26.5%
Taylor expanded in x around 0 99.1%
*-commutative99.1%
Simplified99.1%
unpow299.1%
Applied egg-rr99.1%
if 0.5 < x Initial program 58.4%
Taylor expanded in x around -inf 5.6%
mul-1-neg5.6%
*-commutative5.6%
distribute-rgt-neg-in5.6%
mul-1-neg5.6%
unsub-neg5.6%
sub-neg5.6%
rem-square-sqrt8.1%
fabs-sqr8.1%
rem-square-sqrt5.6%
associate-*r/5.6%
metadata-eval5.6%
distribute-neg-frac5.6%
metadata-eval5.6%
Simplified5.6%
metadata-eval5.6%
add-sqr-sqrt5.6%
sqrt-prod5.6%
sqr-neg5.6%
sqrt-unprod-0.0%
add-sqr-sqrt11.9%
frac-2neg11.9%
div-inv11.9%
metadata-eval11.9%
cancel-sign-sub-inv11.9%
div-inv11.9%
Applied egg-rr11.9%
Taylor expanded in x around 0 97.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) 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.5f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), 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.5)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), 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.5)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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.5:\\
\;\;\;\;\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 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 63.8%
Taylor expanded in x around -inf 95.8%
mul-1-neg95.8%
*-commutative95.8%
distribute-rgt-neg-in95.8%
mul-1-neg95.8%
unsub-neg95.8%
sub-neg95.8%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.7%
associate-*r/13.7%
metadata-eval13.7%
distribute-neg-frac13.7%
metadata-eval13.7%
Simplified13.7%
Taylor expanded in x around 0 95.5%
if -1 < x < 0.5Initial program 26.1%
add-log-exp26.0%
*-un-lft-identity26.0%
log-prod26.0%
metadata-eval26.0%
add-log-exp26.1%
add-sqr-sqrt14.6%
fabs-sqr14.6%
add-sqr-sqrt26.5%
Applied egg-rr26.5%
Taylor expanded in x around 0 99.1%
*-commutative99.1%
Simplified99.1%
unpow299.1%
Applied egg-rr99.1%
if 0.5 < x Initial program 58.4%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
*-inverses97.3%
metadata-eval97.3%
Simplified97.3%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- x)) x)
(if (<= x 0.5)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.5f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), 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(-5.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.5)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666))))); 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.1%
Taylor expanded in x around -inf 43.8%
neg-mul-143.8%
Simplified43.8%
if -5 < x < 0.5Initial program 26.7%
add-log-exp26.6%
*-un-lft-identity26.6%
log-prod26.6%
metadata-eval26.6%
add-log-exp26.7%
add-sqr-sqrt14.5%
fabs-sqr14.5%
add-sqr-sqrt27.1%
Applied egg-rr27.1%
Taylor expanded in x around 0 98.6%
*-commutative98.6%
Simplified98.6%
unpow298.6%
Applied egg-rr98.6%
if 0.5 < x Initial program 58.4%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
*-inverses97.3%
metadata-eval97.3%
Simplified97.3%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- x)) x)
(if (<= x 0.5)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log1p x) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.5f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.1%
Taylor expanded in x around -inf 43.8%
neg-mul-143.8%
Simplified43.8%
if -5 < x < 0.5Initial program 26.7%
add-log-exp26.6%
*-un-lft-identity26.6%
log-prod26.6%
metadata-eval26.6%
add-log-exp26.7%
add-sqr-sqrt14.5%
fabs-sqr14.5%
add-sqr-sqrt27.1%
Applied egg-rr27.1%
Taylor expanded in x around 0 98.6%
*-commutative98.6%
Simplified98.6%
unpow298.6%
Applied egg-rr98.6%
if 0.5 < x Initial program 58.4%
Taylor expanded in x around 0 43.9%
log1p-define43.9%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt43.9%
Simplified43.9%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 37.3%
add-log-exp22.9%
*-un-lft-identity22.9%
log-prod22.9%
metadata-eval22.9%
add-log-exp37.3%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt23.1%
Applied egg-rr23.1%
Taylor expanded in x around 0 72.3%
*-commutative72.3%
Simplified72.3%
unpow272.3%
Applied egg-rr72.3%
if 0.5 < x Initial program 58.4%
Taylor expanded in x around 0 43.9%
log1p-define43.9%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt43.9%
Simplified43.9%
(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 44.0%
add-log-exp19.1%
*-un-lft-identity19.1%
log-prod19.1%
metadata-eval19.1%
add-log-exp44.0%
add-sqr-sqrt25.5%
fabs-sqr25.5%
add-sqr-sqrt34.3%
Applied egg-rr34.3%
Taylor expanded in x around 0 52.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 2024177
(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))