
(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)))))
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)));
}
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
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)));
}
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)))
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 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
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]
\begin{array}{l}
\\
\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)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 26 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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)))))
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)));
}
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
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)));
}
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)))
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 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
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]
\begin{array}{l}
\\
\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)
\end{array}
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ d h)))
(t_1 (sqrt (- d)))
(t_2 (/ (* M D) (* d 2.0)))
(t_3
(+ 1.0 (* (/ t_2 l) (/ (/ (* (* M D) 0.5) (* d 2.0)) (/ -1.0 h))))))
(if (<= h -4.5e+126)
(*
(* (/ t_1 (sqrt (- h))) (sqrt (/ d l)))
(+ 1.0 (* (/ h l) (* (/ (* (* M D) t_2) (* d 2.0)) (/ -1.0 2.0)))))
(if (<= h -5e-310)
(* (* t_0 (/ t_1 (sqrt (- l)))) t_3)
(if (<= h 2.15e+105)
(* t_3 (* t_0 (/ (sqrt d) (sqrt l))))
(*
(* (/ (sqrt d) (sqrt h)) (pow (/ d l) (/ 1.0 2.0)))
(+ 1.0 (* (/ h l) (* (pow t_2 2.0) (/ -1.0 2.0))))))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt(-d);
double t_2 = (M * D) / (d * 2.0);
double t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h)));
double tmp;
if (h <= -4.5e+126) {
tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0))));
} else if (h <= -5e-310) {
tmp = (t_0 * (t_1 / sqrt(-l))) * t_3;
} else if (h <= 2.15e+105) {
tmp = t_3 * (t_0 * (sqrt(d) / sqrt(l)));
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), (1.0 / 2.0))) * (1.0 + ((h / l) * (pow(t_2, 2.0) * (-1.0 / 2.0))));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sqrt((d / h))
t_1 = sqrt(-d)
t_2 = (m * d_1) / (d * 2.0d0)
t_3 = 1.0d0 + ((t_2 / l) * ((((m * d_1) * 0.5d0) / (d * 2.0d0)) / ((-1.0d0) / h)))
if (h <= (-4.5d+126)) then
tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0d0 + ((h / l) * ((((m * d_1) * t_2) / (d * 2.0d0)) * ((-1.0d0) / 2.0d0))))
else if (h <= (-5d-310)) then
tmp = (t_0 * (t_1 / sqrt(-l))) * t_3
else if (h <= 2.15d+105) then
tmp = t_3 * (t_0 * (sqrt(d) / sqrt(l)))
else
tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 + ((h / l) * ((t_2 ** 2.0d0) * ((-1.0d0) / 2.0d0))))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / h));
double t_1 = Math.sqrt(-d);
double t_2 = (M * D) / (d * 2.0);
double t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h)));
double tmp;
if (h <= -4.5e+126) {
tmp = ((t_1 / Math.sqrt(-h)) * Math.sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0))));
} else if (h <= -5e-310) {
tmp = (t_0 * (t_1 / Math.sqrt(-l))) * t_3;
} else if (h <= 2.15e+105) {
tmp = t_3 * (t_0 * (Math.sqrt(d) / Math.sqrt(l)));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 + ((h / l) * (Math.pow(t_2, 2.0) * (-1.0 / 2.0))));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = math.sqrt((d / h)) t_1 = math.sqrt(-d) t_2 = (M * D) / (d * 2.0) t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h))) tmp = 0 if h <= -4.5e+126: tmp = ((t_1 / math.sqrt(-h)) * math.sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0)))) elif h <= -5e-310: tmp = (t_0 * (t_1 / math.sqrt(-l))) * t_3 elif h <= 2.15e+105: tmp = t_3 * (t_0 * (math.sqrt(d) / math.sqrt(l))) else: tmp = ((math.sqrt(d) / math.sqrt(h)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 + ((h / l) * (math.pow(t_2, 2.0) * (-1.0 / 2.0)))) return tmp
function code(d, h, l, M, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(-d)) t_2 = Float64(Float64(M * D) / Float64(d * 2.0)) t_3 = Float64(1.0 + Float64(Float64(t_2 / l) * Float64(Float64(Float64(Float64(M * D) * 0.5) / Float64(d * 2.0)) / Float64(-1.0 / h)))) tmp = 0.0 if (h <= -4.5e+126) tmp = Float64(Float64(Float64(t_1 / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 + Float64(Float64(h / l) * Float64(Float64(Float64(Float64(M * D) * t_2) / Float64(d * 2.0)) * Float64(-1.0 / 2.0))))); elseif (h <= -5e-310) tmp = Float64(Float64(t_0 * Float64(t_1 / sqrt(Float64(-l)))) * t_3); elseif (h <= 2.15e+105) tmp = Float64(t_3 * Float64(t_0 * Float64(sqrt(d) / sqrt(l)))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 + Float64(Float64(h / l) * Float64((t_2 ^ 2.0) * Float64(-1.0 / 2.0))))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = sqrt((d / h)); t_1 = sqrt(-d); t_2 = (M * D) / (d * 2.0); t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h))); tmp = 0.0; if (h <= -4.5e+126) tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0)))); elseif (h <= -5e-310) tmp = (t_0 * (t_1 / sqrt(-l))) * t_3; elseif (h <= 2.15e+105) tmp = t_3 * (t_0 * (sqrt(d) / sqrt(l))); else tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 + ((h / l) * ((t_2 ^ 2.0) * (-1.0 / 2.0)))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$2 = N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[(N[(t$95$2 / l), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * 0.5), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4.5e+126], N[(N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * t$95$2), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(t$95$0 * N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[h, 2.15e+105], N[(t$95$3 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[t$95$2, 2.0], $MachinePrecision] * N[(-1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{-d}\\
t_2 := \frac{M \cdot D}{d \cdot 2}\\
t_3 := 1 + \frac{t\_2}{\ell} \cdot \frac{\frac{\left(M \cdot D\right) \cdot 0.5}{d \cdot 2}}{\frac{-1}{h}}\\
\mathbf{if}\;h \leq -4.5 \cdot 10^{+126}:\\
\;\;\;\;\left(\frac{t\_1}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 + \frac{h}{\ell} \cdot \left(\frac{\left(M \cdot D\right) \cdot t\_2}{d \cdot 2} \cdot \frac{-1}{2}\right)\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_0 \cdot \frac{t\_1}{\sqrt{-\ell}}\right) \cdot t\_3\\
\mathbf{elif}\;h \leq 2.15 \cdot 10^{+105}:\\
\;\;\;\;t\_3 \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 + \frac{h}{\ell} \cdot \left({t\_2}^{2} \cdot \frac{-1}{2}\right)\right)\\
\end{array}
\end{array}
if h < -4.49999999999999974e126Initial program 52.9%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6474.3
Applied egg-rr74.3%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6474.3
Applied egg-rr74.3%
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6474.4
Applied egg-rr74.4%
if -4.49999999999999974e126 < h < -4.999999999999985e-310Initial program 74.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
div-invN/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
times-fracN/A
Applied egg-rr81.2%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6481.2
Applied egg-rr81.2%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6481.2
Applied egg-rr81.2%
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6489.4
Applied egg-rr89.4%
if -4.999999999999985e-310 < h < 2.1500000000000001e105Initial program 68.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
div-invN/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
times-fracN/A
Applied egg-rr68.2%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6468.2
Applied egg-rr68.2%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6468.2
Applied egg-rr68.2%
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6483.6
Applied egg-rr83.6%
if 2.1500000000000001e105 < h Initial program 58.1%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6473.2
Applied egg-rr73.2%
Final simplification82.2%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ d h)))
(t_1 (sqrt (- d)))
(t_2 (/ (* M D) (* d 2.0)))
(t_3
(+ 1.0 (* (/ t_2 l) (/ (/ (* (* M D) 0.5) (* d 2.0)) (/ -1.0 h))))))
(if (<= h -4.5e+126)
(*
(* (/ t_1 (sqrt (- h))) (sqrt (/ d l)))
(+ 1.0 (* (/ h l) (* (/ (* (* M D) t_2) (* d 2.0)) (/ -1.0 2.0)))))
(if (<= h -5e-310)
(* (* t_0 (/ t_1 (sqrt (- l)))) t_3)
(* t_3 (* t_0 (/ (sqrt d) (sqrt l))))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt(-d);
double t_2 = (M * D) / (d * 2.0);
double t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h)));
double tmp;
if (h <= -4.5e+126) {
tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0))));
} else if (h <= -5e-310) {
tmp = (t_0 * (t_1 / sqrt(-l))) * t_3;
} else {
tmp = t_3 * (t_0 * (sqrt(d) / sqrt(l)));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sqrt((d / h))
t_1 = sqrt(-d)
t_2 = (m * d_1) / (d * 2.0d0)
t_3 = 1.0d0 + ((t_2 / l) * ((((m * d_1) * 0.5d0) / (d * 2.0d0)) / ((-1.0d0) / h)))
if (h <= (-4.5d+126)) then
tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0d0 + ((h / l) * ((((m * d_1) * t_2) / (d * 2.0d0)) * ((-1.0d0) / 2.0d0))))
else if (h <= (-5d-310)) then
tmp = (t_0 * (t_1 / sqrt(-l))) * t_3
else
tmp = t_3 * (t_0 * (sqrt(d) / sqrt(l)))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / h));
double t_1 = Math.sqrt(-d);
double t_2 = (M * D) / (d * 2.0);
double t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h)));
double tmp;
if (h <= -4.5e+126) {
tmp = ((t_1 / Math.sqrt(-h)) * Math.sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0))));
} else if (h <= -5e-310) {
tmp = (t_0 * (t_1 / Math.sqrt(-l))) * t_3;
} else {
tmp = t_3 * (t_0 * (Math.sqrt(d) / Math.sqrt(l)));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = math.sqrt((d / h)) t_1 = math.sqrt(-d) t_2 = (M * D) / (d * 2.0) t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h))) tmp = 0 if h <= -4.5e+126: tmp = ((t_1 / math.sqrt(-h)) * math.sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0)))) elif h <= -5e-310: tmp = (t_0 * (t_1 / math.sqrt(-l))) * t_3 else: tmp = t_3 * (t_0 * (math.sqrt(d) / math.sqrt(l))) return tmp
function code(d, h, l, M, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(-d)) t_2 = Float64(Float64(M * D) / Float64(d * 2.0)) t_3 = Float64(1.0 + Float64(Float64(t_2 / l) * Float64(Float64(Float64(Float64(M * D) * 0.5) / Float64(d * 2.0)) / Float64(-1.0 / h)))) tmp = 0.0 if (h <= -4.5e+126) tmp = Float64(Float64(Float64(t_1 / sqrt(Float64(-h))) * sqrt(Float64(d / l))) * Float64(1.0 + Float64(Float64(h / l) * Float64(Float64(Float64(Float64(M * D) * t_2) / Float64(d * 2.0)) * Float64(-1.0 / 2.0))))); elseif (h <= -5e-310) tmp = Float64(Float64(t_0 * Float64(t_1 / sqrt(Float64(-l)))) * t_3); else tmp = Float64(t_3 * Float64(t_0 * Float64(sqrt(d) / sqrt(l)))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = sqrt((d / h)); t_1 = sqrt(-d); t_2 = (M * D) / (d * 2.0); t_3 = 1.0 + ((t_2 / l) * ((((M * D) * 0.5) / (d * 2.0)) / (-1.0 / h))); tmp = 0.0; if (h <= -4.5e+126) tmp = ((t_1 / sqrt(-h)) * sqrt((d / l))) * (1.0 + ((h / l) * ((((M * D) * t_2) / (d * 2.0)) * (-1.0 / 2.0)))); elseif (h <= -5e-310) tmp = (t_0 * (t_1 / sqrt(-l))) * t_3; else tmp = t_3 * (t_0 * (sqrt(d) / sqrt(l))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$2 = N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[(N[(t$95$2 / l), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * 0.5), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4.5e+126], N[(N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * t$95$2), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(t$95$0 * N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision], N[(t$95$3 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{-d}\\
t_2 := \frac{M \cdot D}{d \cdot 2}\\
t_3 := 1 + \frac{t\_2}{\ell} \cdot \frac{\frac{\left(M \cdot D\right) \cdot 0.5}{d \cdot 2}}{\frac{-1}{h}}\\
\mathbf{if}\;h \leq -4.5 \cdot 10^{+126}:\\
\;\;\;\;\left(\frac{t\_1}{\sqrt{-h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 + \frac{h}{\ell} \cdot \left(\frac{\left(M \cdot D\right) \cdot t\_2}{d \cdot 2} \cdot \frac{-1}{2}\right)\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_0 \cdot \frac{t\_1}{\sqrt{-\ell}}\right) \cdot t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_3 \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right)\\
\end{array}
\end{array}
if h < -4.49999999999999974e126Initial program 54.3%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6467.0
Applied egg-rr67.0%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6467.0
Applied egg-rr67.0%
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6466.4
Applied egg-rr66.4%
if -4.49999999999999974e126 < h < -4.999999999999985e-310Initial program 71.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
div-invN/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
times-fracN/A
Applied egg-rr76.1%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6476.1
Applied egg-rr76.1%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6476.1
Applied egg-rr76.1%
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6484.2
Applied egg-rr84.2%
if -4.999999999999985e-310 < h Initial program 66.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
div-invN/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
times-fracN/A
Applied egg-rr70.7%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6470.7
Applied egg-rr70.7%
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6470.7
Applied egg-rr70.7%
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6478.7
Applied egg-rr78.7%
Final simplification78.8%
herbie shell --seed 2024218
(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)))))