
(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 13 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.05)
(copysign (log (/ -1.0 (- x (hypot 1.0 x)))) x)
(if (<= t_0 2e-7)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) 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.05) {
tmp = copysign(log((-1.0 / (x - hypot(1.0, x)))), x);
} else if (t_0 <= 2e-7) {
tmp = copysign((x - (pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -0.05) {
tmp = Math.copySign(Math.log((-1.0 / (x - Math.hypot(1.0, x)))), x);
} else if (t_0 <= 2e-7) {
tmp = Math.copySign((x - (Math.pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): t_0 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) tmp = 0 if t_0 <= -0.05: tmp = math.copysign(math.log((-1.0 / (x - math.hypot(1.0, x)))), x) elif t_0 <= 2e-7: tmp = math.copysign((x - (math.pow(x, 3.0) * 0.16666666666666666)), x) else: tmp = math.copysign(math.log((x + math.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.05) tmp = copysign(log(Float64(-1.0 / Float64(x - hypot(1.0, x)))), x); elseif (t_0 <= 2e-7) tmp = copysign(Float64(x - Float64((x ^ 3.0) * 0.16666666666666666)), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); tmp = 0.0; if (t_0 <= -0.05) tmp = sign(x) * abs(log((-1.0 / (x - hypot(1.0, x))))); elseif (t_0 <= 2e-7) tmp = sign(x) * abs((x - ((x ^ 3.0) * 0.16666666666666666))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = 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.05], N[With[{TMP1 = Abs[N[Log[N[(-1.0 / N[(x - N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 2e-7], N[With[{TMP1 = Abs[N[(x - N[(N[Power[x, 3.0], $MachinePrecision] * 0.16666666666666666), $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.05:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\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.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -0.050000000000000003Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
flip-+3.4%
div-sub3.3%
pow23.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt3.3%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt1.0%
Applied egg-rr5.0%
div-sub6.0%
fma-udef6.0%
unpow26.0%
associate--r+55.8%
+-inverses100.0%
metadata-eval100.0%
Simplified100.0%
if -0.050000000000000003 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 1.9999999999999999e-7Initial program 8.1%
+-commutative8.1%
hypot-1-def8.1%
Simplified8.1%
flip-+8.2%
frac-2neg8.2%
log-div8.3%
Applied egg-rr8.3%
sub-neg8.3%
sub-neg8.3%
fma-udef8.3%
unpow28.3%
associate--r+8.3%
+-inverses8.3%
metadata-eval8.3%
metadata-eval8.3%
metadata-eval8.3%
neg-sub08.3%
sub-neg8.3%
+-commutative8.3%
distribute-neg-in8.3%
remove-double-neg8.3%
sub-neg8.3%
Simplified8.3%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
Simplified100.0%
if 1.9999999999999999e-7 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 56.7%
+-commutative56.7%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= x -0.96)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.001)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -0.96) {
tmp = copysign(-log(((x * -2.0) - (0.5 / x))), x);
} else if (x <= 0.001) {
tmp = copysign((x - (pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.96) {
tmp = Math.copySign(-Math.log(((x * -2.0) - (0.5 / x))), x);
} else if (x <= 0.001) {
tmp = Math.copySign((x - (Math.pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.96: tmp = math.copysign(-math.log(((x * -2.0) - (0.5 / x))), x) elif x <= 0.001: tmp = math.copysign((x - (math.pow(x, 3.0) * 0.16666666666666666)), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.96) tmp = copysign(Float64(-log(Float64(Float64(x * -2.0) - Float64(0.5 / x)))), x); elseif (x <= 0.001) tmp = copysign(Float64(x - Float64((x ^ 3.0) * 0.16666666666666666)), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.96) tmp = sign(x) * abs(-log(((x * -2.0) - (0.5 / x)))); elseif (x <= 0.001) tmp = sign(x) * abs((x - ((x ^ 3.0) * 0.16666666666666666))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.96], N[With[{TMP1 = Abs[(-N[Log[N[(N[(x * -2.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.001], N[With[{TMP1 = Abs[N[(x - N[(N[Power[x, 3.0], $MachinePrecision] * 0.16666666666666666), $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 -0.96:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.001:\\
\;\;\;\;\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.95999999999999996Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.0%
frac-2neg2.0%
log-div2.0%
Applied egg-rr4.6%
sub-neg4.6%
sub-neg4.6%
fma-udef4.6%
unpow24.6%
associate--r+55.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.3%
*-commutative99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
if -0.95999999999999996 < x < 1e-3Initial program 8.8%
+-commutative8.8%
hypot-1-def8.8%
Simplified8.8%
flip-+8.9%
frac-2neg8.9%
log-div9.0%
Applied egg-rr9.0%
sub-neg9.0%
sub-neg9.0%
fma-udef9.0%
unpow29.0%
associate--r+9.0%
+-inverses9.0%
metadata-eval9.0%
metadata-eval9.0%
metadata-eval9.0%
neg-sub09.0%
sub-neg9.0%
+-commutative9.0%
distribute-neg-in9.0%
remove-double-neg9.0%
sub-neg9.0%
Simplified9.0%
Taylor expanded in x around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
*-commutative99.6%
Simplified99.6%
if 1e-3 < x Initial program 56.7%
+-commutative56.7%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x)
:precision binary64
(if (<= x -0.00096)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.001)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -0.00096) {
tmp = copysign(-log((hypot(1.0, x) - x)), x);
} else if (x <= 0.001) {
tmp = copysign((x - (pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.00096) {
tmp = Math.copySign(-Math.log((Math.hypot(1.0, x) - x)), x);
} else if (x <= 0.001) {
tmp = Math.copySign((x - (Math.pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.00096: tmp = math.copysign(-math.log((math.hypot(1.0, x) - x)), x) elif x <= 0.001: tmp = math.copysign((x - (math.pow(x, 3.0) * 0.16666666666666666)), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.00096) tmp = copysign(Float64(-log(Float64(hypot(1.0, x) - x))), x); elseif (x <= 0.001) tmp = copysign(Float64(x - Float64((x ^ 3.0) * 0.16666666666666666)), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.00096) tmp = sign(x) * abs(-log((hypot(1.0, x) - x))); elseif (x <= 0.001) tmp = sign(x) * abs((x - ((x ^ 3.0) * 0.16666666666666666))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.00096], N[With[{TMP1 = Abs[(-N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.001], N[With[{TMP1 = Abs[N[(x - N[(N[Power[x, 3.0], $MachinePrecision] * 0.16666666666666666), $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 -0.00096:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.001:\\
\;\;\;\;\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 < -9.60000000000000024e-4Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
flip-+3.4%
frac-2neg3.4%
log-div3.4%
Applied egg-rr6.0%
sub-neg6.0%
sub-neg6.0%
fma-udef6.0%
unpow26.0%
associate--r+55.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
if -9.60000000000000024e-4 < x < 1e-3Initial program 8.1%
+-commutative8.1%
hypot-1-def8.1%
Simplified8.1%
flip-+8.2%
frac-2neg8.2%
log-div8.3%
Applied egg-rr8.3%
sub-neg8.3%
sub-neg8.3%
fma-udef8.3%
unpow28.3%
associate--r+8.3%
+-inverses8.3%
metadata-eval8.3%
metadata-eval8.3%
metadata-eval8.3%
neg-sub08.3%
sub-neg8.3%
+-commutative8.3%
distribute-neg-in8.3%
remove-double-neg8.3%
sub-neg8.3%
Simplified8.3%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
Simplified100.0%
if 1e-3 < x Initial program 56.7%
+-commutative56.7%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
*-commutative99.9%
log-prod99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (- (log (* x -2.0))) x) (if (<= x 0.8) (copysign x x) (copysign (log (+ (/ 0.5 x) (+ x x))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 0.8) {
tmp = copysign(x, x);
} else {
tmp = copysign(log(((0.5 / x) + (x + x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 0.8) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log(((0.5 / x) + (x + x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 0.8: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log(((0.5 / x) + (x + x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 0.8) tmp = copysign(x, x); else tmp = copysign(log(Float64(Float64(0.5 / x) + Float64(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = sign(x) * abs(-log((x * -2.0))); elseif (x <= 0.8) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log(((0.5 / x) + (x + x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], 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.8], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(N[(0.5 / x), $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.8:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.0%
frac-2neg2.0%
log-div2.0%
Applied egg-rr4.6%
sub-neg4.6%
sub-neg4.6%
fma-udef4.6%
unpow24.6%
associate--r+55.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
*-commutative98.9%
Simplified98.9%
if -1.25 < x < 0.80000000000000004Initial program 9.5%
+-commutative9.5%
hypot-1-def9.5%
Simplified9.5%
Taylor expanded in x around 0 8.2%
rem-square-sqrt4.6%
fabs-sqr4.6%
rem-square-sqrt8.2%
Simplified8.2%
Taylor expanded in x around 0 98.9%
if 0.80000000000000004 < x Initial program 56.1%
+-commutative56.1%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
rem-square-sqrt98.8%
fabs-sqr98.8%
rem-square-sqrt98.8%
associate-+r+98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Final simplification98.9%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.25)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 1.25) {
tmp = copysign((x - (pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 1.25) {
tmp = Math.copySign((x - (Math.pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 1.25: tmp = math.copysign((x - (math.pow(x, 3.0) * 0.16666666666666666)), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 1.25) tmp = copysign(Float64(x - Float64((x ^ 3.0) * 0.16666666666666666)), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = sign(x) * abs(-log((x * -2.0))); elseif (x <= 1.25) tmp = sign(x) * abs((x - ((x ^ 3.0) * 0.16666666666666666))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], 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.25], N[With[{TMP1 = Abs[N[(x - N[(N[Power[x, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $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 -1.25:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.0%
frac-2neg2.0%
log-div2.0%
Applied egg-rr4.6%
sub-neg4.6%
sub-neg4.6%
fma-udef4.6%
unpow24.6%
associate--r+55.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
*-commutative98.9%
Simplified98.9%
if -1.25 < x < 1.25Initial program 10.2%
+-commutative10.2%
hypot-1-def10.2%
Simplified10.2%
flip-+10.3%
frac-2neg10.3%
log-div10.5%
Applied egg-rr10.5%
sub-neg10.5%
sub-neg10.5%
fma-udef10.4%
unpow210.4%
associate--r+10.4%
+-inverses10.4%
metadata-eval10.4%
metadata-eval10.4%
metadata-eval10.4%
neg-sub010.4%
sub-neg10.4%
+-commutative10.4%
distribute-neg-in10.4%
remove-double-neg10.4%
sub-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 98.6%
+-commutative98.6%
mul-1-neg98.6%
unsub-neg98.6%
*-commutative98.6%
Simplified98.6%
if 1.25 < x Initial program 55.4%
+-commutative55.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification99.0%
(FPCore (x)
:precision binary64
(if (<= x -0.96)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.25)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -0.96) {
tmp = copysign(-log(((x * -2.0) - (0.5 / x))), x);
} else if (x <= 1.25) {
tmp = copysign((x - (pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.96) {
tmp = Math.copySign(-Math.log(((x * -2.0) - (0.5 / x))), x);
} else if (x <= 1.25) {
tmp = Math.copySign((x - (Math.pow(x, 3.0) * 0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.96: tmp = math.copysign(-math.log(((x * -2.0) - (0.5 / x))), x) elif x <= 1.25: tmp = math.copysign((x - (math.pow(x, 3.0) * 0.16666666666666666)), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.96) tmp = copysign(Float64(-log(Float64(Float64(x * -2.0) - Float64(0.5 / x)))), x); elseif (x <= 1.25) tmp = copysign(Float64(x - Float64((x ^ 3.0) * 0.16666666666666666)), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.96) tmp = sign(x) * abs(-log(((x * -2.0) - (0.5 / x)))); elseif (x <= 1.25) tmp = sign(x) * abs((x - ((x ^ 3.0) * 0.16666666666666666))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.96], N[With[{TMP1 = Abs[(-N[Log[N[(N[(x * -2.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.25], N[With[{TMP1 = Abs[N[(x - N[(N[Power[x, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $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.96:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -0.95999999999999996Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.0%
frac-2neg2.0%
log-div2.0%
Applied egg-rr4.6%
sub-neg4.6%
sub-neg4.6%
fma-udef4.6%
unpow24.6%
associate--r+55.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.3%
*-commutative99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
if -0.95999999999999996 < x < 1.25Initial program 10.2%
+-commutative10.2%
hypot-1-def10.2%
Simplified10.2%
flip-+10.3%
frac-2neg10.3%
log-div10.5%
Applied egg-rr10.5%
sub-neg10.5%
sub-neg10.5%
fma-udef10.4%
unpow210.4%
associate--r+10.4%
+-inverses10.4%
metadata-eval10.4%
metadata-eval10.4%
metadata-eval10.4%
neg-sub010.4%
sub-neg10.4%
+-commutative10.4%
distribute-neg-in10.4%
remove-double-neg10.4%
sub-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 98.6%
+-commutative98.6%
mul-1-neg98.6%
unsub-neg98.6%
*-commutative98.6%
Simplified98.6%
if 1.25 < x Initial program 55.4%
+-commutative55.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x -3.1) (copysign (log (- x)) x) (if (<= x 1.25) (copysign x x) (copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -3.1) {
tmp = copysign(log(-x), x);
} else if (x <= 1.25) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -3.1) {
tmp = Math.copySign(Math.log(-x), x);
} else if (x <= 1.25) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -3.1: tmp = math.copysign(math.log(-x), x) elif x <= 1.25: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -3.1) tmp = copysign(log(Float64(-x)), x); elseif (x <= 1.25) tmp = copysign(x, x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -3.1) tmp = sign(x) * abs(log(-x)); elseif (x <= 1.25) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -3.1], N[With[{TMP1 = Abs[N[Log[(-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.25], N[With[{TMP1 = Abs[x], 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 -3.1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -3.10000000000000009Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 30.9%
mul-1-neg30.9%
Simplified30.9%
if -3.10000000000000009 < x < 1.25Initial program 10.2%
+-commutative10.2%
hypot-1-def10.2%
Simplified10.2%
Taylor expanded in x around 0 8.3%
rem-square-sqrt4.7%
fabs-sqr4.7%
rem-square-sqrt8.3%
Simplified8.3%
Taylor expanded in x around 0 98.3%
if 1.25 < x Initial program 55.4%
+-commutative55.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification81.0%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (- (log (* x -2.0))) x) (if (<= x 1.25) (copysign x x) (copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 1.25) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 1.25) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 1.25: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 1.25) tmp = copysign(x, x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = sign(x) * abs(-log((x * -2.0))); elseif (x <= 1.25) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], 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.25], N[With[{TMP1 = Abs[x], 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 -1.25:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.0%
frac-2neg2.0%
log-div2.0%
Applied egg-rr4.6%
sub-neg4.6%
sub-neg4.6%
fma-udef4.6%
unpow24.6%
associate--r+55.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
*-commutative98.9%
Simplified98.9%
if -1.25 < x < 1.25Initial program 10.2%
+-commutative10.2%
hypot-1-def10.2%
Simplified10.2%
Taylor expanded in x around 0 8.3%
rem-square-sqrt4.7%
fabs-sqr4.7%
rem-square-sqrt8.3%
Simplified8.3%
Taylor expanded in x around 0 98.3%
if 1.25 < x Initial program 55.4%
+-commutative55.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification98.9%
(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 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 30.9%
mul-1-neg30.9%
Simplified30.9%
if -0.5 < x Initial program 25.3%
+-commutative25.3%
hypot-1-def40.1%
Simplified40.1%
Taylor expanded in x around 0 16.1%
log1p-def75.1%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt75.1%
Simplified75.1%
Final simplification63.5%
(FPCore (x) :precision binary64 (if (<= x -1.0) (copysign 8.0 x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign(8.0, x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = Math.copySign(8.0, x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = math.copysign(8.0, x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(8.0, x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[With[{TMP1 = Abs[8.0], 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(8, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 30.9%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt0.0%
Simplified0.0%
Applied egg-rr15.4%
if -1 < x Initial program 25.3%
+-commutative25.3%
hypot-1-def40.1%
Simplified40.1%
Taylor expanded in x around 0 16.1%
log1p-def75.1%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt75.1%
Simplified75.1%
Final simplification59.5%
(FPCore (x) :precision binary64 (if (or (<= x -8.0) (not (<= x 8.0))) (copysign 8.0 x) (copysign x x)))
double code(double x) {
double tmp;
if ((x <= -8.0) || !(x <= 8.0)) {
tmp = copysign(8.0, x);
} else {
tmp = copysign(x, x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -8.0) || !(x <= 8.0)) {
tmp = Math.copySign(8.0, x);
} else {
tmp = Math.copySign(x, x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -8.0) or not (x <= 8.0): tmp = math.copysign(8.0, x) else: tmp = math.copysign(x, x) return tmp
function code(x) tmp = 0.0 if ((x <= -8.0) || !(x <= 8.0)) tmp = copysign(8.0, x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -8.0) || ~((x <= 8.0))) tmp = sign(x) * abs(8.0); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -8.0], N[Not[LessEqual[x, 8.0]], $MachinePrecision]], N[With[{TMP1 = Abs[8.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \lor \neg \left(x \leq 8\right):\\
\;\;\;\;\mathsf{copysign}\left(8, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -8 or 8 < x Initial program 56.0%
+-commutative56.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 31.2%
rem-square-sqrt15.3%
fabs-sqr15.3%
rem-square-sqrt15.3%
Simplified15.3%
Applied egg-rr15.3%
if -8 < x < 8Initial program 10.2%
+-commutative10.2%
hypot-1-def10.2%
Simplified10.2%
Taylor expanded in x around 0 8.3%
rem-square-sqrt4.7%
fabs-sqr4.7%
rem-square-sqrt8.3%
Simplified8.3%
Taylor expanded in x around 0 98.3%
Final simplification56.1%
(FPCore (x) :precision binary64 (copysign 3.0 x))
double code(double x) {
return copysign(3.0, x);
}
public static double code(double x) {
return Math.copySign(3.0, x);
}
def code(x): return math.copysign(3.0, x)
function code(x) return copysign(3.0, x) end
function tmp = code(x) tmp = sign(x) * abs(3.0); end
code[x_] := N[With[{TMP1 = Abs[3.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(3, x\right)
\end{array}
Initial program 33.5%
+-commutative33.5%
hypot-1-def55.8%
Simplified55.8%
Taylor expanded in x around 0 19.9%
rem-square-sqrt10.1%
fabs-sqr10.1%
rem-square-sqrt11.9%
Simplified11.9%
Applied egg-rr10.2%
Final simplification10.2%
(FPCore (x) :precision binary64 (copysign 8.0 x))
double code(double x) {
return copysign(8.0, x);
}
public static double code(double x) {
return Math.copySign(8.0, x);
}
def code(x): return math.copysign(8.0, x)
function code(x) return copysign(8.0, x) end
function tmp = code(x) tmp = sign(x) * abs(8.0); end
code[x_] := N[With[{TMP1 = Abs[8.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(8, x\right)
\end{array}
Initial program 33.5%
+-commutative33.5%
hypot-1-def55.8%
Simplified55.8%
Taylor expanded in x around 0 19.9%
rem-square-sqrt10.1%
fabs-sqr10.1%
rem-square-sqrt11.9%
Simplified11.9%
Applied egg-rr10.5%
Final simplification10.5%
(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 2024031
(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))