| Alternative 1 | |
|---|---|
| Accuracy | 89.8% |
| Cost | 7496 |
(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 -3.5e+26)
(* y (- x))
(if (<= z 2.4e-185)
(/ x (/ (sqrt (- (* z z) (* a t))) (* z y)))
(/ (* y x) (sqrt (- 1.0 (* (/ t z) (/ a z))))))))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 <= -3.5e+26) {
tmp = y * -x;
} else if (z <= 2.4e-185) {
tmp = x / (sqrt(((z * z) - (a * t))) / (z * y));
} else {
tmp = (y * x) / sqrt((1.0 - ((t / z) * (a / z))));
}
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 <= (-3.5d+26)) then
tmp = y * -x
else if (z <= 2.4d-185) then
tmp = x / (sqrt(((z * z) - (a * t))) / (z * y))
else
tmp = (y * x) / sqrt((1.0d0 - ((t / z) * (a / z))))
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 <= -3.5e+26) {
tmp = y * -x;
} else if (z <= 2.4e-185) {
tmp = x / (Math.sqrt(((z * z) - (a * t))) / (z * y));
} else {
tmp = (y * x) / Math.sqrt((1.0 - ((t / z) * (a / z))));
}
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 <= -3.5e+26: tmp = y * -x elif z <= 2.4e-185: tmp = x / (math.sqrt(((z * z) - (a * t))) / (z * y)) else: tmp = (y * x) / math.sqrt((1.0 - ((t / z) * (a / z)))) 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 <= -3.5e+26) tmp = Float64(y * Float64(-x)); elseif (z <= 2.4e-185) tmp = Float64(x / Float64(sqrt(Float64(Float64(z * z) - Float64(a * t))) / Float64(z * y))); else tmp = Float64(Float64(y * x) / sqrt(Float64(1.0 - Float64(Float64(t / z) * Float64(a / z))))); 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 <= -3.5e+26) tmp = y * -x; elseif (z <= 2.4e-185) tmp = x / (sqrt(((z * z) - (a * t))) / (z * y)); else tmp = (y * x) / sqrt((1.0 - ((t / z) * (a / z)))); 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, -3.5e+26], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 2.4e-185], N[(x / N[(N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t / z), $MachinePrecision] * N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+26}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-185}:\\
\;\;\;\;\frac{x}{\frac{\sqrt{z \cdot z - a \cdot t}}{z \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{\sqrt{1 - \frac{t}{z} \cdot \frac{a}{z}}}\\
\end{array}
Results
| Original | 61.4% |
|---|---|
| Target | 89.0% |
| Herbie | 89.7% |
if z < -3.4999999999999999e26Initial program 41.2%
Simplified44.5%
[Start]41.2 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
*-commutative [=>]41.2 | \[ \frac{\color{blue}{\left(y \cdot x\right)} \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
associate-*l* [=>]40.9 | \[ \frac{\color{blue}{y \cdot \left(x \cdot z\right)}}{\sqrt{z \cdot z - t \cdot a}}
\] |
associate-*r/ [<=]44.5 | \[ \color{blue}{y \cdot \frac{x \cdot z}{\sqrt{z \cdot z - t \cdot a}}}
\] |
Taylor expanded in z around -inf 97.8%
Simplified97.8%
[Start]97.8 | \[ y \cdot \left(-1 \cdot x\right)
\] |
|---|---|
neg-mul-1 [<=]97.8 | \[ y \cdot \color{blue}{\left(-x\right)}
\] |
if -3.4999999999999999e26 < z < 2.4000000000000001e-185Initial program 82.2%
Simplified82.8%
[Start]82.2 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-*l/ [<=]82.8 | \[ \color{blue}{\frac{x \cdot y}{\sqrt{z \cdot z - t \cdot a}} \cdot z}
\] |
Applied egg-rr86.1%
[Start]82.8 | \[ \frac{x \cdot y}{\sqrt{z \cdot z - t \cdot a}} \cdot z
\] |
|---|---|
associate-*l/ [=>]82.2 | \[ \color{blue}{\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}}
\] |
add-sqr-sqrt [=>]82.0 | \[ \frac{\left(x \cdot y\right) \cdot z}{\color{blue}{\sqrt{\sqrt{z \cdot z - t \cdot a}} \cdot \sqrt{\sqrt{z \cdot z - t \cdot a}}}}
\] |
associate-/r* [=>]82.1 | \[ \color{blue}{\frac{\frac{\left(x \cdot y\right) \cdot z}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}}
\] |
associate-*l* [=>]86.0 | \[ \frac{\frac{\color{blue}{x \cdot \left(y \cdot z\right)}}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}
\] |
pow1/2 [=>]86.0 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{\sqrt{\color{blue}{{\left(z \cdot z - t \cdot a\right)}^{0.5}}}}}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}
\] |
sqrt-pow1 [=>]86.1 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{\color{blue}{{\left(z \cdot z - t \cdot a\right)}^{\left(\frac{0.5}{2}\right)}}}}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}
\] |
metadata-eval [=>]86.1 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{{\left(z \cdot z - t \cdot a\right)}^{\color{blue}{0.25}}}}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}
\] |
pow1/2 [=>]86.1 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{{\left(z \cdot z - t \cdot a\right)}^{0.25}}}{\sqrt{\color{blue}{{\left(z \cdot z - t \cdot a\right)}^{0.5}}}}
\] |
sqrt-pow1 [=>]86.1 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{{\left(z \cdot z - t \cdot a\right)}^{0.25}}}{\color{blue}{{\left(z \cdot z - t \cdot a\right)}^{\left(\frac{0.5}{2}\right)}}}
\] |
metadata-eval [=>]86.1 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{{\left(z \cdot z - t \cdot a\right)}^{0.25}}}{{\left(z \cdot z - t \cdot a\right)}^{\color{blue}{0.25}}}
\] |
Simplified84.7%
[Start]86.1 | \[ \frac{\frac{x \cdot \left(y \cdot z\right)}{{\left(z \cdot z - t \cdot a\right)}^{0.25}}}{{\left(z \cdot z - t \cdot a\right)}^{0.25}}
\] |
|---|---|
associate-/l/ [=>]86.0 | \[ \color{blue}{\frac{x \cdot \left(y \cdot z\right)}{{\left(z \cdot z - t \cdot a\right)}^{0.25} \cdot {\left(z \cdot z - t \cdot a\right)}^{0.25}}}
\] |
associate-/l* [=>]84.7 | \[ \color{blue}{\frac{x}{\frac{{\left(z \cdot z - t \cdot a\right)}^{0.25} \cdot {\left(z \cdot z - t \cdot a\right)}^{0.25}}{y \cdot z}}}
\] |
pow-sqr [=>]84.7 | \[ \frac{x}{\frac{\color{blue}{{\left(z \cdot z - t \cdot a\right)}^{\left(2 \cdot 0.25\right)}}}{y \cdot z}}
\] |
metadata-eval [=>]84.7 | \[ \frac{x}{\frac{{\left(z \cdot z - t \cdot a\right)}^{\color{blue}{0.5}}}{y \cdot z}}
\] |
unpow1/2 [=>]84.7 | \[ \frac{x}{\frac{\color{blue}{\sqrt{z \cdot z - t \cdot a}}}{y \cdot z}}
\] |
*-commutative [<=]84.7 | \[ \frac{x}{\frac{\sqrt{z \cdot z - \color{blue}{a \cdot t}}}{y \cdot z}}
\] |
*-commutative [=>]84.7 | \[ \frac{x}{\frac{\sqrt{z \cdot z - a \cdot t}}{\color{blue}{z \cdot y}}}
\] |
if 2.4000000000000001e-185 < z Initial program 56.2%
Simplified58.3%
[Start]56.2 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-/l* [=>]58.3 | \[ \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}
\] |
Applied egg-rr45.1%
[Start]58.3 | \[ \frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}
\] |
|---|---|
add-sqr-sqrt [=>]58.3 | \[ \frac{x \cdot y}{\color{blue}{\sqrt{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot \sqrt{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}}
\] |
sqrt-unprod [=>]55.4 | \[ \frac{x \cdot y}{\color{blue}{\sqrt{\frac{\sqrt{z \cdot z - t \cdot a}}{z} \cdot \frac{\sqrt{z \cdot z - t \cdot a}}{z}}}}
\] |
frac-times [=>]45.1 | \[ \frac{x \cdot y}{\sqrt{\color{blue}{\frac{\sqrt{z \cdot z - t \cdot a} \cdot \sqrt{z \cdot z - t \cdot a}}{z \cdot z}}}}
\] |
add-sqr-sqrt [<=]45.1 | \[ \frac{x \cdot y}{\sqrt{\frac{\color{blue}{z \cdot z - t \cdot a}}{z \cdot z}}}
\] |
Simplified96.1%
[Start]45.1 | \[ \frac{x \cdot y}{\sqrt{\frac{z \cdot z - t \cdot a}{z \cdot z}}}
\] |
|---|---|
unpow2 [<=]45.1 | \[ \frac{x \cdot y}{\sqrt{\frac{\color{blue}{{z}^{2}} - t \cdot a}{z \cdot z}}}
\] |
unpow2 [<=]45.1 | \[ \frac{x \cdot y}{\sqrt{\frac{{z}^{2} - t \cdot a}{\color{blue}{{z}^{2}}}}}
\] |
div-sub [=>]45.1 | \[ \frac{x \cdot y}{\sqrt{\color{blue}{\frac{{z}^{2}}{{z}^{2}} - \frac{t \cdot a}{{z}^{2}}}}}
\] |
*-inverses [=>]84.9 | \[ \frac{x \cdot y}{\sqrt{\color{blue}{1} - \frac{t \cdot a}{{z}^{2}}}}
\] |
unpow2 [=>]84.9 | \[ \frac{x \cdot y}{\sqrt{1 - \frac{t \cdot a}{\color{blue}{z \cdot z}}}}
\] |
times-frac [=>]96.1 | \[ \frac{x \cdot y}{\sqrt{1 - \color{blue}{\frac{t}{z} \cdot \frac{a}{z}}}}
\] |
Final simplification93.5%
| Alternative 1 | |
|---|---|
| Accuracy | 89.8% |
| Cost | 7496 |
| Alternative 2 | |
|---|---|
| Accuracy | 89.7% |
| Cost | 7496 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.3% |
| Cost | 7496 |
| Alternative 4 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 7304 |
| Alternative 5 | |
|---|---|
| Accuracy | 81.3% |
| Cost | 7304 |
| Alternative 6 | |
|---|---|
| Accuracy | 75.4% |
| Cost | 1224 |
| Alternative 7 | |
|---|---|
| Accuracy | 76.2% |
| Cost | 1092 |
| Alternative 8 | |
|---|---|
| Accuracy | 72.9% |
| Cost | 712 |
| Alternative 9 | |
|---|---|
| Accuracy | 74.5% |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Accuracy | 74.4% |
| Cost | 712 |
| Alternative 11 | |
|---|---|
| Accuracy | 72.1% |
| Cost | 388 |
| Alternative 12 | |
|---|---|
| Accuracy | 42.0% |
| Cost | 192 |
herbie shell --seed 2023158
(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)))))