
(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
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) 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 <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), 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(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), 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(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); 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 -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\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 < -0.100000001Initial program 51.2%
+-commutative51.2%
hypot-1-def99.8%
Simplified99.8%
flip-+7.2%
clear-num7.2%
log-div7.2%
metadata-eval7.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.9%
pow28.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.9%
hypot-1-def8.9%
hypot-1-def8.9%
add-sqr-sqrt9.1%
+-commutative9.1%
Applied egg-rr9.1%
neg-sub09.1%
div-sub9.1%
fma-undefine9.1%
unpow29.1%
associate--r+9.1%
+-inverses9.1%
metadata-eval9.1%
*-rgt-identity9.1%
associate-/l*9.1%
metadata-eval9.1%
*-commutative9.1%
fma-undefine9.1%
unpow29.1%
associate--r+47.8%
+-inverses99.8%
metadata-eval99.8%
*-rgt-identity99.8%
associate-/l*99.8%
metadata-eval99.8%
*-commutative99.8%
neg-mul-199.8%
Simplified99.8%
if -0.100000001 < x < 0.00499999989Initial program 17.1%
+-commutative17.1%
hypot-1-def17.2%
Simplified17.2%
add-cube-cbrt16.5%
pow316.4%
log-pow16.5%
add-sqr-sqrt7.4%
fabs-sqr7.4%
add-sqr-sqrt16.7%
Applied egg-rr16.7%
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 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<=
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
-9.999999747378752e-5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -9.999999747378752e-5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), 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(-9.999999747378752e-5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), 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 -9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\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) < -9.99999975e-5Initial program 52.5%
+-commutative52.5%
hypot-1-def98.7%
Simplified98.7%
flip-+10.8%
clear-num10.8%
log-div10.7%
metadata-eval10.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
pow212.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
hypot-1-def12.4%
hypot-1-def12.3%
add-sqr-sqrt12.6%
+-commutative12.6%
Applied egg-rr12.6%
neg-sub012.6%
div-sub12.6%
fma-undefine12.6%
unpow212.6%
associate--r+12.6%
+-inverses12.6%
metadata-eval12.6%
*-rgt-identity12.6%
associate-/l*12.6%
metadata-eval12.6%
*-commutative12.6%
fma-undefine12.6%
unpow212.6%
associate--r+49.4%
+-inverses98.7%
metadata-eval98.7%
*-rgt-identity98.7%
associate-/l*98.7%
metadata-eval98.7%
*-commutative98.7%
neg-mul-198.7%
Simplified98.7%
if -9.99999975e-5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 29.3%
+-commutative29.3%
hypot-1-def46.2%
Simplified46.2%
*-un-lft-identity46.2%
*-commutative46.2%
log-prod46.2%
add-sqr-sqrt41.7%
fabs-sqr41.7%
add-sqr-sqrt46.2%
metadata-eval46.2%
Applied egg-rr46.2%
+-rgt-identity46.2%
Simplified46.2%
log1p-expm1-u46.2%
expm1-undefine46.2%
add-exp-log46.2%
Applied egg-rr46.2%
associate--l+99.3%
Simplified99.3%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) 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 <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), 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(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\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 < -10Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
metadata-eval10.9%
Applied egg-rr10.9%
+-rgt-identity10.9%
Simplified10.9%
Taylor expanded in x around -inf 98.5%
if -10 < x < 0.00499999989Initial program 18.4%
+-commutative18.4%
hypot-1-def18.4%
Simplified18.4%
add-cube-cbrt17.7%
pow317.7%
log-pow17.7%
add-sqr-sqrt7.3%
fabs-sqr7.3%
add-sqr-sqrt17.9%
Applied egg-rr17.9%
Taylor expanded in x around 0 99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
unpow299.5%
cube-mult99.5%
Simplified99.5%
if 0.00499999989 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(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 <= -10.0f) {
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(-10.0)) 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(-10.0)) 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 -10:\\
\;\;\;\;\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 < -10Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
metadata-eval10.9%
Applied egg-rr10.9%
+-rgt-identity10.9%
Simplified10.9%
Taylor expanded in x around -inf 98.5%
if -10 < x < 0.5Initial program 19.1%
+-commutative19.1%
hypot-1-def19.1%
Simplified19.1%
add-cube-cbrt18.4%
pow318.4%
log-pow18.4%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt18.5%
Applied egg-rr18.5%
Taylor expanded in x around 0 99.1%
distribute-rgt-in99.1%
*-lft-identity99.1%
*-commutative99.1%
*-commutative99.1%
associate-*r*99.1%
unpow299.1%
cube-mult99.1%
Simplified99.1%
if 0.5 < x Initial program 53.2%
+-commutative53.2%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.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 96.9%
*-commutative96.9%
Simplified96.9%
Final simplification98.4%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-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(-10.0)) tmp = copysign(log(Float32(-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(-10.0)) tmp = sign(x) * abs(log(-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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-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 < -10Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.5%
mul-1-neg44.5%
Simplified44.5%
if -10 < x < 0.5Initial program 19.1%
+-commutative19.1%
hypot-1-def19.1%
Simplified19.1%
Taylor expanded in x around 0 16.6%
log1p-define95.4%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 98.0%
if 0.5 < x Initial program 53.2%
+-commutative53.2%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.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 96.9%
*-commutative96.9%
Simplified96.9%
Final simplification82.4%
(FPCore (x) :precision binary32 (if (<= x -10.0) (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 <= -10.0f) {
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(-10.0)) 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(-10.0)) 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 -10:\\
\;\;\;\;\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 < -10Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
metadata-eval10.9%
Applied egg-rr10.9%
+-rgt-identity10.9%
Simplified10.9%
Taylor expanded in x around -inf 98.5%
if -10 < x < 0.5Initial program 19.1%
+-commutative19.1%
hypot-1-def19.1%
Simplified19.1%
Taylor expanded in x around 0 16.6%
log1p-define95.4%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 98.0%
if 0.5 < x Initial program 53.2%
+-commutative53.2%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.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 96.9%
*-commutative96.9%
Simplified96.9%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.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 -10:\\
\;\;\;\;\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 < -10Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.5%
mul-1-neg44.5%
Simplified44.5%
if -10 < x Initial program 31.0%
+-commutative31.0%
hypot-1-def47.4%
Simplified47.4%
Taylor expanded in x around 0 26.2%
log1p-define77.4%
rem-square-sqrt45.5%
fabs-sqr45.5%
rem-square-sqrt77.4%
Simplified77.4%
Final simplification68.0%
(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 30.8%
+-commutative30.8%
hypot-1-def49.9%
Simplified49.9%
Taylor expanded in x around 0 27.2%
log1p-define76.0%
rem-square-sqrt28.7%
fabs-sqr28.7%
rem-square-sqrt59.1%
Simplified59.1%
Taylor expanded in x around 0 64.9%
if 0.5 < x Initial program 53.2%
+-commutative53.2%
hypot-1-def100.0%
Simplified100.0%
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 simplification59.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 36.4%
+-commutative36.4%
hypot-1-def62.4%
Simplified62.4%
Taylor expanded in x around 0 31.4%
log1p-define68.0%
rem-square-sqrt32.6%
fabs-sqr32.6%
rem-square-sqrt55.4%
Simplified55.4%
Taylor expanded in x around 0 51.6%
Final simplification51.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 2024067
(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))