| Alternative 1 | |
|---|---|
| Error | 9.3 |
| Cost | 29452 |
(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 (* d (* l 4.0)))
(t_1 (* w0 (sqrt (- 1.0 (/ (* h (/ (pow (* M D) 2.0) t_0)) d))))))
(if (<= (* M D) -4e+141)
(*
w0
(sqrt
(- 1.0 (/ M (* (/ l h) (* (* (/ d M) (/ 2.0 D)) (* d (/ 2.0 D))))))))
(if (<= (* M D) -2e-141)
t_1
(if (<= (* M D) 2e-39)
(* w0 (sqrt (- 1.0 (/ (* h (pow (/ (* M 0.5) (/ d D)) 2.0)) l))))
(if (<= (* M D) 1e+36)
t_1
(* w0 (sqrt (- 1.0 (* (* M D) (* (* h (/ M t_0)) (/ 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 = d * (l * 4.0);
double t_1 = w0 * sqrt((1.0 - ((h * (pow((M * D), 2.0) / t_0)) / d)));
double tmp;
if ((M * D) <= -4e+141) {
tmp = w0 * sqrt((1.0 - (M / ((l / h) * (((d / M) * (2.0 / D)) * (d * (2.0 / D)))))));
} else if ((M * D) <= -2e-141) {
tmp = t_1;
} else if ((M * D) <= 2e-39) {
tmp = w0 * sqrt((1.0 - ((h * pow(((M * 0.5) / (d / D)), 2.0)) / l)));
} else if ((M * D) <= 1e+36) {
tmp = t_1;
} else {
tmp = w0 * sqrt((1.0 - ((M * D) * ((h * (M / t_0)) * (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 = d_1 * (l * 4.0d0)
t_1 = w0 * sqrt((1.0d0 - ((h * (((m * d) ** 2.0d0) / t_0)) / d_1)))
if ((m * d) <= (-4d+141)) then
tmp = w0 * sqrt((1.0d0 - (m / ((l / h) * (((d_1 / m) * (2.0d0 / d)) * (d_1 * (2.0d0 / d)))))))
else if ((m * d) <= (-2d-141)) then
tmp = t_1
else if ((m * d) <= 2d-39) then
tmp = w0 * sqrt((1.0d0 - ((h * (((m * 0.5d0) / (d_1 / d)) ** 2.0d0)) / l)))
else if ((m * d) <= 1d+36) then
tmp = t_1
else
tmp = w0 * sqrt((1.0d0 - ((m * d) * ((h * (m / t_0)) * (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 = d * (l * 4.0);
double t_1 = w0 * Math.sqrt((1.0 - ((h * (Math.pow((M * D), 2.0) / t_0)) / d)));
double tmp;
if ((M * D) <= -4e+141) {
tmp = w0 * Math.sqrt((1.0 - (M / ((l / h) * (((d / M) * (2.0 / D)) * (d * (2.0 / D)))))));
} else if ((M * D) <= -2e-141) {
tmp = t_1;
} else if ((M * D) <= 2e-39) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow(((M * 0.5) / (d / D)), 2.0)) / l)));
} else if ((M * D) <= 1e+36) {
tmp = t_1;
} else {
tmp = w0 * Math.sqrt((1.0 - ((M * D) * ((h * (M / t_0)) * (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 = d * (l * 4.0) t_1 = w0 * math.sqrt((1.0 - ((h * (math.pow((M * D), 2.0) / t_0)) / d))) tmp = 0 if (M * D) <= -4e+141: tmp = w0 * math.sqrt((1.0 - (M / ((l / h) * (((d / M) * (2.0 / D)) * (d * (2.0 / D))))))) elif (M * D) <= -2e-141: tmp = t_1 elif (M * D) <= 2e-39: tmp = w0 * math.sqrt((1.0 - ((h * math.pow(((M * 0.5) / (d / D)), 2.0)) / l))) elif (M * D) <= 1e+36: tmp = t_1 else: tmp = w0 * math.sqrt((1.0 - ((M * D) * ((h * (M / t_0)) * (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(d * Float64(l * 4.0)) t_1 = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64((Float64(M * D) ^ 2.0) / t_0)) / d)))) tmp = 0.0 if (Float64(M * D) <= -4e+141) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(M / Float64(Float64(l / h) * Float64(Float64(Float64(d / M) * Float64(2.0 / D)) * Float64(d * Float64(2.0 / D)))))))); elseif (Float64(M * D) <= -2e-141) tmp = t_1; elseif (Float64(M * D) <= 2e-39) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(M * 0.5) / Float64(d / D)) ^ 2.0)) / l)))); elseif (Float64(M * D) <= 1e+36) tmp = t_1; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M * D) * Float64(Float64(h * Float64(M / t_0)) * Float64(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 = d * (l * 4.0); t_1 = w0 * sqrt((1.0 - ((h * (((M * D) ^ 2.0) / t_0)) / d))); tmp = 0.0; if ((M * D) <= -4e+141) tmp = w0 * sqrt((1.0 - (M / ((l / h) * (((d / M) * (2.0 / D)) * (d * (2.0 / D))))))); elseif ((M * D) <= -2e-141) tmp = t_1; elseif ((M * D) <= 2e-39) tmp = w0 * sqrt((1.0 - ((h * (((M * 0.5) / (d / D)) ^ 2.0)) / l))); elseif ((M * D) <= 1e+36) tmp = t_1; else tmp = w0 * sqrt((1.0 - ((M * D) * ((h * (M / t_0)) * (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[(d * N[(l * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], -4e+141], N[(w0 * N[Sqrt[N[(1.0 - N[(M / N[(N[(l / h), $MachinePrecision] * N[(N[(N[(d / M), $MachinePrecision] * N[(2.0 / D), $MachinePrecision]), $MachinePrecision] * N[(d * N[(2.0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], -2e-141], t$95$1, If[LessEqual[N[(M * D), $MachinePrecision], 2e-39], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(M * 0.5), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+36], t$95$1, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M * D), $MachinePrecision] * N[(N[(h * N[(M / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $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}
t_0 := d \cdot \left(\ell \cdot 4\right)\\
t_1 := w0 \cdot \sqrt{1 - \frac{h \cdot \frac{{\left(M \cdot D\right)}^{2}}{t_0}}{d}}\\
\mathbf{if}\;M \cdot D \leq -4 \cdot 10^{+141}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{h} \cdot \left(\left(\frac{d}{M} \cdot \frac{2}{D}\right) \cdot \left(d \cdot \frac{2}{D}\right)\right)}}\\
\mathbf{elif}\;M \cdot D \leq -2 \cdot 10^{-141}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;M \cdot D \leq 2 \cdot 10^{-39}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}}{\ell}}\\
\mathbf{elif}\;M \cdot D \leq 10^{+36}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(M \cdot D\right) \cdot \left(\left(h \cdot \frac{M}{t_0}\right) \cdot \frac{D}{d}\right)}\\
\end{array}
Results
if (*.f64 M D) < -4.00000000000000007e141Initial program 35.2
Applied egg-rr32.5
Simplified32.6
[Start]32.5 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\ell}{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}}}
\] |
|---|---|
associate-/r/ [=>]32.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{1}{\ell} \cdot \left({\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h\right)}}
\] |
*-commutative [=>]32.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left({\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h\right) \cdot \frac{1}{\ell}}}
\] |
*-commutative [=>]32.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} \cdot \frac{1}{\ell}}
\] |
*-commutative [=>]32.5 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\left(M \cdot \color{blue}{\left(\frac{D}{d} \cdot 0.5\right)}\right)}^{2}\right) \cdot \frac{1}{\ell}}
\] |
associate-*l/ [=>]32.5 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\left(M \cdot \color{blue}{\frac{D \cdot 0.5}{d}}\right)}^{2}\right) \cdot \frac{1}{\ell}}
\] |
associate-*r/ [=>]36.4 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\color{blue}{\left(\frac{M \cdot \left(D \cdot 0.5\right)}{d}\right)}}^{2}\right) \cdot \frac{1}{\ell}}
\] |
associate-/l* [=>]32.6 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D \cdot 0.5}}\right)}}^{2}\right) \cdot \frac{1}{\ell}}
\] |
Applied egg-rr27.7
if -4.00000000000000007e141 < (*.f64 M D) < -2.0000000000000001e-141 or 1.99999999999999986e-39 < (*.f64 M D) < 1.00000000000000004e36Initial program 13.7
Simplified14.8
[Start]13.7 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
associate-*l/ [<=]14.8 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2 \cdot d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [=>]14.8 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(D \cdot \frac{M}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Applied egg-rr14.5
Simplified14.5
[Start]14.5 | \[ w0 \cdot \sqrt{1 - \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)}}
\] |
|---|---|
associate-/l* [=>]14.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\frac{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)}{D \cdot M}}}}
\] |
associate-/r/ [=>]14.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)} \cdot \left(D \cdot M\right)}}
\] |
*-commutative [=>]14.5 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\frac{\ell}{h} \cdot \color{blue}{\left(4 \cdot \left(d \cdot d\right)\right)}} \cdot \left(D \cdot M\right)}
\] |
unpow2 [<=]14.5 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\frac{\ell}{h} \cdot \left(4 \cdot \color{blue}{{d}^{2}}\right)} \cdot \left(D \cdot M\right)}
\] |
associate-*r* [=>]14.5 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{\ell}{h} \cdot 4\right) \cdot {d}^{2}}} \cdot \left(D \cdot M\right)}
\] |
unpow2 [=>]14.5 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(\frac{\ell}{h} \cdot 4\right) \cdot \color{blue}{\left(d \cdot d\right)}} \cdot \left(D \cdot M\right)}
\] |
Applied egg-rr9.2
if -2.0000000000000001e-141 < (*.f64 M D) < 1.99999999999999986e-39Initial program 8.1
Simplified8.4
[Start]8.1 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
associate-*l/ [<=]8.4 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2 \cdot d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [=>]8.4 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(D \cdot \frac{M}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Applied egg-rr2.7
Applied egg-rr2.6
if 1.00000000000000004e36 < (*.f64 M D) Initial program 27.3
Simplified26.0
[Start]27.3 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
associate-*l/ [<=]26.0 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2 \cdot d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [=>]26.0 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(D \cdot \frac{M}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Applied egg-rr39.6
Simplified27.2
[Start]39.6 | \[ w0 \cdot \sqrt{1 - \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)}}
\] |
|---|---|
associate-/l* [=>]27.2 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\frac{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)}{D \cdot M}}}}
\] |
associate-/r/ [=>]27.2 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)} \cdot \left(D \cdot M\right)}}
\] |
*-commutative [=>]27.2 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\frac{\ell}{h} \cdot \color{blue}{\left(4 \cdot \left(d \cdot d\right)\right)}} \cdot \left(D \cdot M\right)}
\] |
unpow2 [<=]27.2 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\frac{\ell}{h} \cdot \left(4 \cdot \color{blue}{{d}^{2}}\right)} \cdot \left(D \cdot M\right)}
\] |
associate-*r* [=>]27.2 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{\ell}{h} \cdot 4\right) \cdot {d}^{2}}} \cdot \left(D \cdot M\right)}
\] |
unpow2 [=>]27.2 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(\frac{\ell}{h} \cdot 4\right) \cdot \color{blue}{\left(d \cdot d\right)}} \cdot \left(D \cdot M\right)}
\] |
Applied egg-rr25.3
Final simplification9.5
| Alternative 1 | |
|---|---|
| Error | 9.3 |
| Cost | 29452 |
| Alternative 2 | |
|---|---|
| Error | 8.8 |
| Cost | 20804 |
| Alternative 3 | |
|---|---|
| Error | 9.3 |
| Cost | 8264 |
| Alternative 4 | |
|---|---|
| Error | 13.1 |
| Cost | 8141 |
| Alternative 5 | |
|---|---|
| Error | 13.1 |
| Cost | 8141 |
| Alternative 6 | |
|---|---|
| Error | 14.1 |
| Cost | 8008 |
| Alternative 7 | |
|---|---|
| Error | 13.3 |
| Cost | 8008 |
| Alternative 8 | |
|---|---|
| Error | 14.2 |
| Cost | 64 |
herbie shell --seed 2023083
(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))))))