
(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
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.03999999910593033)
(copysign (+ x (* (pow x 3.0) -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.20000000298023224f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (t_0 <= 0.03999999910593033f) {
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) 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.20000000298023224)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.03999999910593033)) 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.20000000298023224)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.03999999910593033)) 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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.03999999910593033:\\
\;\;\;\;\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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.200000003Initial program 63.9%
+-commutative63.9%
hypot-1-def99.8%
flip-+16.2%
hypot-1-def16.2%
hypot-1-def16.2%
add-sqr-sqrt16.2%
+-commutative16.2%
hypot-1-def16.1%
+-commutative16.1%
div-sub15.9%
Applied egg-rr19.2%
div-sub22.5%
remove-double-neg22.5%
remove-double-neg22.5%
fma-undefine22.5%
unpow222.5%
associate--r+61.5%
+-inverses99.8%
metadata-eval99.8%
Simplified99.8%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.0399999991Initial program 20.1%
Taylor expanded in x around 0 21.2%
+-commutative21.2%
fma-define21.2%
rem-square-sqrt12.6%
fabs-sqr12.6%
rem-square-sqrt21.1%
log1p-define99.6%
rem-square-sqrt54.3%
fabs-sqr54.3%
rem-square-sqrt99.8%
Simplified99.8%
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.0399999991 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
*-un-lft-identity53.1%
*-un-lft-identity53.1%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt53.1%
+-commutative53.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (- (/ -0.5 x) x) x))) x)
(if (<= x 0.03999999910593033)
(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) - x)), x);
} else if (x <= 0.03999999910593033f) {
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(Float32(-log(Float32(Float32(Float32(Float32(-0.5) / x) - x) - x))), x); elseif (x <= Float32(0.03999999910593033)) 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) - x) - x))); elseif (x <= single(0.03999999910593033)) 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(\left(\frac{-0.5}{x} - x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 62.3%
flip-+12.2%
frac-2neg12.2%
log-div12.2%
pow212.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
add-sqr-sqrt11.9%
fma-define11.9%
Applied egg-rr18.6%
neg-sub018.6%
associate--r-18.6%
neg-sub018.6%
+-commutative18.6%
fma-undefine18.6%
unpow218.6%
+-commutative18.6%
associate-+l+59.6%
sub-neg59.6%
+-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%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
neg-sub097.5%
metadata-eval97.5%
associate-*r/97.5%
metadata-eval97.5%
unpow297.5%
associate-/r*97.5%
*-rgt-identity97.5%
associate-*r/97.5%
associate-+r+97.5%
rgt-mult-inverse97.5%
distribute-rgt-in97.5%
associate-*l/97.5%
*-lft-identity97.5%
distribute-rgt-in97.5%
*-lft-identity97.5%
+-commutative97.5%
Simplified97.5%
if -1 < x < 0.0399999991Initial program 21.8%
Taylor expanded in x around 0 21.9%
+-commutative21.9%
fma-define21.9%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt21.5%
log1p-define98.2%
rem-square-sqrt53.1%
fabs-sqr53.1%
rem-square-sqrt98.6%
Simplified98.6%
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.0399999991 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
*-un-lft-identity53.1%
*-un-lft-identity53.1%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt53.1%
+-commutative53.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.03999999910593033)
(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.03999999910593033f) {
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(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.03999999910593033)) 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.03999999910593033)) 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.03999999910593033:\\
\;\;\;\;\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 63.9%
flip-+16.4%
frac-2neg16.4%
log-div16.4%
pow216.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.4%
add-sqr-sqrt16.1%
fma-define16.1%
Applied egg-rr22.4%
neg-sub022.4%
associate--r-22.4%
neg-sub022.4%
+-commutative22.4%
fma-undefine22.4%
unpow222.4%
+-commutative22.4%
associate-+l+61.4%
sub-neg61.4%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
if -0.200000003 < x < 0.0399999991Initial program 20.1%
Taylor expanded in x around 0 21.2%
+-commutative21.2%
fma-define21.2%
rem-square-sqrt12.6%
fabs-sqr12.6%
rem-square-sqrt21.1%
log1p-define99.6%
rem-square-sqrt54.3%
fabs-sqr54.3%
rem-square-sqrt99.8%
Simplified99.8%
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.0399999991 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
*-un-lft-identity53.1%
*-un-lft-identity53.1%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt53.1%
+-commutative53.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (- (/ -0.5 x) x) x))) x)
(if (<= x 1.0)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (* x (/ (+ x (/ 0.5 x)) x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((((-0.5f / x) - x) - x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x + (x * ((x + (0.5f / x)) / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(Float32(Float32(-0.5) / x) - x) - x))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x + Float32(x * Float32(Float32(x + Float32(Float32(0.5) / x)) / 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) - x) - x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x + (x * ((x + (single(0.5) / x)) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\left(\frac{-0.5}{x} - x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x \cdot \frac{x + \frac{0.5}{x}}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 62.3%
flip-+12.2%
frac-2neg12.2%
log-div12.2%
pow212.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
add-sqr-sqrt11.9%
fma-define11.9%
Applied egg-rr18.6%
neg-sub018.6%
associate--r-18.6%
neg-sub018.6%
+-commutative18.6%
fma-undefine18.6%
unpow218.6%
+-commutative18.6%
associate-+l+59.6%
sub-neg59.6%
+-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%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
neg-sub097.5%
metadata-eval97.5%
associate-*r/97.5%
metadata-eval97.5%
unpow297.5%
associate-/r*97.5%
*-rgt-identity97.5%
associate-*r/97.5%
associate-+r+97.5%
rgt-mult-inverse97.5%
distribute-rgt-in97.5%
associate-*l/97.5%
*-lft-identity97.5%
distribute-rgt-in97.5%
*-lft-identity97.5%
+-commutative97.5%
Simplified97.5%
if -1 < x < 1Initial program 23.5%
Taylor expanded in x around 0 22.5%
+-commutative22.5%
fma-define22.5%
rem-square-sqrt13.2%
fabs-sqr13.2%
rem-square-sqrt22.1%
log1p-define97.1%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt97.5%
Simplified97.5%
Taylor expanded in x around 0 98.2%
distribute-lft-in98.2%
*-rgt-identity98.2%
*-commutative98.2%
associate-*r*98.2%
unpow298.2%
cube-mult98.2%
Simplified98.2%
if 1 < x Initial program 50.9%
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-sqrt7.1%
fabs-sqr7.1%
rem-square-sqrt5.6%
associate-*r/5.6%
metadata-eval5.6%
distribute-neg-frac5.6%
metadata-eval5.6%
Simplified5.6%
*-commutative5.6%
sub-neg5.6%
distribute-rgt-in5.6%
*-un-lft-identity5.6%
add-sqr-sqrt-0.0%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-prod96.7%
add-sqr-sqrt96.8%
Applied egg-rr99.2%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (* x (+ (/ x x) 1.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 + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x * ((x / x) + 1.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(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x * Float32(Float32(x / x) + Float32(1.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 + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x * ((x / x) + single(1.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}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot \left(\frac{x}{x} + 1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 62.3%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
*-commutative97.5%
distribute-rgt-neg-in97.5%
mul-1-neg97.5%
unsub-neg97.5%
sub-neg97.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.8%
associate-*r/13.8%
metadata-eval13.8%
distribute-neg-frac13.8%
metadata-eval13.8%
Simplified13.8%
Taylor expanded in x around 0 95.3%
if -1 < x < 1Initial program 23.5%
Taylor expanded in x around 0 22.5%
+-commutative22.5%
fma-define22.5%
rem-square-sqrt13.2%
fabs-sqr13.2%
rem-square-sqrt22.1%
log1p-define97.1%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt97.5%
Simplified97.5%
Taylor expanded in x around 0 98.2%
distribute-lft-in98.2%
*-rgt-identity98.2%
*-commutative98.2%
associate-*r*98.2%
unpow298.2%
cube-mult98.2%
Simplified98.2%
if 1 < x Initial program 50.9%
Taylor expanded in x around inf 97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
Simplified97.2%
Final simplification97.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (- (/ -0.5 x) x) x))) x)
(if (<= x 1.0)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (* x (+ (/ x x) 1.0))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((((-0.5f / x) - x) - x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x * ((x / x) + 1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(Float32(Float32(-0.5) / x) - x) - x))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x * Float32(Float32(x / x) + Float32(1.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) - x) - x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x * ((x / x) + single(1.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\left(\frac{-0.5}{x} - x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot \left(\frac{x}{x} + 1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 62.3%
flip-+12.2%
frac-2neg12.2%
log-div12.2%
pow212.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
add-sqr-sqrt11.9%
fma-define11.9%
Applied egg-rr18.6%
neg-sub018.6%
associate--r-18.6%
neg-sub018.6%
+-commutative18.6%
fma-undefine18.6%
unpow218.6%
+-commutative18.6%
associate-+l+59.6%
sub-neg59.6%
+-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%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
neg-sub097.5%
metadata-eval97.5%
associate-*r/97.5%
metadata-eval97.5%
unpow297.5%
associate-/r*97.5%
*-rgt-identity97.5%
associate-*r/97.5%
associate-+r+97.5%
rgt-mult-inverse97.5%
distribute-rgt-in97.5%
associate-*l/97.5%
*-lft-identity97.5%
distribute-rgt-in97.5%
*-lft-identity97.5%
+-commutative97.5%
Simplified97.5%
if -1 < x < 1Initial program 23.5%
Taylor expanded in x around 0 22.5%
+-commutative22.5%
fma-define22.5%
rem-square-sqrt13.2%
fabs-sqr13.2%
rem-square-sqrt22.1%
log1p-define97.1%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt97.5%
Simplified97.5%
Taylor expanded in x around 0 98.2%
distribute-lft-in98.2%
*-rgt-identity98.2%
*-commutative98.2%
associate-*r*98.2%
unpow298.2%
cube-mult98.2%
Simplified98.2%
if 1 < x Initial program 50.9%
Taylor expanded in x around inf 97.2%
rem-square-sqrt97.2%
fabs-sqr97.2%
rem-square-sqrt97.2%
Simplified97.2%
Final simplification97.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(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 <= 1.0f) {
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(1.0)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(Float32(-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(1.0)) 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 1:\\
\;\;\;\;\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 62.3%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
*-commutative97.5%
distribute-rgt-neg-in97.5%
mul-1-neg97.5%
unsub-neg97.5%
sub-neg97.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.8%
associate-*r/13.8%
metadata-eval13.8%
distribute-neg-frac13.8%
metadata-eval13.8%
Simplified13.8%
Taylor expanded in x around 0 95.3%
if -1 < x < 1Initial program 23.5%
Taylor expanded in x around 0 22.5%
+-commutative22.5%
fma-define22.5%
rem-square-sqrt13.2%
fabs-sqr13.2%
rem-square-sqrt22.1%
log1p-define97.1%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt97.5%
Simplified97.5%
Taylor expanded in x around 0 98.2%
distribute-lft-in98.2%
*-rgt-identity98.2%
*-commutative98.2%
associate-*r*98.2%
unpow298.2%
cube-mult98.2%
Simplified98.2%
if 1 < x Initial program 50.9%
flip-+9.6%
frac-2neg9.6%
log-div9.6%
pow29.6%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt9.6%
add-sqr-sqrt8.8%
fma-define8.9%
Applied egg-rr9.0%
neg-sub09.0%
associate--r-9.0%
neg-sub09.0%
+-commutative9.0%
fma-undefine8.9%
unpow28.9%
+-commutative8.9%
associate-+l+11.1%
sub-neg11.1%
+-inverses14.5%
metadata-eval14.5%
metadata-eval14.5%
neg-sub014.5%
neg-sub014.5%
associate--r-14.5%
neg-sub014.5%
+-commutative14.5%
sub-neg14.5%
Simplified14.5%
Taylor expanded in x around inf 97.2%
Final simplification97.3%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x 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 <= 1.0f) {
tmp = copysignf(x, 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(1.0)) tmp = copysign(x, x); else tmp = copysign(Float32(-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(1.0)) tmp = sign(x) * abs(x); 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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 62.3%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
*-commutative97.5%
distribute-rgt-neg-in97.5%
mul-1-neg97.5%
unsub-neg97.5%
sub-neg97.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.8%
associate-*r/13.8%
metadata-eval13.8%
distribute-neg-frac13.8%
metadata-eval13.8%
Simplified13.8%
Taylor expanded in x around 0 95.3%
if -1 < x < 1Initial program 23.5%
flip-+23.5%
frac-2neg23.5%
log-div23.8%
pow223.8%
add-sqr-sqrt13.5%
fabs-sqr13.5%
add-sqr-sqrt23.8%
add-sqr-sqrt23.9%
fma-define23.9%
Applied egg-rr23.5%
neg-sub023.5%
associate--r-23.5%
neg-sub023.5%
+-commutative23.5%
fma-undefine23.5%
unpow223.5%
+-commutative23.5%
associate-+l+23.6%
sub-neg23.6%
+-inverses23.6%
metadata-eval23.6%
metadata-eval23.6%
neg-sub023.6%
neg-sub023.6%
associate--r-23.6%
neg-sub023.6%
+-commutative23.6%
sub-neg23.6%
Simplified23.6%
Taylor expanded in x around 0 97.0%
mul-1-neg97.0%
Simplified97.0%
if 1 < x Initial program 50.9%
flip-+9.6%
frac-2neg9.6%
log-div9.6%
pow29.6%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt9.6%
add-sqr-sqrt8.8%
fma-define8.9%
Applied egg-rr9.0%
neg-sub09.0%
associate--r-9.0%
neg-sub09.0%
+-commutative9.0%
fma-undefine8.9%
unpow28.9%
+-commutative8.9%
associate-+l+11.1%
sub-neg11.1%
+-inverses14.5%
metadata-eval14.5%
metadata-eval14.5%
neg-sub014.5%
neg-sub014.5%
associate--r-14.5%
neg-sub014.5%
+-commutative14.5%
sub-neg14.5%
Simplified14.5%
Taylor expanded in x around inf 97.2%
Final simplification96.7%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 1.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(1.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(1.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 + 1\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 34.8%
flip-+20.2%
frac-2neg20.2%
log-div20.4%
pow220.4%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt20.4%
add-sqr-sqrt20.4%
fma-define20.4%
Applied egg-rr22.1%
neg-sub022.1%
associate--r-22.1%
neg-sub022.1%
+-commutative22.1%
fma-undefine22.1%
unpow222.1%
+-commutative22.1%
associate-+l+34.1%
sub-neg34.1%
+-inverses45.9%
metadata-eval45.9%
metadata-eval45.9%
neg-sub045.9%
neg-sub045.9%
associate--r-45.9%
neg-sub045.9%
+-commutative45.9%
sub-neg45.9%
Simplified45.9%
Taylor expanded in x around 0 72.3%
mul-1-neg72.3%
Simplified72.3%
if 1 < x Initial program 50.9%
Taylor expanded in x around 0 44.1%
rem-square-sqrt44.1%
fabs-sqr44.1%
rem-square-sqrt44.1%
Simplified44.1%
Final simplification65.6%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / 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(Float32(-0.5) / 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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 62.3%
Taylor expanded in x around -inf 97.5%
mul-1-neg97.5%
*-commutative97.5%
distribute-rgt-neg-in97.5%
mul-1-neg97.5%
unsub-neg97.5%
sub-neg97.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt13.8%
associate-*r/13.8%
metadata-eval13.8%
distribute-neg-frac13.8%
metadata-eval13.8%
Simplified13.8%
Taylor expanded in x around 0 95.3%
if -1 < x Initial program 31.9%
Taylor expanded in x around 0 27.3%
log1p-define78.2%
rem-square-sqrt48.2%
fabs-sqr48.2%
rem-square-sqrt78.1%
Simplified78.1%
Final simplification82.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%
flip-+20.2%
frac-2neg20.2%
log-div20.4%
pow220.4%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt20.4%
add-sqr-sqrt20.4%
fma-define20.4%
Applied egg-rr22.1%
neg-sub022.1%
associate--r-22.1%
neg-sub022.1%
+-commutative22.1%
fma-undefine22.1%
unpow222.1%
+-commutative22.1%
associate-+l+34.1%
sub-neg34.1%
+-inverses45.9%
metadata-eval45.9%
metadata-eval45.9%
neg-sub045.9%
neg-sub045.9%
associate--r-45.9%
neg-sub045.9%
+-commutative45.9%
sub-neg45.9%
Simplified45.9%
Taylor expanded in x around 0 72.3%
mul-1-neg72.3%
Simplified72.3%
if 1 < x Initial program 50.9%
Taylor expanded in x around 0 44.1%
log1p-define44.1%
rem-square-sqrt44.1%
fabs-sqr44.1%
rem-square-sqrt44.1%
Simplified44.1%
Final simplification65.6%
(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 38.6%
flip-+17.6%
frac-2neg17.6%
log-div17.8%
pow217.8%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt17.8%
add-sqr-sqrt17.6%
fma-define17.6%
Applied egg-rr19.0%
neg-sub019.0%
associate--r-19.0%
neg-sub019.0%
+-commutative19.0%
fma-undefine18.9%
unpow218.9%
+-commutative18.9%
associate-+l+28.7%
sub-neg28.7%
+-inverses38.4%
metadata-eval38.4%
metadata-eval38.4%
neg-sub038.4%
neg-sub038.4%
associate--r-38.4%
neg-sub038.4%
+-commutative38.4%
sub-neg38.4%
Simplified38.4%
Taylor expanded in x around 0 57.8%
mul-1-neg57.8%
Simplified57.8%
Final simplification57.8%
(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 2024079
(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))