
(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 8 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.03999999910593033)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= t_0 0.004999999888241291)
(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.03999999910593033f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.004999999888241291f) {
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.03999999910593033)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(0.004999999888241291)) 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.03999999910593033)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.004999999888241291)) 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.03999999910593033:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.004999999888241291:\\
\;\;\;\;\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.0399999991Initial program 52.4%
flip-+9.4%
clear-num9.4%
log-div9.3%
metadata-eval9.3%
+-commutative9.3%
hypot-1-def9.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
Applied egg-rr11.4%
neg-sub011.4%
div-sub11.4%
*-rgt-identity11.4%
associate-/l*11.4%
fma-neg11.4%
fma-undefine11.4%
unpow211.4%
associate--r+11.4%
+-inverses11.4%
metadata-eval11.4%
metadata-eval11.4%
*-rgt-identity11.4%
associate-/l*11.4%
fma-undefine11.4%
unpow211.4%
associate--r+49.1%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.4%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
if -0.0399999991 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00499999989Initial program 17.3%
flip-+17.6%
clear-num17.6%
log-div17.8%
metadata-eval17.8%
+-commutative17.8%
hypot-1-def17.7%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt17.2%
Applied egg-rr17.4%
neg-sub017.4%
div-sub17.4%
*-rgt-identity17.4%
associate-/l*17.4%
fma-neg17.4%
fma-undefine17.4%
unpow217.4%
associate--r+17.4%
+-inverses17.4%
metadata-eval17.4%
metadata-eval17.4%
*-rgt-identity17.4%
associate-/l*17.4%
fma-undefine17.4%
unpow217.4%
associate--r+17.4%
Simplified17.4%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
cube-mult100.0%
Simplified100.0%
if 0.00499999989 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 57.1%
Taylor expanded in x around 0 57.1%
rem-square-sqrt57.1%
fabs-sqr57.1%
rem-square-sqrt57.1%
metadata-eval57.1%
unpow257.1%
hypot-undefine99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (* x -2.0)) x)
(if (<= x 0.004999999888241291)
(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 <= -2.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else if (x <= 0.004999999888241291f) {
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(-2.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(0.004999999888241291)) 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(-2.0)) tmp = sign(x) * abs(log((x * single(-2.0)))); elseif (x <= single(0.004999999888241291)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 < -2Initial program 51.6%
flip-+7.9%
clear-num7.9%
log-div7.9%
metadata-eval7.9%
+-commutative7.9%
hypot-1-def7.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.4%
Applied egg-rr9.9%
neg-sub09.9%
div-sub9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-neg9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
metadata-eval9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-undefine9.9%
unpow29.9%
associate--r+48.3%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.4%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.1%
*-commutative97.1%
Simplified97.1%
if -2 < x < 0.00499999989Initial program 17.9%
flip-+18.2%
clear-num18.2%
log-div18.4%
metadata-eval18.4%
+-commutative18.4%
hypot-1-def18.3%
add-sqr-sqrt7.9%
fabs-sqr7.9%
add-sqr-sqrt17.8%
Applied egg-rr18.0%
neg-sub018.0%
div-sub18.0%
*-rgt-identity18.0%
associate-/l*18.0%
fma-neg18.0%
fma-undefine18.0%
unpow218.0%
associate--r+18.0%
+-inverses18.0%
metadata-eval18.0%
metadata-eval18.0%
*-rgt-identity18.0%
associate-/l*18.0%
fma-undefine18.0%
unpow218.0%
associate--r+18.0%
Simplified18.0%
Taylor expanded in x around 0 99.9%
distribute-rgt-in99.9%
*-lft-identity99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
unpow299.9%
cube-mult99.9%
Simplified99.9%
if 0.00499999989 < x Initial program 57.1%
Taylor expanded in x around 0 57.1%
rem-square-sqrt57.1%
fabs-sqr57.1%
rem-square-sqrt57.1%
metadata-eval57.1%
unpow257.1%
hypot-undefine99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (* x -2.0)) 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 <= -2.0f) {
tmp = copysignf(logf((x * -2.0f)), 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(-2.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), 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(-2.0)) tmp = sign(x) * abs(log((x * single(-2.0)))); 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\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 < -2Initial program 51.6%
flip-+7.9%
clear-num7.9%
log-div7.9%
metadata-eval7.9%
+-commutative7.9%
hypot-1-def7.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.4%
Applied egg-rr9.9%
neg-sub09.9%
div-sub9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-neg9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
metadata-eval9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-undefine9.9%
unpow29.9%
associate--r+48.3%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.4%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.1%
*-commutative97.1%
Simplified97.1%
if -2 < x < 0.5Initial program 18.4%
flip-+18.7%
clear-num18.8%
log-div19.0%
metadata-eval19.0%
+-commutative19.0%
hypot-1-def18.8%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt18.4%
Applied egg-rr18.6%
neg-sub018.6%
div-sub18.6%
*-rgt-identity18.6%
associate-/l*18.6%
fma-neg18.6%
fma-undefine18.6%
unpow218.6%
associate--r+18.6%
+-inverses18.6%
metadata-eval18.6%
metadata-eval18.6%
*-rgt-identity18.6%
associate-/l*18.6%
fma-undefine18.6%
unpow218.6%
associate--r+18.6%
Simplified18.6%
Taylor expanded in x around 0 99.6%
distribute-rgt-in99.6%
*-lft-identity99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
unpow299.6%
cube-mult99.6%
Simplified99.6%
if 0.5 < x Initial program 56.4%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
*-inverses97.8%
metadata-eval97.8%
Simplified97.8%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (* x -2.0)) x)
(if (<= x 0.5)
(copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), 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(log(Float32(x * Float32(-2.0))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-2.0)) tmp = sign(x) * abs(log((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.6%
flip-+7.9%
clear-num7.9%
log-div7.9%
metadata-eval7.9%
+-commutative7.9%
hypot-1-def7.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.4%
Applied egg-rr9.9%
neg-sub09.9%
div-sub9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-neg9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
metadata-eval9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-undefine9.9%
unpow29.9%
associate--r+48.3%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.4%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.1%
*-commutative97.1%
Simplified97.1%
if -2 < x < 0.5Initial program 18.4%
flip-+18.7%
clear-num18.8%
log-div19.0%
metadata-eval19.0%
+-commutative19.0%
hypot-1-def18.8%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt18.4%
Applied egg-rr18.6%
neg-sub018.6%
div-sub18.6%
*-rgt-identity18.6%
associate-/l*18.6%
fma-neg18.6%
fma-undefine18.6%
unpow218.6%
associate--r+18.6%
+-inverses18.6%
metadata-eval18.6%
metadata-eval18.6%
*-rgt-identity18.6%
associate-/l*18.6%
fma-undefine18.6%
unpow218.6%
associate--r+18.6%
Simplified18.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
unpow299.6%
Applied egg-rr99.6%
if 0.5 < x Initial program 56.4%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
*-inverses97.8%
metadata-eval97.8%
Simplified97.8%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (* x -2.0)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((x * -2.0f)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(x * Float32(-2.0))), 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(\log \left(x \cdot -2\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.6%
flip-+7.9%
clear-num7.9%
log-div7.9%
metadata-eval7.9%
+-commutative7.9%
hypot-1-def7.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.4%
Applied egg-rr9.9%
neg-sub09.9%
div-sub9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-neg9.9%
fma-undefine9.9%
unpow29.9%
associate--r+9.9%
+-inverses9.9%
metadata-eval9.9%
metadata-eval9.9%
*-rgt-identity9.9%
associate-/l*9.9%
fma-undefine9.9%
unpow29.9%
associate--r+48.3%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt-0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod98.4%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.1%
*-commutative97.1%
Simplified97.1%
if -2 < x Initial program 29.7%
Taylor expanded in x around 0 25.0%
log1p-define80.7%
rem-square-sqrt44.0%
fabs-sqr44.0%
rem-square-sqrt80.7%
Simplified80.7%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.6%
Taylor expanded in x around -inf 44.0%
neg-mul-144.0%
Simplified44.0%
if -2 < x Initial program 29.7%
Taylor expanded in x around 0 25.0%
log1p-define80.7%
rem-square-sqrt44.0%
fabs-sqr44.0%
rem-square-sqrt80.7%
Simplified80.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 28.5%
Taylor expanded in x around 0 25.1%
+-commutative25.1%
rem-square-sqrt5.5%
fabs-sqr5.5%
rem-square-sqrt12.1%
Simplified12.1%
Taylor expanded in x around 0 72.3%
if 0.5 < x Initial program 56.4%
Taylor expanded in x around 0 44.2%
log1p-define44.2%
rem-square-sqrt44.2%
fabs-sqr44.2%
rem-square-sqrt44.2%
Simplified44.2%
(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 34.8%
Taylor expanded in x around 0 29.5%
+-commutative29.5%
rem-square-sqrt14.3%
fabs-sqr14.3%
rem-square-sqrt19.4%
Simplified19.4%
Taylor expanded in x around 0 58.6%
(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 2024146
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))