| Alternative 1 | |
|---|---|
| Accuracy | 71.2% |
| Cost | 1108 |
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
:precision binary64
(if (<= t -3.6e+85)
(+ (- x (* (/ y t) a)) (* (/ y t) z))
(if (<= t 2.3e+33)
(+ x (+ y (/ (- t z) (/ (- a t) y))))
(- x (/ y (/ t (- a z)))))))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 tmp;
if (t <= -3.6e+85) {
tmp = (x - ((y / t) * a)) + ((y / t) * z);
} else if (t <= 2.3e+33) {
tmp = x + (y + ((t - z) / ((a - t) / y)));
} else {
tmp = x - (y / (t / (a - z)));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (x + y) - (((z - t) * y) / (a - t))
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (t <= (-3.6d+85)) then
tmp = (x - ((y / t) * a)) + ((y / t) * z)
else if (t <= 2.3d+33) then
tmp = x + (y + ((t - z) / ((a - t) / y)))
else
tmp = x - (y / (t / (a - z)))
end if
code = tmp
end function
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 tmp;
if (t <= -3.6e+85) {
tmp = (x - ((y / t) * a)) + ((y / t) * z);
} else if (t <= 2.3e+33) {
tmp = x + (y + ((t - z) / ((a - t) / y)));
} else {
tmp = x - (y / (t / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a): tmp = 0 if t <= -3.6e+85: tmp = (x - ((y / t) * a)) + ((y / t) * z) elif t <= 2.3e+33: tmp = x + (y + ((t - z) / ((a - t) / y))) else: tmp = x - (y / (t / (a - z))) 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) tmp = 0.0 if (t <= -3.6e+85) tmp = Float64(Float64(x - Float64(Float64(y / t) * a)) + Float64(Float64(y / t) * z)); elseif (t <= 2.3e+33) tmp = Float64(x + Float64(y + Float64(Float64(t - z) / Float64(Float64(a - t) / y)))); else tmp = Float64(x - Float64(y / Float64(t / Float64(a - z)))); 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) tmp = 0.0; if (t <= -3.6e+85) tmp = (x - ((y / t) * a)) + ((y / t) * z); elseif (t <= 2.3e+33) tmp = x + (y + ((t - z) / ((a - t) / y))); else tmp = x - (y / (t / (a - z))); 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_] := If[LessEqual[t, -3.6e+85], N[(N[(x - N[(N[(y / t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.3e+33], N[(x + N[(y + N[(N[(t - z), $MachinePrecision] / N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -3.6 \cdot 10^{+85}:\\
\;\;\;\;\left(x - \frac{y}{t} \cdot a\right) + \frac{y}{t} \cdot z\\
\mathbf{elif}\;t \leq 2.3 \cdot 10^{+33}:\\
\;\;\;\;x + \left(y + \frac{t - z}{\frac{a - t}{y}}\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\
\end{array}
Results
| Original | 74.3% |
|---|---|
| Target | 86.5% |
| Herbie | 89.4% |
if t < -3.5999999999999998e85Initial program 55.0%
Simplified68.9%
[Start]55.0 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
associate-/l* [=>]68.9 | \[ \left(x + y\right) - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}
\] |
Taylor expanded in t around inf 72.7%
Simplified84.8%
[Start]72.7 | \[ \left(-1 \cdot \frac{y \cdot a}{t} + x\right) - -1 \cdot \frac{y \cdot z}{t}
\] |
|---|---|
sub-neg [=>]72.7 | \[ \color{blue}{\left(-1 \cdot \frac{y \cdot a}{t} + x\right) + \left(--1 \cdot \frac{y \cdot z}{t}\right)}
\] |
+-commutative [=>]72.7 | \[ \color{blue}{\left(x + -1 \cdot \frac{y \cdot a}{t}\right)} + \left(--1 \cdot \frac{y \cdot z}{t}\right)
\] |
mul-1-neg [=>]72.7 | \[ \left(x + \color{blue}{\left(-\frac{y \cdot a}{t}\right)}\right) + \left(--1 \cdot \frac{y \cdot z}{t}\right)
\] |
unsub-neg [=>]72.7 | \[ \color{blue}{\left(x - \frac{y \cdot a}{t}\right)} + \left(--1 \cdot \frac{y \cdot z}{t}\right)
\] |
associate-/l* [=>]76.7 | \[ \left(x - \color{blue}{\frac{y}{\frac{t}{a}}}\right) + \left(--1 \cdot \frac{y \cdot z}{t}\right)
\] |
associate-/r/ [=>]77.0 | \[ \left(x - \color{blue}{\frac{y}{t} \cdot a}\right) + \left(--1 \cdot \frac{y \cdot z}{t}\right)
\] |
mul-1-neg [=>]77.0 | \[ \left(x - \frac{y}{t} \cdot a\right) + \left(-\color{blue}{\left(-\frac{y \cdot z}{t}\right)}\right)
\] |
remove-double-neg [=>]77.0 | \[ \left(x - \frac{y}{t} \cdot a\right) + \color{blue}{\frac{y \cdot z}{t}}
\] |
associate-/l* [=>]85.9 | \[ \left(x - \frac{y}{t} \cdot a\right) + \color{blue}{\frac{y}{\frac{t}{z}}}
\] |
associate-/r/ [=>]84.8 | \[ \left(x - \frac{y}{t} \cdot a\right) + \color{blue}{\frac{y}{t} \cdot z}
\] |
if -3.5999999999999998e85 < t < 2.30000000000000011e33Initial program 89.0%
Simplified93.0%
[Start]89.0 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
+-rgt-identity [<=]89.0 | \[ \color{blue}{\left(\left(x + y\right) + 0\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+l+ [=>]89.0 | \[ \color{blue}{\left(x + \left(y + 0\right)\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+r- [<=]90.2 | \[ \color{blue}{x + \left(\left(y + 0\right) - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
+-rgt-identity [=>]90.2 | \[ x + \left(\color{blue}{y} - \frac{\left(z - t\right) \cdot y}{a - t}\right)
\] |
associate-/l* [=>]93.0 | \[ x + \left(y - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\right)
\] |
if 2.30000000000000011e33 < t Initial program 54.2%
Simplified68.5%
[Start]54.2 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
associate-/l* [=>]68.5 | \[ \left(x + y\right) - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}
\] |
Taylor expanded in t around -inf 72.7%
Simplified84.3%
[Start]72.7 | \[ -1 \cdot \frac{y \cdot a - y \cdot z}{t} + x
\] |
|---|---|
+-commutative [=>]72.7 | \[ \color{blue}{x + -1 \cdot \frac{y \cdot a - y \cdot z}{t}}
\] |
mul-1-neg [=>]72.7 | \[ x + \color{blue}{\left(-\frac{y \cdot a - y \cdot z}{t}\right)}
\] |
unsub-neg [=>]72.7 | \[ \color{blue}{x - \frac{y \cdot a - y \cdot z}{t}}
\] |
distribute-lft-out-- [=>]72.7 | \[ x - \frac{\color{blue}{y \cdot \left(a - z\right)}}{t}
\] |
associate-/l* [=>]84.3 | \[ x - \color{blue}{\frac{y}{\frac{t}{a - z}}}
\] |
Final simplification89.4%
| Alternative 1 | |
|---|---|
| Accuracy | 71.2% |
| Cost | 1108 |
| Alternative 2 | |
|---|---|
| Accuracy | 71.1% |
| Cost | 1108 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.5% |
| Cost | 1097 |
| Alternative 4 | |
|---|---|
| Accuracy | 89.6% |
| Cost | 1097 |
| Alternative 5 | |
|---|---|
| Accuracy | 66.2% |
| Cost | 844 |
| Alternative 6 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 841 |
| Alternative 7 | |
|---|---|
| Accuracy | 80.1% |
| Cost | 840 |
| Alternative 8 | |
|---|---|
| Accuracy | 76.9% |
| Cost | 713 |
| Alternative 9 | |
|---|---|
| Accuracy | 66.6% |
| Cost | 456 |
| Alternative 10 | |
|---|---|
| Accuracy | 54.1% |
| Cost | 64 |
herbie shell --seed 2023141
(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))))