
(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 24 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}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ h l))) (t_1 (/ (* M_m D) (* d 2.0))))
(if (<= d -8.5e-193)
(*
(* (pow (/ d h) (/ 1.0 2.0)) (/ 1.0 (/ (sqrt (- l)) (sqrt (- d)))))
(+ 1.0 (* (/ (/ (* M_m (* D 0.5)) (* d 2.0)) l) (/ t_1 (/ -1.0 h)))))
(if (<= d 1.8e-276)
(/
(/
(fma
-0.125
(* (* D (* (/ h l) t_0)) (* M_m (* M_m D)))
(* t_0 (* d d)))
d)
h)
(*
(* (* (sqrt d) (sqrt (/ 1.0 h))) (/ 1.0 (sqrt (/ l d))))
(+
1.0
(* (/ t_1 (/ 1.0 h)) (* (* (/ (* M_m D) d) 0.25) (/ -1.0 l)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((h / l));
double t_1 = (M_m * D) / (d * 2.0);
double tmp;
if (d <= -8.5e-193) {
tmp = (pow((d / h), (1.0 / 2.0)) * (1.0 / (sqrt(-l) / sqrt(-d)))) * (1.0 + ((((M_m * (D * 0.5)) / (d * 2.0)) / l) * (t_1 / (-1.0 / h))));
} else if (d <= 1.8e-276) {
tmp = (fma(-0.125, ((D * ((h / l) * t_0)) * (M_m * (M_m * D))), (t_0 * (d * d))) / d) / h;
} else {
tmp = ((sqrt(d) * sqrt((1.0 / h))) * (1.0 / sqrt((l / d)))) * (1.0 + ((t_1 / (1.0 / h)) * ((((M_m * D) / d) * 0.25) * (-1.0 / l))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(h / l)) t_1 = Float64(Float64(M_m * D) / Float64(d * 2.0)) tmp = 0.0 if (d <= -8.5e-193) tmp = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * Float64(1.0 / Float64(sqrt(Float64(-l)) / sqrt(Float64(-d))))) * Float64(1.0 + Float64(Float64(Float64(Float64(M_m * Float64(D * 0.5)) / Float64(d * 2.0)) / l) * Float64(t_1 / Float64(-1.0 / h))))); elseif (d <= 1.8e-276) tmp = Float64(Float64(fma(-0.125, Float64(Float64(D * Float64(Float64(h / l) * t_0)) * Float64(M_m * Float64(M_m * D))), Float64(t_0 * Float64(d * d))) / d) / h); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(Float64(1.0 / h))) * Float64(1.0 / sqrt(Float64(l / d)))) * Float64(1.0 + Float64(Float64(t_1 / Float64(1.0 / h)) * Float64(Float64(Float64(Float64(M_m * D) / d) * 0.25) * Float64(-1.0 / l))))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(M$95$m * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.5e-193], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[(-l)], $MachinePrecision] / N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(N[(M$95$m * N[(D * 0.5), $MachinePrecision]), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(t$95$1 / N[(-1.0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e-276], N[(N[(N[(-0.125 * N[(N[(D * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(t$95$1 / N[(1.0 / h), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(M$95$m * D), $MachinePrecision] / d), $MachinePrecision] * 0.25), $MachinePrecision] * N[(-1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := \frac{M\_m \cdot D}{d \cdot 2}\\
\mathbf{if}\;d \leq -8.5 \cdot 10^{-193}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \frac{1}{\frac{\sqrt{-\ell}}{\sqrt{-d}}}\right) \cdot \left(1 + \frac{\frac{M\_m \cdot \left(D \cdot 0.5\right)}{d \cdot 2}}{\ell} \cdot \frac{t\_1}{\frac{-1}{h}}\right)\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{-276}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-0.125, \left(D \cdot \left(\frac{h}{\ell} \cdot t\_0\right)\right) \cdot \left(M\_m \cdot \left(M\_m \cdot D\right)\right), t\_0 \cdot \left(d \cdot d\right)\right)}{d}}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\sqrt{d} \cdot \sqrt{\frac{1}{h}}\right) \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 + \frac{t\_1}{\frac{1}{h}} \cdot \left(\left(\frac{M\_m \cdot D}{d} \cdot 0.25\right) \cdot \frac{-1}{\ell}\right)\right)\\
\end{array}
\end{array}
if d < -8.50000000000000004e-193Initial program 68.3%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
div-invN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites72.1%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6472.4
Applied rewrites72.4%
lift-sqrt.f64N/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.f6487.3
Applied rewrites87.3%
if -8.50000000000000004e-193 < d < 1.79999999999999997e-276Initial program 41.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites21.2%
Taylor expanded in d around 0
Applied rewrites25.4%
Applied rewrites51.9%
Applied rewrites69.5%
if 1.79999999999999997e-276 < d Initial program 62.2%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
div-invN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites68.2%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6468.6
Applied rewrites68.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f6468.6
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f6468.6
Applied rewrites68.6%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
unpow-prod-downN/A
lift-/.f64N/A
inv-powN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f6481.2
Applied rewrites81.2%
Final simplification81.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(+
1.0
(* (/ h l) (* (pow (/ (* M_m D) (* d 2.0)) 2.0) (/ -1.0 2.0)))))))
(if (<= t_0 -5e-160)
(*
(- 1.0 (* h (/ (* (* M_m D) (/ (* (* M_m D) 0.25) d)) (* l (* d 2.0)))))
(sqrt (* d (/ d (* h l)))))
(if (<= t_0 INFINITY)
(/ (* d (sqrt (/ h l))) h)
(/
(*
d
(+
1.0
(/ (* (* h -0.5) (* M_m (* D (* M_m D)))) (* l (* (* d d) 4.0)))))
(sqrt (* h l)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 + ((h / l) * (pow(((M_m * D) / (d * 2.0)), 2.0) * (-1.0 / 2.0))));
double tmp;
if (t_0 <= -5e-160) {
tmp = (1.0 - (h * (((M_m * D) * (((M_m * D) * 0.25) / d)) / (l * (d * 2.0))))) * sqrt((d * (d / (h * l))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (d * sqrt((h / l))) / h;
} else {
tmp = (d * (1.0 + (((h * -0.5) * (M_m * (D * (M_m * D)))) / (l * ((d * d) * 4.0))))) / sqrt((h * l));
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 + ((h / l) * (Math.pow(((M_m * D) / (d * 2.0)), 2.0) * (-1.0 / 2.0))));
double tmp;
if (t_0 <= -5e-160) {
tmp = (1.0 - (h * (((M_m * D) * (((M_m * D) * 0.25) / d)) / (l * (d * 2.0))))) * Math.sqrt((d * (d / (h * l))));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (d * Math.sqrt((h / l))) / h;
} else {
tmp = (d * (1.0 + (((h * -0.5) * (M_m * (D * (M_m * D)))) / (l * ((d * d) * 4.0))))) / Math.sqrt((h * l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 + ((h / l) * (math.pow(((M_m * D) / (d * 2.0)), 2.0) * (-1.0 / 2.0)))) tmp = 0 if t_0 <= -5e-160: tmp = (1.0 - (h * (((M_m * D) * (((M_m * D) * 0.25) / d)) / (l * (d * 2.0))))) * math.sqrt((d * (d / (h * l)))) elif t_0 <= math.inf: tmp = (d * math.sqrt((h / l))) / h else: tmp = (d * (1.0 + (((h * -0.5) * (M_m * (D * (M_m * D)))) / (l * ((d * d) * 4.0))))) / math.sqrt((h * l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m * D) / Float64(d * 2.0)) ^ 2.0) * Float64(-1.0 / 2.0))))) tmp = 0.0 if (t_0 <= -5e-160) tmp = Float64(Float64(1.0 - Float64(h * Float64(Float64(Float64(M_m * D) * Float64(Float64(Float64(M_m * D) * 0.25) / d)) / Float64(l * Float64(d * 2.0))))) * sqrt(Float64(d * Float64(d / Float64(h * l))))); elseif (t_0 <= Inf) tmp = Float64(Float64(d * sqrt(Float64(h / l))) / h); else tmp = Float64(Float64(d * Float64(1.0 + Float64(Float64(Float64(h * -0.5) * Float64(M_m * Float64(D * Float64(M_m * D)))) / Float64(l * Float64(Float64(d * d) * 4.0))))) / sqrt(Float64(h * l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 + ((h / l) * ((((M_m * D) / (d * 2.0)) ^ 2.0) * (-1.0 / 2.0))));
tmp = 0.0;
if (t_0 <= -5e-160)
tmp = (1.0 - (h * (((M_m * D) * (((M_m * D) * 0.25) / d)) / (l * (d * 2.0))))) * sqrt((d * (d / (h * l))));
elseif (t_0 <= Inf)
tmp = (d * sqrt((h / l))) / h;
else
tmp = (d * (1.0 + (((h * -0.5) * (M_m * (D * (M_m * D)))) / (l * ((d * d) * 4.0))))) / sqrt((h * l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = 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[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-160], N[(N[(1.0 - N[(h * N[(N[(N[(M$95$m * D), $MachinePrecision] * N[(N[(N[(M$95$m * D), $MachinePrecision] * 0.25), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d * N[(d / N[(h * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(d * N[(1.0 + N[(N[(N[(h * -0.5), $MachinePrecision] * N[(M$95$m * N[(D * N[(M$95$m * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(N[(d * d), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \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 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{-1}{2}\right)\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-160}:\\
\;\;\;\;\left(1 - h \cdot \frac{\left(M\_m \cdot D\right) \cdot \frac{\left(M\_m \cdot D\right) \cdot 0.25}{d}}{\ell \cdot \left(d \cdot 2\right)}\right) \cdot \sqrt{d \cdot \frac{d}{h \cdot \ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \left(1 + \frac{\left(h \cdot -0.5\right) \cdot \left(M\_m \cdot \left(D \cdot \left(M\_m \cdot D\right)\right)\right)}{\ell \cdot \left(\left(d \cdot d\right) \cdot 4\right)}\right)}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.99999999999999994e-160Initial program 86.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
div-invN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites90.0%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f6489.5
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
Applied rewrites68.2%
if -4.99999999999999994e-160 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 77.3%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites37.8%
Taylor expanded in d around inf
Applied rewrites74.8%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites0.0%
Applied rewrites26.2%
Final simplification63.7%
herbie shell --seed 2024225
(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)))))