| Alternative 1 | |
|---|---|
| Error | 3.5 |
| Cost | 1736 |
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x y) (* (* z z) (+ z 1.0)))))
(if (<= z -3.3e+92)
(* (/ y z) (/ (/ x z) (+ z 1.0)))
(if (<= z -2.4e-108)
t_0
(if (<= z 3e-129)
(* (/ y z) (/ x z))
(if (<= z 8e+66) t_0 (/ (/ x (/ z (/ y z))) z)))))))double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
double code(double x, double y, double z) {
double t_0 = (x * y) / ((z * z) * (z + 1.0));
double tmp;
if (z <= -3.3e+92) {
tmp = (y / z) * ((x / z) / (z + 1.0));
} else if (z <= -2.4e-108) {
tmp = t_0;
} else if (z <= 3e-129) {
tmp = (y / z) * (x / z);
} else if (z <= 8e+66) {
tmp = t_0;
} else {
tmp = (x / (z / (y / z))) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) / ((z * z) * (z + 1.0d0))
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x * y) / ((z * z) * (z + 1.0d0))
if (z <= (-3.3d+92)) then
tmp = (y / z) * ((x / z) / (z + 1.0d0))
else if (z <= (-2.4d-108)) then
tmp = t_0
else if (z <= 3d-129) then
tmp = (y / z) * (x / z)
else if (z <= 8d+66) then
tmp = t_0
else
tmp = (x / (z / (y / z))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
public static double code(double x, double y, double z) {
double t_0 = (x * y) / ((z * z) * (z + 1.0));
double tmp;
if (z <= -3.3e+92) {
tmp = (y / z) * ((x / z) / (z + 1.0));
} else if (z <= -2.4e-108) {
tmp = t_0;
} else if (z <= 3e-129) {
tmp = (y / z) * (x / z);
} else if (z <= 8e+66) {
tmp = t_0;
} else {
tmp = (x / (z / (y / z))) / z;
}
return tmp;
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
def code(x, y, z): t_0 = (x * y) / ((z * z) * (z + 1.0)) tmp = 0 if z <= -3.3e+92: tmp = (y / z) * ((x / z) / (z + 1.0)) elif z <= -2.4e-108: tmp = t_0 elif z <= 3e-129: tmp = (y / z) * (x / z) elif z <= 8e+66: tmp = t_0 else: tmp = (x / (z / (y / z))) / z return tmp
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function code(x, y, z) t_0 = Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) tmp = 0.0 if (z <= -3.3e+92) tmp = Float64(Float64(y / z) * Float64(Float64(x / z) / Float64(z + 1.0))); elseif (z <= -2.4e-108) tmp = t_0; elseif (z <= 3e-129) tmp = Float64(Float64(y / z) * Float64(x / z)); elseif (z <= 8e+66) tmp = t_0; else tmp = Float64(Float64(x / Float64(z / Float64(y / z))) / z); end return tmp end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
function tmp_2 = code(x, y, z) t_0 = (x * y) / ((z * z) * (z + 1.0)); tmp = 0.0; if (z <= -3.3e+92) tmp = (y / z) * ((x / z) / (z + 1.0)); elseif (z <= -2.4e-108) tmp = t_0; elseif (z <= 3e-129) tmp = (y / z) * (x / z); elseif (z <= 8e+66) tmp = t_0; else tmp = (x / (z / (y / z))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+92], N[(N[(y / z), $MachinePrecision] * N[(N[(x / z), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2.4e-108], t$95$0, If[LessEqual[z, 3e-129], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8e+66], t$95$0, N[(N[(x / N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]]]]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
t_0 := \frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+92}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{\frac{x}{z}}{z + 1}\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{-108}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-129}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+66}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{z}{\frac{y}{z}}}}{z}\\
\end{array}
Results
| Original | 14.9 |
|---|---|
| Target | 4.1 |
| Herbie | 3.8 |
if z < -3.29999999999999974e92Initial program 12.5
Simplified4.8
[Start]12.5 | \[ \frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\] |
|---|---|
rational.json-simplify-46 [=>]8.6 | \[ \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}}
\] |
rational.json-simplify-2 [=>]8.6 | \[ \frac{\frac{\color{blue}{y \cdot x}}{z \cdot z}}{z + 1}
\] |
rational.json-simplify-49 [=>]4.8 | \[ \frac{\color{blue}{x \cdot \frac{y}{z \cdot z}}}{z + 1}
\] |
Applied egg-rr1.5
Simplified1.5
[Start]1.5 | \[ \frac{y}{z} \cdot \frac{\frac{1}{z}}{\frac{z + 1}{x}}
\] |
|---|---|
rational.json-simplify-44 [=>]1.5 | \[ \frac{y}{z} \cdot \color{blue}{\frac{\frac{1}{\frac{z + 1}{x}}}{z}}
\] |
rational.json-simplify-61 [=>]1.5 | \[ \frac{y}{z} \cdot \frac{\color{blue}{\frac{x}{\frac{z + 1}{1}}}}{z}
\] |
rational.json-simplify-7 [=>]1.5 | \[ \frac{y}{z} \cdot \frac{\frac{x}{\color{blue}{z + 1}}}{z}
\] |
rational.json-simplify-44 [=>]1.5 | \[ \frac{y}{z} \cdot \color{blue}{\frac{\frac{x}{z}}{z + 1}}
\] |
if -3.29999999999999974e92 < z < -2.40000000000000017e-108 or 2.9999999999999998e-129 < z < 7.99999999999999956e66Initial program 5.6
if -2.40000000000000017e-108 < z < 2.9999999999999998e-129Initial program 46.4
Simplified46.7
[Start]46.4 | \[ \frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\] |
|---|---|
rational.json-simplify-46 [=>]46.4 | \[ \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}}
\] |
rational.json-simplify-2 [=>]46.4 | \[ \frac{\frac{\color{blue}{y \cdot x}}{z \cdot z}}{z + 1}
\] |
rational.json-simplify-49 [=>]46.7 | \[ \frac{\color{blue}{x \cdot \frac{y}{z \cdot z}}}{z + 1}
\] |
Applied egg-rr6.5
Simplified6.4
[Start]6.5 | \[ \frac{y}{z} \cdot \frac{\frac{1}{z}}{\frac{z + 1}{x}}
\] |
|---|---|
rational.json-simplify-44 [=>]6.5 | \[ \frac{y}{z} \cdot \color{blue}{\frac{\frac{1}{\frac{z + 1}{x}}}{z}}
\] |
rational.json-simplify-61 [=>]6.4 | \[ \frac{y}{z} \cdot \frac{\color{blue}{\frac{x}{\frac{z + 1}{1}}}}{z}
\] |
rational.json-simplify-7 [=>]6.4 | \[ \frac{y}{z} \cdot \frac{\frac{x}{\color{blue}{z + 1}}}{z}
\] |
rational.json-simplify-44 [=>]6.4 | \[ \frac{y}{z} \cdot \color{blue}{\frac{\frac{x}{z}}{z + 1}}
\] |
Taylor expanded in z around 0 6.4
if 7.99999999999999956e66 < z Initial program 12.0
Simplified6.0
[Start]12.0 | \[ \frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\] |
|---|---|
rational.json-simplify-49 [=>]9.3 | \[ \color{blue}{y \cdot \frac{x}{\left(z \cdot z\right) \cdot \left(z + 1\right)}}
\] |
rational.json-simplify-46 [=>]6.0 | \[ y \cdot \color{blue}{\frac{\frac{x}{z \cdot z}}{z + 1}}
\] |
Applied egg-rr1.7
Simplified1.9
[Start]1.7 | \[ \frac{\frac{y}{z}}{z \cdot \frac{z + 1}{x}} + 0
\] |
|---|---|
rational.json-simplify-4 [=>]1.7 | \[ \color{blue}{\frac{\frac{y}{z}}{z \cdot \frac{z + 1}{x}}}
\] |
rational.json-simplify-44 [=>]1.8 | \[ \color{blue}{\frac{\frac{y}{z \cdot \frac{z + 1}{x}}}{z}}
\] |
rational.json-simplify-46 [=>]0.8 | \[ \frac{\color{blue}{\frac{\frac{y}{z}}{\frac{z + 1}{x}}}}{z}
\] |
rational.json-simplify-61 [<=]1.9 | \[ \frac{\color{blue}{\frac{x}{\frac{z + 1}{\frac{y}{z}}}}}{z}
\] |
rational.json-simplify-61 [<=]1.9 | \[ \frac{\frac{x}{\color{blue}{\frac{z}{\frac{y}{z + 1}}}}}{z}
\] |
Taylor expanded in z around inf 1.9
Final simplification3.8
| Alternative 1 | |
|---|---|
| Error | 3.5 |
| Cost | 1736 |
| Alternative 2 | |
|---|---|
| Error | 3.1 |
| Cost | 1232 |
| Alternative 3 | |
|---|---|
| Error | 4.1 |
| Cost | 972 |
| Alternative 4 | |
|---|---|
| Error | 3.3 |
| Cost | 968 |
| Alternative 5 | |
|---|---|
| Error | 4.4 |
| Cost | 840 |
| Alternative 6 | |
|---|---|
| Error | 17.9 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 17.6 |
| Cost | 712 |
| Alternative 8 | |
|---|---|
| Error | 17.4 |
| Cost | 712 |
| Alternative 9 | |
|---|---|
| Error | 17.3 |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Error | 43.4 |
| Cost | 516 |
| Alternative 11 | |
|---|---|
| Error | 43.0 |
| Cost | 516 |
| Alternative 12 | |
|---|---|
| Error | 43.2 |
| Cost | 516 |
| Alternative 13 | |
|---|---|
| Error | 24.0 |
| Cost | 448 |
| Alternative 14 | |
|---|---|
| Error | 46.4 |
| Cost | 384 |
herbie shell --seed 2023074
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z))
(/ (* x y) (* (* z z) (+ z 1.0))))