
(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 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (fma (* x 0.075) x -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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * fmaf((x * 0.075f), x, -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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * fma(Float32(x * Float32(0.075)), x, Float32(-0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \mathsf{fma}\left(x \cdot 0.075, x, -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.100000001Initial program 56.8%
+-commutative56.8%
hypot-1-def99.9%
Simplified99.9%
flip-+6.6%
clear-num6.6%
log-div6.6%
metadata-eval6.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.1%
pow28.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.1%
hypot-1-def9.1%
hypot-1-def7.5%
add-sqr-sqrt9.3%
+-commutative9.3%
Applied egg-rr9.3%
neg-sub09.3%
div-sub9.2%
fma-undefine9.2%
unpow29.2%
associate--r+9.3%
+-inverses9.3%
metadata-eval9.3%
*-rgt-identity9.3%
associate-/l*9.3%
metadata-eval9.3%
*-commutative9.3%
*-rgt-identity9.3%
fma-undefine9.3%
unpow29.3%
associate--r+53.9%
+-inverses99.9%
metadata-eval99.9%
associate-/l*99.9%
metadata-eval99.9%
*-commutative99.9%
neg-mul-199.9%
Simplified99.9%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001Initial program 19.8%
+-commutative19.8%
hypot-1-def19.8%
Simplified19.8%
add-sqr-sqrt19.6%
pow219.6%
log-pow19.5%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt19.6%
Applied egg-rr19.6%
Taylor expanded in x around 0 100.0%
unpow2100.0%
associate-*r*100.0%
fmm-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 62.2%
+-commutative62.2%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.009999999776482582)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.009999999776482582f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.009999999776482582)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.009999999776482582)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.2%
metadata-eval11.2%
Applied egg-rr11.2%
+-rgt-identity11.2%
Simplified11.2%
Taylor expanded in x around -inf 98.8%
if -10 < x < 0.00999999978Initial program 19.3%
+-commutative19.3%
hypot-1-def19.3%
Simplified19.3%
add-sqr-sqrt19.1%
pow219.1%
log-pow19.0%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt19.1%
Applied egg-rr19.1%
Taylor expanded in x around 0 99.7%
distribute-rgt-in99.7%
*-lft-identity99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
Simplified99.7%
if 0.00999999978 < x Initial program 63.2%
+-commutative63.2%
hypot-1-def99.7%
Simplified99.7%
*-un-lft-identity99.7%
*-commutative99.7%
log-prod99.7%
add-sqr-sqrt99.7%
fabs-sqr99.7%
add-sqr-sqrt99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.009999999776482582)
(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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.009999999776482582f) {
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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.009999999776482582)) 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.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.009999999776482582)) 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\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.200000003Initial program 56.8%
+-commutative56.8%
hypot-1-def99.9%
Simplified99.9%
flip-+6.6%
clear-num6.6%
log-div6.6%
metadata-eval6.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.1%
pow28.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.1%
hypot-1-def9.1%
hypot-1-def7.5%
add-sqr-sqrt9.3%
+-commutative9.3%
Applied egg-rr9.3%
neg-sub09.3%
div-sub9.2%
fma-undefine9.2%
unpow29.2%
associate--r+9.3%
+-inverses9.3%
metadata-eval9.3%
*-rgt-identity9.3%
associate-/l*9.3%
metadata-eval9.3%
*-commutative9.3%
*-rgt-identity9.3%
fma-undefine9.3%
unpow29.3%
associate--r+53.9%
+-inverses99.9%
metadata-eval99.9%
associate-/l*99.9%
metadata-eval99.9%
*-commutative99.9%
neg-mul-199.9%
Simplified99.9%
if -0.200000003 < x < 0.00999999978Initial program 18.6%
+-commutative18.6%
hypot-1-def18.7%
Simplified18.7%
add-sqr-sqrt18.5%
pow218.5%
log-pow18.4%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt18.5%
Applied egg-rr18.5%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.00999999978 < x Initial program 63.2%
+-commutative63.2%
hypot-1-def99.7%
Simplified99.7%
*-un-lft-identity99.7%
*-commutative99.7%
log-prod99.7%
add-sqr-sqrt99.7%
fabs-sqr99.7%
add-sqr-sqrt99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.2%
metadata-eval11.2%
Applied egg-rr11.2%
+-rgt-identity11.2%
Simplified11.2%
Taylor expanded in x around -inf 98.8%
if -10 < x < 0.200000003Initial program 21.0%
+-commutative21.0%
hypot-1-def21.0%
Simplified21.0%
add-sqr-sqrt20.7%
pow220.7%
log-pow20.7%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt20.8%
Applied egg-rr20.8%
Taylor expanded in x around 0 99.3%
distribute-rgt-in99.3%
*-lft-identity99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
unpow299.3%
cube-mult99.3%
Simplified99.3%
if 0.200000003 < x Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (- x)) x)
(if (<= x 0.20000000298023224)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 43.9%
mul-1-neg43.9%
Simplified43.9%
if -10 < x < 0.200000003Initial program 21.0%
+-commutative21.0%
hypot-1-def21.0%
Simplified21.0%
add-sqr-sqrt20.7%
pow220.7%
log-pow20.7%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt20.8%
Applied egg-rr20.8%
Taylor expanded in x around 0 98.0%
if 0.200000003 < x Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification84.8%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.2%
metadata-eval11.2%
Applied egg-rr11.2%
+-rgt-identity11.2%
Simplified11.2%
Taylor expanded in x around -inf 98.8%
if -10 < x < 0.200000003Initial program 21.0%
+-commutative21.0%
hypot-1-def21.0%
Simplified21.0%
add-sqr-sqrt20.7%
pow220.7%
log-pow20.7%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt20.8%
Applied egg-rr20.8%
Taylor expanded in x around 0 98.0%
if 0.200000003 < x Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification98.1%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 43.9%
mul-1-neg43.9%
Simplified43.9%
if -10 < x Initial program 33.8%
+-commutative33.8%
hypot-1-def45.8%
Simplified45.8%
Taylor expanded in x around 0 26.4%
log1p-define78.8%
rem-square-sqrt48.3%
fabs-sqr48.3%
rem-square-sqrt78.8%
Simplified78.8%
Final simplification70.3%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.20000000298023224)) 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.20000000298023224:\\
\;\;\;\;\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.200000003Initial program 32.1%
+-commutative32.1%
hypot-1-def46.1%
Simplified46.1%
add-sqr-sqrt45.9%
pow245.9%
log-pow45.9%
add-sqr-sqrt7.5%
fabs-sqr7.5%
add-sqr-sqrt17.7%
Applied egg-rr17.7%
Taylor expanded in x around 0 70.6%
if 0.200000003 < x Initial program 61.7%
+-commutative61.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 44.3%
log1p-define44.3%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt44.3%
Simplified44.3%
Final simplification64.3%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 39.2%
+-commutative39.2%
hypot-1-def58.9%
Simplified58.9%
add-sqr-sqrt58.8%
pow258.8%
log-pow58.8%
add-sqr-sqrt29.5%
fabs-sqr29.5%
add-sqr-sqrt37.3%
Applied egg-rr37.3%
Taylor expanded in x around 0 56.4%
Final simplification56.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 2024130
(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))