| Alternative 1 | |
|---|---|
| Accuracy | 93.0% |
| Cost | 9672 |
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ y (* z (- b y))))
(t_2 (* z (- t a)))
(t_3 (/ (+ t_2 (* x y)) t_1)))
(if (<= t_3 (- INFINITY))
(- (/ (- a t) y) (/ x (+ z -1.0)))
(if (<= t_3 -2e-301)
(/ (fma x y t_2) t_1)
(if (<= t_3 2e-231)
(+
(/ t (- b y))
(-
(/ (+ (/ (* x y) (- b y)) (/ (- a t) (/ (pow (- b y) 2.0) y))) z)
(/ a (- b y))))
(if (<= t_3 5e+305)
t_3
(+ (* (/ y (- b y)) (/ x z)) (/ (- t a) (- b y)))))))))double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (z * (b - y));
double t_2 = z * (t - a);
double t_3 = (t_2 + (x * y)) / t_1;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = ((a - t) / y) - (x / (z + -1.0));
} else if (t_3 <= -2e-301) {
tmp = fma(x, y, t_2) / t_1;
} else if (t_3 <= 2e-231) {
tmp = (t / (b - y)) + (((((x * y) / (b - y)) + ((a - t) / (pow((b - y), 2.0) / y))) / z) - (a / (b - y)));
} else if (t_3 <= 5e+305) {
tmp = t_3;
} else {
tmp = ((y / (b - y)) * (x / z)) + ((t - a) / (b - y));
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function code(x, y, z, t, a, b) t_1 = Float64(y + Float64(z * Float64(b - y))) t_2 = Float64(z * Float64(t - a)) t_3 = Float64(Float64(t_2 + Float64(x * y)) / t_1) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(Float64(a - t) / y) - Float64(x / Float64(z + -1.0))); elseif (t_3 <= -2e-301) tmp = Float64(fma(x, y, t_2) / t_1); elseif (t_3 <= 2e-231) tmp = Float64(Float64(t / Float64(b - y)) + Float64(Float64(Float64(Float64(Float64(x * y) / Float64(b - y)) + Float64(Float64(a - t) / Float64((Float64(b - y) ^ 2.0) / y))) / z) - Float64(a / Float64(b - y)))); elseif (t_3 <= 5e+305) tmp = t_3; else tmp = Float64(Float64(Float64(y / Float64(b - y)) * Float64(x / z)) + Float64(Float64(t - a) / Float64(b - y))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 + N[(x * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -2e-301], N[(N[(x * y + t$95$2), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 2e-231], N[(N[(t / N[(b - y), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(x * y), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision] + N[(N[(a - t), $MachinePrecision] / N[(N[Power[N[(b - y), $MachinePrecision], 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] - N[(a / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5e+305], t$95$3, N[(N[(N[(y / N[(b - y), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] + N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
t_1 := y + z \cdot \left(b - y\right)\\
t_2 := z \cdot \left(t - a\right)\\
t_3 := \frac{t_2 + x \cdot y}{t_1}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{a - t}{y} - \frac{x}{z + -1}\\
\mathbf{elif}\;t_3 \leq -2 \cdot 10^{-301}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, t_2\right)}{t_1}\\
\mathbf{elif}\;t_3 \leq 2 \cdot 10^{-231}:\\
\;\;\;\;\frac{t}{b - y} + \left(\frac{\frac{x \cdot y}{b - y} + \frac{a - t}{\frac{{\left(b - y\right)}^{2}}{y}}}{z} - \frac{a}{b - y}\right)\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{b - y} \cdot \frac{x}{z} + \frac{t - a}{b - y}\\
\end{array}
| Original | 62.9% |
|---|---|
| Target | 70.9% |
| Herbie | 93.1% |
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0Initial program 0.0%
Simplified0.0%
[Start]0.0 | \[ \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\] |
|---|---|
fma-def [=>]0.0 | \[ \frac{\color{blue}{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}}{y + z \cdot \left(b - y\right)}
\] |
Taylor expanded in y around -inf 34.8%
Simplified58.2%
[Start]34.8 | \[ -1 \cdot \frac{x}{z - 1} + -1 \cdot \frac{\frac{\left(t - a\right) \cdot z}{z - 1} - -1 \cdot \frac{z \cdot \left(b \cdot x\right)}{{\left(z - 1\right)}^{2}}}{y}
\] |
|---|---|
mul-1-neg [=>]34.8 | \[ -1 \cdot \frac{x}{z - 1} + \color{blue}{\left(-\frac{\frac{\left(t - a\right) \cdot z}{z - 1} - -1 \cdot \frac{z \cdot \left(b \cdot x\right)}{{\left(z - 1\right)}^{2}}}{y}\right)}
\] |
unsub-neg [=>]34.8 | \[ \color{blue}{-1 \cdot \frac{x}{z - 1} - \frac{\frac{\left(t - a\right) \cdot z}{z - 1} - -1 \cdot \frac{z \cdot \left(b \cdot x\right)}{{\left(z - 1\right)}^{2}}}{y}}
\] |
mul-1-neg [=>]34.8 | \[ \color{blue}{\left(-\frac{x}{z - 1}\right)} - \frac{\frac{\left(t - a\right) \cdot z}{z - 1} - -1 \cdot \frac{z \cdot \left(b \cdot x\right)}{{\left(z - 1\right)}^{2}}}{y}
\] |
distribute-neg-frac [=>]34.8 | \[ \color{blue}{\frac{-x}{z - 1}} - \frac{\frac{\left(t - a\right) \cdot z}{z - 1} - -1 \cdot \frac{z \cdot \left(b \cdot x\right)}{{\left(z - 1\right)}^{2}}}{y}
\] |
Taylor expanded in z around inf 70.7%
if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -2.00000000000000013e-301Initial program 99.5%
Simplified99.5%
[Start]99.5 | \[ \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\] |
|---|---|
fma-def [=>]99.5 | \[ \frac{\color{blue}{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}}{y + z \cdot \left(b - y\right)}
\] |
if -2.00000000000000013e-301 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 2e-231Initial program 35.3%
Applied egg-rr31.6%
Simplified24.5%
[Start]31.6 | \[ \frac{x \cdot y + \frac{z \cdot \left(t \cdot t - a \cdot a\right)}{t + a}}{y + z \cdot \left(b - y\right)}
\] |
|---|---|
*-commutative [<=]31.6 | \[ \frac{x \cdot y + \frac{\color{blue}{\left(t \cdot t - a \cdot a\right) \cdot z}}{t + a}}{y + z \cdot \left(b - y\right)}
\] |
associate-/l* [=>]23.3 | \[ \frac{x \cdot y + \color{blue}{\frac{t \cdot t - a \cdot a}{\frac{t + a}{z}}}}{y + z \cdot \left(b - y\right)}
\] |
difference-of-squares [=>]23.3 | \[ \frac{x \cdot y + \frac{\color{blue}{\left(t + a\right) \cdot \left(t - a\right)}}{\frac{t + a}{z}}}{y + z \cdot \left(b - y\right)}
\] |
associate-/l* [=>]24.5 | \[ \frac{x \cdot y + \color{blue}{\frac{t + a}{\frac{\frac{t + a}{z}}{t - a}}}}{y + z \cdot \left(b - y\right)}
\] |
Taylor expanded in z around -inf 79.6%
Simplified89.8%
[Start]79.6 | \[ \left(\frac{t}{b - y} + -1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z}\right) - \frac{a}{b - y}
\] |
|---|---|
associate--l+ [=>]79.6 | \[ \color{blue}{\frac{t}{b - y} + \left(-1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z} - \frac{a}{b - y}\right)}
\] |
mul-1-neg [=>]79.6 | \[ \frac{t}{b - y} + \left(\color{blue}{\left(-\frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z}\right)} - \frac{a}{b - y}\right)
\] |
distribute-lft-out-- [=>]79.6 | \[ \frac{t}{b - y} + \left(\left(-\frac{\color{blue}{-1 \cdot \left(\frac{y \cdot x}{b - y} - \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}\right)}}{z}\right) - \frac{a}{b - y}\right)
\] |
associate-/l* [=>]89.8 | \[ \frac{t}{b - y} + \left(\left(-\frac{-1 \cdot \left(\frac{y \cdot x}{b - y} - \color{blue}{\frac{t - a}{\frac{{\left(b - y\right)}^{2}}{y}}}\right)}{z}\right) - \frac{a}{b - y}\right)
\] |
if 2e-231 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 5.00000000000000009e305Initial program 99.5%
if 5.00000000000000009e305 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 0.2%
Applied egg-rr0.1%
Simplified0.2%
[Start]0.1 | \[ \frac{x \cdot y + \frac{z \cdot \left(t \cdot t - a \cdot a\right)}{t + a}}{y + z \cdot \left(b - y\right)}
\] |
|---|---|
*-commutative [<=]0.1 | \[ \frac{x \cdot y + \frac{\color{blue}{\left(t \cdot t - a \cdot a\right) \cdot z}}{t + a}}{y + z \cdot \left(b - y\right)}
\] |
associate-/l* [=>]0.1 | \[ \frac{x \cdot y + \color{blue}{\frac{t \cdot t - a \cdot a}{\frac{t + a}{z}}}}{y + z \cdot \left(b - y\right)}
\] |
difference-of-squares [=>]0.1 | \[ \frac{x \cdot y + \frac{\color{blue}{\left(t + a\right) \cdot \left(t - a\right)}}{\frac{t + a}{z}}}{y + z \cdot \left(b - y\right)}
\] |
associate-/l* [=>]0.2 | \[ \frac{x \cdot y + \color{blue}{\frac{t + a}{\frac{\frac{t + a}{z}}{t - a}}}}{y + z \cdot \left(b - y\right)}
\] |
Taylor expanded in z around -inf 37.8%
Simplified85.3%
[Start]37.8 | \[ \left(\frac{t}{b - y} + -1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z}\right) - \frac{a}{b - y}
\] |
|---|---|
+-commutative [=>]37.8 | \[ \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z} + \frac{t}{b - y}\right)} - \frac{a}{b - y}
\] |
associate--l+ [=>]37.8 | \[ \color{blue}{-1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z} + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)}
\] |
Taylor expanded in x around inf 59.0%
Simplified85.2%
[Start]59.0 | \[ \frac{y \cdot x}{\left(b - y\right) \cdot z} + \frac{t - a}{b - y}
\] |
|---|---|
times-frac [=>]85.2 | \[ \color{blue}{\frac{y}{b - y} \cdot \frac{x}{z}} + \frac{t - a}{b - y}
\] |
Final simplification93.1%
| Alternative 1 | |
|---|---|
| Accuracy | 93.0% |
| Cost | 9672 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.0% |
| Cost | 5713 |
| Alternative 3 | |
|---|---|
| Accuracy | 65.6% |
| Cost | 1888 |
| Alternative 4 | |
|---|---|
| Accuracy | 65.3% |
| Cost | 1628 |
| Alternative 5 | |
|---|---|
| Accuracy | 70.9% |
| Cost | 1356 |
| Alternative 6 | |
|---|---|
| Accuracy | 80.9% |
| Cost | 1353 |
| Alternative 7 | |
|---|---|
| Accuracy | 63.2% |
| Cost | 1100 |
| Alternative 8 | |
|---|---|
| Accuracy | 32.2% |
| Cost | 784 |
| Alternative 9 | |
|---|---|
| Accuracy | 52.3% |
| Cost | 713 |
| Alternative 10 | |
|---|---|
| Accuracy | 62.9% |
| Cost | 713 |
| Alternative 11 | |
|---|---|
| Accuracy | 41.1% |
| Cost | 585 |
| Alternative 12 | |
|---|---|
| Accuracy | 52.3% |
| Cost | 585 |
| Alternative 13 | |
|---|---|
| Accuracy | 36.1% |
| Cost | 521 |
| Alternative 14 | |
|---|---|
| Accuracy | 36.2% |
| Cost | 456 |
| Alternative 15 | |
|---|---|
| Accuracy | 25.8% |
| Cost | 64 |
herbie shell --seed 2023141
(FPCore (x y z t a b)
:name "Development.Shake.Progress:decay from shake-0.15.5"
:precision binary64
:herbie-target
(- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z))))
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))