| Alternative 1 | |
|---|---|
| Accuracy | 81.1% |
| Cost | 1237.00 |
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (+ x y) (/ (* y (- t z)) (- a t)))))
(if (<= t_1 (- INFINITY))
(- x (* (/ y t) (- a z)))
(if (or (<= t_1 -1e-237) (not (<= t_1 0.0)))
(+ x (- y (/ y (/ (- a t) (- z t)))))
(+ x (/ (* y (- z a)) t))))))double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) + ((y * (t - z)) / (a - t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x - ((y / t) * (a - z));
} else if ((t_1 <= -1e-237) || !(t_1 <= 0.0)) {
tmp = x + (y - (y / ((a - t) / (z - t))));
} else {
tmp = x + ((y * (z - a)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) + ((y * (t - z)) / (a - t));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x - ((y / t) * (a - z));
} else if ((t_1 <= -1e-237) || !(t_1 <= 0.0)) {
tmp = x + (y - (y / ((a - t) / (z - t))));
} else {
tmp = x + ((y * (z - a)) / t);
}
return tmp;
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a): t_1 = (x + y) + ((y * (t - z)) / (a - t)) tmp = 0 if t_1 <= -math.inf: tmp = x - ((y / t) * (a - z)) elif (t_1 <= -1e-237) or not (t_1 <= 0.0): tmp = x + (y - (y / ((a - t) / (z - t)))) else: tmp = x + ((y * (z - a)) / t) return tmp
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function code(x, y, z, t, a) t_1 = Float64(Float64(x + y) + Float64(Float64(y * Float64(t - z)) / Float64(a - t))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x - Float64(Float64(y / t) * Float64(a - z))); elseif ((t_1 <= -1e-237) || !(t_1 <= 0.0)) tmp = Float64(x + Float64(y - Float64(y / Float64(Float64(a - t) / Float64(z - t))))); else tmp = Float64(x + Float64(Float64(y * Float64(z - a)) / t)); end return tmp end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
function tmp_2 = code(x, y, z, t, a) t_1 = (x + y) + ((y * (t - z)) / (a - t)); tmp = 0.0; if (t_1 <= -Inf) tmp = x - ((y / t) * (a - z)); elseif ((t_1 <= -1e-237) || ~((t_1 <= 0.0))) tmp = x + (y - (y / ((a - t) / (z - t)))); else tmp = x + ((y * (z - a)) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] + N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x - N[(N[(y / t), $MachinePrecision] * N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$1, -1e-237], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(x + N[(y - N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := \left(x + y\right) + \frac{y \cdot \left(t - z\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x - \frac{y}{t} \cdot \left(a - z\right)\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-237} \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;x + \left(y - \frac{y}{\frac{a - t}{z - t}}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot \left(z - a\right)}{t}\\
\end{array}
Results
| Original | 74.4% |
|---|---|
| Target | 86.9% |
| Herbie | 92.3% |
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -inf.0Initial program 0.0%
Simplified70.1%
[Start]0.0 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
associate--l+ [=>]0.0 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
sub-neg [=>]0.0 | \[ x + \color{blue}{\left(y + \left(-\frac{\left(z - t\right) \cdot y}{a - t}\right)\right)}
\] |
+-commutative [=>]0.0 | \[ x + \color{blue}{\left(\left(-\frac{\left(z - t\right) \cdot y}{a - t}\right) + y\right)}
\] |
neg-mul-1 [=>]0.0 | \[ x + \left(\color{blue}{-1 \cdot \frac{\left(z - t\right) \cdot y}{a - t}} + y\right)
\] |
associate-*l/ [<=]70.1 | \[ x + \left(-1 \cdot \color{blue}{\left(\frac{z - t}{a - t} \cdot y\right)} + y\right)
\] |
associate-*r* [=>]70.1 | \[ x + \left(\color{blue}{\left(-1 \cdot \frac{z - t}{a - t}\right) \cdot y} + y\right)
\] |
fma-def [=>]70.1 | \[ x + \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{z - t}{a - t}, y, y\right)}
\] |
mul-1-neg [=>]70.1 | \[ x + \mathsf{fma}\left(\color{blue}{-\frac{z - t}{a - t}}, y, y\right)
\] |
neg-sub0 [=>]70.1 | \[ x + \mathsf{fma}\left(\color{blue}{0 - \frac{z - t}{a - t}}, y, y\right)
\] |
div-sub [=>]70.2 | \[ x + \mathsf{fma}\left(0 - \color{blue}{\left(\frac{z}{a - t} - \frac{t}{a - t}\right)}, y, y\right)
\] |
associate--r- [=>]70.2 | \[ x + \mathsf{fma}\left(\color{blue}{\left(0 - \frac{z}{a - t}\right) + \frac{t}{a - t}}, y, y\right)
\] |
neg-sub0 [<=]70.2 | \[ x + \mathsf{fma}\left(\color{blue}{\left(-\frac{z}{a - t}\right)} + \frac{t}{a - t}, y, y\right)
\] |
+-commutative [=>]70.2 | \[ x + \mathsf{fma}\left(\color{blue}{\frac{t}{a - t} + \left(-\frac{z}{a - t}\right)}, y, y\right)
\] |
sub-neg [<=]70.2 | \[ x + \mathsf{fma}\left(\color{blue}{\frac{t}{a - t} - \frac{z}{a - t}}, y, y\right)
\] |
div-sub [<=]70.1 | \[ x + \mathsf{fma}\left(\color{blue}{\frac{t - z}{a - t}}, y, y\right)
\] |
Taylor expanded in y around 0 83.2%
Taylor expanded in t around inf 39.0%
Simplified72.0%
[Start]39.0 | \[ -1 \cdot \frac{\left(-1 \cdot z + a\right) \cdot y}{t} + x
\] |
|---|---|
+-commutative [=>]39.0 | \[ \color{blue}{x + -1 \cdot \frac{\left(-1 \cdot z + a\right) \cdot y}{t}}
\] |
mul-1-neg [=>]39.0 | \[ x + \color{blue}{\left(-\frac{\left(-1 \cdot z + a\right) \cdot y}{t}\right)}
\] |
*-commutative [=>]39.0 | \[ x + \left(-\frac{\color{blue}{y \cdot \left(-1 \cdot z + a\right)}}{t}\right)
\] |
+-commutative [=>]39.0 | \[ x + \left(-\frac{y \cdot \color{blue}{\left(a + -1 \cdot z\right)}}{t}\right)
\] |
mul-1-neg [=>]39.0 | \[ x + \left(-\frac{y \cdot \left(a + \color{blue}{\left(-z\right)}\right)}{t}\right)
\] |
sub-neg [<=]39.0 | \[ x + \left(-\frac{y \cdot \color{blue}{\left(a - z\right)}}{t}\right)
\] |
unsub-neg [=>]39.0 | \[ \color{blue}{x - \frac{y \cdot \left(a - z\right)}{t}}
\] |
associate-/l* [=>]70.0 | \[ x - \color{blue}{\frac{y}{\frac{t}{a - z}}}
\] |
associate-/r/ [=>]72.0 | \[ x - \color{blue}{\frac{y}{t} \cdot \left(a - z\right)}
\] |
if -inf.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -9.9999999999999999e-238 or 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 87.9%
Simplified93.8%
[Start]87.9 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
+-rgt-identity [<=]87.9 | \[ \color{blue}{\left(\left(x + y\right) + 0\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+l+ [=>]87.9 | \[ \color{blue}{\left(x + \left(y + 0\right)\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+r- [<=]88.2 | \[ \color{blue}{x + \left(\left(y + 0\right) - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
+-rgt-identity [=>]88.2 | \[ x + \left(\color{blue}{y} - \frac{\left(z - t\right) \cdot y}{a - t}\right)
\] |
*-commutative [=>]88.2 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
associate-/l* [=>]93.8 | \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right)
\] |
if -9.9999999999999999e-238 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0Initial program 10.7%
Simplified48.8%
[Start]10.7 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
+-rgt-identity [<=]10.7 | \[ \color{blue}{\left(\left(x + y\right) + 0\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+l+ [=>]10.7 | \[ \color{blue}{\left(x + \left(y + 0\right)\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+r- [<=]48.2 | \[ \color{blue}{x + \left(\left(y + 0\right) - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
+-rgt-identity [=>]48.2 | \[ x + \left(\color{blue}{y} - \frac{\left(z - t\right) \cdot y}{a - t}\right)
\] |
*-commutative [=>]48.2 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
associate-/l* [=>]48.8 | \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right)
\] |
Taylor expanded in t around inf 96.1%
Simplified96.1%
[Start]96.1 | \[ x + \frac{-1 \cdot \left(a \cdot y\right) - -1 \cdot \left(y \cdot z\right)}{t}
\] |
|---|---|
*-commutative [<=]96.1 | \[ x + \frac{-1 \cdot \color{blue}{\left(y \cdot a\right)} - -1 \cdot \left(y \cdot z\right)}{t}
\] |
distribute-lft-out-- [=>]96.1 | \[ x + \frac{\color{blue}{-1 \cdot \left(y \cdot a - y \cdot z\right)}}{t}
\] |
distribute-lft-out-- [=>]96.1 | \[ x + \frac{-1 \cdot \color{blue}{\left(y \cdot \left(a - z\right)\right)}}{t}
\] |
associate-*r* [=>]96.1 | \[ x + \frac{\color{blue}{\left(-1 \cdot y\right) \cdot \left(a - z\right)}}{t}
\] |
neg-mul-1 [<=]96.1 | \[ x + \frac{\color{blue}{\left(-y\right)} \cdot \left(a - z\right)}{t}
\] |
Final simplification92.3%
| Alternative 1 | |
|---|---|
| Accuracy | 81.1% |
| Cost | 1237.00 |
| Alternative 2 | |
|---|---|
| Accuracy | 80.0% |
| Cost | 1236.00 |
| Alternative 3 | |
|---|---|
| Accuracy | 87.7% |
| Cost | 1232.00 |
| Alternative 4 | |
|---|---|
| Accuracy | 93.1% |
| Cost | 1220.00 |
| Alternative 5 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 1104.00 |
| Alternative 6 | |
|---|---|
| Accuracy | 82.1% |
| Cost | 1104.00 |
| Alternative 7 | |
|---|---|
| Accuracy | 68.0% |
| Cost | 720.00 |
| Alternative 8 | |
|---|---|
| Accuracy | 76.1% |
| Cost | 712.00 |
| Alternative 9 | |
|---|---|
| Accuracy | 76.4% |
| Cost | 712.00 |
| Alternative 10 | |
|---|---|
| Accuracy | 55.8% |
| Cost | 592.00 |
| Alternative 11 | |
|---|---|
| Accuracy | 67.7% |
| Cost | 456.00 |
| Alternative 12 | |
|---|---|
| Accuracy | 54.7% |
| Cost | 64.00 |
herbie shell --seed 2023096
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:precision binary64
:herbie-target
(if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))
(- (+ x y) (/ (* (- z t) y) (- a t))))