| Alternative 1 | |
|---|---|
| Error | 4.6 |
| Cost | 4432 |
(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 -6.6e+206)
(+ x (* y (- (/ (- a z) t))))
(if (<= t 3.4e+76)
(+ x (* y (+ 1.0 (- (/ (- z t) (- a 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 tmp;
if (t <= -6.6e+206) {
tmp = x + (y * -((a - z) / t));
} else if (t <= 3.4e+76) {
tmp = x + (y * (1.0 + -((z - t) / (a - t))));
} else {
tmp = x + (y * -(z / (a - t)));
}
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 <= (-6.6d+206)) then
tmp = x + (y * -((a - z) / t))
else if (t <= 3.4d+76) then
tmp = x + (y * (1.0d0 + -((z - t) / (a - t))))
else
tmp = x + (y * -(z / (a - t)))
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 <= -6.6e+206) {
tmp = x + (y * -((a - z) / t));
} else if (t <= 3.4e+76) {
tmp = x + (y * (1.0 + -((z - t) / (a - 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): tmp = 0 if t <= -6.6e+206: tmp = x + (y * -((a - z) / t)) elif t <= 3.4e+76: tmp = x + (y * (1.0 + -((z - t) / (a - 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) tmp = 0.0 if (t <= -6.6e+206) tmp = Float64(x + Float64(y * Float64(-Float64(Float64(a - z) / t)))); elseif (t <= 3.4e+76) tmp = Float64(x + Float64(y * Float64(1.0 + Float64(-Float64(Float64(z - t) / Float64(a - t)))))); else tmp = Float64(x + Float64(y * Float64(-Float64(z / 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) tmp = 0.0; if (t <= -6.6e+206) tmp = x + (y * -((a - z) / t)); elseif (t <= 3.4e+76) tmp = x + (y * (1.0 + -((z - t) / (a - 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_] := If[LessEqual[t, -6.6e+206], N[(x + N[(y * (-N[(N[(a - z), $MachinePrecision] / t), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.4e+76], N[(x + N[(y * N[(1.0 + (-N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * (-N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -6.6 \cdot 10^{+206}:\\
\;\;\;\;x + y \cdot \left(-\frac{a - z}{t}\right)\\
\mathbf{elif}\;t \leq 3.4 \cdot 10^{+76}:\\
\;\;\;\;x + y \cdot \left(1 + \left(-\frac{z - t}{a - t}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(-\frac{z}{a - t}\right)\\
\end{array}
Results
| Original | 16.1 |
|---|---|
| Target | 8.4 |
| Herbie | 6.5 |
if t < -6.59999999999999969e206Initial program 34.8
Taylor expanded in y around -inf 11.9
Simplified11.9
[Start]11.9 | \[ y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right) + x
\] |
|---|---|
rational_best.json-simplify-1 [=>]11.9 | \[ \color{blue}{x + y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational_best.json-simplify-2 [=>]11.9 | \[ x + y \cdot \left(1 + \color{blue}{\frac{z - t}{a - t} \cdot -1}\right)
\] |
rational_best.json-simplify-12 [=>]11.9 | \[ x + y \cdot \left(1 + \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
Taylor expanded in t around -inf 3.7
Simplified3.7
[Start]3.7 | \[ x + y \cdot \left(-1 \cdot \frac{a - z}{t}\right)
\] |
|---|---|
rational_best.json-simplify-2 [=>]3.7 | \[ x + y \cdot \color{blue}{\left(\frac{a - z}{t} \cdot -1\right)}
\] |
rational_best.json-simplify-12 [=>]3.7 | \[ x + y \cdot \color{blue}{\left(-\frac{a - z}{t}\right)}
\] |
if -6.59999999999999969e206 < t < 3.3999999999999997e76Initial program 10.2
Taylor expanded in y around -inf 5.6
Simplified5.6
[Start]5.6 | \[ y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right) + x
\] |
|---|---|
rational_best.json-simplify-1 [=>]5.6 | \[ \color{blue}{x + y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational_best.json-simplify-2 [=>]5.6 | \[ x + y \cdot \left(1 + \color{blue}{\frac{z - t}{a - t} \cdot -1}\right)
\] |
rational_best.json-simplify-12 [=>]5.6 | \[ x + y \cdot \left(1 + \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
if 3.3999999999999997e76 < t Initial program 28.4
Taylor expanded in y around -inf 11.2
Simplified11.2
[Start]11.2 | \[ y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right) + x
\] |
|---|---|
rational_best.json-simplify-1 [=>]11.2 | \[ \color{blue}{x + y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational_best.json-simplify-2 [=>]11.2 | \[ x + y \cdot \left(1 + \color{blue}{\frac{z - t}{a - t} \cdot -1}\right)
\] |
rational_best.json-simplify-12 [=>]11.2 | \[ x + y \cdot \left(1 + \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
Taylor expanded in z around inf 10.9
Simplified10.9
[Start]10.9 | \[ x + y \cdot \left(-1 \cdot \frac{z}{a - t}\right)
\] |
|---|---|
rational_best.json-simplify-2 [=>]10.9 | \[ x + y \cdot \color{blue}{\left(\frac{z}{a - t} \cdot -1\right)}
\] |
rational_best.json-simplify-12 [=>]10.9 | \[ x + y \cdot \color{blue}{\left(-\frac{z}{a - t}\right)}
\] |
Final simplification6.5
| Alternative 1 | |
|---|---|
| Error | 4.6 |
| Cost | 4432 |
| Alternative 2 | |
|---|---|
| Error | 14.0 |
| Cost | 904 |
| Alternative 3 | |
|---|---|
| Error | 8.4 |
| Cost | 904 |
| Alternative 4 | |
|---|---|
| Error | 11.8 |
| Cost | 904 |
| Alternative 5 | |
|---|---|
| Error | 13.1 |
| Cost | 840 |
| Alternative 6 | |
|---|---|
| Error | 16.0 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 20.5 |
| Cost | 456 |
| Alternative 8 | |
|---|---|
| Error | 27.2 |
| Cost | 328 |
| Alternative 9 | |
|---|---|
| Error | 28.7 |
| Cost | 64 |
herbie shell --seed 2023090
(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))))