| Alternative 1 | |
|---|---|
| Error | 14.5 |
| Cost | 1104 |
(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) (/ (* (- z t) y) (- a t)))))
(if (<= t_1 (- INFINITY))
(+ x (* (- z a) (/ y t)))
(if (<= t_1 -1e-237)
t_1
(if (<= t_1 0.0)
(+ (/ (* y (- z a)) t) x)
(- (+ x y) (* y (/ (- z t) (- 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) - (((z - t) * y) / (a - t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x + ((z - a) * (y / t));
} else if (t_1 <= -1e-237) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = ((y * (z - a)) / t) + x;
} else {
tmp = (x + y) - (y * ((z - t) / (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) - (((z - t) * y) / (a - t));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x + ((z - a) * (y / t));
} else if (t_1 <= -1e-237) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = ((y * (z - a)) / t) + x;
} else {
tmp = (x + y) - (y * ((z - t) / (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) - (((z - t) * y) / (a - t)) tmp = 0 if t_1 <= -math.inf: tmp = x + ((z - a) * (y / t)) elif t_1 <= -1e-237: tmp = t_1 elif t_1 <= 0.0: tmp = ((y * (z - a)) / t) + x else: tmp = (x + y) - (y * ((z - t) / (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(Float64(z - t) * y) / Float64(a - t))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x + Float64(Float64(z - a) * Float64(y / t))); elseif (t_1 <= -1e-237) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(y * Float64(z - a)) / t) + x); else tmp = Float64(Float64(x + y) - Float64(y * Float64(Float64(z - t) / Float64(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) - (((z - t) * y) / (a - t)); tmp = 0.0; if (t_1 <= -Inf) tmp = x + ((z - a) * (y / t)); elseif (t_1 <= -1e-237) tmp = t_1; elseif (t_1 <= 0.0) tmp = ((y * (z - a)) / t) + x; else tmp = (x + y) - (y * ((z - t) / (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[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(N[(z - a), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-237], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(N[(y * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $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{\left(z - t\right) \cdot y}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + \left(z - a\right) \cdot \frac{y}{t}\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-237}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{y \cdot \left(z - a\right)}{t} + x\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) - y \cdot \frac{z - t}{a - t}\\
\end{array}
Results
| Original | 16.4 |
|---|---|
| Target | 8.4 |
| Herbie | 5.6 |
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -inf.0Initial program 64.0
Simplified28.6
[Start]64.0 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational_best-simplify-47 [=>]28.6 | \[ \left(x + y\right) - \color{blue}{y \cdot \frac{z - t}{a - t}}
\] |
Taylor expanded in t around -inf 39.0
Simplified17.9
[Start]39.0 | \[ -1 \cdot \frac{y \cdot a - y \cdot z}{t} + x
\] |
|---|---|
rational_best-simplify-1 [=>]39.0 | \[ \color{blue}{x + -1 \cdot \frac{y \cdot a - y \cdot z}{t}}
\] |
rational_best-simplify-2 [=>]39.0 | \[ x + \color{blue}{\frac{y \cdot a - y \cdot z}{t} \cdot -1}
\] |
rational_best-simplify-12 [=>]39.0 | \[ x + \color{blue}{\left(-\frac{y \cdot a - y \cdot z}{t}\right)}
\] |
rational_best-simplify-10 [=>]39.0 | \[ x + \color{blue}{\left(0 - \frac{y \cdot a - y \cdot z}{t}\right)}
\] |
rational_best-simplify-53 [=>]39.0 | \[ x + \left(0 - \color{blue}{\left(\frac{y \cdot a}{t} - \frac{y \cdot z}{t}\right)}\right)
\] |
rational_best-simplify-46 [=>]39.0 | \[ x + \color{blue}{\left(\frac{y \cdot z}{t} - \left(\frac{y \cdot a}{t} - 0\right)\right)}
\] |
rational_best-simplify-4 [=>]39.0 | \[ x + \left(\frac{y \cdot z}{t} - \color{blue}{\frac{y \cdot a}{t}}\right)
\] |
rational_best-simplify-53 [<=]39.0 | \[ x + \color{blue}{\frac{y \cdot z - y \cdot a}{t}}
\] |
rational_best-simplify-50 [=>]39.0 | \[ x + \frac{\color{blue}{y \cdot \left(z - a\right)}}{t}
\] |
rational_best-simplify-47 [=>]17.9 | \[ x + \color{blue}{\left(z - a\right) \cdot \frac{y}{t}}
\] |
if -inf.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -9.9999999999999999e-238Initial program 1.5
if -9.9999999999999999e-238 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0Initial program 57.2
Simplified57.5
[Start]57.2 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational_best-simplify-2 [=>]57.2 | \[ \left(x + y\right) - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}
\] |
rational_best-simplify-47 [=>]57.5 | \[ \left(x + y\right) - \color{blue}{\left(z - t\right) \cdot \frac{y}{a - t}}
\] |
Taylor expanded in t around -inf 2.5
Simplified2.3
[Start]2.5 | \[ -1 \cdot \frac{y \cdot a - y \cdot z}{t} + x
\] |
|---|---|
rational_best-simplify-1 [=>]2.5 | \[ \color{blue}{x + -1 \cdot \frac{y \cdot a - y \cdot z}{t}}
\] |
rational_best-simplify-2 [=>]2.5 | \[ x + \color{blue}{\frac{y \cdot a - y \cdot z}{t} \cdot -1}
\] |
rational_best-simplify-12 [=>]2.5 | \[ x + \color{blue}{\left(-\frac{y \cdot a - y \cdot z}{t}\right)}
\] |
rational_best-simplify-10 [=>]2.5 | \[ x + \color{blue}{\left(0 - \frac{y \cdot a - y \cdot z}{t}\right)}
\] |
rational_best-simplify-53 [=>]2.5 | \[ x + \left(0 - \color{blue}{\left(\frac{y \cdot a}{t} - \frac{y \cdot z}{t}\right)}\right)
\] |
rational_best-simplify-46 [=>]2.5 | \[ x + \color{blue}{\left(\frac{y \cdot z}{t} - \left(\frac{y \cdot a}{t} - 0\right)\right)}
\] |
rational_best-simplify-4 [=>]2.5 | \[ x + \left(\frac{y \cdot z}{t} - \color{blue}{\frac{y \cdot a}{t}}\right)
\] |
rational_best-simplify-53 [<=]2.5 | \[ x + \color{blue}{\frac{y \cdot z - y \cdot a}{t}}
\] |
rational_best-simplify-50 [=>]2.5 | \[ x + \frac{\color{blue}{y \cdot \left(z - a\right)}}{t}
\] |
rational_best-simplify-2 [=>]2.5 | \[ x + \frac{\color{blue}{\left(z - a\right) \cdot y}}{t}
\] |
rational_best-simplify-47 [=>]2.3 | \[ x + \color{blue}{y \cdot \frac{z - a}{t}}
\] |
Taylor expanded in x around 0 2.5
if 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 12.8
Simplified7.3
[Start]12.8 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational_best-simplify-47 [=>]7.3 | \[ \left(x + y\right) - \color{blue}{y \cdot \frac{z - t}{a - t}}
\] |
Final simplification5.6
| Alternative 1 | |
|---|---|
| Error | 14.5 |
| Cost | 1104 |
| Alternative 2 | |
|---|---|
| Error | 14.6 |
| Cost | 1104 |
| Alternative 3 | |
|---|---|
| Error | 11.5 |
| Cost | 1104 |
| Alternative 4 | |
|---|---|
| Error | 7.6 |
| Cost | 1096 |
| Alternative 5 | |
|---|---|
| Error | 20.5 |
| Cost | 720 |
| Alternative 6 | |
|---|---|
| Error | 15.1 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 28.3 |
| Cost | 592 |
| Alternative 8 | |
|---|---|
| Error | 20.7 |
| Cost | 456 |
| Alternative 9 | |
|---|---|
| Error | 29.0 |
| Cost | 64 |
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))))