| Alternative 1 | |
|---|---|
| Accuracy | 88.8% |
| Cost | 7760 |
(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 -1e+89)
(/ (* x y) (/ (- (/ (* 0.5 a) (/ z t)) z) z))
(if (<= z -1e-137)
(/ (* x y) (/ (sqrt (- (* z z) (* a t))) z))
(if (<= z 1e-163)
(* x (* (* (pow a -0.5) (pow (- t) -0.5)) (* z y)))
(/ (* x y) (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 <= -1e+89) {
tmp = (x * y) / ((((0.5 * a) / (z / t)) - z) / z);
} else if (z <= -1e-137) {
tmp = (x * y) / (sqrt(((z * z) - (a * t))) / z);
} else if (z <= 1e-163) {
tmp = x * ((pow(a, -0.5) * pow(-t, -0.5)) * (z * y));
} else {
tmp = (x * y) / 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 <= (-1d+89)) then
tmp = (x * y) / ((((0.5d0 * a) / (z / t)) - z) / z)
else if (z <= (-1d-137)) then
tmp = (x * y) / (sqrt(((z * z) - (a * t))) / z)
else if (z <= 1d-163) then
tmp = x * (((a ** (-0.5d0)) * (-t ** (-0.5d0))) * (z * y))
else
tmp = (x * y) / 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 <= -1e+89) {
tmp = (x * y) / ((((0.5 * a) / (z / t)) - z) / z);
} else if (z <= -1e-137) {
tmp = (x * y) / (Math.sqrt(((z * z) - (a * t))) / z);
} else if (z <= 1e-163) {
tmp = x * ((Math.pow(a, -0.5) * Math.pow(-t, -0.5)) * (z * y));
} else {
tmp = (x * y) / 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 <= -1e+89: tmp = (x * y) / ((((0.5 * a) / (z / t)) - z) / z) elif z <= -1e-137: tmp = (x * y) / (math.sqrt(((z * z) - (a * t))) / z) elif z <= 1e-163: tmp = x * ((math.pow(a, -0.5) * math.pow(-t, -0.5)) * (z * y)) else: tmp = (x * y) / 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 <= -1e+89) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(Float64(0.5 * a) / Float64(z / t)) - z) / z)); elseif (z <= -1e-137) tmp = Float64(Float64(x * y) / Float64(sqrt(Float64(Float64(z * z) - Float64(a * t))) / z)); elseif (z <= 1e-163) tmp = Float64(x * Float64(Float64((a ^ -0.5) * (Float64(-t) ^ -0.5)) * Float64(z * y))); else tmp = Float64(Float64(x * y) / 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 <= -1e+89) tmp = (x * y) / ((((0.5 * a) / (z / t)) - z) / z); elseif (z <= -1e-137) tmp = (x * y) / (sqrt(((z * z) - (a * t))) / z); elseif (z <= 1e-163) tmp = x * (((a ^ -0.5) * (-t ^ -0.5)) * (z * y)); else tmp = (x * y) / 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, -1e+89], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(N[(0.5 * a), $MachinePrecision] / N[(z / t), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1e-137], N[(N[(x * y), $MachinePrecision] / N[(N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e-163], N[(x * N[(N[(N[Power[a, -0.5], $MachinePrecision] * N[Power[(-t), -0.5], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $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 -1 \cdot 10^{+89}:\\
\;\;\;\;\frac{x \cdot y}{\frac{\frac{0.5 \cdot a}{\frac{z}{t}} - z}{z}}\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-137}:\\
\;\;\;\;\frac{x \cdot y}{\frac{\sqrt{z \cdot z - a \cdot t}}{z}}\\
\mathbf{elif}\;z \leq 10^{-163}:\\
\;\;\;\;x \cdot \left(\left({a}^{-0.5} \cdot {\left(-t\right)}^{-0.5}\right) \cdot \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{\sqrt{1 - \frac{t}{z} \cdot \frac{a}{z}}}\\
\end{array}
Results
| Original | 61.7% |
|---|---|
| Target | 87.6% |
| Herbie | 90.7% |
if z < -9.99999999999999995e88Initial program 36.3%
Simplified40.2%
[Start]36.3 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-/l* [=>]40.2 | \[ \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}
\] |
Taylor expanded in z around -inf 91.9%
Simplified96.5%
[Start]91.9 | \[ \frac{x \cdot y}{\frac{0.5 \cdot \frac{a \cdot t}{z} + -1 \cdot z}{z}}
\] |
|---|---|
mul-1-neg [=>]91.9 | \[ \frac{x \cdot y}{\frac{0.5 \cdot \frac{a \cdot t}{z} + \color{blue}{\left(-z\right)}}{z}}
\] |
unsub-neg [=>]91.9 | \[ \frac{x \cdot y}{\frac{\color{blue}{0.5 \cdot \frac{a \cdot t}{z} - z}}{z}}
\] |
associate-/l* [=>]96.5 | \[ \frac{x \cdot y}{\frac{0.5 \cdot \color{blue}{\frac{a}{\frac{z}{t}}} - z}{z}}
\] |
associate-*r/ [=>]96.5 | \[ \frac{x \cdot y}{\frac{\color{blue}{\frac{0.5 \cdot a}{\frac{z}{t}}} - z}{z}}
\] |
if -9.99999999999999995e88 < z < -9.99999999999999978e-138Initial program 88.7%
Simplified91.9%
[Start]88.7 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-/l* [=>]91.9 | \[ \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}
\] |
if -9.99999999999999978e-138 < z < 9.99999999999999923e-164Initial program 71.0%
Applied egg-rr71.9%
[Start]71.0 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
div-inv [=>]71.0 | \[ \color{blue}{\left(\left(x \cdot y\right) \cdot z\right) \cdot \frac{1}{\sqrt{z \cdot z - t \cdot a}}}
\] |
associate-*l* [=>]71.7 | \[ \color{blue}{\left(x \cdot \left(y \cdot z\right)\right)} \cdot \frac{1}{\sqrt{z \cdot z - t \cdot a}}
\] |
associate-*l* [=>]71.9 | \[ \color{blue}{x \cdot \left(\left(y \cdot z\right) \cdot \frac{1}{\sqrt{z \cdot z - t \cdot a}}\right)}
\] |
pow1/2 [=>]71.9 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \frac{1}{\color{blue}{{\left(z \cdot z - t \cdot a\right)}^{0.5}}}\right)
\] |
pow-flip [=>]71.9 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \color{blue}{{\left(z \cdot z - t \cdot a\right)}^{\left(-0.5\right)}}\right)
\] |
metadata-eval [=>]71.9 | \[ x \cdot \left(\left(y \cdot z\right) \cdot {\left(z \cdot z - t \cdot a\right)}^{\color{blue}{-0.5}}\right)
\] |
Taylor expanded in a around inf 74.6%
Simplified77.7%
[Start]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{-0.5 \cdot \left(\log \left(-t\right) + -1 \cdot \log \left(\frac{1}{a}\right)\right)}\right)
\] |
|---|---|
distribute-lft-in [=>]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{\color{blue}{-0.5 \cdot \log \left(-t\right) + -0.5 \cdot \left(-1 \cdot \log \left(\frac{1}{a}\right)\right)}}\right)
\] |
+-commutative [=>]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{\color{blue}{-0.5 \cdot \left(-1 \cdot \log \left(\frac{1}{a}\right)\right) + -0.5 \cdot \log \left(-t\right)}}\right)
\] |
mul-1-neg [=>]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{-0.5 \cdot \color{blue}{\left(-\log \left(\frac{1}{a}\right)\right)} + -0.5 \cdot \log \left(-t\right)}\right)
\] |
log-rec [=>]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{-0.5 \cdot \left(-\color{blue}{\left(-\log a\right)}\right) + -0.5 \cdot \log \left(-t\right)}\right)
\] |
remove-double-neg [=>]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{-0.5 \cdot \color{blue}{\log a} + -0.5 \cdot \log \left(-t\right)}\right)
\] |
remove-double-neg [<=]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{-0.5 \cdot \log \color{blue}{\left(-\left(-a\right)\right)} + -0.5 \cdot \log \left(-t\right)}\right)
\] |
neg-mul-1 [=>]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{-0.5 \cdot \log \left(-\color{blue}{-1 \cdot a}\right) + -0.5 \cdot \log \left(-t\right)}\right)
\] |
*-commutative [<=]74.6 | \[ x \cdot \left(\left(y \cdot z\right) \cdot e^{\color{blue}{\log \left(--1 \cdot a\right) \cdot -0.5} + -0.5 \cdot \log \left(-t\right)}\right)
\] |
exp-sum [=>]74.8 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \color{blue}{\left(e^{\log \left(--1 \cdot a\right) \cdot -0.5} \cdot e^{-0.5 \cdot \log \left(-t\right)}\right)}\right)
\] |
neg-mul-1 [<=]74.8 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \left(e^{\log \left(-\color{blue}{\left(-a\right)}\right) \cdot -0.5} \cdot e^{-0.5 \cdot \log \left(-t\right)}\right)\right)
\] |
remove-double-neg [=>]74.8 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \left(e^{\log \color{blue}{a} \cdot -0.5} \cdot e^{-0.5 \cdot \log \left(-t\right)}\right)\right)
\] |
exp-to-pow [=>]75.2 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \left(\color{blue}{{a}^{-0.5}} \cdot e^{-0.5 \cdot \log \left(-t\right)}\right)\right)
\] |
*-commutative [=>]75.2 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \left({a}^{-0.5} \cdot e^{\color{blue}{\log \left(-t\right) \cdot -0.5}}\right)\right)
\] |
neg-mul-1 [=>]75.2 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \left({a}^{-0.5} \cdot e^{\log \color{blue}{\left(-1 \cdot t\right)} \cdot -0.5}\right)\right)
\] |
exp-to-pow [=>]77.7 | \[ x \cdot \left(\left(y \cdot z\right) \cdot \left({a}^{-0.5} \cdot \color{blue}{{\left(-1 \cdot t\right)}^{-0.5}}\right)\right)
\] |
if 9.99999999999999923e-164 < z Initial program 59.4%
Simplified63.0%
[Start]59.4 | \[ \frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\] |
|---|---|
associate-/l* [=>]63.0 | \[ \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}
\] |
Applied egg-rr55.2%
[Start]63.0 | \[ \frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}
\] |
|---|---|
add-sqr-sqrt [=>]63.0 | \[ \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 [=>]60.9 | \[ \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 [=>]55.2 | \[ \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 [<=]55.2 | \[ \frac{x \cdot y}{\sqrt{\frac{\color{blue}{z \cdot z - t \cdot a}}{z \cdot z}}}
\] |
Simplified93.1%
[Start]55.2 | \[ \frac{x \cdot y}{\sqrt{\frac{z \cdot z - t \cdot a}{z \cdot z}}}
\] |
|---|---|
unpow2 [<=]55.2 | \[ \frac{x \cdot y}{\sqrt{\frac{\color{blue}{{z}^{2}} - t \cdot a}{z \cdot z}}}
\] |
unpow2 [<=]55.2 | \[ \frac{x \cdot y}{\sqrt{\frac{{z}^{2} - t \cdot a}{\color{blue}{{z}^{2}}}}}
\] |
div-sub [=>]55.1 | \[ \frac{x \cdot y}{\sqrt{\color{blue}{\frac{{z}^{2}}{{z}^{2}} - \frac{t \cdot a}{{z}^{2}}}}}
\] |
*-inverses [=>]88.9 | \[ \frac{x \cdot y}{\sqrt{\color{blue}{1} - \frac{t \cdot a}{{z}^{2}}}}
\] |
unpow2 [=>]88.9 | \[ \frac{x \cdot y}{\sqrt{1 - \frac{t \cdot a}{\color{blue}{z \cdot z}}}}
\] |
times-frac [=>]93.1 | \[ \frac{x \cdot y}{\sqrt{1 - \color{blue}{\frac{t}{z} \cdot \frac{a}{z}}}}
\] |
Final simplification90.7%
| Alternative 1 | |
|---|---|
| Accuracy | 88.8% |
| Cost | 7760 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.2% |
| Cost | 7760 |
| Alternative 3 | |
|---|---|
| Accuracy | 90.6% |
| Cost | 7760 |
| Alternative 4 | |
|---|---|
| Accuracy | 89.1% |
| Cost | 7496 |
| Alternative 5 | |
|---|---|
| Accuracy | 82.5% |
| Cost | 7304 |
| Alternative 6 | |
|---|---|
| Accuracy | 82.1% |
| Cost | 7304 |
| Alternative 7 | |
|---|---|
| Accuracy | 74.2% |
| Cost | 1224 |
| Alternative 8 | |
|---|---|
| Accuracy | 75.2% |
| Cost | 1224 |
| Alternative 9 | |
|---|---|
| Accuracy | 74.6% |
| Cost | 1224 |
| Alternative 10 | |
|---|---|
| Accuracy | 73.4% |
| Cost | 1096 |
| Alternative 11 | |
|---|---|
| Accuracy | 73.4% |
| Cost | 1096 |
| Alternative 12 | |
|---|---|
| Accuracy | 73.2% |
| Cost | 1096 |
| Alternative 13 | |
|---|---|
| Accuracy | 73.1% |
| Cost | 1096 |
| Alternative 14 | |
|---|---|
| Accuracy | 73.7% |
| Cost | 1092 |
| Alternative 15 | |
|---|---|
| Accuracy | 75.7% |
| Cost | 1092 |
| Alternative 16 | |
|---|---|
| Accuracy | 77.8% |
| Cost | 1092 |
| Alternative 17 | |
|---|---|
| Accuracy | 73.3% |
| Cost | 776 |
| Alternative 18 | |
|---|---|
| Accuracy | 71.6% |
| Cost | 712 |
| Alternative 19 | |
|---|---|
| Accuracy | 72.9% |
| Cost | 712 |
| Alternative 20 | |
|---|---|
| Accuracy | 73.3% |
| Cost | 712 |
| Alternative 21 | |
|---|---|
| Accuracy | 70.1% |
| Cost | 388 |
| Alternative 22 | |
|---|---|
| Accuracy | 42.0% |
| Cost | 192 |
herbie shell --seed 2023151
(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)))))