
(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 34 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 (* M_m (* D 0.5)))
(t_1 (sqrt (* h l)))
(t_2 (sqrt (/ d l)))
(t_3 (/ (* M_m D) (* d 2.0)))
(t_4 (+ 1.0 (* (/ (/ t_0 (* d 2.0)) l) (/ t_3 (/ -1.0 h))))))
(if (<= d -1.5e-201)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_2) t_4)
(if (<= d -5e-310)
(/ (* d (fma t_3 (* h (/ t_0 (* 2.0 (* d l)))) 1.0)) t_1)
(if (<= d 3.8e-133)
(/ (/ (fma -0.125 (* D (* D (* h (/ (* M_m M_m) d)))) (* d l)) l) t_1)
(if (<= d 3.4e+122)
(* t_4 (* t_2 (sqrt (/ d h))))
(/
(*
d
(fma
(*
(/ (* (* M_m D) -0.5) (* l (* d 2.0)))
(* M_m (/ D (* d 2.0))))
h
1.0))
t_1)))))))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 = M_m * (D * 0.5);
double t_1 = sqrt((h * l));
double t_2 = sqrt((d / l));
double t_3 = (M_m * D) / (d * 2.0);
double t_4 = 1.0 + (((t_0 / (d * 2.0)) / l) * (t_3 / (-1.0 / h)));
double tmp;
if (d <= -1.5e-201) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_2) * t_4;
} else if (d <= -5e-310) {
tmp = (d * fma(t_3, (h * (t_0 / (2.0 * (d * l)))), 1.0)) / t_1;
} else if (d <= 3.8e-133) {
tmp = (fma(-0.125, (D * (D * (h * ((M_m * M_m) / d)))), (d * l)) / l) / t_1;
} else if (d <= 3.4e+122) {
tmp = t_4 * (t_2 * sqrt((d / h)));
} else {
tmp = (d * fma(((((M_m * D) * -0.5) / (l * (d * 2.0))) * (M_m * (D / (d * 2.0)))), h, 1.0)) / t_1;
}
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(M_m * Float64(D * 0.5)) t_1 = sqrt(Float64(h * l)) t_2 = sqrt(Float64(d / l)) t_3 = Float64(Float64(M_m * D) / Float64(d * 2.0)) t_4 = Float64(1.0 + Float64(Float64(Float64(t_0 / Float64(d * 2.0)) / l) * Float64(t_3 / Float64(-1.0 / h)))) tmp = 0.0 if (d <= -1.5e-201) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_2) * t_4); elseif (d <= -5e-310) tmp = Float64(Float64(d * fma(t_3, Float64(h * Float64(t_0 / Float64(2.0 * Float64(d * l)))), 1.0)) / t_1); elseif (d <= 3.8e-133) tmp = Float64(Float64(fma(-0.125, Float64(D * Float64(D * Float64(h * Float64(Float64(M_m * M_m) / d)))), Float64(d * l)) / l) / t_1); elseif (d <= 3.4e+122) tmp = Float64(t_4 * Float64(t_2 * sqrt(Float64(d / h)))); else tmp = Float64(Float64(d * fma(Float64(Float64(Float64(Float64(M_m * D) * -0.5) / Float64(l * Float64(d * 2.0))) * Float64(M_m * Float64(D / Float64(d * 2.0)))), h, 1.0)) / t_1); 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[(M$95$m * N[(D * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(M$95$m * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 + N[(N[(N[(t$95$0 / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(t$95$3 / N[(-1.0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.5e-201], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$4), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(d * N[(t$95$3 * N[(h * N[(t$95$0 / N[(2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[d, 3.8e-133], N[(N[(N[(-0.125 * N[(D * N[(D * N[(h * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(d * l), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[d, 3.4e+122], N[(t$95$4 * N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(N[(N[(N[(N[(M$95$m * D), $MachinePrecision] * -0.5), $MachinePrecision] / N[(l * N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision] / t$95$1), $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 := M\_m \cdot \left(D \cdot 0.5\right)\\
t_1 := \sqrt{h \cdot \ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
t_3 := \frac{M\_m \cdot D}{d \cdot 2}\\
t_4 := 1 + \frac{\frac{t\_0}{d \cdot 2}}{\ell} \cdot \frac{t\_3}{\frac{-1}{h}}\\
\mathbf{if}\;d \leq -1.5 \cdot 10^{-201}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_2\right) \cdot t\_4\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(t\_3, h \cdot \frac{t\_0}{2 \cdot \left(d \cdot \ell\right)}, 1\right)}{t\_1}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-133}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-0.125, D \cdot \left(D \cdot \left(h \cdot \frac{M\_m \cdot M\_m}{d}\right)\right), d \cdot \ell\right)}{\ell}}{t\_1}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{+122}:\\
\;\;\;\;t\_4 \cdot \left(t\_2 \cdot \sqrt{\frac{d}{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(\frac{\left(M\_m \cdot D\right) \cdot -0.5}{\ell \cdot \left(d \cdot 2\right)} \cdot \left(M\_m \cdot \frac{D}{d \cdot 2}\right), h, 1\right)}{t\_1}\\
\end{array}
\end{array}
if d < -1.50000000000000001e-201Initial program 78.7%
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 rewrites81.0%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6481.0
Applied rewrites81.0%
lift-/.f64N/A
metadata-eval81.0
lift-pow.f64N/A
pow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-neg.f6489.8
Applied rewrites89.8%
if -1.50000000000000001e-201 < d < -4.999999999999985e-310Initial program 21.3%
Applied rewrites0.0%
Applied rewrites0.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites0.3%
Applied rewrites61.3%
if -4.999999999999985e-310 < d < 3.8000000000000003e-133Initial program 37.8%
Applied rewrites11.8%
Applied rewrites37.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites43.3%
Taylor expanded in l around 0
lower-/.f64N/A
lower-fma.f64N/A
associate-/l*N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6461.7
Applied rewrites61.7%
if 3.8000000000000003e-133 < d < 3.4e122Initial program 79.8%
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 rewrites87.3%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6487.3
Applied rewrites87.3%
lift-/.f64N/A
metadata-eval87.3
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6487.3
Applied rewrites87.3%
if 3.4e122 < d Initial program 73.7%
Applied rewrites29.5%
Applied rewrites60.1%
Applied rewrites95.1%
Final simplification83.3%
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
(*
(+
1.0
(* (/ h l) (* (pow (/ (* M_m D) (* d 2.0)) 2.0) (/ -1.0 2.0))))
(* (pow (/ d l) (/ 1.0 2.0)) (pow (/ d h) (/ 1.0 2.0))))))
(if (<= t_0 -1e+247)
(*
(sqrt (/ h (* l (* l l))))
(* -0.125 (/ (* M_m (* M_m (* D D))) (- d))))
(if (<= t_0 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(/
(/ (* (* D D) (* -0.125 (* h (* M_m M_m)))) (* d l))
(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 = (1.0 + ((h / l) * (pow(((M_m * D) / (d * 2.0)), 2.0) * (-1.0 / 2.0)))) * (pow((d / l), (1.0 / 2.0)) * pow((d / h), (1.0 / 2.0)));
double tmp;
if (t_0 <= -1e+247) {
tmp = sqrt((h / (l * (l * l)))) * (-0.125 * ((M_m * (M_m * (D * D))) / -d));
} else if (t_0 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (((D * D) * (-0.125 * (h * (M_m * M_m)))) / (d * l)) / 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 = (1.0 + ((h / l) * (Math.pow(((M_m * D) / (d * 2.0)), 2.0) * (-1.0 / 2.0)))) * (Math.pow((d / l), (1.0 / 2.0)) * Math.pow((d / h), (1.0 / 2.0)));
double tmp;
if (t_0 <= -1e+247) {
tmp = Math.sqrt((h / (l * (l * l)))) * (-0.125 * ((M_m * (M_m * (D * D))) / -d));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = (((D * D) * (-0.125 * (h * (M_m * M_m)))) / (d * l)) / 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 = (1.0 + ((h / l) * (math.pow(((M_m * D) / (d * 2.0)), 2.0) * (-1.0 / 2.0)))) * (math.pow((d / l), (1.0 / 2.0)) * math.pow((d / h), (1.0 / 2.0))) tmp = 0 if t_0 <= -1e+247: tmp = math.sqrt((h / (l * (l * l)))) * (-0.125 * ((M_m * (M_m * (D * D))) / -d)) elif t_0 <= math.inf: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = (((D * D) * (-0.125 * (h * (M_m * M_m)))) / (d * l)) / 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(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(M_m * D) / Float64(d * 2.0)) ^ 2.0) * Float64(-1.0 / 2.0)))) * Float64((Float64(d / l) ^ Float64(1.0 / 2.0)) * (Float64(d / h) ^ Float64(1.0 / 2.0)))) tmp = 0.0 if (t_0 <= -1e+247) tmp = Float64(sqrt(Float64(h / Float64(l * Float64(l * l)))) * Float64(-0.125 * Float64(Float64(M_m * Float64(M_m * Float64(D * D))) / Float64(-d)))); elseif (t_0 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(Float64(D * D) * Float64(-0.125 * Float64(h * Float64(M_m * M_m)))) / Float64(d * l)) / 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 = (1.0 + ((h / l) * ((((M_m * D) / (d * 2.0)) ^ 2.0) * (-1.0 / 2.0)))) * (((d / l) ^ (1.0 / 2.0)) * ((d / h) ^ (1.0 / 2.0)));
tmp = 0.0;
if (t_0 <= -1e+247)
tmp = sqrt((h / (l * (l * l)))) * (-0.125 * ((M_m * (M_m * (D * D))) / -d));
elseif (t_0 <= Inf)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = (((D * D) * (-0.125 * (h * (M_m * M_m)))) / (d * l)) / 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[(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] * N[(N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+247], N[(N[Sqrt[N[(h / N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.125 * N[(N[(M$95$m * N[(M$95$m * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(D * D), $MachinePrecision] * N[(-0.125 * N[(h * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * l), $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(1 + \frac{h}{\ell} \cdot \left({\left(\frac{M\_m \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{-1}{2}\right)\right) \cdot \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+247}:\\
\;\;\;\;\sqrt{\frac{h}{\ell \cdot \left(\ell \cdot \ell\right)}} \cdot \left(-0.125 \cdot \frac{M\_m \cdot \left(M\_m \cdot \left(D \cdot D\right)\right)}{-d}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(D \cdot D\right) \cdot \left(-0.125 \cdot \left(h \cdot \left(M\_m \cdot M\_m\right)\right)\right)}{d \cdot \ell}}{\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)))) < -9.99999999999999952e246Initial program 84.2%
Applied rewrites34.3%
Taylor expanded in h around -inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
unpow2N/A
rem-square-sqrtN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
Applied rewrites37.6%
if -9.99999999999999952e246 < (*.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 80.4%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6439.4
Applied rewrites39.4%
Applied rewrites69.3%
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 rewrites3.2%
Applied rewrites26.1%
Taylor expanded in D around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6419.5
Applied rewrites19.5%
Final simplification51.0%
herbie shell --seed 2024229
(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)))))