| Alternative 1 | |
|---|---|
| Error | 9.8 |
| Cost | 7628 |
(FPCore (x y z t a) :precision binary64 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (* x y) (/ z (sqrt (- (* z z) (* t a)))))))
(if (<= z -1e+152)
(* y (- x))
(if (<= z -1.8e-166)
t_1
(if (<= z 4e-269)
(* (/ y (sqrt (* t (- a)))) (* x z))
(if (<= z 5.6e+79) t_1 (* 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 t_1 = (x * y) * (z / sqrt(((z * z) - (t * a))));
double tmp;
if (z <= -1e+152) {
tmp = y * -x;
} else if (z <= -1.8e-166) {
tmp = t_1;
} else if (z <= 4e-269) {
tmp = (y / sqrt((t * -a))) * (x * z);
} else if (z <= 5.6e+79) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = (x * y) * (z / sqrt(((z * z) - (t * a))))
if (z <= (-1d+152)) then
tmp = y * -x
else if (z <= (-1.8d-166)) then
tmp = t_1
else if (z <= 4d-269) then
tmp = (y / sqrt((t * -a))) * (x * z)
else if (z <= 5.6d+79) then
tmp = t_1
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 t_1 = (x * y) * (z / Math.sqrt(((z * z) - (t * a))));
double tmp;
if (z <= -1e+152) {
tmp = y * -x;
} else if (z <= -1.8e-166) {
tmp = t_1;
} else if (z <= 4e-269) {
tmp = (y / Math.sqrt((t * -a))) * (x * z);
} else if (z <= 5.6e+79) {
tmp = t_1;
} 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): t_1 = (x * y) * (z / math.sqrt(((z * z) - (t * a)))) tmp = 0 if z <= -1e+152: tmp = y * -x elif z <= -1.8e-166: tmp = t_1 elif z <= 4e-269: tmp = (y / math.sqrt((t * -a))) * (x * z) elif z <= 5.6e+79: tmp = t_1 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) t_1 = Float64(Float64(x * y) * Float64(z / sqrt(Float64(Float64(z * z) - Float64(t * a))))) tmp = 0.0 if (z <= -1e+152) tmp = Float64(y * Float64(-x)); elseif (z <= -1.8e-166) tmp = t_1; elseif (z <= 4e-269) tmp = Float64(Float64(y / sqrt(Float64(t * Float64(-a)))) * Float64(x * z)); elseif (z <= 5.6e+79) tmp = t_1; 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) t_1 = (x * y) * (z / sqrt(((z * z) - (t * a)))); tmp = 0.0; if (z <= -1e+152) tmp = y * -x; elseif (z <= -1.8e-166) tmp = t_1; elseif (z <= 4e-269) tmp = (y / sqrt((t * -a))) * (x * z); elseif (z <= 5.6e+79) tmp = t_1; 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_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+152], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, -1.8e-166], t$95$1, If[LessEqual[z, 4e-269], N[(N[(y / N[Sqrt[N[(t * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.6e+79], t$95$1, N[(y * x), $MachinePrecision]]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+152}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-166}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-269}:\\
\;\;\;\;\frac{y}{\sqrt{t \cdot \left(-a\right)}} \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{+79}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
Results
| Original | 24.6 |
|---|---|
| Target | 8.2 |
| Herbie | 6.3 |
if z < -1e152Initial program 53.9
Simplified53.6
[Start]53.9 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
rational.json-simplify-49 [=>]53.5 | \[ \color{blue}{z \cdot \frac{x \cdot y}{\sqrt{z \cdot z - t \cdot a}}}
\] |
rational.json-simplify-2 [=>]53.5 | \[ z \cdot \frac{\color{blue}{y \cdot x}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational.json-simplify-49 [=>]53.7 | \[ z \cdot \color{blue}{\left(x \cdot \frac{y}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
rational.json-simplify-43 [=>]53.6 | \[ \color{blue}{x \cdot \left(\frac{y}{\sqrt{z \cdot z - t \cdot a}} \cdot z\right)}
\] |
rational.json-simplify-2 [=>]53.6 | \[ x \cdot \color{blue}{\left(z \cdot \frac{y}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
Taylor expanded in z around -inf 1.3
Simplified1.3
[Start]1.3 | \[ -1 \cdot \left(y \cdot x\right)
\] |
|---|---|
rational.json-simplify-43 [=>]1.3 | \[ \color{blue}{y \cdot \left(x \cdot -1\right)}
\] |
rational.json-simplify-9 [=>]1.3 | \[ y \cdot \color{blue}{\left(-x\right)}
\] |
if -1e152 < z < -1.8e-166 or 3.9999999999999998e-269 < z < 5.6000000000000002e79Initial program 9.4
Simplified6.6
[Start]9.4 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
rational.json-simplify-2 [=>]9.4 | \[ \frac{\color{blue}{z \cdot \left(x \cdot y\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational.json-simplify-49 [=>]6.6 | \[ \color{blue}{\left(x \cdot y\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}}
\] |
if -1.8e-166 < z < 3.9999999999999998e-269Initial program 19.1
Taylor expanded in z around 0 64.0
Simplified19.1
[Start]64.0 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{-1} \cdot \sqrt{a \cdot t}}
\] |
|---|---|
exponential.json-simplify-20 [=>]19.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\color{blue}{\sqrt{\left(a \cdot t\right) \cdot -1}}}
\] |
rational.json-simplify-2 [<=]19.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{\color{blue}{-1 \cdot \left(a \cdot t\right)}}}
\] |
rational.json-simplify-2 [=>]19.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{-1 \cdot \color{blue}{\left(t \cdot a\right)}}}
\] |
rational.json-simplify-43 [=>]19.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{\color{blue}{t \cdot \left(a \cdot -1\right)}}}
\] |
rational.json-simplify-9 [=>]19.1 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{t \cdot \color{blue}{\left(-a\right)}}}
\] |
Applied egg-rr19.3
if 5.6000000000000002e79 < z Initial program 41.0
Simplified40.5
[Start]41.0 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
rational.json-simplify-49 [=>]40.6 | \[ \color{blue}{z \cdot \frac{x \cdot y}{\sqrt{z \cdot z - t \cdot a}}}
\] |
rational.json-simplify-2 [=>]40.6 | \[ z \cdot \frac{\color{blue}{y \cdot x}}{\sqrt{z \cdot z - t \cdot a}}
\] |
rational.json-simplify-49 [=>]42.0 | \[ z \cdot \color{blue}{\left(x \cdot \frac{y}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
rational.json-simplify-43 [=>]40.5 | \[ \color{blue}{x \cdot \left(\frac{y}{\sqrt{z \cdot z - t \cdot a}} \cdot z\right)}
\] |
rational.json-simplify-2 [=>]40.5 | \[ x \cdot \color{blue}{\left(z \cdot \frac{y}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
Taylor expanded in z around inf 2.8
Final simplification6.3
| Alternative 1 | |
|---|---|
| Error | 9.8 |
| Cost | 7628 |
| Alternative 2 | |
|---|---|
| Error | 9.2 |
| Cost | 7496 |
| Alternative 3 | |
|---|---|
| Error | 11.9 |
| Cost | 7304 |
| Alternative 4 | |
|---|---|
| Error | 12.0 |
| Cost | 7304 |
| Alternative 5 | |
|---|---|
| Error | 12.0 |
| Cost | 7304 |
| Alternative 6 | |
|---|---|
| Error | 12.1 |
| Cost | 7304 |
| Alternative 7 | |
|---|---|
| Error | 16.2 |
| Cost | 1224 |
| Alternative 8 | |
|---|---|
| Error | 16.1 |
| Cost | 1224 |
| Alternative 9 | |
|---|---|
| Error | 17.1 |
| Cost | 1224 |
| Alternative 10 | |
|---|---|
| Error | 16.7 |
| Cost | 1156 |
| Alternative 11 | |
|---|---|
| Error | 16.7 |
| Cost | 1156 |
| Alternative 12 | |
|---|---|
| Error | 18.0 |
| Cost | 1096 |
| Alternative 13 | |
|---|---|
| Error | 18.0 |
| Cost | 1096 |
| Alternative 14 | |
|---|---|
| Error | 18.0 |
| Cost | 1096 |
| Alternative 15 | |
|---|---|
| Error | 18.0 |
| Cost | 1096 |
| Alternative 16 | |
|---|---|
| Error | 17.9 |
| Cost | 1096 |
| Alternative 17 | |
|---|---|
| Error | 16.7 |
| Cost | 1092 |
| Alternative 18 | |
|---|---|
| Error | 17.2 |
| Cost | 968 |
| Alternative 19 | |
|---|---|
| Error | 17.7 |
| Cost | 712 |
| Alternative 20 | |
|---|---|
| Error | 19.1 |
| Cost | 388 |
| Alternative 21 | |
|---|---|
| Error | 36.5 |
| Cost | 192 |
herbie shell --seed 2023074
(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)))))