| Alternative 1 | |
|---|---|
| Error | 10.2 |
| Cost | 8392 |
(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
(let* ((t_0 (pow (/ (* M D) (* 2.0 d)) 2.0)) (t_1 (* (* D (/ M d)) 0.5)))
(if (<= t_0 5e-48)
(* w0 (sqrt (+ 1.0 (/ -1.0 (* (/ l t_1) (/ (/ 1.0 h) t_1))))))
(if (<= t_0 1e+278)
(* w0 (sqrt (- 1.0 (* t_0 (/ h l)))))
(*
w0
(sqrt
(- 1.0 (/ (/ (* D (* 0.25 (* h (* M (/ M l))))) (/ d D)) d))))))))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 t_0 = pow(((M * D) / (2.0 * d)), 2.0);
double t_1 = (D * (M / d)) * 0.5;
double tmp;
if (t_0 <= 5e-48) {
tmp = w0 * sqrt((1.0 + (-1.0 / ((l / t_1) * ((1.0 / h) / t_1)))));
} else if (t_0 <= 1e+278) {
tmp = w0 * sqrt((1.0 - (t_0 * (h / l))));
} else {
tmp = w0 * sqrt((1.0 - (((D * (0.25 * (h * (M * (M / l))))) / (d / D)) / d)));
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((m * d) / (2.0d0 * d_1)) ** 2.0d0
t_1 = (d * (m / d_1)) * 0.5d0
if (t_0 <= 5d-48) then
tmp = w0 * sqrt((1.0d0 + ((-1.0d0) / ((l / t_1) * ((1.0d0 / h) / t_1)))))
else if (t_0 <= 1d+278) then
tmp = w0 * sqrt((1.0d0 - (t_0 * (h / l))))
else
tmp = w0 * sqrt((1.0d0 - (((d * (0.25d0 * (h * (m * (m / l))))) / (d_1 / d)) / d_1)))
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 t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0);
double t_1 = (D * (M / d)) * 0.5;
double tmp;
if (t_0 <= 5e-48) {
tmp = w0 * Math.sqrt((1.0 + (-1.0 / ((l / t_1) * ((1.0 / h) / t_1)))));
} else if (t_0 <= 1e+278) {
tmp = w0 * Math.sqrt((1.0 - (t_0 * (h / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - (((D * (0.25 * (h * (M * (M / l))))) / (d / D)) / d)));
}
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): t_0 = math.pow(((M * D) / (2.0 * d)), 2.0) t_1 = (D * (M / d)) * 0.5 tmp = 0 if t_0 <= 5e-48: tmp = w0 * math.sqrt((1.0 + (-1.0 / ((l / t_1) * ((1.0 / h) / t_1))))) elif t_0 <= 1e+278: tmp = w0 * math.sqrt((1.0 - (t_0 * (h / l)))) else: tmp = w0 * math.sqrt((1.0 - (((D * (0.25 * (h * (M * (M / l))))) / (d / D)) / d))) 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) t_0 = Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0 t_1 = Float64(Float64(D * Float64(M / d)) * 0.5) tmp = 0.0 if (t_0 <= 5e-48) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-1.0 / Float64(Float64(l / t_1) * Float64(Float64(1.0 / h) / t_1)))))); elseif (t_0 <= 1e+278) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(h / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(D * Float64(0.25 * Float64(h * Float64(M * Float64(M / l))))) / Float64(d / D)) / d)))); 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) t_0 = ((M * D) / (2.0 * d)) ^ 2.0; t_1 = (D * (M / d)) * 0.5; tmp = 0.0; if (t_0 <= 5e-48) tmp = w0 * sqrt((1.0 + (-1.0 / ((l / t_1) * ((1.0 / h) / t_1))))); elseif (t_0 <= 1e+278) tmp = w0 * sqrt((1.0 - (t_0 * (h / l)))); else tmp = w0 * sqrt((1.0 - (((D * (0.25 * (h * (M * (M / l))))) / (d / D)) / d))); 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_] := Block[{t$95$0 = N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-48], N[(w0 * N[Sqrt[N[(1.0 + N[(-1.0 / N[(N[(l / t$95$1), $MachinePrecision] * N[(N[(1.0 / h), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+278], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(D * N[(0.25 * N[(h * N[(M * N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] / d), $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}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\\
t_1 := \left(D \cdot \frac{M}{d}\right) \cdot 0.5\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-48}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{t_1} \cdot \frac{\frac{1}{h}}{t_1}}}\\
\mathbf{elif}\;t_0 \leq 10^{+278}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{D \cdot \left(0.25 \cdot \left(h \cdot \left(M \cdot \frac{M}{\ell}\right)\right)\right)}{\frac{d}{D}}}{d}}\\
\end{array}
Results
if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 4.9999999999999999e-48Initial program 6.2
Applied egg-rr5.7
Applied egg-rr5.7
Simplified5.7
[Start]5.7 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h} \cdot \left(\frac{2}{D} \cdot \frac{d}{M}\right)}{0.5 \cdot \frac{D}{\frac{d}{M}}}}}
\] |
|---|---|
associate-/l* [=>]5.7 | \[ w0 \cdot \sqrt{1 - \frac{1}{\color{blue}{\frac{\frac{\ell}{h}}{\frac{0.5 \cdot \frac{D}{\frac{d}{M}}}{\frac{2}{D} \cdot \frac{d}{M}}}}}}
\] |
times-frac [<=]5.8 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h}}{\frac{0.5 \cdot \frac{D}{\frac{d}{M}}}{\color{blue}{\frac{2 \cdot d}{D \cdot M}}}}}}
\] |
associate-*r/ [<=]5.8 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h}}{\frac{0.5 \cdot \frac{D}{\frac{d}{M}}}{\color{blue}{2 \cdot \frac{d}{D \cdot M}}}}}}
\] |
times-frac [=>]5.8 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h}}{\color{blue}{\frac{0.5}{2} \cdot \frac{\frac{D}{\frac{d}{M}}}{\frac{d}{D \cdot M}}}}}}
\] |
metadata-eval [=>]5.8 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h}}{\color{blue}{0.25} \cdot \frac{\frac{D}{\frac{d}{M}}}{\frac{d}{D \cdot M}}}}}
\] |
associate-/l* [<=]5.6 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h}}{0.25 \cdot \frac{\color{blue}{\frac{D \cdot M}{d}}}{\frac{d}{D \cdot M}}}}}
\] |
associate-*r/ [<=]5.7 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\frac{\ell}{h}}{0.25 \cdot \frac{\color{blue}{D \cdot \frac{M}{d}}}{\frac{d}{D \cdot M}}}}}
\] |
Applied egg-rr0.5
if 4.9999999999999999e-48 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 9.99999999999999964e277Initial program 8.4
if 9.99999999999999964e277 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) Initial program 60.7
Simplified56.4
[Start]60.7 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
associate-/l* [=>]56.4 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{\frac{2 \cdot d}{D}}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Taylor expanded in M around 0 61.2
Simplified62.0
[Start]61.2 | \[ w0 \cdot \sqrt{1 - 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}}}
\] |
|---|---|
*-commutative [=>]61.2 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell \cdot {d}^{2}} \cdot 0.25}}
\] |
*-commutative [=>]61.2 | \[ w0 \cdot \sqrt{1 - \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{{d}^{2} \cdot \ell}} \cdot 0.25}
\] |
*-commutative [=>]61.2 | \[ w0 \cdot \sqrt{1 - \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2} \cdot \ell} \cdot 0.25}
\] |
times-frac [=>]62.1 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{{D}^{2}}{{d}^{2}} \cdot \frac{h \cdot {M}^{2}}{\ell}\right)} \cdot 0.25}
\] |
associate-*l* [=>]62.1 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{{D}^{2}}{{d}^{2}} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}}
\] |
unpow2 [=>]62.1 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}
\] |
unpow2 [=>]62.1 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}
\] |
*-commutative [<=]62.1 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot D}{d \cdot d} \cdot \left(\frac{\color{blue}{{M}^{2} \cdot h}}{\ell} \cdot 0.25\right)}
\] |
associate-/l* [=>]62.0 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot D}{d \cdot d} \cdot \left(\color{blue}{\frac{{M}^{2}}{\frac{\ell}{h}}} \cdot 0.25\right)}
\] |
unpow2 [=>]62.0 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot D}{d \cdot d} \cdot \left(\frac{\color{blue}{M \cdot M}}{\frac{\ell}{h}} \cdot 0.25\right)}
\] |
Applied egg-rr58.4
Taylor expanded in M around 0 57.9
Simplified53.4
[Start]57.9 | \[ w0 \cdot \sqrt{1 - \frac{\left(\frac{D}{d} \cdot D\right) \cdot \left(0.25 \cdot \frac{h \cdot {M}^{2}}{\ell}\right)}{d}}
\] |
|---|---|
associate-/l* [=>]57.8 | \[ w0 \cdot \sqrt{1 - \frac{\left(\frac{D}{d} \cdot D\right) \cdot \left(0.25 \cdot \color{blue}{\frac{h}{\frac{\ell}{{M}^{2}}}}\right)}{d}}
\] |
unpow2 [=>]57.8 | \[ w0 \cdot \sqrt{1 - \frac{\left(\frac{D}{d} \cdot D\right) \cdot \left(0.25 \cdot \frac{h}{\frac{\ell}{\color{blue}{M \cdot M}}}\right)}{d}}
\] |
associate-/r* [=>]53.4 | \[ w0 \cdot \sqrt{1 - \frac{\left(\frac{D}{d} \cdot D\right) \cdot \left(0.25 \cdot \frac{h}{\color{blue}{\frac{\frac{\ell}{M}}{M}}}\right)}{d}}
\] |
Applied egg-rr51.4
Final simplification8.8
| Alternative 1 | |
|---|---|
| Error | 10.2 |
| Cost | 8392 |
| Alternative 2 | |
|---|---|
| Error | 9.2 |
| Cost | 8392 |
| Alternative 3 | |
|---|---|
| Error | 9.2 |
| Cost | 8392 |
| Alternative 4 | |
|---|---|
| Error | 13.9 |
| Cost | 8008 |
| Alternative 5 | |
|---|---|
| Error | 12.8 |
| Cost | 8008 |
| Alternative 6 | |
|---|---|
| Error | 8.5 |
| Cost | 8000 |
| Alternative 7 | |
|---|---|
| Error | 13.8 |
| Cost | 64 |
herbie shell --seed 2023059
(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))))))