| Alternative 1 | |
|---|---|
| Accuracy | 85.9% |
| Cost | 14344 |
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
(FPCore (w0 M D h l d)
:precision binary64
(if (<= (* M D) 1e-185)
(* w0 (sqrt (- 1.0 (/ (* (pow (* M (* 0.5 (/ D d))) 2.0) h) l))))
(if (<= (* M D) 5e+152)
(* w0 (sqrt (- 1.0 (/ (/ h (/ d (pow (* M D) 2.0))) (* d (* l 4.0))))))
(* w0 (sqrt (- 1.0 (* (pow (/ M (/ (* d 2.0) D)) 2.0) (/ h l))))))))double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((M * D) <= 1e-185) {
tmp = w0 * sqrt((1.0 - ((pow((M * (0.5 * (D / d))), 2.0) * h) / l)));
} else if ((M * D) <= 5e+152) {
tmp = w0 * sqrt((1.0 - ((h / (d / pow((M * D), 2.0))) / (d * (l * 4.0)))));
} else {
tmp = w0 * sqrt((1.0 - (pow((M / ((d * 2.0) / D)), 2.0) * (h / l))));
}
return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if ((m * d) <= 1d-185) then
tmp = w0 * sqrt((1.0d0 - ((((m * (0.5d0 * (d / d_1))) ** 2.0d0) * h) / l)))
else if ((m * d) <= 5d+152) then
tmp = w0 * sqrt((1.0d0 - ((h / (d_1 / ((m * d) ** 2.0d0))) / (d_1 * (l * 4.0d0)))))
else
tmp = w0 * sqrt((1.0d0 - (((m / ((d_1 * 2.0d0) / d)) ** 2.0d0) * (h / l))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((M * D) <= 1e-185) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((M * (0.5 * (D / d))), 2.0) * h) / l)));
} else if ((M * D) <= 5e+152) {
tmp = w0 * Math.sqrt((1.0 - ((h / (d / Math.pow((M * D), 2.0))) / (d * (l * 4.0)))));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((M / ((d * 2.0) / D)), 2.0) * (h / l))));
}
return tmp;
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
def code(w0, M, D, h, l, d): tmp = 0 if (M * D) <= 1e-185: tmp = w0 * math.sqrt((1.0 - ((math.pow((M * (0.5 * (D / d))), 2.0) * h) / l))) elif (M * D) <= 5e+152: tmp = w0 * math.sqrt((1.0 - ((h / (d / math.pow((M * D), 2.0))) / (d * (l * 4.0))))) else: tmp = w0 * math.sqrt((1.0 - (math.pow((M / ((d * 2.0) / D)), 2.0) * (h / l)))) return tmp
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64(M * D) <= 1e-185) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) * h) / l)))); elseif (Float64(M * D) <= 5e+152) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / Float64(d / (Float64(M * D) ^ 2.0))) / Float64(d * Float64(l * 4.0)))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(M / Float64(Float64(d * 2.0) / D)) ^ 2.0) * Float64(h / l))))); end return tmp end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if ((M * D) <= 1e-185) tmp = w0 * sqrt((1.0 - ((((M * (0.5 * (D / d))) ^ 2.0) * h) / l))); elseif ((M * D) <= 5e+152) tmp = w0 * sqrt((1.0 - ((h / (d / ((M * D) ^ 2.0))) / (d * (l * 4.0))))); else tmp = w0 * sqrt((1.0 - (((M / ((d * 2.0) / D)) ^ 2.0) * (h / l)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(M * D), $MachinePrecision], 1e-185], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+152], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / N[(d / N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(M / N[(N[(d * 2.0), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 10^{-185}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\\
\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+152}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{h}{\frac{d}{{\left(M \cdot D\right)}^{2}}}}{d \cdot \left(\ell \cdot 4\right)}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{M}{\frac{d \cdot 2}{D}}\right)}^{2} \cdot \frac{h}{\ell}}\\
\end{array}
Results
if (*.f64 M D) < 9.9999999999999999e-186Initial program 80.5%
Simplified80.7%
[Start]80.5 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
times-frac [=>]80.7 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Applied egg-rr88.0%
[Start]80.7 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
associate-*r/ [=>]88.0 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}}
\] |
div-inv [=>]88.0 | \[ w0 \cdot \sqrt{1 - \frac{{\left(\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}
\] |
metadata-eval [=>]88.0 | \[ w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot \color{blue}{0.5}\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}
\] |
associate-*l* [=>]88.0 | \[ w0 \cdot \sqrt{1 - \frac{{\color{blue}{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}}^{2} \cdot h}{\ell}}
\] |
if 9.9999999999999999e-186 < (*.f64 M D) < 5e152Initial program 81.5%
Simplified80.0%
[Start]81.5 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
*-commutative [=>]81.5 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{\color{blue}{d \cdot 2}}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
times-frac [=>]80.0 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{d} \cdot \frac{D}{2}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Taylor expanded in M around 0 46.7%
Simplified76.7%
[Start]46.7 | \[ w0 \cdot \sqrt{1 - 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}}
\] |
|---|---|
associate-*r/ [=>]46.7 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{\ell \cdot {d}^{2}}}}
\] |
times-frac [=>]46.8 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{0.25}{\ell} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}}}
\] |
associate-*r* [=>]49.5 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}}
\] |
*-commutative [=>]49.5 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{\color{blue}{h \cdot \left({D}^{2} \cdot {M}^{2}\right)}}{{d}^{2}}}
\] |
unpow2 [=>]49.5 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{h \cdot \left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right)}{{d}^{2}}}
\] |
unpow2 [=>]49.5 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{h \cdot \left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right)}{{d}^{2}}}
\] |
unswap-sqr [=>]76.7 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}}{{d}^{2}}}
\] |
unpow2 [=>]76.7 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{\color{blue}{d \cdot d}}}
\] |
Applied egg-rr86.6%
[Start]76.7 | \[ w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d \cdot d}}
\] |
|---|---|
clear-num [=>]76.7 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{1}{\frac{\ell}{0.25}}} \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d \cdot d}}
\] |
associate-/r* [=>]81.2 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\ell}{0.25}} \cdot \color{blue}{\frac{\frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d}}{d}}}
\] |
frac-times [=>]83.6 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{1 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d}}{\frac{\ell}{0.25} \cdot d}}}
\] |
*-un-lft-identity [<=]83.6 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d}}}{\frac{\ell}{0.25} \cdot d}}
\] |
associate-/l* [=>]86.6 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{h}{\frac{d}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}}}{\frac{\ell}{0.25} \cdot d}}
\] |
pow2 [=>]86.6 | \[ w0 \cdot \sqrt{1 - \frac{\frac{h}{\frac{d}{\color{blue}{{\left(D \cdot M\right)}^{2}}}}}{\frac{\ell}{0.25} \cdot d}}
\] |
div-inv [=>]86.6 | \[ w0 \cdot \sqrt{1 - \frac{\frac{h}{\frac{d}{{\left(D \cdot M\right)}^{2}}}}{\color{blue}{\left(\ell \cdot \frac{1}{0.25}\right)} \cdot d}}
\] |
metadata-eval [=>]86.6 | \[ w0 \cdot \sqrt{1 - \frac{\frac{h}{\frac{d}{{\left(D \cdot M\right)}^{2}}}}{\left(\ell \cdot \color{blue}{4}\right) \cdot d}}
\] |
if 5e152 < (*.f64 M D) Initial program 44.1%
Simplified48.7%
[Start]44.1 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
associate-/l* [=>]48.7 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{\frac{2 \cdot d}{D}}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Final simplification84.9%
| Alternative 1 | |
|---|---|
| Accuracy | 85.9% |
| Cost | 14344 |
| Alternative 2 | |
|---|---|
| Accuracy | 84.9% |
| Cost | 14344 |
| Alternative 3 | |
|---|---|
| Accuracy | 84.1% |
| Cost | 14088 |
| Alternative 4 | |
|---|---|
| Accuracy | 84.3% |
| Cost | 8009 |
| Alternative 5 | |
|---|---|
| Accuracy | 85.0% |
| Cost | 8004 |
| Alternative 6 | |
|---|---|
| Accuracy | 78.8% |
| Cost | 64 |
herbie shell --seed 2023136
(FPCore (w0 M D h l d)
:name "Henrywood and Agarwal, Equation (9a)"
:precision binary64
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))