| Alternative 1 | |
|---|---|
| Error | 8.24% |
| Cost | 8588 |
(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 (- y b))) (t_2 (/ (- a t) (- y b))) (t_3 (* z (- t a))))
(if (<= z -1750000.0)
(- t_2 (* t_1 (/ x z)))
(if (<= z -8.8e-259)
(/ (fma y x t_3) (fma z (- b y) y))
(if (<= z 2.6e-262)
(-
(/
(-
(* z (/ (- a t) (+ z -1.0)))
(* (/ b (pow (+ z -1.0) 2.0)) (* z x)))
y)
(/ x (+ z -1.0)))
(if (<= z 4.45e+15)
(/ (+ t_3 (* y x)) (- y (* z (- y b))))
(- t_2 (/ t_1 (/ z x)))))))))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 / (y - b);
double t_2 = (a - t) / (y - b);
double t_3 = z * (t - a);
double tmp;
if (z <= -1750000.0) {
tmp = t_2 - (t_1 * (x / z));
} else if (z <= -8.8e-259) {
tmp = fma(y, x, t_3) / fma(z, (b - y), y);
} else if (z <= 2.6e-262) {
tmp = (((z * ((a - t) / (z + -1.0))) - ((b / pow((z + -1.0), 2.0)) * (z * x))) / y) - (x / (z + -1.0));
} else if (z <= 4.45e+15) {
tmp = (t_3 + (y * x)) / (y - (z * (y - b)));
} else {
tmp = t_2 - (t_1 / (z / x));
}
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(y - b)) t_2 = Float64(Float64(a - t) / Float64(y - b)) t_3 = Float64(z * Float64(t - a)) tmp = 0.0 if (z <= -1750000.0) tmp = Float64(t_2 - Float64(t_1 * Float64(x / z))); elseif (z <= -8.8e-259) tmp = Float64(fma(y, x, t_3) / fma(z, Float64(b - y), y)); elseif (z <= 2.6e-262) tmp = Float64(Float64(Float64(Float64(z * Float64(Float64(a - t) / Float64(z + -1.0))) - Float64(Float64(b / (Float64(z + -1.0) ^ 2.0)) * Float64(z * x))) / y) - Float64(x / Float64(z + -1.0))); elseif (z <= 4.45e+15) tmp = Float64(Float64(t_3 + Float64(y * x)) / Float64(y - Float64(z * Float64(y - b)))); else tmp = Float64(t_2 - Float64(t_1 / Float64(z / x))); 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[(y - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - t), $MachinePrecision] / N[(y - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1750000.0], N[(t$95$2 - N[(t$95$1 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -8.8e-259], N[(N[(y * x + t$95$3), $MachinePrecision] / N[(z * N[(b - y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.6e-262], N[(N[(N[(N[(z * N[(N[(a - t), $MachinePrecision] / N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(b / N[Power[N[(z + -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.45e+15], N[(N[(t$95$3 + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(y - N[(z * N[(y - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 - N[(t$95$1 / N[(z / x), $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 := \frac{y}{y - b}\\
t_2 := \frac{a - t}{y - b}\\
t_3 := z \cdot \left(t - a\right)\\
\mathbf{if}\;z \leq -1750000:\\
\;\;\;\;t_2 - t_1 \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq -8.8 \cdot 10^{-259}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, t_3\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-262}:\\
\;\;\;\;\frac{z \cdot \frac{a - t}{z + -1} - \frac{b}{{\left(z + -1\right)}^{2}} \cdot \left(z \cdot x\right)}{y} - \frac{x}{z + -1}\\
\mathbf{elif}\;z \leq 4.45 \cdot 10^{+15}:\\
\;\;\;\;\frac{t_3 + y \cdot x}{y - z \cdot \left(y - b\right)}\\
\mathbf{else}:\\
\;\;\;\;t_2 - \frac{t_1}{\frac{z}{x}}\\
\end{array}
| Original | 35.66% |
|---|---|
| Target | 27.73% |
| Herbie | 8.33% |
if z < -1.75e6Initial program 59.5
Taylor expanded in y around 0 59.61
Taylor expanded in z around -inf 30.08
Simplified7.88
[Start]30.08 | \[ -1 \cdot \frac{t - a}{y + -1 \cdot b} + -1 \cdot \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
|---|---|
mul-1-neg [=>]30.08 | \[ -1 \cdot \frac{t - a}{y + -1 \cdot b} + \color{blue}{\left(-\frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}\right)}
\] |
unsub-neg [=>]30.08 | \[ \color{blue}{-1 \cdot \frac{t - a}{y + -1 \cdot b} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}}
\] |
mul-1-neg [=>]30.08 | \[ \color{blue}{\left(-\frac{t - a}{y + -1 \cdot b}\right)} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
distribute-neg-frac [=>]30.08 | \[ \color{blue}{\frac{-\left(t - a\right)}{y + -1 \cdot b}} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
mul-1-neg [=>]30.08 | \[ \frac{-\left(t - a\right)}{y + \color{blue}{\left(-b\right)}} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
unsub-neg [=>]30.08 | \[ \frac{-\left(t - a\right)}{\color{blue}{y - b}} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
Taylor expanded in x around inf 15.81
Simplified0.89
[Start]15.81 | \[ \frac{-\left(t - a\right)}{y - b} - \frac{y \cdot x}{\left(y - b\right) \cdot z}
\] |
|---|---|
times-frac [=>]0.89 | \[ \frac{-\left(t - a\right)}{y - b} - \color{blue}{\frac{y}{y - b} \cdot \frac{x}{z}}
\] |
if -1.75e6 < z < -8.80000000000000038e-259Initial program 14.86
Simplified14.85
[Start]14.86 | \[ \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\] |
|---|---|
*-commutative [=>]14.86 | \[ \frac{\color{blue}{y \cdot x} + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\] |
fma-def [=>]14.85 | \[ \frac{\color{blue}{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}}{y + z \cdot \left(b - y\right)}
\] |
+-commutative [=>]14.85 | \[ \frac{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}{\color{blue}{z \cdot \left(b - y\right) + y}}
\] |
fma-def [=>]14.85 | \[ \frac{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}{\color{blue}{\mathsf{fma}\left(z, b - y, y\right)}}
\] |
if -8.80000000000000038e-259 < z < 2.5999999999999999e-262Initial program 11.74
Simplified11.74
[Start]11.74 | \[ \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\] |
|---|---|
*-commutative [=>]11.74 | \[ \frac{\color{blue}{y \cdot x} + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\] |
fma-def [=>]11.74 | \[ \frac{\color{blue}{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}}{y + z \cdot \left(b - y\right)}
\] |
+-commutative [=>]11.74 | \[ \frac{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}{\color{blue}{z \cdot \left(b - y\right) + y}}
\] |
fma-def [=>]11.74 | \[ \frac{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}{\color{blue}{\mathsf{fma}\left(z, b - y, y\right)}}
\] |
Taylor expanded in y around -inf 23.46
Simplified17.48
[Start]23.46 | \[ -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 [=>]23.46 | \[ -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 [=>]23.46 | \[ \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 [=>]23.46 | \[ \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 [=>]23.46 | \[ \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}
\] |
sub-neg [=>]23.46 | \[ \frac{-x}{\color{blue}{z + \left(-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}
\] |
metadata-eval [=>]23.46 | \[ \frac{-x}{z + \color{blue}{-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}
\] |
if 2.5999999999999999e-262 < z < 4.45e15Initial program 14.06
if 4.45e15 < z Initial program 61.2
Taylor expanded in y around 0 61.32
Taylor expanded in z around -inf 30.96
Simplified5.59
[Start]30.96 | \[ -1 \cdot \frac{t - a}{y + -1 \cdot b} + -1 \cdot \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
|---|---|
mul-1-neg [=>]30.96 | \[ -1 \cdot \frac{t - a}{y + -1 \cdot b} + \color{blue}{\left(-\frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}\right)}
\] |
unsub-neg [=>]30.96 | \[ \color{blue}{-1 \cdot \frac{t - a}{y + -1 \cdot b} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}}
\] |
mul-1-neg [=>]30.96 | \[ \color{blue}{\left(-\frac{t - a}{y + -1 \cdot b}\right)} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
distribute-neg-frac [=>]30.96 | \[ \color{blue}{\frac{-\left(t - a\right)}{y + -1 \cdot b}} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
mul-1-neg [=>]30.96 | \[ \frac{-\left(t - a\right)}{y + \color{blue}{\left(-b\right)}} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
unsub-neg [=>]30.96 | \[ \frac{-\left(t - a\right)}{\color{blue}{y - b}} - \frac{\frac{y \cdot x}{y + -1 \cdot b} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(y + -1 \cdot b\right)}^{2}}}{z}
\] |
Taylor expanded in x around inf 17.53
Simplified0.61
[Start]17.53 | \[ \frac{-\left(t - a\right)}{y - b} - \frac{y \cdot x}{\left(y - b\right) \cdot z}
\] |
|---|---|
times-frac [=>]0.61 | \[ \frac{-\left(t - a\right)}{y - b} - \color{blue}{\frac{y}{y - b} \cdot \frac{x}{z}}
\] |
Applied egg-rr0.75
Final simplification8.33
| Alternative 1 | |
|---|---|
| Error | 8.24% |
| Cost | 8588 |
| Alternative 2 | |
|---|---|
| Error | 8.47% |
| Cost | 5840 |
| Alternative 3 | |
|---|---|
| Error | 8.31% |
| Cost | 5713 |
| Alternative 4 | |
|---|---|
| Error | 11.12% |
| Cost | 5712 |
| Alternative 5 | |
|---|---|
| Error | 8.47% |
| Cost | 5712 |
| Alternative 6 | |
|---|---|
| Error | 40.58% |
| Cost | 2152 |
| Alternative 7 | |
|---|---|
| Error | 32.04% |
| Cost | 1630 |
| Alternative 8 | |
|---|---|
| Error | 32.24% |
| Cost | 1498 |
| Alternative 9 | |
|---|---|
| Error | 31.07% |
| Cost | 1366 |
| Alternative 10 | |
|---|---|
| Error | 58.29% |
| Cost | 980 |
| Alternative 11 | |
|---|---|
| Error | 33.96% |
| Cost | 977 |
| Alternative 12 | |
|---|---|
| Error | 33.76% |
| Cost | 977 |
| Alternative 13 | |
|---|---|
| Error | 69.95% |
| Cost | 852 |
| Alternative 14 | |
|---|---|
| Error | 66.38% |
| Cost | 716 |
| Alternative 15 | |
|---|---|
| Error | 66.39% |
| Cost | 588 |
| Alternative 16 | |
|---|---|
| Error | 46.49% |
| Cost | 585 |
| Alternative 17 | |
|---|---|
| Error | 64.06% |
| Cost | 456 |
| Alternative 18 | |
|---|---|
| Error | 72.69% |
| Cost | 64 |
herbie shell --seed 2023090
(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)))))