
(FPCore (x) :precision binary64 (asinh x))
double code(double x) {
return asinh(x);
}
def code(x): return math.asinh(x)
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
code[x_] := N[ArcSinh[x], $MachinePrecision]
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
double code(double x) {
return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
public static double code(double x) {
return Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
}
def code(x): return math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
function code(x) return copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.2)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= t_0 2e-11)
(copysign (fma 0.5 (/ (* x x) (+ x 1.0)) (log1p x)) x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
double code(double x) {
double t_0 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -0.2) {
tmp = copysign(log((1.0 / (hypot(1.0, x) - x))), x);
} else if (t_0 <= 2e-11) {
tmp = copysign(fma(0.5, ((x * x) / (x + 1.0)), log1p(x)), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) tmp = 0.0 if (t_0 <= -0.2) tmp = copysign(log(Float64(1.0 / Float64(hypot(1.0, x) - x))), x); elseif (t_0 <= 2e-11) tmp = copysign(fma(0.5, Float64(Float64(x * x) / Float64(x + 1.0)), log1p(x)), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], N[With[{TMP1 = Abs[N[Log[N[(1.0 / N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 2e-11], N[With[{TMP1 = Abs[N[(0.5 * N[(N[(x * x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]]
\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.2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{x \cdot x}{x + 1}, \mathsf{log1p}\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 (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -0.20000000000000001Initial program 62.0%
+-commutative62.0%
hypot-1-def100.0%
Simplified100.0%
flip-+5.6%
div-sub5.7%
pow25.7%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt5.7%
pow25.7%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt1.3%
hypot-udef1.3%
hypot-udef1.3%
add-sqr-sqrt1.3%
metadata-eval1.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt7.3%
Applied egg-rr7.3%
unpow27.3%
div-sub8.4%
unpow28.4%
unpow28.4%
unpow28.4%
+-commutative8.4%
associate--r+60.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
if -0.20000000000000001 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 1.99999999999999988e-11Initial program 6.5%
+-commutative6.5%
hypot-1-def6.5%
Simplified6.5%
Taylor expanded in x around 0 7.6%
fma-def7.6%
unpow27.6%
unpow17.6%
sqr-pow4.1%
fabs-sqr4.1%
sqr-pow7.6%
unpow17.6%
log1p-def100.0%
unpow1100.0%
sqr-pow52.8%
fabs-sqr52.8%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
if 1.99999999999999988e-11 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 9e-9)
(copysign (log1p (fabs x)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 9e-9) {
tmp = copysign(log1p(fabs(x)), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 9e-9) {
tmp = Math.copySign(Math.log1p(Math.abs(x)), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 9e-9: tmp = math.copysign(math.log1p(math.fabs(x)), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 9e-9) tmp = copysign(log1p(abs(x)), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 9e-9], N[With[{TMP1 = Abs[N[Log[1 + N[Abs[x], $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\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 9 \cdot 10^{-9}:\\
\;\;\;\;\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 < -1Initial program 61.5%
+-commutative61.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.4%
associate--l+98.4%
unpow198.4%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow5.4%
unpow15.4%
associate-+r-97.3%
mul-1-neg97.3%
sub-neg97.3%
+-inverses97.3%
neg-sub097.3%
associate-*r/97.3%
metadata-eval97.3%
distribute-neg-frac97.3%
metadata-eval97.3%
Simplified97.3%
if -1 < x < 8.99999999999999953e-9Initial program 7.2%
+-commutative7.2%
hypot-1-def7.2%
Simplified7.2%
Taylor expanded in x around 0 6.6%
log1p-def98.8%
Simplified98.8%
if 8.99999999999999953e-9 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification98.6%
(FPCore (x)
:precision binary64
(if (<= x -1.5e-8)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 9e-9)
(copysign (log1p x) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.5e-8) {
tmp = copysign(log((1.0 / (hypot(1.0, x) - x))), x);
} else if (x <= 9e-9) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.5e-8) {
tmp = Math.copySign(Math.log((1.0 / (Math.hypot(1.0, x) - x))), x);
} else if (x <= 9e-9) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.5e-8: tmp = math.copysign(math.log((1.0 / (math.hypot(1.0, x) - x))), x) elif x <= 9e-9: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.5e-8) tmp = copysign(log(Float64(1.0 / Float64(hypot(1.0, x) - x))), x); elseif (x <= 9e-9) tmp = copysign(log1p(x), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
code[x_] := If[LessEqual[x, -1.5e-8], N[With[{TMP1 = Abs[N[Log[N[(1.0 / N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 9e-9], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\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 < -1.49999999999999987e-8Initial program 62.0%
+-commutative62.0%
hypot-1-def100.0%
Simplified100.0%
flip-+5.6%
div-sub5.7%
pow25.7%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt5.7%
pow25.7%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt1.3%
hypot-udef1.3%
hypot-udef1.3%
add-sqr-sqrt1.3%
metadata-eval1.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt7.3%
Applied egg-rr7.3%
unpow27.3%
div-sub8.4%
unpow28.4%
unpow28.4%
unpow28.4%
+-commutative8.4%
associate--r+60.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
if -1.49999999999999987e-8 < x < 8.99999999999999953e-9Initial program 6.5%
+-commutative6.5%
hypot-1-def6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
log1p-def99.4%
unpow199.4%
sqr-pow52.4%
fabs-sqr52.4%
sqr-pow99.4%
unpow199.4%
Simplified99.4%
if 8.99999999999999953e-9 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification99.7%
(FPCore (x)
:precision binary64
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.65)
(copysign (log1p (fabs x)) x)
(copysign (log (+ x (+ x (/ 0.5 x)))) x))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 0.65) {
tmp = copysign(log1p(fabs(x)), x);
} else {
tmp = copysign(log((x + (x + (0.5 / x)))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 0.65) {
tmp = Math.copySign(Math.log1p(Math.abs(x)), x);
} else {
tmp = Math.copySign(Math.log((x + (x + (0.5 / x)))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 0.65: tmp = math.copysign(math.log1p(math.fabs(x)), x) else: tmp = math.copysign(math.log((x + (x + (0.5 / x)))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 0.65) tmp = copysign(log1p(abs(x)), x); else tmp = copysign(log(Float64(x + Float64(x + Float64(0.5 / x)))), x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.65], N[With[{TMP1 = Abs[N[Log[1 + N[Abs[x], $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[(x + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\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 0.65:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 61.5%
+-commutative61.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.4%
associate--l+98.4%
unpow198.4%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow5.4%
unpow15.4%
associate-+r-97.3%
mul-1-neg97.3%
sub-neg97.3%
+-inverses97.3%
neg-sub097.3%
associate-*r/97.3%
metadata-eval97.3%
distribute-neg-frac97.3%
metadata-eval97.3%
Simplified97.3%
if -1 < x < 0.650000000000000022Initial program 7.2%
+-commutative7.2%
hypot-1-def7.2%
Simplified7.2%
Taylor expanded in x around 0 6.6%
log1p-def98.8%
Simplified98.8%
if 0.650000000000000022 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
associate-+r+98.8%
+-commutative98.8%
+-commutative98.8%
unpow198.8%
sqr-pow98.8%
fabs-sqr98.8%
sqr-pow98.8%
unpow198.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Final simplification98.4%
(FPCore (x)
:precision binary64
(if (<= x -0.33)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.65)
(copysign (log1p x) x)
(copysign (log (+ x (+ x (/ 0.5 x)))) x))))
double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 0.65) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log((x + (x + (0.5 / x)))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 0.65) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log((x + (x + (0.5 / x)))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.33: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 0.65: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log((x + (x + (0.5 / x)))), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.33) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 0.65) tmp = copysign(log1p(x), x); else tmp = copysign(log(Float64(x + Float64(x + Float64(0.5 / x)))), x); end return tmp end
code[x_] := If[LessEqual[x, -0.33], N[With[{TMP1 = Abs[(-N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.65], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[(x + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.33:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.330000000000000016Initial program 62.0%
+-commutative62.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.3%
associate--l+97.3%
unpow197.3%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow5.6%
unpow15.6%
associate-+r-96.3%
mul-1-neg96.3%
sub-neg96.3%
+-inverses96.3%
neg-sub096.3%
associate-*r/96.3%
metadata-eval96.3%
distribute-neg-frac96.3%
metadata-eval96.3%
Simplified96.3%
clear-num96.3%
log-div96.3%
metadata-eval96.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
div-inv0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt96.3%
metadata-eval96.3%
Applied egg-rr96.3%
neg-sub096.3%
Simplified96.3%
if -0.330000000000000016 < x < 0.650000000000000022Initial program 6.5%
+-commutative6.5%
hypot-1-def6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
log1p-def99.4%
unpow199.4%
sqr-pow52.4%
fabs-sqr52.4%
sqr-pow99.4%
unpow199.4%
Simplified99.4%
if 0.650000000000000022 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
associate-+r+98.8%
+-commutative98.8%
+-commutative98.8%
unpow198.8%
sqr-pow98.8%
fabs-sqr98.8%
sqr-pow98.8%
unpow198.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Final simplification98.4%
(FPCore (x) :precision binary64 (if (<= x -0.5) (copysign (log (- x)) x) (if (<= x 1.0) (copysign (log1p x) x) (copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -0.5) {
tmp = copysign(log(-x), x);
} else if (x <= 1.0) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.5) {
tmp = Math.copySign(Math.log(-x), x);
} else if (x <= 1.0) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.5: tmp = math.copysign(math.log(-x), x) elif x <= 1.0: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.5) tmp = copysign(log(Float64(-x)), x); elseif (x <= 1.0) tmp = copysign(log1p(x), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
code[x_] := If[LessEqual[x, -0.5], N[With[{TMP1 = Abs[N[Log[(-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.0], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -0.5Initial program 61.5%
+-commutative61.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 30.7%
mul-1-neg30.7%
Simplified30.7%
if -0.5 < x < 1Initial program 7.2%
+-commutative7.2%
hypot-1-def7.2%
Simplified7.2%
Taylor expanded in x around 0 6.6%
log1p-def98.8%
unpow198.8%
sqr-pow52.0%
fabs-sqr52.0%
sqr-pow98.7%
unpow198.7%
Simplified98.7%
if 1 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
unpow198.7%
sqr-pow98.7%
fabs-sqr98.7%
sqr-pow98.7%
unpow198.7%
Simplified98.7%
Final simplification79.3%
(FPCore (x) :precision binary64 (if (<= x -0.33) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign (log1p x) x) (copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 1.0) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 1.0) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.33: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 1.0: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.33) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 1.0) tmp = copysign(log1p(x), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
code[x_] := If[LessEqual[x, -0.33], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.0], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.33:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -0.330000000000000016Initial program 62.0%
+-commutative62.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.3%
associate--l+97.3%
unpow197.3%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow5.6%
unpow15.6%
associate-+r-96.3%
mul-1-neg96.3%
sub-neg96.3%
+-inverses96.3%
neg-sub096.3%
associate-*r/96.3%
metadata-eval96.3%
distribute-neg-frac96.3%
metadata-eval96.3%
Simplified96.3%
if -0.330000000000000016 < x < 1Initial program 6.5%
+-commutative6.5%
hypot-1-def6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
log1p-def99.4%
unpow199.4%
sqr-pow52.4%
fabs-sqr52.4%
sqr-pow99.4%
unpow199.4%
Simplified99.4%
if 1 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
unpow198.7%
sqr-pow98.7%
fabs-sqr98.7%
sqr-pow98.7%
unpow198.7%
Simplified98.7%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (<= x -0.33) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign (log1p x) x) (copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 1.0) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 1.0) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.33: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 1.0: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.33) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 1.0) tmp = copysign(log1p(x), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
code[x_] := If[LessEqual[x, -0.33], N[With[{TMP1 = Abs[(-N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.0], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.33:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -0.330000000000000016Initial program 62.0%
+-commutative62.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 97.3%
associate--l+97.3%
unpow197.3%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow5.6%
unpow15.6%
associate-+r-96.3%
mul-1-neg96.3%
sub-neg96.3%
+-inverses96.3%
neg-sub096.3%
associate-*r/96.3%
metadata-eval96.3%
distribute-neg-frac96.3%
metadata-eval96.3%
Simplified96.3%
clear-num96.3%
log-div96.3%
metadata-eval96.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
div-inv0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt96.3%
metadata-eval96.3%
Applied egg-rr96.3%
neg-sub096.3%
Simplified96.3%
if -0.330000000000000016 < x < 1Initial program 6.5%
+-commutative6.5%
hypot-1-def6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
log1p-def99.4%
unpow199.4%
sqr-pow52.4%
fabs-sqr52.4%
sqr-pow99.4%
unpow199.4%
Simplified99.4%
if 1 < x Initial program 44.9%
+-commutative44.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
unpow198.7%
sqr-pow98.7%
fabs-sqr98.7%
sqr-pow98.7%
unpow198.7%
Simplified98.7%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (<= x -0.5) (copysign (log (- x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -0.5) {
tmp = copysign(log(-x), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.5) {
tmp = Math.copySign(Math.log(-x), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.5: tmp = math.copysign(math.log(-x), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.5) tmp = copysign(log(Float64(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -0.5], N[With[{TMP1 = Abs[N[Log[(-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.5:\\
\;\;\;\;\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 < -0.5Initial program 61.5%
+-commutative61.5%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 30.7%
mul-1-neg30.7%
Simplified30.7%
if -0.5 < x Initial program 19.2%
+-commutative19.2%
hypot-1-def36.6%
Simplified36.6%
Taylor expanded in x around 0 14.6%
log1p-def77.5%
unpow177.5%
sqr-pow45.6%
fabs-sqr45.6%
sqr-pow77.5%
unpow177.5%
Simplified77.5%
Final simplification64.1%
(FPCore (x) :precision binary64 (copysign (log 0.0) x))
double code(double x) {
return copysign(log(0.0), x);
}
public static double code(double x) {
return Math.copySign(Math.log(0.0), x);
}
def code(x): return math.copysign(math.log(0.0), x)
function code(x) return copysign(log(0.0), x) end
function tmp = code(x) tmp = sign(x) * abs(log(0.0)); end
code[x_] := N[With[{TMP1 = Abs[N[Log[0.0], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log 0, x\right)
\end{array}
Initial program 31.2%
+-commutative31.2%
hypot-1-def54.7%
Simplified54.7%
Taylor expanded in x around -inf 30.3%
unpow130.3%
sqr-pow2.4%
fabs-sqr2.4%
sqr-pow2.7%
unpow12.7%
mul-1-neg2.7%
sub-neg2.7%
+-inverses2.7%
Simplified2.7%
Final simplification2.7%
(FPCore (x) :precision binary64 (copysign (log1p x) x))
double code(double x) {
return copysign(log1p(x), x);
}
public static double code(double x) {
return Math.copySign(Math.log1p(x), x);
}
def code(x): return math.copysign(math.log1p(x), x)
function code(x) return copysign(log1p(x), x) end
code[x_] := N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)
\end{array}
Initial program 31.2%
+-commutative31.2%
hypot-1-def54.7%
Simplified54.7%
Taylor expanded in x around 0 19.2%
log1p-def64.2%
unpow164.2%
sqr-pow32.6%
fabs-sqr32.6%
sqr-pow55.4%
unpow155.4%
Simplified55.4%
Final simplification55.4%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
double code(double x) {
double t_0 = 1.0 / fabs(x);
return copysign(log1p((fabs(x) + (fabs(x) / (hypot(1.0, t_0) + t_0)))), x);
}
public static double code(double x) {
double t_0 = 1.0 / Math.abs(x);
return Math.copySign(Math.log1p((Math.abs(x) + (Math.abs(x) / (Math.hypot(1.0, t_0) + t_0)))), x);
}
def code(x): t_0 = 1.0 / math.fabs(x) return math.copysign(math.log1p((math.fabs(x) + (math.fabs(x) / (math.hypot(1.0, t_0) + t_0)))), x)
function code(x) t_0 = Float64(1.0 / abs(x)) return copysign(log1p(Float64(abs(x) + Float64(abs(x) / Float64(hypot(1.0, t_0) + t_0)))), x) end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[With[{TMP1 = Abs[N[Log[1 + N[(N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + t$95$0 ^ 2], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\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 2023224
(FPCore (x)
:name "Rust f64::asinh"
:precision binary64
:herbie-target
(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))