
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.0020000000949949026)
(copysign
(*
x
(+ 1.0 (* (pow x 2.0) (- (* (pow x 2.0) 0.075) 0.16666666666666666))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.0020000000949949026f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * 0.075f) - 0.16666666666666666f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.0020000000949949026)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(0.075)) - Float32(0.16666666666666666))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.0020000000949949026)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * single(0.075)) - single(0.16666666666666666)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.0020000000949949026:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.100000001Initial program 53.2%
+-commutative53.2%
hypot-1-def100.0%
Simplified100.0%
flip-+7.5%
clear-num7.5%
log-div7.4%
metadata-eval7.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.3%
pow29.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.3%
hypot-1-def9.3%
hypot-1-def9.3%
add-sqr-sqrt9.3%
+-commutative9.3%
Applied egg-rr9.3%
neg-sub09.3%
div-sub9.3%
fma-undefine9.4%
unpow29.4%
associate--r+9.3%
+-inverses9.3%
metadata-eval9.3%
*-rgt-identity9.3%
associate-/l*9.3%
metadata-eval9.3%
*-commutative9.3%
fma-undefine9.4%
unpow29.4%
associate--r+50.0%
+-inverses100.0%
metadata-eval100.0%
*-rgt-identity100.0%
associate-/l*100.0%
metadata-eval100.0%
*-commutative100.0%
neg-mul-1100.0%
Simplified100.0%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00200000009Initial program 19.0%
+-commutative19.0%
hypot-1-def19.0%
Simplified19.0%
expm1-log1p-u19.0%
expm1-undefine18.4%
log1p-undefine18.2%
rem-exp-log18.2%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt18.8%
Applied egg-rr18.8%
Taylor expanded in x around 0 100.0%
if 0.00200000009 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 48.3%
+-commutative48.3%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt100.0%
fabs-sqr100.0%
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 -20.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.0020000000949949026)
(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 <= -20.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.0020000000949949026f) {
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(-20.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.0020000000949949026)) 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(-20.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.0020000000949949026)) 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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\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 < -20Initial program 51.7%
+-commutative51.7%
hypot-1-def100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-undefine100.0%
log1p-undefine100.0%
rem-exp-log100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.5%
Applied egg-rr10.5%
Taylor expanded in x around -inf 98.8%
if -20 < x < 0.00200000009Initial program 20.2%
+-commutative20.2%
hypot-1-def20.3%
Simplified20.3%
*-un-lft-identity20.3%
*-commutative20.3%
log-prod20.3%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt20.4%
metadata-eval20.4%
Applied egg-rr20.4%
+-rgt-identity20.4%
Simplified20.4%
Taylor expanded in x around 0 99.1%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate-*l*99.2%
unpow299.2%
unpow399.2%
Simplified99.2%
if 0.00200000009 < x Initial program 48.3%
+-commutative48.3%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.0020000000949949026)
(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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.0020000000949949026f) {
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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.0020000000949949026)) 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.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.0020000000949949026)) 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\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.100000001Initial program 53.2%
+-commutative53.2%
hypot-1-def100.0%
Simplified100.0%
flip-+7.5%
clear-num7.5%
log-div7.4%
metadata-eval7.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.3%
pow29.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.3%
hypot-1-def9.3%
hypot-1-def9.3%
add-sqr-sqrt9.3%
+-commutative9.3%
Applied egg-rr9.3%
neg-sub09.3%
div-sub9.3%
fma-undefine9.4%
unpow29.4%
associate--r+9.3%
+-inverses9.3%
metadata-eval9.3%
*-rgt-identity9.3%
associate-/l*9.3%
metadata-eval9.3%
*-commutative9.3%
fma-undefine9.4%
unpow29.4%
associate--r+50.0%
+-inverses100.0%
metadata-eval100.0%
*-rgt-identity100.0%
associate-/l*100.0%
metadata-eval100.0%
*-commutative100.0%
neg-mul-1100.0%
Simplified100.0%
if -0.100000001 < x < 0.00200000009Initial program 19.0%
+-commutative19.0%
hypot-1-def19.0%
Simplified19.0%
*-un-lft-identity19.0%
*-commutative19.0%
log-prod19.0%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt19.2%
metadata-eval19.2%
Applied egg-rr19.2%
+-rgt-identity19.2%
Simplified19.2%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.00200000009 < x Initial program 48.3%
+-commutative48.3%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -20.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
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(-20.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-20.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -20Initial program 51.7%
+-commutative51.7%
hypot-1-def100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-undefine100.0%
log1p-undefine100.0%
rem-exp-log100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.5%
Applied egg-rr10.5%
Taylor expanded in x around -inf 98.8%
if -20 < x < 1Initial program 21.5%
+-commutative21.5%
hypot-1-def21.5%
Simplified21.5%
*-un-lft-identity21.5%
*-commutative21.5%
log-prod21.5%
add-sqr-sqrt10.1%
fabs-sqr10.1%
add-sqr-sqrt21.6%
metadata-eval21.6%
Applied egg-rr21.6%
+-rgt-identity21.6%
Simplified21.6%
Taylor expanded in x around 0 98.5%
distribute-rgt-in98.5%
*-lft-identity98.5%
associate-*l*98.5%
unpow298.5%
unpow398.5%
Simplified98.5%
if 1 < x Initial program 46.7%
+-commutative46.7%
hypot-1-def100.0%
Simplified100.0%
expm1-log1p-u99.8%
expm1-undefine99.8%
log1p-undefine99.8%
rem-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign (log (- x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.0)) 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(-20.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(1.0)) 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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -20Initial program 51.7%
+-commutative51.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.7%
mul-1-neg44.7%
Simplified44.7%
if -20 < x < 1Initial program 21.5%
+-commutative21.5%
hypot-1-def21.5%
Simplified21.5%
expm1-log1p-u21.4%
expm1-undefine20.8%
log1p-undefine20.6%
rem-exp-log20.7%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt21.1%
Applied egg-rr21.1%
Taylor expanded in x around 0 96.9%
if 1 < x Initial program 46.7%
+-commutative46.7%
hypot-1-def100.0%
Simplified100.0%
expm1-log1p-u99.8%
expm1-undefine99.8%
log1p-undefine99.8%
rem-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification84.4%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-20.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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 -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -20Initial program 51.7%
+-commutative51.7%
hypot-1-def100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-undefine100.0%
log1p-undefine100.0%
rem-exp-log100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.5%
Applied egg-rr10.5%
Taylor expanded in x around -inf 98.8%
if -20 < x < 1Initial program 21.5%
+-commutative21.5%
hypot-1-def21.5%
Simplified21.5%
expm1-log1p-u21.4%
expm1-undefine20.8%
log1p-undefine20.6%
rem-exp-log20.7%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt21.1%
Applied egg-rr21.1%
Taylor expanded in x around 0 96.9%
if 1 < x Initial program 46.7%
+-commutative46.7%
hypot-1-def100.0%
Simplified100.0%
expm1-log1p-u99.8%
expm1-undefine99.8%
log1p-undefine99.8%
rem-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification97.5%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 52.5%
+-commutative52.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.3%
mul-1-neg44.3%
Simplified44.3%
if -1 < x Initial program 29.6%
+-commutative29.6%
hypot-1-def47.5%
Simplified47.5%
Taylor expanded in x around 0 26.8%
log1p-define77.6%
rem-square-sqrt47.2%
fabs-sqr47.2%
rem-square-sqrt77.6%
Simplified77.6%
Final simplification69.4%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign -1.0 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-1.0f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-1.0), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-1, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 52.5%
+-commutative52.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 48.3%
mul-1-neg48.3%
unsub-neg48.3%
mul-1-neg48.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt40.7%
Simplified40.7%
Applied egg-rr21.0%
if -1 < x Initial program 29.6%
+-commutative29.6%
hypot-1-def47.5%
Simplified47.5%
Taylor expanded in x around 0 26.8%
log1p-define77.6%
rem-square-sqrt47.2%
fabs-sqr47.2%
rem-square-sqrt77.6%
Simplified77.6%
Final simplification63.7%
(FPCore (x) :precision binary32 (copysign -1.0 x))
float code(float x) {
return copysignf(-1.0f, x);
}
function code(x) return copysign(Float32(-1.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-1.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-1, x\right)
\end{array}
Initial program 35.2%
+-commutative35.2%
hypot-1-def60.4%
Simplified60.4%
Taylor expanded in x around -inf 14.4%
mul-1-neg14.4%
unsub-neg14.4%
mul-1-neg14.4%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.6%
Simplified12.6%
Applied egg-rr15.9%
Final simplification15.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 35.2%
+-commutative35.2%
hypot-1-def60.4%
Simplified60.4%
expm1-log1p-u60.3%
expm1-undefine60.0%
log1p-undefine60.0%
rem-exp-log60.0%
add-sqr-sqrt30.3%
fabs-sqr30.3%
add-sqr-sqrt38.6%
Applied egg-rr38.6%
Taylor expanded in x around 0 54.2%
Final simplification54.2%
(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 2024076
(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))