| Alternative 1 | |
|---|---|
| Accuracy | 73.1% |
| Cost | 1176 |
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t) :precision binary64 (if (<= (* z t) (- INFINITY)) (/ (/ x (- z)) t) (if (<= (* z t) 2e+230) (/ x (- y (* z t))) (/ (/ (- x) t) z))))
double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = (x / -z) / t;
} else if ((z * t) <= 2e+230) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / t) / z;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = (x / -z) / t;
} else if ((z * t) <= 2e+230) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / t) / z;
}
return tmp;
}
def code(x, y, z, t): return x / (y - (z * t))
def code(x, y, z, t): tmp = 0 if (z * t) <= -math.inf: tmp = (x / -z) / t elif (z * t) <= 2e+230: tmp = x / (y - (z * t)) else: tmp = (-x / t) / z return tmp
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = Float64(Float64(x / Float64(-z)) / t); elseif (Float64(z * t) <= 2e+230) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(Float64(-x) / t) / z); end return tmp end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * t) <= -Inf) tmp = (x / -z) / t; elseif ((z * t) <= 2e+230) tmp = x / (y - (z * t)); else tmp = (-x / t) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(N[(x / (-z)), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+230], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision]]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{\frac{x}{-z}}{t}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+230}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\end{array}
Results
| Original | 95.7% |
|---|---|
| Target | 96.7% |
| Herbie | 99.7% |
if (*.f64 z t) < -inf.0Initial program 58.2%
Applied egg-rr58.2%
[Start]58.2 | \[ \frac{x}{y - z \cdot t}
\] |
|---|---|
add-cube-cbrt [=>]58.2 | \[ \frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{y - z \cdot t}
\] |
add-sqr-sqrt [=>]58.2 | \[ \frac{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}{\color{blue}{\sqrt{y - z \cdot t} \cdot \sqrt{y - z \cdot t}}}
\] |
times-frac [=>]58.2 | \[ \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt{y - z \cdot t}} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}}
\] |
pow2 [=>]58.2 | \[ \frac{\color{blue}{{\left(\sqrt[3]{x}\right)}^{2}}}{\sqrt{y - z \cdot t}} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}
\] |
Simplified58.2%
[Start]58.2 | \[ \frac{{\left(\sqrt[3]{x}\right)}^{2}}{\sqrt{y - z \cdot t}} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}
\] |
|---|---|
associate-*l/ [=>]58.2 | \[ \color{blue}{\frac{{\left(\sqrt[3]{x}\right)}^{2} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}}{\sqrt{y - z \cdot t}}}
\] |
associate-*r/ [=>]58.2 | \[ \frac{\color{blue}{\frac{{\left(\sqrt[3]{x}\right)}^{2} \cdot \sqrt[3]{x}}{\sqrt{y - z \cdot t}}}}{\sqrt{y - z \cdot t}}
\] |
unpow2 [=>]58.2 | \[ \frac{\frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)} \cdot \sqrt[3]{x}}{\sqrt{y - z \cdot t}}}{\sqrt{y - z \cdot t}}
\] |
rem-3cbrt-lft [=>]58.2 | \[ \frac{\frac{\color{blue}{x}}{\sqrt{y - z \cdot t}}}{\sqrt{y - z \cdot t}}
\] |
associate-/l/ [=>]58.2 | \[ \color{blue}{\frac{x}{\sqrt{y - z \cdot t} \cdot \sqrt{y - z \cdot t}}}
\] |
*-commutative [=>]58.2 | \[ \frac{x}{\sqrt{y - \color{blue}{t \cdot z}} \cdot \sqrt{y - z \cdot t}}
\] |
*-commutative [=>]58.2 | \[ \frac{x}{\sqrt{y - t \cdot z} \cdot \sqrt{y - \color{blue}{t \cdot z}}}
\] |
Taylor expanded in y around 0 58.2%
Simplified99.8%
[Start]58.2 | \[ -1 \cdot \frac{x}{t \cdot z}
\] |
|---|---|
associate-*r/ [=>]58.2 | \[ \color{blue}{\frac{-1 \cdot x}{t \cdot z}}
\] |
neg-mul-1 [<=]58.2 | \[ \frac{\color{blue}{-x}}{t \cdot z}
\] |
associate-/r* [=>]99.8 | \[ \color{blue}{\frac{\frac{-x}{t}}{z}}
\] |
Taylor expanded in x around 0 58.2%
Simplified99.8%
[Start]58.2 | \[ -1 \cdot \frac{x}{t \cdot z}
\] |
|---|---|
associate-/r* [=>]99.8 | \[ -1 \cdot \color{blue}{\frac{\frac{x}{t}}{z}}
\] |
metadata-eval [<=]99.8 | \[ \color{blue}{\frac{1}{-1}} \cdot \frac{\frac{x}{t}}{z}
\] |
times-frac [<=]99.8 | \[ \color{blue}{\frac{1 \cdot \frac{x}{t}}{-1 \cdot z}}
\] |
neg-mul-1 [<=]99.8 | \[ \frac{1 \cdot \frac{x}{t}}{\color{blue}{-z}}
\] |
associate-*l/ [<=]99.7 | \[ \color{blue}{\frac{1}{-z} \cdot \frac{x}{t}}
\] |
associate-*r/ [=>]99.7 | \[ \color{blue}{\frac{\frac{1}{-z} \cdot x}{t}}
\] |
associate-*l/ [=>]99.8 | \[ \frac{\color{blue}{\frac{1 \cdot x}{-z}}}{t}
\] |
*-lft-identity [=>]99.8 | \[ \frac{\frac{\color{blue}{x}}{-z}}{t}
\] |
if -inf.0 < (*.f64 z t) < 2.0000000000000002e230Initial program 99.9%
if 2.0000000000000002e230 < (*.f64 z t) Initial program 72.0%
Applied egg-rr0.0%
[Start]72.0 | \[ \frac{x}{y - z \cdot t}
\] |
|---|---|
add-cube-cbrt [=>]71.5 | \[ \frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{y - z \cdot t}
\] |
add-sqr-sqrt [=>]0.0 | \[ \frac{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}{\color{blue}{\sqrt{y - z \cdot t} \cdot \sqrt{y - z \cdot t}}}
\] |
times-frac [=>]0.0 | \[ \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt{y - z \cdot t}} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}}
\] |
pow2 [=>]0.0 | \[ \frac{\color{blue}{{\left(\sqrt[3]{x}\right)}^{2}}}{\sqrt{y - z \cdot t}} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}
\] |
Simplified0.0%
[Start]0.0 | \[ \frac{{\left(\sqrt[3]{x}\right)}^{2}}{\sqrt{y - z \cdot t}} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}
\] |
|---|---|
associate-*l/ [=>]0.0 | \[ \color{blue}{\frac{{\left(\sqrt[3]{x}\right)}^{2} \cdot \frac{\sqrt[3]{x}}{\sqrt{y - z \cdot t}}}{\sqrt{y - z \cdot t}}}
\] |
associate-*r/ [=>]0.0 | \[ \frac{\color{blue}{\frac{{\left(\sqrt[3]{x}\right)}^{2} \cdot \sqrt[3]{x}}{\sqrt{y - z \cdot t}}}}{\sqrt{y - z \cdot t}}
\] |
unpow2 [=>]0.0 | \[ \frac{\frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)} \cdot \sqrt[3]{x}}{\sqrt{y - z \cdot t}}}{\sqrt{y - z \cdot t}}
\] |
rem-3cbrt-lft [=>]0.0 | \[ \frac{\frac{\color{blue}{x}}{\sqrt{y - z \cdot t}}}{\sqrt{y - z \cdot t}}
\] |
associate-/l/ [=>]0.0 | \[ \color{blue}{\frac{x}{\sqrt{y - z \cdot t} \cdot \sqrt{y - z \cdot t}}}
\] |
*-commutative [=>]0.0 | \[ \frac{x}{\sqrt{y - \color{blue}{t \cdot z}} \cdot \sqrt{y - z \cdot t}}
\] |
*-commutative [=>]0.0 | \[ \frac{x}{\sqrt{y - t \cdot z} \cdot \sqrt{y - \color{blue}{t \cdot z}}}
\] |
Taylor expanded in y around 0 72.0%
Simplified99.7%
[Start]72.0 | \[ -1 \cdot \frac{x}{t \cdot z}
\] |
|---|---|
associate-*r/ [=>]72.0 | \[ \color{blue}{\frac{-1 \cdot x}{t \cdot z}}
\] |
neg-mul-1 [<=]72.0 | \[ \frac{\color{blue}{-x}}{t \cdot z}
\] |
associate-/r* [=>]99.7 | \[ \color{blue}{\frac{\frac{-x}{t}}{z}}
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 73.1% |
| Cost | 1176 |
| Alternative 2 | |
|---|---|
| Accuracy | 73.4% |
| Cost | 1176 |
| Alternative 3 | |
|---|---|
| Accuracy | 70.8% |
| Cost | 913 |
| Alternative 4 | |
|---|---|
| Accuracy | 58.1% |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Accuracy | 58.6% |
| Cost | 584 |
| Alternative 6 | |
|---|---|
| Accuracy | 54.0% |
| Cost | 192 |
herbie shell --seed 2023160
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))
(/ x (- y (* z t))))