| Alternative 1 | |
|---|---|
| Error | 12.5 |
| Cost | 7568 |
(FPCore (x y z t a) :precision binary64 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
:precision binary64
(if (<= z -7.8e+68)
(* y (- x))
(if (<= z 4e+74)
(- 0.0 (* (- x) (* y (* z (sqrt (/ 1.0 (- (pow z 2.0) (* a t))))))))
(* y x))))double code(double x, double y, double z, double t, double a) {
return ((x * y) * z) / sqrt(((z * z) - (t * a)));
}
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -7.8e+68) {
tmp = y * -x;
} else if (z <= 4e+74) {
tmp = 0.0 - (-x * (y * (z * sqrt((1.0 / (pow(z, 2.0) - (a * t)))))));
} else {
tmp = y * x;
}
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) / sqrt(((z * z) - (t * a)))
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 (z <= (-7.8d+68)) then
tmp = y * -x
else if (z <= 4d+74) then
tmp = 0.0d0 - (-x * (y * (z * sqrt((1.0d0 / ((z ** 2.0d0) - (a * t)))))))
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) * z) / Math.sqrt(((z * z) - (t * a)));
}
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -7.8e+68) {
tmp = y * -x;
} else if (z <= 4e+74) {
tmp = 0.0 - (-x * (y * (z * Math.sqrt((1.0 / (Math.pow(z, 2.0) - (a * t)))))));
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a): return ((x * y) * z) / math.sqrt(((z * z) - (t * a)))
def code(x, y, z, t, a): tmp = 0 if z <= -7.8e+68: tmp = y * -x elif z <= 4e+74: tmp = 0.0 - (-x * (y * (z * math.sqrt((1.0 / (math.pow(z, 2.0) - (a * t))))))) else: tmp = y * x return tmp
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) * z) / sqrt(Float64(Float64(z * z) - Float64(t * a)))) end
function code(x, y, z, t, a) tmp = 0.0 if (z <= -7.8e+68) tmp = Float64(y * Float64(-x)); elseif (z <= 4e+74) tmp = Float64(0.0 - Float64(Float64(-x) * Float64(y * Float64(z * sqrt(Float64(1.0 / Float64((z ^ 2.0) - Float64(a * t)))))))); else tmp = Float64(y * x); end return tmp end
function tmp = code(x, y, z, t, a) tmp = ((x * y) * z) / sqrt(((z * z) - (t * a))); end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -7.8e+68) tmp = y * -x; elseif (z <= 4e+74) tmp = 0.0 - (-x * (y * (z * sqrt((1.0 / ((z ^ 2.0) - (a * t))))))); else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -7.8e+68], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 4e+74], N[(0.0 - N[((-x) * N[(y * N[(z * N[Sqrt[N[(1.0 / N[(N[Power[z, 2.0], $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{+68}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+74}:\\
\;\;\;\;0 - \left(-x\right) \cdot \left(y \cdot \left(z \cdot \sqrt{\frac{1}{{z}^{2} - a \cdot t}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
Results
| Original | 24.3 |
|---|---|
| Target | 7.4 |
| Herbie | 6.5 |
if z < -7.80000000000000037e68Initial program 39.1
Simplified41.0
[Start]39.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]39.1 | \[ \frac{\color{blue}{z \cdot \left(x \cdot y\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]41.0 | \[ \frac{\color{blue}{x \cdot \left(z \cdot y\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]41.0 | \[ \frac{x \cdot \color{blue}{\left(y \cdot z\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
Taylor expanded in z around -inf 2.9
Simplified2.9
[Start]2.9 | \[ -1 \cdot \left(y \cdot x\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-7 [=>]2.9 | \[ \color{blue}{y \cdot \left(-1 \cdot x\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.9 | \[ y \cdot \color{blue}{\left(x \cdot -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]2.9 | \[ y \cdot \color{blue}{\left(-x\right)}
\] |
if -7.80000000000000037e68 < z < 3.99999999999999981e74Initial program 11.1
Simplified11.6
[Start]11.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]11.1 | \[ \frac{\color{blue}{z \cdot \left(x \cdot y\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]11.1 | \[ \frac{z \cdot \color{blue}{\left(y \cdot x\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]11.6 | \[ \frac{\color{blue}{y \cdot \left(z \cdot x\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]11.6 | \[ \frac{y \cdot \color{blue}{\left(x \cdot z\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
Taylor expanded in y around 0 11.8
Simplified11.7
[Start]11.8 | \[ \sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot \left(y \cdot \left(z \cdot x\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [<=]11.8 | \[ \sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot \left(y \cdot \color{blue}{\left(x \cdot z\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]11.7 | \[ \sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot \color{blue}{\left(x \cdot \left(y \cdot z\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]11.7 | \[ \sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot \left(x \cdot \color{blue}{\left(z \cdot y\right)}\right)
\] |
Applied egg-rr10.7
Taylor expanded in y around 0 10.6
Simplified9.7
[Start]10.6 | \[ 0 - \left(-x\right) \cdot \left(\sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot \left(y \cdot z\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-7 [=>]9.7 | \[ 0 - \left(-x\right) \cdot \color{blue}{\left(y \cdot \left(\sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot z\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]9.7 | \[ 0 - \left(-x\right) \cdot \left(y \cdot \color{blue}{\left(z \cdot \sqrt{\frac{1}{{z}^{2} - a \cdot t}}\right)}\right)
\] |
if 3.99999999999999981e74 < z Initial program 38.8
Simplified40.7
[Start]38.8 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]38.8 | \[ \frac{\color{blue}{z \cdot \left(x \cdot y\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]40.7 | \[ \frac{\color{blue}{x \cdot \left(z \cdot y\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]40.7 | \[ \frac{x \cdot \color{blue}{\left(y \cdot z\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
Taylor expanded in z around inf 2.8
Final simplification6.5
| Alternative 1 | |
|---|---|
| Error | 12.5 |
| Cost | 7568 |
| Alternative 2 | |
|---|---|
| Error | 7.9 |
| Cost | 7496 |
| Alternative 3 | |
|---|---|
| Error | 16.2 |
| Cost | 1288 |
| Alternative 4 | |
|---|---|
| Error | 16.1 |
| Cost | 1224 |
| Alternative 5 | |
|---|---|
| Error | 16.1 |
| Cost | 1224 |
| Alternative 6 | |
|---|---|
| Error | 16.2 |
| Cost | 1224 |
| Alternative 7 | |
|---|---|
| Error | 17.0 |
| Cost | 776 |
| Alternative 8 | |
|---|---|
| Error | 17.1 |
| Cost | 712 |
| Alternative 9 | |
|---|---|
| Error | 17.3 |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Error | 19.0 |
| Cost | 388 |
| Alternative 11 | |
|---|---|
| Error | 36.2 |
| Cost | 192 |
herbie shell --seed 2023090
(FPCore (x y z t a)
:name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))
(/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))