(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (pow (/ d l) 0.5))
(t_1
(*
(* (pow (/ d h) 0.5) t_0)
(- 1.0 (* (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)) (/ h l)))))
(t_2
(*
(* t_0 (sqrt (/ d h)))
(-
1.0
(pow (/ (* (* M (* 0.5 (/ D d))) (sqrt 0.5)) (sqrt (/ l h))) 2.0))))
(t_3 (* d (sqrt (/ 1.0 (* h l))))))
(if (<= t_1 -4e-121)
t_2
(if (<= t_1 1e-237) t_3 (if (<= t_1 5e+246) t_2 t_3)))))double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((d / l), 0.5);
double t_1 = (pow((d / h), 0.5) * t_0) * (1.0 - ((0.5 * pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
double t_2 = (t_0 * sqrt((d / h))) * (1.0 - pow((((M * (0.5 * (D / d))) * sqrt(0.5)) / sqrt((l / h))), 2.0));
double t_3 = d * sqrt((1.0 / (h * l)));
double tmp;
if (t_1 <= -4e-121) {
tmp = t_2;
} else if (t_1 <= 1e-237) {
tmp = t_3;
} else if (t_1 <= 5e+246) {
tmp = t_2;
} else {
tmp = t_3;
}
return tmp;
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (d / l) ** 0.5d0
t_1 = (((d / h) ** 0.5d0) * t_0) * (1.0d0 - ((0.5d0 * (((m * d_1) / (d * 2.0d0)) ** 2.0d0)) * (h / l)))
t_2 = (t_0 * sqrt((d / h))) * (1.0d0 - ((((m * (0.5d0 * (d_1 / d))) * sqrt(0.5d0)) / sqrt((l / h))) ** 2.0d0))
t_3 = d * sqrt((1.0d0 / (h * l)))
if (t_1 <= (-4d-121)) then
tmp = t_2
else if (t_1 <= 1d-237) then
tmp = t_3
else if (t_1 <= 5d+246) then
tmp = t_2
else
tmp = t_3
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.pow((d / l), 0.5);
double t_1 = (Math.pow((d / h), 0.5) * t_0) * (1.0 - ((0.5 * Math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l)));
double t_2 = (t_0 * Math.sqrt((d / h))) * (1.0 - Math.pow((((M * (0.5 * (D / d))) * Math.sqrt(0.5)) / Math.sqrt((l / h))), 2.0));
double t_3 = d * Math.sqrt((1.0 / (h * l)));
double tmp;
if (t_1 <= -4e-121) {
tmp = t_2;
} else if (t_1 <= 1e-237) {
tmp = t_3;
} else if (t_1 <= 5e+246) {
tmp = t_2;
} else {
tmp = t_3;
}
return tmp;
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
def code(d, h, l, M, D): t_0 = math.pow((d / l), 0.5) t_1 = (math.pow((d / h), 0.5) * t_0) * (1.0 - ((0.5 * math.pow(((M * D) / (d * 2.0)), 2.0)) * (h / l))) t_2 = (t_0 * math.sqrt((d / h))) * (1.0 - math.pow((((M * (0.5 * (D / d))) * math.sqrt(0.5)) / math.sqrt((l / h))), 2.0)) t_3 = d * math.sqrt((1.0 / (h * l))) tmp = 0 if t_1 <= -4e-121: tmp = t_2 elif t_1 <= 1e-237: tmp = t_3 elif t_1 <= 5e+246: tmp = t_2 else: tmp = t_3 return tmp
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function code(d, h, l, M, D) t_0 = Float64(d / l) ^ 0.5 t_1 = Float64(Float64((Float64(d / h) ^ 0.5) * t_0) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(Float64(t_0 * sqrt(Float64(d / h))) * Float64(1.0 - (Float64(Float64(Float64(M * Float64(0.5 * Float64(D / d))) * sqrt(0.5)) / sqrt(Float64(l / h))) ^ 2.0))) t_3 = Float64(d * sqrt(Float64(1.0 / Float64(h * l)))) tmp = 0.0 if (t_1 <= -4e-121) tmp = t_2; elseif (t_1 <= 1e-237) tmp = t_3; elseif (t_1 <= 5e+246) tmp = t_2; else tmp = t_3; end return tmp end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
function tmp_2 = code(d, h, l, M, D) t_0 = (d / l) ^ 0.5; t_1 = (((d / h) ^ 0.5) * t_0) * (1.0 - ((0.5 * (((M * D) / (d * 2.0)) ^ 2.0)) * (h / l))); t_2 = (t_0 * sqrt((d / h))) * (1.0 - ((((M * (0.5 * (D / d))) * sqrt(0.5)) / sqrt((l / h))) ^ 2.0)); t_3 = d * sqrt((1.0 / (h * l))); tmp = 0.0; if (t_1 <= -4e-121) tmp = t_2; elseif (t_1 <= 1e-237) tmp = t_3; elseif (t_1 <= 5e+246) tmp = t_2; else tmp = t_3; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Power[N[(N[(N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-121], t$95$2, If[LessEqual[t$95$1, 1e-237], t$95$3, If[LessEqual[t$95$1, 5e+246], t$95$2, t$95$3]]]]]]]
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\begin{array}{l}
t_0 := {\left(\frac{d}{\ell}\right)}^{0.5}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot t_0\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \left(t_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - {\left(\frac{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot \sqrt{0.5}}{\sqrt{\frac{\ell}{h}}}\right)}^{2}\right)\\
t_3 := d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-121}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 10^{-237}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+246}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
Results
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < -3.9999999999999999e-121 or 9.9999999999999999e-238 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 4.99999999999999976e246Initial program 8.5
Applied egg-rr9.0
Applied egg-rr7.3
Applied egg-rr7.3
if -3.9999999999999999e-121 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 9.9999999999999999e-238 or 4.99999999999999976e246 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) Initial program 53.2
Taylor expanded in d around inf 41.2
Final simplification20.4
herbie shell --seed 2022192
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))