| Alternative 1 | |
|---|---|
| Error | 15.1 |
| Cost | 20560 |
(FPCore (x l t) :precision binary64 (/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))
(FPCore (x l t)
:precision binary64
(let* ((t_1
(/
(* (sqrt 2.0) t)
(sqrt
(+
(/ (+ (pow l 2.0) (* 2.0 (pow t 2.0))) x)
(+
(/ (pow l 2.0) x)
(* 2.0 (+ (pow t 2.0) (/ (pow t 2.0) x)))))))))
(if (<= t -7.9e+31)
(- (sqrt (/ (+ -1.0 x) (+ x 1.0))))
(if (<= t -1.3e-248)
t_1
(if (<= t -8.6e-277) -1.0 (if (<= t 8e+74) t_1 (- 1.0 (/ 1.0 x))))))))double code(double x, double l, double t) {
return (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
double code(double x, double l, double t) {
double t_1 = (sqrt(2.0) * t) / sqrt((((pow(l, 2.0) + (2.0 * pow(t, 2.0))) / x) + ((pow(l, 2.0) / x) + (2.0 * (pow(t, 2.0) + (pow(t, 2.0) / x))))));
double tmp;
if (t <= -7.9e+31) {
tmp = -sqrt(((-1.0 + x) / (x + 1.0)));
} else if (t <= -1.3e-248) {
tmp = t_1;
} else if (t <= -8.6e-277) {
tmp = -1.0;
} else if (t <= 8e+74) {
tmp = t_1;
} else {
tmp = 1.0 - (1.0 / x);
}
return tmp;
}
real(8) function code(x, l, t)
real(8), intent (in) :: x
real(8), intent (in) :: l
real(8), intent (in) :: t
code = (sqrt(2.0d0) * t) / sqrt(((((x + 1.0d0) / (x - 1.0d0)) * ((l * l) + (2.0d0 * (t * t)))) - (l * l)))
end function
real(8) function code(x, l, t)
real(8), intent (in) :: x
real(8), intent (in) :: l
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (sqrt(2.0d0) * t) / sqrt(((((l ** 2.0d0) + (2.0d0 * (t ** 2.0d0))) / x) + (((l ** 2.0d0) / x) + (2.0d0 * ((t ** 2.0d0) + ((t ** 2.0d0) / x))))))
if (t <= (-7.9d+31)) then
tmp = -sqrt((((-1.0d0) + x) / (x + 1.0d0)))
else if (t <= (-1.3d-248)) then
tmp = t_1
else if (t <= (-8.6d-277)) then
tmp = -1.0d0
else if (t <= 8d+74) then
tmp = t_1
else
tmp = 1.0d0 - (1.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double l, double t) {
return (Math.sqrt(2.0) * t) / Math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
public static double code(double x, double l, double t) {
double t_1 = (Math.sqrt(2.0) * t) / Math.sqrt((((Math.pow(l, 2.0) + (2.0 * Math.pow(t, 2.0))) / x) + ((Math.pow(l, 2.0) / x) + (2.0 * (Math.pow(t, 2.0) + (Math.pow(t, 2.0) / x))))));
double tmp;
if (t <= -7.9e+31) {
tmp = -Math.sqrt(((-1.0 + x) / (x + 1.0)));
} else if (t <= -1.3e-248) {
tmp = t_1;
} else if (t <= -8.6e-277) {
tmp = -1.0;
} else if (t <= 8e+74) {
tmp = t_1;
} else {
tmp = 1.0 - (1.0 / x);
}
return tmp;
}
def code(x, l, t): return (math.sqrt(2.0) * t) / math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)))
def code(x, l, t): t_1 = (math.sqrt(2.0) * t) / math.sqrt((((math.pow(l, 2.0) + (2.0 * math.pow(t, 2.0))) / x) + ((math.pow(l, 2.0) / x) + (2.0 * (math.pow(t, 2.0) + (math.pow(t, 2.0) / x)))))) tmp = 0 if t <= -7.9e+31: tmp = -math.sqrt(((-1.0 + x) / (x + 1.0))) elif t <= -1.3e-248: tmp = t_1 elif t <= -8.6e-277: tmp = -1.0 elif t <= 8e+74: tmp = t_1 else: tmp = 1.0 - (1.0 / x) return tmp
function code(x, l, t) return Float64(Float64(sqrt(2.0) * t) / sqrt(Float64(Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * Float64(Float64(l * l) + Float64(2.0 * Float64(t * t)))) - Float64(l * l)))) end
function code(x, l, t) t_1 = Float64(Float64(sqrt(2.0) * t) / sqrt(Float64(Float64(Float64((l ^ 2.0) + Float64(2.0 * (t ^ 2.0))) / x) + Float64(Float64((l ^ 2.0) / x) + Float64(2.0 * Float64((t ^ 2.0) + Float64((t ^ 2.0) / x))))))) tmp = 0.0 if (t <= -7.9e+31) tmp = Float64(-sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0)))); elseif (t <= -1.3e-248) tmp = t_1; elseif (t <= -8.6e-277) tmp = -1.0; elseif (t <= 8e+74) tmp = t_1; else tmp = Float64(1.0 - Float64(1.0 / x)); end return tmp end
function tmp = code(x, l, t) tmp = (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l))); end
function tmp_2 = code(x, l, t) t_1 = (sqrt(2.0) * t) / sqrt(((((l ^ 2.0) + (2.0 * (t ^ 2.0))) / x) + (((l ^ 2.0) / x) + (2.0 * ((t ^ 2.0) + ((t ^ 2.0) / x)))))); tmp = 0.0; if (t <= -7.9e+31) tmp = -sqrt(((-1.0 + x) / (x + 1.0))); elseif (t <= -1.3e-248) tmp = t_1; elseif (t <= -8.6e-277) tmp = -1.0; elseif (t <= 8e+74) tmp = t_1; else tmp = 1.0 - (1.0 / x); end tmp_2 = tmp; end
code[x_, l_, t_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] + N[(2.0 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, l_, t_] := Block[{t$95$1 = N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Power[l, 2.0], $MachinePrecision] + N[(2.0 * N[Power[t, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(N[(N[Power[l, 2.0], $MachinePrecision] / x), $MachinePrecision] + N[(2.0 * N[(N[Power[t, 2.0], $MachinePrecision] + N[(N[Power[t, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -7.9e+31], (-N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[t, -1.3e-248], t$95$1, If[LessEqual[t, -8.6e-277], -1.0, If[LessEqual[t, 8e+74], t$95$1, N[(1.0 - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}
\begin{array}{l}
t_1 := \frac{\sqrt{2} \cdot t}{\sqrt{\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} + \left(\frac{{\ell}^{2}}{x} + 2 \cdot \left({t}^{2} + \frac{{t}^{2}}{x}\right)\right)}}\\
\mathbf{if}\;t \leq -7.9 \cdot 10^{+31}:\\
\;\;\;\;-\sqrt{\frac{-1 + x}{x + 1}}\\
\mathbf{elif}\;t \leq -1.3 \cdot 10^{-248}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -8.6 \cdot 10^{-277}:\\
\;\;\;\;-1\\
\mathbf{elif}\;t \leq 8 \cdot 10^{+74}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{x}\\
\end{array}
Results
if t < -7.9000000000000003e31Initial program 43.4
Taylor expanded in t around -inf 5.4
Simplified4.5
[Start]5.4 | \[ -1 \cdot \left(\left(\sqrt{2} \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{x - 1}{1 + x}}\right)
\] |
|---|---|
rational_best-simplify-2 [=>]5.4 | \[ \color{blue}{\left(\left(\sqrt{2} \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{x - 1}{1 + x}}\right) \cdot -1}
\] |
rational_best-simplify-12 [=>]5.4 | \[ \color{blue}{-\left(\sqrt{2} \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{x - 1}{1 + x}}}
\] |
rational_best-simplify-2 [=>]5.4 | \[ -\color{blue}{\sqrt{\frac{x - 1}{1 + x}} \cdot \left(\sqrt{2} \cdot \sqrt{0.5}\right)}
\] |
exponential-simplify-19 [=>]4.5 | \[ -\sqrt{\frac{x - 1}{1 + x}} \cdot \color{blue}{\sqrt{0.5 \cdot 2}}
\] |
metadata-eval [=>]4.5 | \[ -\sqrt{\frac{x - 1}{1 + x}} \cdot \sqrt{\color{blue}{1}}
\] |
metadata-eval [=>]4.5 | \[ -\sqrt{\frac{x - 1}{1 + x}} \cdot \color{blue}{1}
\] |
rational_best-simplify-5 [=>]4.5 | \[ -\color{blue}{\sqrt{\frac{x - 1}{1 + x}}}
\] |
rational_best-simplify-18 [<=]4.5 | \[ -\sqrt{\frac{\color{blue}{x + -1}}{1 + x}}
\] |
rational_best-simplify-1 [=>]4.5 | \[ -\sqrt{\frac{\color{blue}{-1 + x}}{1 + x}}
\] |
rational_best-simplify-1 [=>]4.5 | \[ -\sqrt{\frac{-1 + x}{\color{blue}{x + 1}}}
\] |
if -7.9000000000000003e31 < t < -1.30000000000000003e-248 or -8.59999999999999981e-277 < t < 7.99999999999999961e74Initial program 41.3
Taylor expanded in x around inf 18.9
Simplified18.9
[Start]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{{\ell}^{2}}{x} + \left(2 \cdot \frac{{t}^{2}}{x} + 2 \cdot {t}^{2}\right)\right) - -1 \cdot \frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x}}}
\] |
|---|---|
rational_best-simplify-2 [=>]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{{\ell}^{2}}{x} + \left(2 \cdot \frac{{t}^{2}}{x} + 2 \cdot {t}^{2}\right)\right) - \color{blue}{\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} \cdot -1}}}
\] |
rational_best-simplify-12 [=>]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{{\ell}^{2}}{x} + \left(2 \cdot \frac{{t}^{2}}{x} + 2 \cdot {t}^{2}\right)\right) - \color{blue}{\left(-\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x}\right)}}}
\] |
rational_best-simplify-11 [=>]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{{\ell}^{2}}{x} + \left(2 \cdot \frac{{t}^{2}}{x} + 2 \cdot {t}^{2}\right)\right) - \color{blue}{\left(0 - \frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x}\right)}}}
\] |
rational_best-simplify-46 [=>]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} + \left(\left(\frac{{\ell}^{2}}{x} + \left(2 \cdot \frac{{t}^{2}}{x} + 2 \cdot {t}^{2}\right)\right) - 0\right)}}}
\] |
rational_best-simplify-6 [=>]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} + \color{blue}{\left(\frac{{\ell}^{2}}{x} + \left(2 \cdot \frac{{t}^{2}}{x} + 2 \cdot {t}^{2}\right)\right)}}}
\] |
rational_best-simplify-47 [=>]18.9 | \[ \frac{\sqrt{2} \cdot t}{\sqrt{\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} + \left(\frac{{\ell}^{2}}{x} + \color{blue}{2 \cdot \left({t}^{2} + \frac{{t}^{2}}{x}\right)}\right)}}
\] |
if -1.30000000000000003e-248 < t < -8.59999999999999981e-277Initial program 63.4
Taylor expanded in t around -inf 35.6
Simplified35.6
[Start]35.6 | \[ \frac{\sqrt{2} \cdot t}{-1 \cdot \left(\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}\right)}
\] |
|---|---|
rational_best-simplify-2 [=>]35.6 | \[ \frac{\sqrt{2} \cdot t}{\color{blue}{\left(\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}\right) \cdot -1}}
\] |
rational_best-simplify-12 [=>]35.6 | \[ \frac{\sqrt{2} \cdot t}{\color{blue}{-\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}}}
\] |
rational_best-simplify-2 [=>]35.6 | \[ \frac{\sqrt{2} \cdot t}{-\color{blue}{\sqrt{\frac{1 + x}{x - 1}} \cdot \left(\sqrt{2} \cdot t\right)}}
\] |
rational_best-simplify-44 [=>]35.6 | \[ \frac{\sqrt{2} \cdot t}{-\color{blue}{\sqrt{2} \cdot \left(\sqrt{\frac{1 + x}{x - 1}} \cdot t\right)}}
\] |
rational_best-simplify-1 [=>]35.6 | \[ \frac{\sqrt{2} \cdot t}{-\sqrt{2} \cdot \left(\sqrt{\frac{\color{blue}{x + 1}}{x - 1}} \cdot t\right)}
\] |
rational_best-simplify-18 [<=]35.6 | \[ \frac{\sqrt{2} \cdot t}{-\sqrt{2} \cdot \left(\sqrt{\frac{x + 1}{\color{blue}{x + -1}}} \cdot t\right)}
\] |
rational_best-simplify-1 [=>]35.6 | \[ \frac{\sqrt{2} \cdot t}{-\sqrt{2} \cdot \left(\sqrt{\frac{x + 1}{\color{blue}{-1 + x}}} \cdot t\right)}
\] |
Taylor expanded in x around inf 35.6
if 7.99999999999999961e74 < t Initial program 47.5
Taylor expanded in t around inf 4.2
Simplified3.2
[Start]4.2 | \[ \left(\sqrt{2} \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{x - 1}{1 + x}}
\] |
|---|---|
rational_best-simplify-2 [=>]4.2 | \[ \color{blue}{\sqrt{\frac{x - 1}{1 + x}} \cdot \left(\sqrt{2} \cdot \sqrt{0.5}\right)}
\] |
exponential-simplify-19 [=>]3.2 | \[ \sqrt{\frac{x - 1}{1 + x}} \cdot \color{blue}{\sqrt{0.5 \cdot 2}}
\] |
metadata-eval [=>]3.2 | \[ \sqrt{\frac{x - 1}{1 + x}} \cdot \sqrt{\color{blue}{1}}
\] |
metadata-eval [=>]3.2 | \[ \sqrt{\frac{x - 1}{1 + x}} \cdot \color{blue}{1}
\] |
rational_best-simplify-5 [=>]3.2 | \[ \color{blue}{\sqrt{\frac{x - 1}{1 + x}}}
\] |
rational_best-simplify-18 [<=]3.2 | \[ \sqrt{\frac{\color{blue}{x + -1}}{1 + x}}
\] |
rational_best-simplify-1 [=>]3.2 | \[ \sqrt{\frac{\color{blue}{-1 + x}}{1 + x}}
\] |
rational_best-simplify-1 [=>]3.2 | \[ \sqrt{\frac{-1 + x}{\color{blue}{x + 1}}}
\] |
Taylor expanded in x around inf 3.9
Final simplification11.9
| Alternative 1 | |
|---|---|
| Error | 15.1 |
| Cost | 20560 |
| Alternative 2 | |
|---|---|
| Error | 14.8 |
| Cost | 13640 |
| Alternative 3 | |
|---|---|
| Error | 15.3 |
| Cost | 7112 |
| Alternative 4 | |
|---|---|
| Error | 15.1 |
| Cost | 7112 |
| Alternative 5 | |
|---|---|
| Error | 15.5 |
| Cost | 6984 |
| Alternative 6 | |
|---|---|
| Error | 15.8 |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Error | 15.6 |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Error | 16.0 |
| Cost | 196 |
| Alternative 9 | |
|---|---|
| Error | 39.8 |
| Cost | 64 |
herbie shell --seed 2023094
(FPCore (x l t)
:name "Toniolo and Linder, Equation (7)"
:precision binary64
(/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))