| Alternative 1 | |
|---|---|
| Error | 14.0 |
| Cost | 34641 |
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (sqrt (- A))))
(if (<= (* V l) (- INFINITY))
(/ (* t_0 (/ c0 (sqrt (- V)))) (sqrt l))
(if (<= (* V l) -2e-310)
(* c0 (/ t_0 (sqrt (* V (- l)))))
(if (<= (* V l) 2e-321)
(* c0 (* (pow (/ (- l) A) -0.5) (pow (/ -1.0 V) 0.5)))
(if (<= (* V l) 1e+301)
(* c0 (/ (sqrt A) (sqrt (* V l))))
(/ (sqrt (* (/ c0 V) (/ c0 l))) (pow A -0.5))))))))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 t_0 = sqrt(-A);
double tmp;
if ((V * l) <= -((double) INFINITY)) {
tmp = (t_0 * (c0 / sqrt(-V))) / sqrt(l);
} else if ((V * l) <= -2e-310) {
tmp = c0 * (t_0 / sqrt((V * -l)));
} else if ((V * l) <= 2e-321) {
tmp = c0 * (pow((-l / A), -0.5) * pow((-1.0 / V), 0.5));
} else if ((V * l) <= 1e+301) {
tmp = c0 * (sqrt(A) / sqrt((V * l)));
} else {
tmp = sqrt(((c0 / V) * (c0 / l))) / pow(A, -0.5);
}
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 t_0 = Math.sqrt(-A);
double tmp;
if ((V * l) <= -Double.POSITIVE_INFINITY) {
tmp = (t_0 * (c0 / Math.sqrt(-V))) / Math.sqrt(l);
} else if ((V * l) <= -2e-310) {
tmp = c0 * (t_0 / Math.sqrt((V * -l)));
} else if ((V * l) <= 2e-321) {
tmp = c0 * (Math.pow((-l / A), -0.5) * Math.pow((-1.0 / V), 0.5));
} else if ((V * l) <= 1e+301) {
tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
} else {
tmp = Math.sqrt(((c0 / V) * (c0 / l))) / Math.pow(A, -0.5);
}
return tmp;
}
def code(c0, A, V, l): return c0 * math.sqrt((A / (V * l)))
def code(c0, A, V, l): t_0 = math.sqrt(-A) tmp = 0 if (V * l) <= -math.inf: tmp = (t_0 * (c0 / math.sqrt(-V))) / math.sqrt(l) elif (V * l) <= -2e-310: tmp = c0 * (t_0 / math.sqrt((V * -l))) elif (V * l) <= 2e-321: tmp = c0 * (math.pow((-l / A), -0.5) * math.pow((-1.0 / V), 0.5)) elif (V * l) <= 1e+301: tmp = c0 * (math.sqrt(A) / math.sqrt((V * l))) else: tmp = math.sqrt(((c0 / V) * (c0 / l))) / math.pow(A, -0.5) return tmp
function code(c0, A, V, l) return Float64(c0 * sqrt(Float64(A / Float64(V * l)))) end
function code(c0, A, V, l) t_0 = sqrt(Float64(-A)) tmp = 0.0 if (Float64(V * l) <= Float64(-Inf)) tmp = Float64(Float64(t_0 * Float64(c0 / sqrt(Float64(-V)))) / sqrt(l)); elseif (Float64(V * l) <= -2e-310) tmp = Float64(c0 * Float64(t_0 / sqrt(Float64(V * Float64(-l))))); elseif (Float64(V * l) <= 2e-321) tmp = Float64(c0 * Float64((Float64(Float64(-l) / A) ^ -0.5) * (Float64(-1.0 / V) ^ 0.5))); elseif (Float64(V * l) <= 1e+301) tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l)))); else tmp = Float64(sqrt(Float64(Float64(c0 / V) * Float64(c0 / l))) / (A ^ -0.5)); 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) t_0 = sqrt(-A); tmp = 0.0; if ((V * l) <= -Inf) tmp = (t_0 * (c0 / sqrt(-V))) / sqrt(l); elseif ((V * l) <= -2e-310) tmp = c0 * (t_0 / sqrt((V * -l))); elseif ((V * l) <= 2e-321) tmp = c0 * (((-l / A) ^ -0.5) * ((-1.0 / V) ^ 0.5)); elseif ((V * l) <= 1e+301) tmp = c0 * (sqrt(A) / sqrt((V * l))); else tmp = sqrt(((c0 / V) * (c0 / l))) / (A ^ -0.5); 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_] := Block[{t$95$0 = N[Sqrt[(-A)], $MachinePrecision]}, If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], N[(N[(t$95$0 * N[(c0 / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -2e-310], N[(c0 * N[(t$95$0 / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e-321], N[(c0 * N[(N[Power[N[((-l) / A), $MachinePrecision], -0.5], $MachinePrecision] * N[Power[N[(-1.0 / V), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 1e+301], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(c0 / V), $MachinePrecision] * N[(c0 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Power[A, -0.5], $MachinePrecision]), $MachinePrecision]]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
t_0 := \sqrt{-A}\\
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;\frac{t_0 \cdot \frac{c0}{\sqrt{-V}}}{\sqrt{\ell}}\\
\mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-310}:\\
\;\;\;\;c0 \cdot \frac{t_0}{\sqrt{V \cdot \left(-\ell\right)}}\\
\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-321}:\\
\;\;\;\;c0 \cdot \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot {\left(\frac{-1}{V}\right)}^{0.5}\right)\\
\mathbf{elif}\;V \cdot \ell \leq 10^{+301}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\frac{c0}{V} \cdot \frac{c0}{\ell}}}{{A}^{-0.5}}\\
\end{array}
Results
if (*.f64 V l) < -inf.0Initial program 42.0
Applied egg-rr10.5
Applied egg-rr4.3
Simplified1.5
[Start]4.3 | \[ \frac{\frac{\sqrt{-A} \cdot c0}{\sqrt{-V}}}{\sqrt{\ell}}
\] |
|---|---|
*-lft-identity [<=]4.3 | \[ \frac{\frac{\sqrt{-A} \cdot c0}{\color{blue}{1 \cdot \sqrt{-V}}}}{\sqrt{\ell}}
\] |
times-frac [=>]1.5 | \[ \frac{\color{blue}{\frac{\sqrt{-A}}{1} \cdot \frac{c0}{\sqrt{-V}}}}{\sqrt{\ell}}
\] |
/-rgt-identity [=>]1.5 | \[ \frac{\color{blue}{\sqrt{-A}} \cdot \frac{c0}{\sqrt{-V}}}{\sqrt{\ell}}
\] |
if -inf.0 < (*.f64 V l) < -1.999999999999994e-310Initial program 10.4
Applied egg-rr2.8
Simplified0.4
[Start]2.8 | \[ \frac{c0 \cdot \sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}
\] |
|---|---|
*-commutative [<=]2.8 | \[ \frac{\color{blue}{\sqrt{-A} \cdot c0}}{\sqrt{V \cdot \left(-\ell\right)}}
\] |
associate-/l* [=>]2.6 | \[ \color{blue}{\frac{\sqrt{-A}}{\frac{\sqrt{V \cdot \left(-\ell\right)}}{c0}}}
\] |
associate-/r/ [=>]0.4 | \[ \color{blue}{\frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}} \cdot c0}
\] |
if -1.999999999999994e-310 < (*.f64 V l) < 2.00097e-321Initial program 63.4
Applied egg-rr37.6
Simplified37.6
[Start]37.6 | \[ \frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}
\] |
|---|---|
associate-/r/ [=>]37.6 | \[ \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}}
\] |
Applied egg-rr37.6
Taylor expanded in V around -inf 30.3
Simplified27.0
[Start]30.3 | \[ e^{-0.5 \cdot \left(\log \left(-1 \cdot \frac{\ell}{A}\right) + -1 \cdot \log \left(\frac{-1}{V}\right)\right)} \cdot c0
\] |
|---|---|
distribute-rgt-in [=>]30.3 | \[ e^{\color{blue}{\log \left(-1 \cdot \frac{\ell}{A}\right) \cdot -0.5 + \left(-1 \cdot \log \left(\frac{-1}{V}\right)\right) \cdot -0.5}} \cdot c0
\] |
exp-sum [=>]30.0 | \[ \color{blue}{\left(e^{\log \left(-1 \cdot \frac{\ell}{A}\right) \cdot -0.5} \cdot e^{\left(-1 \cdot \log \left(\frac{-1}{V}\right)\right) \cdot -0.5}\right)} \cdot c0
\] |
exp-to-pow [=>]29.9 | \[ \left(\color{blue}{{\left(-1 \cdot \frac{\ell}{A}\right)}^{-0.5}} \cdot e^{\left(-1 \cdot \log \left(\frac{-1}{V}\right)\right) \cdot -0.5}\right) \cdot c0
\] |
mul-1-neg [=>]29.9 | \[ \left({\color{blue}{\left(-\frac{\ell}{A}\right)}}^{-0.5} \cdot e^{\left(-1 \cdot \log \left(\frac{-1}{V}\right)\right) \cdot -0.5}\right) \cdot c0
\] |
distribute-neg-frac [=>]29.9 | \[ \left({\color{blue}{\left(\frac{-\ell}{A}\right)}}^{-0.5} \cdot e^{\left(-1 \cdot \log \left(\frac{-1}{V}\right)\right) \cdot -0.5}\right) \cdot c0
\] |
*-commutative [=>]29.9 | \[ \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot e^{\color{blue}{\left(\log \left(\frac{-1}{V}\right) \cdot -1\right)} \cdot -0.5}\right) \cdot c0
\] |
associate-*l* [=>]29.9 | \[ \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot e^{\color{blue}{\log \left(\frac{-1}{V}\right) \cdot \left(-1 \cdot -0.5\right)}}\right) \cdot c0
\] |
metadata-eval [=>]29.9 | \[ \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot e^{\log \left(\frac{-1}{V}\right) \cdot \color{blue}{0.5}}\right) \cdot c0
\] |
metadata-eval [<=]29.9 | \[ \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot e^{\log \left(\frac{-1}{V}\right) \cdot \color{blue}{\frac{1}{2}}}\right) \cdot c0
\] |
exp-to-pow [=>]27.0 | \[ \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot \color{blue}{{\left(\frac{-1}{V}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot c0
\] |
metadata-eval [=>]27.0 | \[ \left({\left(\frac{-\ell}{A}\right)}^{-0.5} \cdot {\left(\frac{-1}{V}\right)}^{\color{blue}{0.5}}\right) \cdot c0
\] |
if 2.00097e-321 < (*.f64 V l) < 1.00000000000000005e301Initial program 10.6
Applied egg-rr0.6
Simplified0.6
[Start]0.6 | \[ c0 \cdot \left(\sqrt{A} \cdot \frac{1}{\sqrt{V \cdot \ell}}\right)
\] |
|---|---|
*-commutative [<=]0.6 | \[ c0 \cdot \color{blue}{\left(\frac{1}{\sqrt{V \cdot \ell}} \cdot \sqrt{A}\right)}
\] |
associate-*l/ [=>]0.6 | \[ c0 \cdot \color{blue}{\frac{1 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}}
\] |
*-lft-identity [=>]0.6 | \[ c0 \cdot \frac{\color{blue}{\sqrt{A}}}{\sqrt{V \cdot \ell}}
\] |
if 1.00000000000000005e301 < (*.f64 V l) Initial program 39.8
Applied egg-rr64.0
Simplified64.0
[Start]64.0 | \[ \frac{c0 \cdot \sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}
\] |
|---|---|
associate-/l* [=>]64.0 | \[ \color{blue}{\frac{c0}{\frac{\sqrt{V \cdot \left(-\ell\right)}}{\sqrt{-A}}}}
\] |
Applied egg-rr39.2
Simplified39.0
[Start]39.2 | \[ \frac{1}{\sqrt{V \cdot \ell}} \cdot \frac{c0}{{A}^{-0.5}}
\] |
|---|---|
associate-*r/ [=>]39.0 | \[ \color{blue}{\frac{\frac{1}{\sqrt{V \cdot \ell}} \cdot c0}{{A}^{-0.5}}}
\] |
associate-*l/ [=>]39.0 | \[ \frac{\color{blue}{\frac{1 \cdot c0}{\sqrt{V \cdot \ell}}}}{{A}^{-0.5}}
\] |
*-lft-identity [=>]39.0 | \[ \frac{\frac{\color{blue}{c0}}{\sqrt{V \cdot \ell}}}{{A}^{-0.5}}
\] |
Applied egg-rr41.2
Simplified28.8
[Start]41.2 | \[ \frac{\sqrt{\frac{c0 \cdot c0}{V \cdot \ell}}}{{A}^{-0.5}}
\] |
|---|---|
times-frac [=>]28.8 | \[ \frac{\sqrt{\color{blue}{\frac{c0}{V} \cdot \frac{c0}{\ell}}}}{{A}^{-0.5}}
\] |
Final simplification4.9
| Alternative 1 | |
|---|---|
| Error | 14.0 |
| Cost | 34641 |
| Alternative 2 | |
|---|---|
| Error | 14.1 |
| Cost | 34641 |
| Alternative 3 | |
|---|---|
| Error | 5.7 |
| Cost | 14480 |
| Alternative 4 | |
|---|---|
| Error | 5.6 |
| Cost | 14480 |
| Alternative 5 | |
|---|---|
| Error | 9.5 |
| Cost | 14289 |
| Alternative 6 | |
|---|---|
| Error | 9.0 |
| Cost | 14288 |
| Alternative 7 | |
|---|---|
| Error | 7.2 |
| Cost | 14288 |
| Alternative 8 | |
|---|---|
| Error | 6.2 |
| Cost | 14288 |
| Alternative 9 | |
|---|---|
| Error | 6.1 |
| Cost | 14288 |
| Alternative 10 | |
|---|---|
| Error | 13.0 |
| Cost | 14028 |
| Alternative 11 | |
|---|---|
| Error | 15.0 |
| Cost | 7625 |
| Alternative 12 | |
|---|---|
| Error | 15.0 |
| Cost | 7624 |
| Alternative 13 | |
|---|---|
| Error | 19.4 |
| Cost | 6848 |
herbie shell --seed 2023017
(FPCore (c0 A V l)
:name "Henrywood and Agarwal, Equation (3)"
:precision binary64
(* c0 (sqrt (/ A (* V l)))))