| Alternative 1 | |
|---|---|
| Error | 23.24% |
| Cost | 841 |
(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 (/ t (- a z))))
(if (<= t 3.4e+76)
(+ x (- y (/ y (/ (- a t) (- z t)))))
(+ 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 <= -6.6e+206) {
tmp = x - (y / (t / (a - z)));
} else if (t <= 3.4e+76) {
tmp = x + (y - (y / ((a - t) / (z - t))));
} 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 <= (-6.6d+206)) then
tmp = x - (y / (t / (a - z)))
else if (t <= 3.4d+76) then
tmp = x + (y - (y / ((a - t) / (z - t))))
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 <= -6.6e+206) {
tmp = x - (y / (t / (a - z)));
} else if (t <= 3.4e+76) {
tmp = x + (y - (y / ((a - t) / (z - t))));
} 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 <= -6.6e+206: tmp = x - (y / (t / (a - z))) elif t <= 3.4e+76: tmp = x + (y - (y / ((a - t) / (z - t)))) 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 <= -6.6e+206) tmp = Float64(x - Float64(y / Float64(t / Float64(a - z)))); elseif (t <= 3.4e+76) tmp = Float64(x + Float64(y - Float64(y / Float64(Float64(a - t) / Float64(z - t))))); else tmp = Float64(x + Float64(y / Float64(Float64(t - 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 <= -6.6e+206) tmp = x - (y / (t / (a - z))); elseif (t <= 3.4e+76) tmp = x + (y - (y / ((a - t) / (z - t)))); 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, -6.6e+206], N[(x - N[(y / N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.4e+76], N[(x + N[(y - N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(N[(t - a), $MachinePrecision] / z), $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 - \frac{y}{\frac{t}{a - z}}\\
\mathbf{elif}\;t \leq 3.4 \cdot 10^{+76}:\\
\;\;\;\;x + \left(y - \frac{y}{\frac{a - t}{z - t}}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\
\end{array}
Results
| Original | 25.11% |
|---|---|
| Target | 13.08% |
| Herbie | 9.88% |
if t < -6.59999999999999969e206Initial program 54.39
Simplified18.57
[Start]54.39 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
+-rgt-identity [<=]54.39 | \[ \color{blue}{\left(\left(x + y\right) + 0\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+l+ [=>]54.39 | \[ \color{blue}{\left(x + \left(y + 0\right)\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+r- [<=]46.83 | \[ \color{blue}{x + \left(\left(y + 0\right) - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
+-rgt-identity [=>]46.83 | \[ x + \left(\color{blue}{y} - \frac{\left(z - t\right) \cdot y}{a - t}\right)
\] |
*-commutative [=>]46.83 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
associate-/l* [=>]18.57 | \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right)
\] |
Applied egg-rr18.76
Simplified18.76
[Start]18.76 | \[ x + {\left(\sqrt[3]{y}\right)}^{2} \cdot \left(\sqrt[3]{y} - \sqrt[3]{y} \cdot \frac{z - t}{a - t}\right)
\] |
|---|---|
*-commutative [=>]18.76 | \[ x + {\left(\sqrt[3]{y}\right)}^{2} \cdot \left(\sqrt[3]{y} - \color{blue}{\frac{z - t}{a - t} \cdot \sqrt[3]{y}}\right)
\] |
Taylor expanded in t around inf 20.44
Simplified6.01
[Start]20.44 | \[ x + -1 \cdot \left({1}^{0.3333333333333333} \cdot \frac{y \cdot \left(-1 \cdot z - -1 \cdot a\right)}{t}\right)
\] |
|---|---|
pow-base-1 [=>]20.44 | \[ x + -1 \cdot \left(\color{blue}{1} \cdot \frac{y \cdot \left(-1 \cdot z - -1 \cdot a\right)}{t}\right)
\] |
associate-/l* [=>]6.01 | \[ x + -1 \cdot \left(1 \cdot \color{blue}{\frac{y}{\frac{t}{-1 \cdot z - -1 \cdot a}}}\right)
\] |
associate-*r/ [=>]6.01 | \[ x + -1 \cdot \color{blue}{\frac{1 \cdot y}{\frac{t}{-1 \cdot z - -1 \cdot a}}}
\] |
*-lft-identity [=>]6.01 | \[ x + -1 \cdot \frac{\color{blue}{y}}{\frac{t}{-1 \cdot z - -1 \cdot a}}
\] |
associate-*r/ [=>]6.01 | \[ x + \color{blue}{\frac{-1 \cdot y}{\frac{t}{-1 \cdot z - -1 \cdot a}}}
\] |
metadata-eval [<=]6.01 | \[ x + \frac{\color{blue}{\left(-1\right)} \cdot y}{\frac{t}{-1 \cdot z - -1 \cdot a}}
\] |
distribute-lft-neg-in [<=]6.01 | \[ x + \frac{\color{blue}{-1 \cdot y}}{\frac{t}{-1 \cdot z - -1 \cdot a}}
\] |
*-lft-identity [=>]6.01 | \[ x + \frac{-\color{blue}{y}}{\frac{t}{-1 \cdot z - -1 \cdot a}}
\] |
sub-neg [=>]6.01 | \[ x + \frac{-y}{\frac{t}{\color{blue}{-1 \cdot z + \left(--1 \cdot a\right)}}}
\] |
mul-1-neg [=>]6.01 | \[ x + \frac{-y}{\frac{t}{\color{blue}{\left(-z\right)} + \left(--1 \cdot a\right)}}
\] |
distribute-neg-out [=>]6.01 | \[ x + \frac{-y}{\frac{t}{\color{blue}{-\left(z + -1 \cdot a\right)}}}
\] |
mul-1-neg [=>]6.01 | \[ x + \frac{-y}{\frac{t}{-\left(z + \color{blue}{\left(-a\right)}\right)}}
\] |
sub-neg [<=]6.01 | \[ x + \frac{-y}{\frac{t}{-\color{blue}{\left(z - a\right)}}}
\] |
Taylor expanded in t around 0 6.01
if -6.59999999999999969e206 < t < 3.3999999999999997e76Initial program 16
Simplified8.33
[Start]16 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
+-rgt-identity [<=]16 | \[ \color{blue}{\left(\left(x + y\right) + 0\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+l+ [=>]16 | \[ \color{blue}{\left(x + \left(y + 0\right)\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
associate-+r- [<=]13.69 | \[ \color{blue}{x + \left(\left(y + 0\right) - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
+-rgt-identity [=>]13.69 | \[ x + \left(\color{blue}{y} - \frac{\left(z - t\right) \cdot y}{a - t}\right)
\] |
*-commutative [=>]13.69 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
associate-/l* [=>]8.33 | \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right)
\] |
if 3.3999999999999997e76 < t Initial program 44.34
Simplified30.69
[Start]44.34 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
associate--l+ [=>]38.84 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
sub-neg [=>]38.84 | \[ x + \color{blue}{\left(y + \left(-\frac{\left(z - t\right) \cdot y}{a - t}\right)\right)}
\] |
+-commutative [=>]38.84 | \[ x + \color{blue}{\left(\left(-\frac{\left(z - t\right) \cdot y}{a - t}\right) + y\right)}
\] |
distribute-neg-frac [=>]38.84 | \[ x + \left(\color{blue}{\frac{-\left(z - t\right) \cdot y}{a - t}} + y\right)
\] |
distribute-rgt-neg-in [=>]38.84 | \[ x + \left(\frac{\color{blue}{\left(z - t\right) \cdot \left(-y\right)}}{a - t} + y\right)
\] |
associate-*r/ [<=]22.55 | \[ x + \left(\color{blue}{\left(z - t\right) \cdot \frac{-y}{a - t}} + y\right)
\] |
mul-1-neg [<=]22.55 | \[ x + \left(\left(z - t\right) \cdot \frac{\color{blue}{-1 \cdot y}}{a - t} + y\right)
\] |
associate-*r/ [<=]22.55 | \[ x + \left(\left(z - t\right) \cdot \color{blue}{\left(-1 \cdot \frac{y}{a - t}\right)} + y\right)
\] |
fma-def [=>]30.69 | \[ x + \color{blue}{\mathsf{fma}\left(z - t, -1 \cdot \frac{y}{a - t}, y\right)}
\] |
Taylor expanded in z around inf 26.71
Simplified17.12
[Start]26.71 | \[ x + \frac{y \cdot z}{t - a}
\] |
|---|---|
associate-/l* [=>]17.12 | \[ x + \color{blue}{\frac{y}{\frac{t - a}{z}}}
\] |
Final simplification9.88
| Alternative 1 | |
|---|---|
| Error | 23.24% |
| Cost | 841 |
| Alternative 2 | |
|---|---|
| Error | 23.04% |
| Cost | 841 |
| Alternative 3 | |
|---|---|
| Error | 14.41% |
| Cost | 841 |
| Alternative 4 | |
|---|---|
| Error | 16.26% |
| Cost | 840 |
| Alternative 5 | |
|---|---|
| Error | 25.07% |
| Cost | 713 |
| Alternative 6 | |
|---|---|
| Error | 32.05% |
| Cost | 456 |
| Alternative 7 | |
|---|---|
| Error | 44.9% |
| 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))))