
(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 11 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 -0.10000000149011612)
(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.10000000149011612f) {
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.10000000149011612)) tmp = copysign(Float32(-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.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 55.2%
fma-define55.2%
Simplified55.2%
Applied egg-rr15.4%
fma-undefine15.4%
unpow215.4%
associate--r+52.1%
+-inverses97.2%
metadata-eval97.2%
metadata-eval97.2%
metadata-eval97.2%
neg-sub097.2%
neg-sub097.2%
associate--r-97.2%
neg-sub097.2%
+-commutative97.2%
sub-neg97.2%
Simplified97.2%
if -0.100000001 < x < 0.0199999996Initial program 18.2%
fma-define18.2%
Simplified18.2%
fma-undefine18.2%
+-commutative18.2%
hypot-1-def18.3%
*-un-lft-identity18.3%
*-commutative18.3%
log-prod18.3%
*-un-lft-identity18.3%
*-un-lft-identity18.3%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt18.8%
metadata-eval18.8%
Applied egg-rr18.8%
+-rgt-identity18.8%
Simplified18.8%
Taylor expanded in x around 0 99.9%
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 49.0%
fma-define49.1%
Simplified49.1%
fma-undefine49.0%
+-commutative49.0%
hypot-1-def99.8%
*-un-lft-identity99.8%
*-commutative99.8%
log-prod99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.2%
(FPCore (x) :precision binary32 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -5.0) (copysign (+ (log (/ -1.0 x)) (log 0.5)) x) (copysign (log1p (+ 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((-1.0f / x)) + logf(0.5f)), x);
} else {
tmp = copysignf(log1pf((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(Float32(log(Float32(Float32(-1.0) / x)) + log(Float32(0.5))), x); else tmp = copysign(log1p(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{-1}{x}\right) + \log 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(-1 + \mathsf{hypot}\left(1, x\right)\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) < -5Initial program 51.8%
fma-define51.8%
Simplified51.8%
fma-undefine51.8%
+-commutative51.8%
hypot-1-def97.1%
*-un-lft-identity97.1%
*-commutative97.1%
log-prod97.1%
*-un-lft-identity97.1%
*-un-lft-identity97.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.6%
metadata-eval9.6%
Applied egg-rr9.6%
+-rgt-identity9.6%
Simplified9.6%
Taylor expanded in x around -inf 98.4%
+-commutative98.4%
Simplified98.4%
if -5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 29.8%
fma-define29.8%
Simplified29.8%
fma-undefine29.8%
+-commutative29.8%
hypot-1-def45.4%
*-un-lft-identity45.4%
*-commutative45.4%
log-prod45.4%
*-un-lft-identity45.4%
*-un-lft-identity45.4%
add-sqr-sqrt36.0%
fabs-sqr36.0%
add-sqr-sqrt45.4%
metadata-eval45.4%
Applied egg-rr45.4%
+-rgt-identity45.4%
Simplified45.4%
log1p-expm1-u45.4%
expm1-undefine45.4%
add-exp-log45.4%
Applied egg-rr45.4%
associate--l+98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x)
:precision binary32
(if (<= x -5.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 <= -5.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(-5.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(-5.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 -5:\\
\;\;\;\;\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 < -5Initial program 54.6%
fma-define54.6%
Simplified54.6%
Taylor expanded in x around -inf 94.5%
neg-mul-194.5%
Simplified94.5%
if -5 < x < 0.0199999996Initial program 18.8%
fma-define18.8%
Simplified18.8%
fma-undefine18.8%
+-commutative18.8%
hypot-1-def18.8%
*-un-lft-identity18.8%
*-commutative18.8%
log-prod18.8%
*-un-lft-identity18.8%
*-un-lft-identity18.8%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
Taylor expanded in x around 0 99.7%
distribute-lft-in99.8%
*-rgt-identity99.8%
*-commutative99.8%
associate-*r*99.8%
unpow299.8%
cube-mult99.8%
Simplified99.8%
if 0.0199999996 < x Initial program 49.0%
fma-define49.1%
Simplified49.1%
fma-undefine49.0%
+-commutative49.0%
hypot-1-def99.8%
*-un-lft-identity99.8%
*-commutative99.8%
log-prod99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification98.4%
(FPCore (x) :precision binary32 (if (<= x 5.000000058430487e-8) (copysign (log1p (fabs x)) x) (copysign (log (+ x (hypot 1.0 x))) x)))
float code(float x) {
float tmp;
if (x <= 5.000000058430487e-8f) {
tmp = copysignf(log1pf(fabsf(x)), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(5.000000058430487e-8)) tmp = copysign(log1p(abs(x)), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\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 x < 5.00000006e-8Initial program 29.6%
fma-define29.6%
Simplified29.6%
Taylor expanded in x around 0 25.0%
log1p-define78.5%
Simplified78.5%
if 5.00000006e-8 < x Initial program 51.9%
fma-define52.0%
Simplified52.0%
fma-undefine51.9%
+-commutative51.9%
hypot-1-def98.1%
*-un-lft-identity98.1%
*-commutative98.1%
log-prod98.1%
*-un-lft-identity98.1%
*-un-lft-identity98.1%
add-sqr-sqrt98.1%
fabs-sqr98.1%
add-sqr-sqrt98.1%
metadata-eval98.1%
Applied egg-rr98.1%
+-rgt-identity98.1%
Simplified98.1%
Final simplification83.4%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign (log1p (fabs x)) x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
tmp = copysignf(log1pf(fabsf(x)), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.20000000298023224)) tmp = copysign(log1p(abs(x)), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.200000003Initial program 31.4%
fma-define31.4%
Simplified31.4%
Taylor expanded in x around 0 26.0%
log1p-define77.5%
Simplified77.5%
if 0.200000003 < x Initial program 48.3%
fma-define48.4%
Simplified48.4%
fma-undefine48.3%
+-commutative48.3%
hypot-1-def99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification82.0%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- (/ -0.5 x) x)) x)
(if (<= x 2.0)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(((-0.5f / x) - x)), x);
} else if (x <= 2.0f) {
tmp = copysignf((x + (powf(x, 3.0f) * -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(Float32(Float32(-0.5) / x) - x)), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * 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(((single(-0.5) / x) - x))); elseif (x <= single(2.0)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * 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(\frac{-0.5}{x} - x\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 54.6%
fma-define54.6%
Simplified54.6%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
neg-sub096.6%
+-commutative96.6%
distribute-rgt-in96.6%
*-lft-identity96.6%
associate--r+96.6%
Simplified12.8%
Taylor expanded in x around 0 44.0%
if -5 < x < 2Initial program 19.9%
fma-define19.9%
Simplified19.9%
fma-undefine19.9%
+-commutative19.9%
hypot-1-def20.0%
*-un-lft-identity20.0%
*-commutative20.0%
log-prod20.0%
*-un-lft-identity20.0%
*-un-lft-identity20.0%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt20.5%
metadata-eval20.5%
Applied egg-rr20.5%
+-rgt-identity20.5%
Simplified20.5%
Taylor expanded in x around 0 99.1%
distribute-lft-in99.2%
*-rgt-identity99.2%
*-commutative99.2%
associate-*r*99.2%
unpow299.2%
cube-mult99.2%
Simplified99.2%
if 2 < x Initial program 47.5%
fma-define47.5%
Simplified47.5%
fma-undefine47.5%
+-commutative47.5%
hypot-1-def100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.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 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification84.4%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 2.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(-5.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(2.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(-5.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(2.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 -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\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 < -5Initial program 54.6%
fma-define54.6%
Simplified54.6%
Taylor expanded in x around -inf 44.0%
mul-1-neg44.0%
Simplified44.0%
if -5 < x < 2Initial program 19.9%
fma-define19.9%
Simplified19.9%
Taylor expanded in x around 0 16.7%
rem-square-sqrt7.2%
fabs-sqr7.2%
rem-square-sqrt17.2%
Simplified17.2%
Taylor expanded in x around 0 97.4%
if 2 < x Initial program 47.5%
fma-define47.5%
Simplified47.5%
fma-undefine47.5%
+-commutative47.5%
hypot-1-def100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.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 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- (/ -0.5 x) x)) x) (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(((-0.5f / x) - x)), x);
} else if (x <= 2.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(-5.0)) tmp = copysign(log(Float32(Float32(Float32(-0.5) / x) - x)), x); elseif (x <= Float32(2.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(-5.0)) tmp = sign(x) * abs(log(((single(-0.5) / x) - x))); elseif (x <= single(2.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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x} - x\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\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 < -5Initial program 54.6%
fma-define54.6%
Simplified54.6%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
neg-sub096.6%
+-commutative96.6%
distribute-rgt-in96.6%
*-lft-identity96.6%
associate--r+96.6%
Simplified12.8%
Taylor expanded in x around 0 44.0%
if -5 < x < 2Initial program 19.9%
fma-define19.9%
Simplified19.9%
Taylor expanded in x around 0 16.7%
rem-square-sqrt7.2%
fabs-sqr7.2%
rem-square-sqrt17.2%
Simplified17.2%
Taylor expanded in x around 0 97.4%
if 2 < x Initial program 47.5%
fma-define47.5%
Simplified47.5%
fma-undefine47.5%
+-commutative47.5%
hypot-1-def100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.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 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 2.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(2.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(2.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 2:\\
\;\;\;\;\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 < 2Initial program 31.8%
fma-define31.8%
Simplified31.8%
Taylor expanded in x around 0 26.0%
rem-square-sqrt4.7%
fabs-sqr4.7%
rem-square-sqrt11.3%
Simplified11.3%
Taylor expanded in x around 0 68.1%
if 2 < x Initial program 47.5%
fma-define47.5%
Simplified47.5%
fma-undefine47.5%
+-commutative47.5%
hypot-1-def100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.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 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification74.9%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.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 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 2Initial program 31.8%
fma-define31.8%
Simplified31.8%
Taylor expanded in x around 0 26.0%
rem-square-sqrt4.7%
fabs-sqr4.7%
rem-square-sqrt11.3%
Simplified11.3%
Taylor expanded in x around 0 68.1%
if 2 < x Initial program 47.5%
fma-define47.5%
Simplified47.5%
Taylor expanded in x around 0 44.8%
log1p-define44.8%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt44.8%
Simplified44.8%
Final simplification62.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.3%
fma-define35.3%
Simplified35.3%
Taylor expanded in x around 0 30.2%
rem-square-sqrt13.7%
fabs-sqr13.7%
rem-square-sqrt18.8%
Simplified18.8%
Taylor expanded in x around 0 55.3%
Final simplification55.3%
(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 2024055
(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))