| Alternative 1 | |
|---|---|
| Error | 82.3% |
| Cost | 13713.00 |
(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
(if (<= t -5.5e-27)
(- (sqrt (/ (+ -1.0 x) (+ x 1.0))))
(if (<= t 3.8e-31)
(/ t (hypot t (sqrt (* l (/ l x)))))
(/ 1.0 (sqrt (/ (- -1.0 x) (- 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 tmp;
if (t <= -5.5e-27) {
tmp = -sqrt(((-1.0 + x) / (x + 1.0)));
} else if (t <= 3.8e-31) {
tmp = t / hypot(t, sqrt((l * (l / x))));
} else {
tmp = 1.0 / sqrt(((-1.0 - x) / (1.0 - x)));
}
return tmp;
}
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 tmp;
if (t <= -5.5e-27) {
tmp = -Math.sqrt(((-1.0 + x) / (x + 1.0)));
} else if (t <= 3.8e-31) {
tmp = t / Math.hypot(t, Math.sqrt((l * (l / x))));
} else {
tmp = 1.0 / Math.sqrt(((-1.0 - x) / (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): tmp = 0 if t <= -5.5e-27: tmp = -math.sqrt(((-1.0 + x) / (x + 1.0))) elif t <= 3.8e-31: tmp = t / math.hypot(t, math.sqrt((l * (l / x)))) else: tmp = 1.0 / math.sqrt(((-1.0 - x) / (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) tmp = 0.0 if (t <= -5.5e-27) tmp = Float64(-sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0)))); elseif (t <= 3.8e-31) tmp = Float64(t / hypot(t, sqrt(Float64(l * Float64(l / x))))); else tmp = Float64(1.0 / sqrt(Float64(Float64(-1.0 - x) / 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) tmp = 0.0; if (t <= -5.5e-27) tmp = -sqrt(((-1.0 + x) / (x + 1.0))); elseif (t <= 3.8e-31) tmp = t / hypot(t, sqrt((l * (l / x)))); else tmp = 1.0 / sqrt(((-1.0 - x) / (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_] := If[LessEqual[t, -5.5e-27], (-N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[t, 3.8e-31], N[(t / N[Sqrt[t ^ 2 + N[Sqrt[N[(l * N[(l / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(N[(-1.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $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}
\mathbf{if}\;t \leq -5.5 \cdot 10^{-27}:\\
\;\;\;\;-\sqrt{\frac{-1 + x}{x + 1}}\\
\mathbf{elif}\;t \leq 3.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{t}{\mathsf{hypot}\left(t, \sqrt{\ell \cdot \frac{\ell}{x}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{-1 - x}{1 - x}}}\\
\end{array}
Results
if t < -5.5000000000000002e-27Initial program 36.5
Taylor expanded in t around -inf 91.3
Simplified91.3
[Start]91.3 | \[ \frac{\sqrt{2} \cdot t}{-1 \cdot \left(\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}\right)}
\] |
|---|---|
mul-1-neg [=>]91.3 | \[ \frac{\sqrt{2} \cdot t}{\color{blue}{-\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}}}
\] |
*-commutative [<=]91.3 | \[ \frac{\sqrt{2} \cdot t}{-\color{blue}{\left(t \cdot \sqrt{2}\right)} \cdot \sqrt{\frac{1 + x}{x - 1}}}
\] |
sub-neg [=>]91.3 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1 + x}{\color{blue}{x + \left(-1\right)}}}}
\] |
metadata-eval [=>]91.3 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1 + x}{x + \color{blue}{-1}}}}
\] |
+-commutative [=>]91.3 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{\color{blue}{x + 1}}{x + -1}}}
\] |
+-commutative [=>]91.3 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{x + 1}{\color{blue}{-1 + x}}}}
\] |
Taylor expanded in t around 0 91.3
Simplified91.3
[Start]91.3 | \[ -1 \cdot \sqrt{\frac{x - 1}{1 + x}}
\] |
|---|---|
mul-1-neg [=>]91.3 | \[ \color{blue}{-\sqrt{\frac{x - 1}{1 + x}}}
\] |
sub-neg [=>]91.3 | \[ -\sqrt{\frac{\color{blue}{x + \left(-1\right)}}{1 + x}}
\] |
metadata-eval [=>]91.3 | \[ -\sqrt{\frac{x + \color{blue}{-1}}{1 + x}}
\] |
+-commutative [=>]91.3 | \[ -\sqrt{\frac{\color{blue}{-1 + x}}{1 + x}}
\] |
+-commutative [<=]91.3 | \[ -\sqrt{\frac{-1 + x}{\color{blue}{x + 1}}}
\] |
if -5.5000000000000002e-27 < t < 3.8e-31Initial program 24.5
Simplified13.5
[Start]24.5 | \[ \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}}
\] |
|---|---|
associate-*r/ [<=]24.5 | \[ \color{blue}{\sqrt{2} \cdot \frac{t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}}
\] |
associate-*l/ [=>]25.7 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{\frac{\left(x + 1\right) \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)}{x - 1}} - \ell \cdot \ell}}
\] |
associate-*r/ [<=]12.4 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{\left(x + 1\right) \cdot \frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1}} - \ell \cdot \ell}}
\] |
*-lft-identity [<=]12.4 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{\left(1 \cdot \left(x + 1\right)\right)} \cdot \frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1} - \ell \cdot \ell}}
\] |
associate-*r* [<=]12.4 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{1 \cdot \left(\left(x + 1\right) \cdot \frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1}\right)} - \ell \cdot \ell}}
\] |
*-commutative [<=]12.4 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{1 \cdot \color{blue}{\left(\frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1} \cdot \left(x + 1\right)\right)} - \ell \cdot \ell}}
\] |
associate-*r* [=>]12.4 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{\left(1 \cdot \frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1}\right) \cdot \left(x + 1\right)} - \ell \cdot \ell}}
\] |
*-commutative [<=]12.4 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{\left(x + 1\right) \cdot \left(1 \cdot \frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1}\right)} - \ell \cdot \ell}}
\] |
fma-neg [=>]13.5 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{\mathsf{fma}\left(x + 1, 1 \cdot \frac{\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)}{x - 1}, -\ell \cdot \ell\right)}}}
\] |
Taylor expanded in x around -inf 65.9
Simplified65.9
[Start]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} + 2 \cdot {t}^{2}}}
\] |
|---|---|
distribute-lft-out [=>]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{\color{blue}{2 \cdot \left(\frac{{\ell}^{2} + 2 \cdot {t}^{2}}{x} + {t}^{2}\right)}}}
\] |
+-commutative [=>]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{\color{blue}{2 \cdot {t}^{2} + {\ell}^{2}}}{x} + {t}^{2}\right)}}
\] |
unpow2 [=>]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{2 \cdot {t}^{2} + \color{blue}{\ell \cdot \ell}}{x} + {t}^{2}\right)}}
\] |
fma-udef [<=]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{\color{blue}{\mathsf{fma}\left(2, {t}^{2}, \ell \cdot \ell\right)}}{x} + {t}^{2}\right)}}
\] |
unpow2 [=>]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{\mathsf{fma}\left(2, \color{blue}{t \cdot t}, \ell \cdot \ell\right)}{x} + {t}^{2}\right)}}
\] |
unpow2 [=>]65.9 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{\mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{x} + \color{blue}{t \cdot t}\right)}}
\] |
Taylor expanded in t around 0 65.7
Simplified72.2
[Start]65.7 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{{\ell}^{2}}{x} + t \cdot t\right)}}
\] |
|---|---|
unpow2 [=>]65.7 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\frac{\color{blue}{\ell \cdot \ell}}{x} + t \cdot t\right)}}
\] |
associate-/l* [=>]72.2 | \[ \sqrt{2} \cdot \frac{t}{\sqrt{2 \cdot \left(\color{blue}{\frac{\ell}{\frac{x}{\ell}}} + t \cdot t\right)}}
\] |
Applied egg-rr87.7
Simplified87.8
[Start]87.7 | \[ \frac{\frac{t \cdot \sqrt{2}}{\sqrt{2}}}{\mathsf{hypot}\left(t, \sqrt{\ell \cdot \frac{\ell}{x}}\right)}
\] |
|---|---|
associate-/l* [=>]87.8 | \[ \frac{\color{blue}{\frac{t}{\frac{\sqrt{2}}{\sqrt{2}}}}}{\mathsf{hypot}\left(t, \sqrt{\ell \cdot \frac{\ell}{x}}\right)}
\] |
*-inverses [=>]87.8 | \[ \frac{\frac{t}{\color{blue}{1}}}{\mathsf{hypot}\left(t, \sqrt{\ell \cdot \frac{\ell}{x}}\right)}
\] |
if 3.8e-31 < t Initial program 36.3
Taylor expanded in t around -inf 1.6
Simplified1.6
[Start]1.6 | \[ \frac{\sqrt{2} \cdot t}{-1 \cdot \left(\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}\right)}
\] |
|---|---|
mul-1-neg [=>]1.6 | \[ \frac{\sqrt{2} \cdot t}{\color{blue}{-\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}}}
\] |
*-commutative [<=]1.6 | \[ \frac{\sqrt{2} \cdot t}{-\color{blue}{\left(t \cdot \sqrt{2}\right)} \cdot \sqrt{\frac{1 + x}{x - 1}}}
\] |
sub-neg [=>]1.6 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1 + x}{\color{blue}{x + \left(-1\right)}}}}
\] |
metadata-eval [=>]1.6 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1 + x}{x + \color{blue}{-1}}}}
\] |
+-commutative [=>]1.6 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{\color{blue}{x + 1}}{x + -1}}}
\] |
+-commutative [=>]1.6 | \[ \frac{\sqrt{2} \cdot t}{-\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{x + 1}{\color{blue}{-1 + x}}}}
\] |
Applied egg-rr92.2
Simplified92.5
[Start]92.2 | \[ \frac{-1}{t \cdot \sqrt{2}} \cdot \frac{t \cdot \sqrt{2}}{-\sqrt{\frac{-1 - x}{1 - x}}}
\] |
|---|---|
associate-*r/ [=>]92.2 | \[ \color{blue}{\frac{\frac{-1}{t \cdot \sqrt{2}} \cdot \left(t \cdot \sqrt{2}\right)}{-\sqrt{\frac{-1 - x}{1 - x}}}}
\] |
neg-mul-1 [=>]92.2 | \[ \frac{\frac{-1}{t \cdot \sqrt{2}} \cdot \left(t \cdot \sqrt{2}\right)}{\color{blue}{-1 \cdot \sqrt{\frac{-1 - x}{1 - x}}}}
\] |
associate-/r* [=>]92.2 | \[ \color{blue}{\frac{\frac{\frac{-1}{t \cdot \sqrt{2}} \cdot \left(t \cdot \sqrt{2}\right)}{-1}}{\sqrt{\frac{-1 - x}{1 - x}}}}
\] |
Final simplification90.4
| Alternative 1 | |
|---|---|
| Error | 82.3% |
| Cost | 13713.00 |
| Alternative 2 | |
|---|---|
| Error | 77.7% |
| Cost | 7505.00 |
| Alternative 3 | |
|---|---|
| Error | 77.0% |
| Cost | 7377.00 |
| Alternative 4 | |
|---|---|
| Error | 77.2% |
| Cost | 7377.00 |
| Alternative 5 | |
|---|---|
| Error | 77.4% |
| Cost | 7377.00 |
| Alternative 6 | |
|---|---|
| Error | 77.5% |
| Cost | 7377.00 |
| Alternative 7 | |
|---|---|
| Error | 76.8% |
| Cost | 7249.00 |
| Alternative 8 | |
|---|---|
| Error | 76.8% |
| Cost | 7248.00 |
| Alternative 9 | |
|---|---|
| Error | 76.9% |
| Cost | 7248.00 |
| Alternative 10 | |
|---|---|
| Error | 76.7% |
| Cost | 7248.00 |
| Alternative 11 | |
|---|---|
| Error | 76.3% |
| Cost | 836.00 |
| Alternative 12 | |
|---|---|
| Error | 76.2% |
| Cost | 452.00 |
| Alternative 13 | |
|---|---|
| Error | 75.8% |
| Cost | 196.00 |
| Alternative 14 | |
|---|---|
| Error | 38.9% |
| Cost | 64.00 |
herbie shell --seed 2023093
(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)))))