| Alternative 1 | |
|---|---|
| Accuracy | 91.1% |
| Cost | 14288 |

(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
:precision binary64
(if (<= (* V l) (- INFINITY))
(* c0 (/ (sqrt (/ -1.0 V)) (sqrt (/ (- l) A))))
(if (<= (* V l) -1.8e-278)
(* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
(if (<= (* V l) 2e-321)
(* c0 (pow (* V (/ l A)) -0.5))
(if (<= (* V l) 5e+298)
(/ c0 (/ (sqrt (* V l)) (sqrt A)))
(* c0 (sqrt (* (/ A V) (/ 1.0 l)))))))))double code(double c0, double A, double V, double l) {
return c0 * sqrt((A / (V * l)));
}
double code(double c0, double A, double V, double l) {
double tmp;
if ((V * l) <= -((double) INFINITY)) {
tmp = c0 * (sqrt((-1.0 / V)) / sqrt((-l / A)));
} else if ((V * l) <= -1.8e-278) {
tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
} else if ((V * l) <= 2e-321) {
tmp = c0 * pow((V * (l / A)), -0.5);
} else if ((V * l) <= 5e+298) {
tmp = c0 / (sqrt((V * l)) / sqrt(A));
} else {
tmp = c0 * sqrt(((A / V) * (1.0 / l)));
}
return tmp;
}
public static double code(double c0, double A, double V, double l) {
return c0 * Math.sqrt((A / (V * l)));
}
public static double code(double c0, double A, double V, double l) {
double tmp;
if ((V * l) <= -Double.POSITIVE_INFINITY) {
tmp = c0 * (Math.sqrt((-1.0 / V)) / Math.sqrt((-l / A)));
} else if ((V * l) <= -1.8e-278) {
tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
} else if ((V * l) <= 2e-321) {
tmp = c0 * Math.pow((V * (l / A)), -0.5);
} else if ((V * l) <= 5e+298) {
tmp = c0 / (Math.sqrt((V * l)) / Math.sqrt(A));
} else {
tmp = c0 * Math.sqrt(((A / V) * (1.0 / l)));
}
return tmp;
}
def code(c0, A, V, l): return c0 * math.sqrt((A / (V * l)))
def code(c0, A, V, l): tmp = 0 if (V * l) <= -math.inf: tmp = c0 * (math.sqrt((-1.0 / V)) / math.sqrt((-l / A))) elif (V * l) <= -1.8e-278: tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l))) elif (V * l) <= 2e-321: tmp = c0 * math.pow((V * (l / A)), -0.5) elif (V * l) <= 5e+298: tmp = c0 / (math.sqrt((V * l)) / math.sqrt(A)) else: tmp = c0 * math.sqrt(((A / V) * (1.0 / l))) return tmp
function code(c0, A, V, l) return Float64(c0 * sqrt(Float64(A / Float64(V * l)))) end
function code(c0, A, V, l) tmp = 0.0 if (Float64(V * l) <= Float64(-Inf)) tmp = Float64(c0 * Float64(sqrt(Float64(-1.0 / V)) / sqrt(Float64(Float64(-l) / A)))); elseif (Float64(V * l) <= -1.8e-278) tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l))))); elseif (Float64(V * l) <= 2e-321) tmp = Float64(c0 * (Float64(V * Float64(l / A)) ^ -0.5)); elseif (Float64(V * l) <= 5e+298) tmp = Float64(c0 / Float64(sqrt(Float64(V * l)) / sqrt(A))); else tmp = Float64(c0 * sqrt(Float64(Float64(A / V) * Float64(1.0 / l)))); end return tmp end
function tmp = code(c0, A, V, l) tmp = c0 * sqrt((A / (V * l))); end
function tmp_2 = code(c0, A, V, l) tmp = 0.0; if ((V * l) <= -Inf) tmp = c0 * (sqrt((-1.0 / V)) / sqrt((-l / A))); elseif ((V * l) <= -1.8e-278) tmp = c0 * (sqrt(-A) / sqrt((V * -l))); elseif ((V * l) <= 2e-321) tmp = c0 * ((V * (l / A)) ^ -0.5); elseif ((V * l) <= 5e+298) tmp = c0 / (sqrt((V * l)) / sqrt(A)); else tmp = c0 * sqrt(((A / V) * (1.0 / l))); end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[c0_, A_, V_, l_] := If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], N[(c0 * N[(N[Sqrt[N[(-1.0 / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[((-l) / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -1.8e-278], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e-321], N[(c0 * N[Power[N[(V * N[(l / A), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 5e+298], N[(c0 / N[(N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[A], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{-1}{V}}}{\sqrt{\frac{-\ell}{A}}}\\
\mathbf{elif}\;V \cdot \ell \leq -1.8 \cdot 10^{-278}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\
\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-321}:\\
\;\;\;\;c0 \cdot {\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}\\
\mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+298}:\\
\;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{A}{V} \cdot \frac{1}{\ell}}\\
\end{array}
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
if (*.f64 V l) < -inf.0Initial program 36.6%
Applied egg-rr65.5%
[Start]36.6% | \[ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\] |
|---|---|
*-un-lft-identity [=>]36.6% | \[ c0 \cdot \sqrt{\frac{\color{blue}{1 \cdot A}}{V \cdot \ell}}
\] |
times-frac [=>]65.5% | \[ c0 \cdot \sqrt{\color{blue}{\frac{1}{V} \cdot \frac{A}{\ell}}}
\] |
Applied egg-rr65.5%
[Start]65.5% | \[ c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}
\] |
|---|---|
clear-num [=>]65.5% | \[ c0 \cdot \sqrt{\frac{1}{V} \cdot \color{blue}{\frac{1}{\frac{\ell}{A}}}}
\] |
un-div-inv [=>]65.5% | \[ c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}}
\] |
Applied egg-rr28.7%
[Start]65.5% | \[ c0 \cdot \sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}
\] |
|---|---|
frac-2neg [=>]65.5% | \[ c0 \cdot \sqrt{\color{blue}{\frac{-\frac{1}{V}}{-\frac{\ell}{A}}}}
\] |
sqrt-div [=>]28.7% | \[ c0 \cdot \color{blue}{\frac{\sqrt{-\frac{1}{V}}}{\sqrt{-\frac{\ell}{A}}}}
\] |
Simplified28.7%
[Start]28.7% | \[ c0 \cdot \frac{\sqrt{-\frac{1}{V}}}{\sqrt{-\frac{\ell}{A}}}
\] |
|---|---|
distribute-neg-frac [=>]28.7% | \[ c0 \cdot \frac{\sqrt{\color{blue}{\frac{-1}{V}}}}{\sqrt{-\frac{\ell}{A}}}
\] |
metadata-eval [=>]28.7% | \[ c0 \cdot \frac{\sqrt{\frac{\color{blue}{-1}}{V}}}{\sqrt{-\frac{\ell}{A}}}
\] |
distribute-neg-frac [=>]28.7% | \[ c0 \cdot \frac{\sqrt{\frac{-1}{V}}}{\sqrt{\color{blue}{\frac{-\ell}{A}}}}
\] |
if -inf.0 < (*.f64 V l) < -1.79999999999999998e-278Initial program 87.1%
Applied egg-rr99.5%
[Start]87.1% | \[ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\] |
|---|---|
frac-2neg [=>]87.1% | \[ c0 \cdot \sqrt{\color{blue}{\frac{-A}{-V \cdot \ell}}}
\] |
sqrt-div [=>]99.5% | \[ c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{-V \cdot \ell}}}
\] |
*-commutative [=>]99.5% | \[ c0 \cdot \frac{\sqrt{-A}}{\sqrt{-\color{blue}{\ell \cdot V}}}
\] |
distribute-rgt-neg-in [=>]99.5% | \[ c0 \cdot \frac{\sqrt{-A}}{\sqrt{\color{blue}{\ell \cdot \left(-V\right)}}}
\] |
if -1.79999999999999998e-278 < (*.f64 V l) < 2.00097e-321Initial program 51.9%
Applied egg-rr84.0%
[Start]51.9% | \[ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\] |
|---|---|
pow1/2 [=>]51.9% | \[ c0 \cdot \color{blue}{{\left(\frac{A}{V \cdot \ell}\right)}^{0.5}}
\] |
clear-num [=>]51.9% | \[ c0 \cdot {\color{blue}{\left(\frac{1}{\frac{V \cdot \ell}{A}}\right)}}^{0.5}
\] |
inv-pow [=>]51.9% | \[ c0 \cdot {\color{blue}{\left({\left(\frac{V \cdot \ell}{A}\right)}^{-1}\right)}}^{0.5}
\] |
pow-pow [=>]51.9% | \[ c0 \cdot \color{blue}{{\left(\frac{V \cdot \ell}{A}\right)}^{\left(-1 \cdot 0.5\right)}}
\] |
associate-/l* [=>]84.0% | \[ c0 \cdot {\color{blue}{\left(\frac{V}{\frac{A}{\ell}}\right)}}^{\left(-1 \cdot 0.5\right)}
\] |
metadata-eval [=>]84.0% | \[ c0 \cdot {\left(\frac{V}{\frac{A}{\ell}}\right)}^{\color{blue}{-0.5}}
\] |
Simplified84.0%
[Start]84.0% | \[ c0 \cdot {\left(\frac{V}{\frac{A}{\ell}}\right)}^{-0.5}
\] |
|---|---|
associate-/l* [<=]51.9% | \[ c0 \cdot {\color{blue}{\left(\frac{V \cdot \ell}{A}\right)}}^{-0.5}
\] |
*-lft-identity [<=]51.9% | \[ c0 \cdot {\left(\frac{V \cdot \ell}{\color{blue}{1 \cdot A}}\right)}^{-0.5}
\] |
times-frac [=>]84.0% | \[ c0 \cdot {\color{blue}{\left(\frac{V}{1} \cdot \frac{\ell}{A}\right)}}^{-0.5}
\] |
/-rgt-identity [=>]84.0% | \[ c0 \cdot {\left(\color{blue}{V} \cdot \frac{\ell}{A}\right)}^{-0.5}
\] |
if 2.00097e-321 < (*.f64 V l) < 5.0000000000000003e298Initial program 82.7%
Applied egg-rr94.1%
[Start]82.7% | \[ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\] |
|---|---|
sqrt-div [=>]98.6% | \[ c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}}
\] |
associate-*r/ [=>]94.1% | \[ \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}}
\] |
Simplified98.7%
[Start]94.1% | \[ \frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}
\] |
|---|---|
associate-/l* [=>]98.7% | \[ \color{blue}{\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}}
\] |
if 5.0000000000000003e298 < (*.f64 V l) Initial program 30.2%
Applied egg-rr73.6%
[Start]30.2% | \[ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\] |
|---|---|
associate-/r* [=>]73.6% | \[ c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}}
\] |
div-inv [=>]73.6% | \[ c0 \cdot \sqrt{\color{blue}{\frac{A}{V} \cdot \frac{1}{\ell}}}
\] |
Final simplification91.3%
| Alternative 1 | |
|---|---|
| Accuracy | 91.1% |
| Cost | 14288 |
| Alternative 2 | |
|---|---|
| Accuracy | 91.8% |
| Cost | 20036 |
| Alternative 3 | |
|---|---|
| Accuracy | 85.9% |
| Cost | 14288 |
| Alternative 4 | |
|---|---|
| Accuracy | 87.1% |
| Cost | 14288 |
| Alternative 5 | |
|---|---|
| Accuracy | 87.1% |
| Cost | 14288 |
| Alternative 6 | |
|---|---|
| Accuracy | 91.1% |
| Cost | 14288 |
| Alternative 7 | |
|---|---|
| Accuracy | 91.1% |
| Cost | 14288 |
| Alternative 8 | |
|---|---|
| Accuracy | 81.4% |
| Cost | 13380 |
| Alternative 9 | |
|---|---|
| Accuracy | 79.5% |
| Cost | 7752 |
| Alternative 10 | |
|---|---|
| Accuracy | 79.6% |
| Cost | 7752 |
| Alternative 11 | |
|---|---|
| Accuracy | 79.5% |
| Cost | 7688 |
| Alternative 12 | |
|---|---|
| Accuracy | 79.5% |
| Cost | 7688 |
| Alternative 13 | |
|---|---|
| Accuracy | 79.5% |
| Cost | 7625 |
| Alternative 14 | |
|---|---|
| Accuracy | 79.4% |
| Cost | 7624 |
| Alternative 15 | |
|---|---|
| Accuracy | 79.8% |
| Cost | 7624 |
| Alternative 16 | |
|---|---|
| Accuracy | 79.5% |
| Cost | 7624 |
| Alternative 17 | |
|---|---|
| Accuracy | 73.5% |
| Cost | 6848 |
herbie shell --seed 2023165
(FPCore (c0 A V l)
:name "Henrywood and Agarwal, Equation (3)"
:precision binary64
(* c0 (sqrt (/ A (* V l)))))