
(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.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.15000000596046448)
(copysign
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (pow x 2.0) -0.044642857142857144)))
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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.15000000596046448f) {
tmp = copysignf((x * (1.0f + (powf(x, 2.0f) * ((powf(x, 2.0f) * (0.075f + (powf(x, 2.0f) * -0.044642857142857144f))) - 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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.15000000596046448)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32((x ^ Float32(2.0)) * Float32(Float32((x ^ Float32(2.0)) * Float32(Float32(0.075) + Float32((x ^ Float32(2.0)) * Float32(-0.044642857142857144)))) - 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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.15000000596046448)) tmp = sign(x) * abs((x * (single(1.0) + ((x ^ single(2.0)) * (((x ^ single(2.0)) * (single(0.075) + ((x ^ single(2.0)) * single(-0.044642857142857144)))) - 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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.15000000596046448:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(0.075 + {x}^{2} \cdot -0.044642857142857144\right) - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.5Initial program 51.0%
flip-+9.3%
frac-2neg9.3%
log-div9.2%
Applied egg-rr14.4%
neg-sub014.4%
associate--r-14.4%
neg-sub014.4%
+-commutative14.4%
fma-undefine14.4%
unpow214.4%
+-commutative14.4%
associate-+l+47.6%
sub-neg47.6%
+-inverses97.1%
metadata-eval97.1%
metadata-eval97.1%
neg-sub097.1%
neg-sub097.1%
associate--r-97.1%
neg-sub097.1%
+-commutative97.1%
sub-neg97.1%
Simplified97.1%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.150000006Initial program 23.2%
*-un-lft-identity23.2%
*-commutative23.2%
log-prod23.2%
*-un-lft-identity23.2%
*-un-lft-identity23.2%
add-sqr-sqrt14.1%
fabs-sqr14.1%
add-sqr-sqrt23.7%
+-commutative23.7%
hypot-1-def23.7%
metadata-eval23.7%
Applied egg-rr23.7%
+-rgt-identity23.7%
Simplified23.7%
Taylor expanded in x around 0 99.9%
if 0.150000006 < (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-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10999999940395355)
(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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10999999940395355f) {
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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10999999940395355)) 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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.10999999940395355)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10999999940395355:\\
\;\;\;\;\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) #s(literal 1 binary32))))) x) < -0.5Initial program 51.0%
flip-+9.3%
frac-2neg9.3%
log-div9.2%
Applied egg-rr14.4%
neg-sub014.4%
associate--r-14.4%
neg-sub014.4%
+-commutative14.4%
fma-undefine14.4%
unpow214.4%
+-commutative14.4%
associate-+l+47.6%
sub-neg47.6%
+-inverses97.1%
metadata-eval97.1%
metadata-eval97.1%
neg-sub097.1%
neg-sub097.1%
associate--r-97.1%
neg-sub097.1%
+-commutative97.1%
sub-neg97.1%
Simplified97.1%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.109999999Initial program 22.6%
*-un-lft-identity22.6%
*-commutative22.6%
log-prod22.6%
*-un-lft-identity22.6%
*-un-lft-identity22.6%
add-sqr-sqrt13.4%
fabs-sqr13.4%
add-sqr-sqrt23.1%
+-commutative23.1%
hypot-1-def23.1%
metadata-eval23.1%
Applied egg-rr23.1%
+-rgt-identity23.1%
Simplified23.1%
Taylor expanded in x around 0 99.9%
if 0.109999999 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 50.6%
*-un-lft-identity50.6%
*-commutative50.6%
log-prod50.6%
*-un-lft-identity50.6%
*-un-lft-identity50.6%
add-sqr-sqrt50.6%
fabs-sqr50.6%
add-sqr-sqrt50.6%
+-commutative50.6%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(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.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
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.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) 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.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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.0500000007Initial program 51.6%
flip-+10.5%
frac-2neg10.5%
log-div10.5%
Applied egg-rr15.6%
neg-sub015.6%
associate--r-15.6%
neg-sub015.6%
+-commutative15.6%
fma-undefine15.6%
unpow215.6%
+-commutative15.6%
associate-+l+48.3%
sub-neg48.3%
+-inverses97.0%
metadata-eval97.0%
metadata-eval97.0%
neg-sub097.0%
neg-sub097.0%
associate--r-97.0%
neg-sub097.0%
+-commutative97.0%
sub-neg97.0%
Simplified97.0%
if -0.0500000007 < x < 0.0500000007Initial program 20.8%
Taylor expanded in x around 0 21.5%
+-commutative21.5%
fma-define21.5%
rem-square-sqrt12.3%
fabs-sqr12.3%
rem-square-sqrt21.2%
log1p-define99.1%
rem-square-sqrt53.9%
fabs-sqr53.9%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around 0 99.9%
distribute-lft-in99.9%
*-rgt-identity99.9%
*-commutative99.9%
associate-*r*99.9%
unpow299.9%
cube-mult99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 51.6%
*-un-lft-identity51.6%
*-commutative51.6%
log-prod51.6%
*-un-lft-identity51.6%
*-un-lft-identity51.6%
add-sqr-sqrt51.6%
fabs-sqr51.6%
add-sqr-sqrt51.6%
+-commutative51.6%
hypot-1-def99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-rgt-identity99.7%
Simplified99.7%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(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.5f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.05000000074505806f) {
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.5)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.05000000074505806)) 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.5)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.05000000074505806)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 < -1.5Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
+-commutative13.5%
hypot-1-def14.1%
metadata-eval14.1%
Applied egg-rr14.1%
+-rgt-identity14.1%
Simplified14.1%
Taylor expanded in x around -inf 96.3%
if -1.5 < x < 0.0500000007Initial program 22.1%
Taylor expanded in x around 0 22.1%
+-commutative22.1%
fma-define22.1%
rem-square-sqrt12.1%
fabs-sqr12.1%
rem-square-sqrt21.5%
log1p-define98.0%
rem-square-sqrt53.0%
fabs-sqr53.0%
rem-square-sqrt98.2%
Simplified98.2%
Taylor expanded in x around 0 99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
*-commutative99.2%
associate-*r*99.2%
unpow299.2%
cube-mult99.2%
Simplified99.2%
if 0.0500000007 < x Initial program 51.6%
*-un-lft-identity51.6%
*-commutative51.6%
log-prod51.6%
*-un-lft-identity51.6%
*-un-lft-identity51.6%
add-sqr-sqrt51.6%
fabs-sqr51.6%
add-sqr-sqrt51.6%
+-commutative51.6%
hypot-1-def99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-rgt-identity99.7%
Simplified99.7%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
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(-1.5)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) 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(-1.5)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) 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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 < -1.5Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
+-commutative13.5%
hypot-1-def14.1%
metadata-eval14.1%
Applied egg-rr14.1%
+-rgt-identity14.1%
Simplified14.1%
Taylor expanded in x around -inf 96.3%
if -1.5 < x < 0.5Initial program 25.1%
Taylor expanded in x around 0 23.6%
+-commutative23.6%
fma-define23.6%
rem-square-sqrt14.0%
fabs-sqr14.0%
rem-square-sqrt23.0%
log1p-define96.3%
rem-square-sqrt53.2%
fabs-sqr53.2%
rem-square-sqrt96.6%
Simplified96.6%
Taylor expanded in x around 0 98.0%
distribute-lft-in98.0%
*-rgt-identity98.0%
*-commutative98.0%
associate-*r*98.0%
unpow298.0%
cube-mult98.0%
Simplified98.0%
if 0.5 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
(FPCore (x) :precision binary32 (if (<= x -1.5) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
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.5)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) 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.5)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 < -1.5Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
+-commutative13.5%
hypot-1-def14.1%
metadata-eval14.1%
Applied egg-rr14.1%
+-rgt-identity14.1%
Simplified14.1%
Taylor expanded in x around -inf 96.3%
if -1.5 < x < 0.5Initial program 25.1%
Taylor expanded in x around 0 20.0%
rem-square-sqrt11.8%
fabs-sqr11.8%
rem-square-sqrt20.2%
Simplified20.2%
Taylor expanded in x around 0 95.8%
if 0.5 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) 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(0.5)) 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 0.5:\\
\;\;\;\;\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 < 0.5Initial program 33.9%
Taylor expanded in x around 0 28.5%
rem-square-sqrt7.7%
fabs-sqr7.7%
rem-square-sqrt13.1%
Simplified13.1%
Taylor expanded in x around 0 66.2%
if 0.5 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
*-commutative98.7%
Simplified98.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 33.9%
Taylor expanded in x around 0 28.5%
rem-square-sqrt7.7%
fabs-sqr7.7%
rem-square-sqrt13.1%
Simplified13.1%
Taylor expanded in x around 0 66.2%
if 0.5 < x Initial program 48.7%
Taylor expanded in x around 0 44.7%
log1p-define44.7%
rem-square-sqrt44.7%
fabs-sqr44.7%
rem-square-sqrt44.7%
Simplified44.7%
(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.1%
Taylor expanded in x around 0 33.2%
rem-square-sqrt18.2%
fabs-sqr18.2%
rem-square-sqrt22.1%
Simplified22.1%
Taylor expanded in x around 0 50.4%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024100
(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))