
(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.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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.019999999552965164f) {
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) 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.019999999552965164)) 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) 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.019999999552965164)) 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}
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.019999999552965164:\\
\;\;\;\;\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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.100000001Initial program 59.9%
flip-+9.9%
frac-2neg9.9%
log-div10.0%
Applied egg-rr17.3%
neg-sub017.3%
associate--r-17.3%
neg-sub017.3%
+-commutative17.3%
fma-undefine16.9%
unpow216.9%
+-commutative16.9%
associate-+l+57.1%
sub-neg57.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0199999996Initial program 18.4%
*-un-lft-identity18.4%
*-commutative18.4%
log-prod18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt19.0%
+-commutative19.0%
hypot-1-def19.2%
metadata-eval19.2%
Applied egg-rr19.2%
+-rgt-identity19.2%
Simplified19.2%
Taylor expanded in x around 0 99.9%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.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 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
*-un-lft-identity50.0%
*-un-lft-identity50.0%
add-sqr-sqrt50.0%
fabs-sqr50.0%
add-sqr-sqrt50.0%
+-commutative50.0%
hypot-1-def97.4%
metadata-eval97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
Simplified97.4%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(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 <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
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(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.019999999552965164)) 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(-1.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.019999999552965164)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 < -1Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.6%
+-commutative13.6%
hypot-1-def13.7%
metadata-eval13.7%
Applied egg-rr13.7%
+-rgt-identity13.7%
Simplified13.7%
Taylor expanded in x around -inf 97.8%
clear-num97.8%
log-div97.9%
metadata-eval97.9%
div-inv97.9%
metadata-eval97.9%
Applied egg-rr97.9%
neg-sub097.9%
Simplified97.9%
if -1 < x < 0.0199999996Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 99.6%
distribute-rgt-in99.7%
*-lft-identity99.7%
associate-*l*99.7%
unpow299.7%
unpow399.7%
Simplified99.7%
if 0.0199999996 < x Initial program 50.0%
*-un-lft-identity50.0%
*-commutative50.0%
log-prod50.0%
*-un-lft-identity50.0%
*-un-lft-identity50.0%
add-sqr-sqrt50.0%
fabs-sqr50.0%
add-sqr-sqrt50.0%
+-commutative50.0%
hypot-1-def97.4%
metadata-eval97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
Simplified97.4%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log x) (log 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((logf(x) + logf(2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(log(x) + log(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((x * single(-2.0)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((log(x) + log(single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 x + \log 2, x\right)\\
\end{array}
\end{array}
if x < -1Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.6%
+-commutative13.6%
hypot-1-def13.7%
metadata-eval13.7%
Applied egg-rr13.7%
+-rgt-identity13.7%
Simplified13.7%
Taylor expanded in x around -inf 97.8%
clear-num97.8%
log-div97.9%
metadata-eval97.9%
div-inv97.9%
metadata-eval97.9%
Applied egg-rr97.9%
neg-sub097.9%
Simplified97.9%
if -1 < x < 1Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
*-un-lft-identity19.8%
*-un-lft-identity19.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt20.5%
+-commutative20.5%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate-*l*99.2%
unpow299.2%
unpow399.2%
Simplified99.2%
if 1 < x Initial program 49.4%
Taylor expanded in x around inf 94.6%
rem-square-sqrt94.6%
fabs-sqr94.6%
rem-square-sqrt94.6%
Simplified94.6%
log-prod96.2%
*-inverses96.2%
metadata-eval96.2%
Applied egg-rr96.2%
Final simplification98.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) 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 <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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(-1.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -1Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.6%
+-commutative13.6%
hypot-1-def13.7%
metadata-eval13.7%
Applied egg-rr13.7%
+-rgt-identity13.7%
Simplified13.7%
Taylor expanded in x around -inf 97.8%
clear-num97.8%
log-div97.9%
metadata-eval97.9%
div-inv97.9%
metadata-eval97.9%
Applied egg-rr97.9%
neg-sub097.9%
Simplified97.9%
if -1 < x < 1Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
*-un-lft-identity19.8%
*-un-lft-identity19.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt20.5%
+-commutative20.5%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 99.2%
distribute-rgt-in99.2%
*-lft-identity99.2%
associate-*l*99.2%
unpow299.2%
unpow399.2%
Simplified99.2%
if 1 < x Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt49.4%
+-commutative49.4%
hypot-1-def97.4%
metadata-eval97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
Simplified97.4%
Taylor expanded in x around inf 94.6%
Final simplification97.5%
(FPCore (x) :precision binary32 (if (<= x -1.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 <= -1.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(-1.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(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.6%
+-commutative13.6%
hypot-1-def13.7%
metadata-eval13.7%
Applied egg-rr13.7%
+-rgt-identity13.7%
Simplified13.7%
Taylor expanded in x around -inf 97.8%
if -1 < x < 1Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
*-un-lft-identity19.8%
*-un-lft-identity19.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt20.5%
+-commutative20.5%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 98.4%
if 1 < x Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt49.4%
+-commutative49.4%
hypot-1-def97.4%
metadata-eval97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
Simplified97.4%
Taylor expanded in x around inf 94.6%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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(-1.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -1Initial program 59.3%
*-un-lft-identity59.3%
*-commutative59.3%
log-prod59.3%
*-un-lft-identity59.3%
*-un-lft-identity59.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.6%
+-commutative13.6%
hypot-1-def13.7%
metadata-eval13.7%
Applied egg-rr13.7%
+-rgt-identity13.7%
Simplified13.7%
Taylor expanded in x around -inf 97.8%
clear-num97.8%
log-div97.9%
metadata-eval97.9%
div-inv97.9%
metadata-eval97.9%
Applied egg-rr97.9%
neg-sub097.9%
Simplified97.9%
if -1 < x < 1Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
*-un-lft-identity19.8%
*-un-lft-identity19.8%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt20.5%
+-commutative20.5%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 98.4%
if 1 < x Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt49.4%
+-commutative49.4%
hypot-1-def97.4%
metadata-eval97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
Simplified97.4%
Taylor expanded in x around inf 94.6%
Final simplification97.2%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
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(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(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 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 < 1Initial program 34.8%
*-un-lft-identity34.8%
*-commutative34.8%
log-prod34.8%
*-un-lft-identity34.8%
*-un-lft-identity34.8%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt17.9%
+-commutative17.9%
hypot-1-def18.0%
metadata-eval18.0%
Applied egg-rr18.0%
+-rgt-identity18.0%
Simplified18.0%
Taylor expanded in x around 0 65.6%
if 1 < x Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt49.4%
+-commutative49.4%
hypot-1-def97.4%
metadata-eval97.4%
Applied egg-rr97.4%
+-rgt-identity97.4%
Simplified97.4%
Taylor expanded in x around inf 94.6%
Final simplification74.0%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 34.8%
*-un-lft-identity34.8%
*-commutative34.8%
log-prod34.8%
*-un-lft-identity34.8%
*-un-lft-identity34.8%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt17.9%
+-commutative17.9%
hypot-1-def18.0%
metadata-eval18.0%
Applied egg-rr18.0%
+-rgt-identity18.0%
Simplified18.0%
Taylor expanded in x around 0 65.6%
if 1 < x Initial program 49.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%
Final simplification59.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.0%
*-un-lft-identity39.0%
*-commutative39.0%
log-prod39.0%
*-un-lft-identity39.0%
*-un-lft-identity39.0%
add-sqr-sqrt18.8%
fabs-sqr18.8%
add-sqr-sqrt27.0%
+-commutative27.0%
hypot-1-def40.9%
metadata-eval40.9%
Applied egg-rr40.9%
+-rgt-identity40.9%
Simplified40.9%
Taylor expanded in x around 0 49.9%
Final simplification49.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 2024078
(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))