Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.7% → 86.2%
Time: 18.7s
Alternatives: 10
Speedup: 1.7×

Specification

?
\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* 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) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
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
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))));
}
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))))
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 tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
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]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 80.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* 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) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
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
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))));
}
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))))
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 tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
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]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}

Alternative 1: 86.2% accurate, 0.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 5 \cdot 10^{-163}:\\ \;\;\;\;w0 \cdot \sqrt[3]{{\left(1 - \frac{h \cdot {\left(\frac{0.5}{d} \cdot \left(M\_m \cdot D\_m\right)\right)}^{2}}{\ell}\right)}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= M_m 5e-163)
   (*
    w0
    (cbrt (pow (- 1.0 (/ (* h (pow (* (/ 0.5 d) (* M_m D_m)) 2.0)) l)) 1.5)))
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* (/ (/ M_m d) (/ 2.0 (* M_m D_m))) (* h (/ (/ D_m d) 2.0))) l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 5e-163) {
		tmp = w0 * cbrt(pow((1.0 - ((h * pow(((0.5 / d) * (M_m * D_m)), 2.0)) / l)), 1.5));
	} else {
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 5e-163) {
		tmp = w0 * Math.cbrt(Math.pow((1.0 - ((h * Math.pow(((0.5 / d) * (M_m * D_m)), 2.0)) / l)), 1.5));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 5e-163)
		tmp = Float64(w0 * cbrt((Float64(1.0 - Float64(Float64(h * (Float64(Float64(0.5 / d) * Float64(M_m * D_m)) ^ 2.0)) / l)) ^ 1.5)));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) / Float64(2.0 / Float64(M_m * D_m))) * Float64(h * Float64(Float64(D_m / d) / 2.0))) / l))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 5e-163], N[(w0 * N[Power[N[Power[N[(1.0 - N[(N[(h * N[Power[N[(N[(0.5 / d), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] / N[(2.0 / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 5 \cdot 10^{-163}:\\
\;\;\;\;w0 \cdot \sqrt[3]{{\left(1 - \frac{h \cdot {\left(\frac{0.5}{d} \cdot \left(M\_m \cdot D\_m\right)\right)}^{2}}{\ell}\right)}^{1.5}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 4.99999999999999977e-163

    1. Initial program 83.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified82.7%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. unpow282.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)\right)} \cdot \frac{h}{\ell}} \]
      2. unpow282.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \frac{h}{\ell}} \]
      3. *-commutative82.7%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. associate-*l/83.3%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. associate-*r/81.5%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      6. times-frac83.3%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      7. associate-*r/90.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}} \]
      8. *-commutative90.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{h \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}}{\ell}} \]
      9. associate-/l*88.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{2}}{\ell}} \]
      10. div-inv88.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}\right)}^{2}}{\ell}} \]
      11. associate-/r*88.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)\right)}^{2}}{\ell}} \]
      12. metadata-eval88.5%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)\right)}^{2}}{\ell}} \]
    5. Applied egg-rr88.5%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}} \]
    6. Step-by-step derivation
      1. add-cbrt-cube87.3%

        \[\leadsto w0 \cdot \color{blue}{\sqrt[3]{\left(\sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}} \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}\right) \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}}} \]
      2. pow1/387.1%

        \[\leadsto w0 \cdot \color{blue}{{\left(\left(\sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}} \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}\right) \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}\right)}^{0.3333333333333333}} \]
    7. Applied egg-rr88.2%

      \[\leadsto w0 \cdot \color{blue}{{\left({\left(1 - h \cdot \frac{{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}\right)}^{1.5}\right)}^{0.3333333333333333}} \]
    8. Step-by-step derivation
      1. unpow1/388.5%

        \[\leadsto w0 \cdot \color{blue}{\sqrt[3]{{\left(1 - h \cdot \frac{{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}\right)}^{1.5}}} \]
      2. associate-*r/89.1%

        \[\leadsto w0 \cdot \sqrt[3]{{\left(1 - \color{blue}{\frac{h \cdot {\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}}\right)}^{1.5}} \]
      3. *-commutative89.1%

        \[\leadsto w0 \cdot \sqrt[3]{{\left(1 - \frac{h \cdot {\left(\color{blue}{\left(D \cdot M\right)} \cdot \frac{0.5}{d}\right)}^{2}}{\ell}\right)}^{1.5}} \]
    9. Simplified89.1%

      \[\leadsto w0 \cdot \color{blue}{\sqrt[3]{{\left(1 - \frac{h \cdot {\left(\left(D \cdot M\right) \cdot \frac{0.5}{d}\right)}^{2}}{\ell}\right)}^{1.5}}} \]

    if 4.99999999999999977e-163 < M

    1. Initial program 71.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified70.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/71.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/71.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac71.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow271.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num71.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr70.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac69.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified69.5%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/75.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr76.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]
    10. Step-by-step derivation
      1. times-frac76.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d \cdot 2}{M \cdot D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
      2. times-frac75.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\color{blue}{\frac{d}{M} \cdot \frac{2}{D}}} \cdot \frac{D}{d \cdot 2}\right) \cdot h}{\ell}} \]
    11. Applied egg-rr75.8%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
    12. Step-by-step derivation
      1. associate-/r*75.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot h}{\ell}} \]
    13. Simplified75.8%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right)} \cdot h}{\ell}} \]
    14. Step-by-step derivation
      1. pow175.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right) \cdot h\right)}^{1}}}{\ell}} \]
      2. associate-*l*79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}}^{1}}{\ell}} \]
      3. frac-times81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{\frac{d \cdot 2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      4. associate-/l*81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{d \cdot \frac{2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      5. associate-/l/81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\color{blue}{\frac{D}{2 \cdot d}} \cdot h\right)\right)}^{1}}{\ell}} \]
      6. *-commutative81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{\color{blue}{d \cdot 2}} \cdot h\right)\right)}^{1}}{\ell}} \]
    15. Applied egg-rr81.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)\right)}^{1}}}{\ell}} \]
    16. Step-by-step derivation
      1. unpow181.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}}{\ell}} \]
      2. associate-/r*79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      3. *-commutative79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{\color{blue}{D \cdot M}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      4. *-commutative79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \color{blue}{\left(h \cdot \frac{D}{d \cdot 2}\right)}}{\ell}} \]
      5. associate-/r*79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right)}{\ell}} \]
    17. Simplified79.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}}{\ell}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 5 \cdot 10^{-163}:\\ \;\;\;\;w0 \cdot \sqrt[3]{{\left(1 - \frac{h \cdot {\left(\frac{0.5}{d} \cdot \left(M \cdot D\right)\right)}^{2}}{\ell}\right)}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.7% accurate, 0.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := 1 - {\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t\_0 \leq 5 \cdot 10^{+201}:\\ \;\;\;\;w0 \cdot \sqrt{t\_0}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (let* ((t_0 (- 1.0 (* (pow (/ (* M_m D_m) (* d 2.0)) 2.0) (/ h l)))))
   (if (<= t_0 5e+201)
     (* w0 (sqrt t_0))
     (*
      w0
      (sqrt
       (-
        1.0
        (/
         (* (/ (/ M_m d) (/ 2.0 (* M_m D_m))) (* h (/ (/ D_m d) 2.0)))
         l)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double t_0 = 1.0 - (pow(((M_m * D_m) / (d * 2.0)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 5e+201) {
		tmp = w0 * sqrt(t_0);
	} else {
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - ((((m_m * d_m) / (d * 2.0d0)) ** 2.0d0) * (h / l))
    if (t_0 <= 5d+201) then
        tmp = w0 * sqrt(t_0)
    else
        tmp = w0 * sqrt((1.0d0 - ((((m_m / d) / (2.0d0 / (m_m * d_m))) * (h * ((d_m / d) / 2.0d0))) / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double t_0 = 1.0 - (Math.pow(((M_m * D_m) / (d * 2.0)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 5e+201) {
		tmp = w0 * Math.sqrt(t_0);
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	t_0 = 1.0 - (math.pow(((M_m * D_m) / (d * 2.0)), 2.0) * (h / l))
	tmp = 0
	if t_0 <= 5e+201:
		tmp = w0 * math.sqrt(t_0)
	else:
		tmp = w0 * math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	t_0 = Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_0 <= 5e+201)
		tmp = Float64(w0 * sqrt(t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) / Float64(2.0 / Float64(M_m * D_m))) * Float64(h * Float64(Float64(D_m / d) / 2.0))) / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	t_0 = 1.0 - ((((M_m * D_m) / (d * 2.0)) ^ 2.0) * (h / l));
	tmp = 0.0;
	if (t_0 <= 5e+201)
		tmp = w0 * sqrt(t_0);
	else
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+201], N[(w0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] / N[(2.0 / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := 1 - {\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+201}:\\
\;\;\;\;w0 \cdot \sqrt{t\_0}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))) < 4.9999999999999995e201

    1. Initial program 99.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing

    if 4.9999999999999995e201 < (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))

    1. Initial program 38.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified38.8%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative38.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/38.9%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/38.9%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac38.9%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow238.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num38.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times38.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative38.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity38.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative38.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac38.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr38.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative38.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac38.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified38.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/57.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times58.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative58.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times58.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative58.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative58.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr58.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]
    10. Step-by-step derivation
      1. times-frac57.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d \cdot 2}{M \cdot D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
      2. times-frac57.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\color{blue}{\frac{d}{M} \cdot \frac{2}{D}}} \cdot \frac{D}{d \cdot 2}\right) \cdot h}{\ell}} \]
    11. Applied egg-rr57.4%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
    12. Step-by-step derivation
      1. associate-/r*57.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot h}{\ell}} \]
    13. Simplified57.4%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right)} \cdot h}{\ell}} \]
    14. Step-by-step derivation
      1. pow157.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right) \cdot h\right)}^{1}}}{\ell}} \]
      2. associate-*l*62.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}}^{1}}{\ell}} \]
      3. frac-times63.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{\frac{d \cdot 2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      4. associate-/l*63.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{d \cdot \frac{2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      5. associate-/l/63.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\color{blue}{\frac{D}{2 \cdot d}} \cdot h\right)\right)}^{1}}{\ell}} \]
      6. *-commutative63.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{\color{blue}{d \cdot 2}} \cdot h\right)\right)}^{1}}{\ell}} \]
    15. Applied egg-rr63.9%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)\right)}^{1}}}{\ell}} \]
    16. Step-by-step derivation
      1. unpow163.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}}{\ell}} \]
      2. associate-/r*62.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      3. *-commutative62.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{\color{blue}{D \cdot M}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      4. *-commutative62.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \color{blue}{\left(h \cdot \frac{D}{d \cdot 2}\right)}}{\ell}} \]
      5. associate-/r*62.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right)}{\ell}} \]
    17. Simplified62.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}}{\ell}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+201}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.8% accurate, 1.6× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\\ \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right) \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot \left(M\_m \cdot D\_m\right)\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-310}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(t\_0 \cdot t\_0\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (let* ((t_0 (* M_m (* D_m (/ 0.5 d)))))
   (if (<= (/ h l) (- INFINITY))
     (*
      w0
      (sqrt
       (-
        1.0
        (* (* M_m (/ h (* d (* 2.0 l)))) (* (/ (/ D_m d) 2.0) (* M_m D_m))))))
     (if (<= (/ h l) -2e-310)
       (* w0 (sqrt (- 1.0 (* (/ h l) (* t_0 t_0)))))
       w0))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double t_0 = M_m * (D_m * (0.5 / d));
	double tmp;
	if ((h / l) <= -((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))));
	} else if ((h / l) <= -2e-310) {
		tmp = w0 * sqrt((1.0 - ((h / l) * (t_0 * t_0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double t_0 = M_m * (D_m * (0.5 / d));
	double tmp;
	if ((h / l) <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))));
	} else if ((h / l) <= -2e-310) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * (t_0 * t_0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	t_0 = M_m * (D_m * (0.5 / d))
	tmp = 0
	if (h / l) <= -math.inf:
		tmp = w0 * math.sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))))
	elif (h / l) <= -2e-310:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * (t_0 * t_0))))
	else:
		tmp = w0
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	t_0 = Float64(M_m * Float64(D_m * Float64(0.5 / d)))
	tmp = 0.0
	if (Float64(h / l) <= Float64(-Inf))
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m * Float64(h / Float64(d * Float64(2.0 * l)))) * Float64(Float64(Float64(D_m / d) / 2.0) * Float64(M_m * D_m))))));
	elseif (Float64(h / l) <= -2e-310)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(t_0 * t_0)))));
	else
		tmp = w0;
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	t_0 = M_m * (D_m * (0.5 / d));
	tmp = 0.0;
	if ((h / l) <= -Inf)
		tmp = w0 * sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))));
	elseif ((h / l) <= -2e-310)
		tmp = w0 * sqrt((1.0 - ((h / l) * (t_0 * t_0))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], (-Infinity)], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m * N[(h / N[(d * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -2e-310], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\\
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right) \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot \left(M\_m \cdot D\_m\right)\right)}\\

\mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-310}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(t\_0 \cdot t\_0\right)}\\

\mathbf{else}:\\
\;\;\;\;w0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 h l) < -inf.0

    1. Initial program 28.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified28.7%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative28.7%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/28.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/28.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac28.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow228.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr28.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative28.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac28.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified28.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. pow1/228.7%

        \[\leadsto w0 \cdot \color{blue}{{\left(1 - \left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot \frac{h}{\ell}\right)}^{0.5}} \]
      2. associate-*l*28.7%

        \[\leadsto w0 \cdot {\left(1 - \color{blue}{\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)}\right)}^{0.5} \]
      3. frac-times28.9%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      4. *-commutative28.9%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      5. *-commutative28.9%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{\color{blue}{d \cdot 2}} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
    9. Applied egg-rr28.9%

      \[\leadsto w0 \cdot \color{blue}{{\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)\right)}^{0.5}} \]
    10. Step-by-step derivation
      1. *-un-lft-identity28.9%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot {\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)\right)}^{0.5}\right)} \]
      2. unpow1/228.9%

        \[\leadsto w0 \cdot \left(1 \cdot \color{blue}{\sqrt{1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}}\right) \]
      3. associate-/r/28.9%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right)} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}\right) \]
      4. *-commutative28.9%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right) \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}}\right) \]
    11. Applied egg-rr28.9%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}\right)} \]
    12. Step-by-step derivation
      1. *-lft-identity28.9%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}} \]
      2. *-commutative28.9%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(M \cdot D\right) \cdot \frac{D}{d \cdot 2}\right)} \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)} \]
      3. *-commutative28.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\color{blue}{\left(D \cdot M\right)} \cdot \frac{D}{d \cdot 2}\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)} \]
      4. associate-/r*28.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)} \]
      5. *-commutative28.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \color{blue}{\left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}} \]
      6. times-frac73.0%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \color{blue}{\frac{M \cdot h}{\left(d \cdot 2\right) \cdot \ell}}} \]
      7. associate-/l*67.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \color{blue}{\left(M \cdot \frac{h}{\left(d \cdot 2\right) \cdot \ell}\right)}} \]
      8. associate-*l*67.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \left(M \cdot \frac{h}{\color{blue}{d \cdot \left(2 \cdot \ell\right)}}\right)} \]
    13. Simplified67.4%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \left(M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right)}} \]

    if -inf.0 < (/.f64 h l) < -1.999999999999994e-310

    1. Initial program 81.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified80.2%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. metadata-eval80.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{\color{blue}{\left(1 + 1\right)}} \cdot \frac{h}{\ell}} \]
      2. *-commutative80.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{\left(1 + 1\right)} \cdot \frac{h}{\ell}} \]
      3. associate-*l/81.0%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{\left(1 + 1\right)} \cdot \frac{h}{\ell}} \]
      4. associate-*r/79.6%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{\left(1 + 1\right)} \cdot \frac{h}{\ell}} \]
      5. times-frac81.0%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{\left(1 + 1\right)} \cdot \frac{h}{\ell}} \]
      6. pow-prod-up81.0%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1}\right)} \cdot \frac{h}{\ell}} \]
      7. associate-/l*79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left({\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1}\right) \cdot \frac{h}{\ell}} \]
      8. pow179.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1}\right) \cdot \frac{h}{\ell}} \]
      9. div-inv79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}\right) \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1}\right) \cdot \frac{h}{\ell}} \]
      10. associate-/r*79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)\right) \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1}\right) \cdot \frac{h}{\ell}} \]
      11. metadata-eval79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)\right) \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{1}\right) \cdot \frac{h}{\ell}} \]
      12. associate-/l*79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot {\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}}^{1}\right) \cdot \frac{h}{\ell}} \]
      13. pow179.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}} \]
      14. div-inv79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot \color{blue}{\left(D \cdot \frac{1}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}} \]
      15. associate-/r*79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot \left(D \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)\right)\right) \cdot \frac{h}{\ell}} \]
      16. metadata-eval79.6%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot \left(D \cdot \frac{\color{blue}{0.5}}{d}\right)\right)\right) \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr79.6%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)\right)} \cdot \frac{h}{\ell}} \]

    if -1.999999999999994e-310 < (/.f64 h l)

    1. Initial program 84.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified83.3%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 93.6%

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification84.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right) \cdot \left(\frac{\frac{D}{d}}{2} \cdot \left(M \cdot D\right)\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-310}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.0% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-132}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right) \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot \left(M\_m \cdot D\_m\right)\right)}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 2e-132)
   w0
   (*
    w0
    (sqrt
     (-
      1.0
      (* (* M_m (/ h (* d (* 2.0 l)))) (* (/ (/ D_m d) 2.0) (* M_m D_m))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 2e-132) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 2d-132) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 - ((m_m * (h / (d * (2.0d0 * l)))) * (((d_m / d) / 2.0d0) * (m_m * d_m)))))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 2e-132) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 2e-132:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 2e-132)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m * Float64(h / Float64(d * Float64(2.0 * l)))) * Float64(Float64(Float64(D_m / d) / 2.0) * Float64(M_m * D_m))))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 2e-132)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 - ((M_m * (h / (d * (2.0 * l)))) * (((D_m / d) / 2.0) * (M_m * D_m)))));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-132], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m * N[(h / N[(d * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-132}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right) \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot \left(M\_m \cdot D\_m\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 2e-132

    1. Initial program 83.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified82.1%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 72.5%

      \[\leadsto \color{blue}{w0} \]

    if 2e-132 < (*.f64 M D)

    1. Initial program 67.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified67.1%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative67.1%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/67.1%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/65.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac67.1%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow267.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num67.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times67.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative67.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity67.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative67.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac65.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr65.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative65.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac63.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified63.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. pow1/263.2%

        \[\leadsto w0 \cdot \color{blue}{{\left(1 - \left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot \frac{h}{\ell}\right)}^{0.5}} \]
      2. associate-*l*64.3%

        \[\leadsto w0 \cdot {\left(1 - \color{blue}{\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)}\right)}^{0.5} \]
      3. frac-times64.4%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      4. *-commutative64.4%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      5. *-commutative64.4%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{\color{blue}{d \cdot 2}} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
    9. Applied egg-rr64.4%

      \[\leadsto w0 \cdot \color{blue}{{\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)\right)}^{0.5}} \]
    10. Step-by-step derivation
      1. *-un-lft-identity64.4%

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot {\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)\right)}^{0.5}\right)} \]
      2. unpow1/264.4%

        \[\leadsto w0 \cdot \left(1 \cdot \color{blue}{\sqrt{1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}}\right) \]
      3. associate-/r/64.4%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right)} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}\right) \]
      4. *-commutative64.4%

        \[\leadsto w0 \cdot \left(1 \cdot \sqrt{1 - \left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right) \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}}\right) \]
    11. Applied egg-rr64.4%

      \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - \left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}\right)} \]
    12. Step-by-step derivation
      1. *-lft-identity64.4%

        \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \left(\frac{D}{d \cdot 2} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}} \]
      2. *-commutative64.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\left(M \cdot D\right) \cdot \frac{D}{d \cdot 2}\right)} \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)} \]
      3. *-commutative64.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\color{blue}{\left(D \cdot M\right)} \cdot \frac{D}{d \cdot 2}\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)} \]
      4. associate-/r*64.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)} \]
      5. *-commutative64.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \color{blue}{\left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}} \]
      6. times-frac72.7%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \color{blue}{\frac{M \cdot h}{\left(d \cdot 2\right) \cdot \ell}}} \]
      7. associate-/l*71.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \color{blue}{\left(M \cdot \frac{h}{\left(d \cdot 2\right) \cdot \ell}\right)}} \]
      8. associate-*l*71.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \left(M \cdot \frac{h}{\color{blue}{d \cdot \left(2 \cdot \ell\right)}}\right)} \]
    13. Simplified71.2%

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 - \left(\left(D \cdot M\right) \cdot \frac{\frac{D}{d}}{2}\right) \cdot \left(M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{-132}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}\right) \cdot \left(\frac{\frac{D}{d}}{2} \cdot \left(M \cdot D\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.8% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;D\_m \leq 2 \cdot 10^{+72}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left(1 - D\_m \cdot \frac{M\_m \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{2 \cdot \frac{d}{M\_m \cdot D\_m}}\right)}^{0.5}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= D_m 2e+72)
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* (/ (/ M_m d) (/ 2.0 (* M_m D_m))) (* h (/ (/ D_m d) 2.0))) l))))
   (*
    w0
    (pow
     (-
      1.0
      (* D_m (/ (* M_m (/ h (* d (* 2.0 l)))) (* 2.0 (/ d (* M_m D_m))))))
     0.5))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (D_m <= 2e+72) {
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	} else {
		tmp = w0 * pow((1.0 - (D_m * ((M_m * (h / (d * (2.0 * l)))) / (2.0 * (d / (M_m * D_m)))))), 0.5);
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if (d_m <= 2d+72) then
        tmp = w0 * sqrt((1.0d0 - ((((m_m / d) / (2.0d0 / (m_m * d_m))) * (h * ((d_m / d) / 2.0d0))) / l)))
    else
        tmp = w0 * ((1.0d0 - (d_m * ((m_m * (h / (d * (2.0d0 * l)))) / (2.0d0 * (d / (m_m * d_m)))))) ** 0.5d0)
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (D_m <= 2e+72) {
		tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	} else {
		tmp = w0 * Math.pow((1.0 - (D_m * ((M_m * (h / (d * (2.0 * l)))) / (2.0 * (d / (M_m * D_m)))))), 0.5);
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if D_m <= 2e+72:
		tmp = w0 * math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)))
	else:
		tmp = w0 * math.pow((1.0 - (D_m * ((M_m * (h / (d * (2.0 * l)))) / (2.0 * (d / (M_m * D_m)))))), 0.5)
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (D_m <= 2e+72)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) / Float64(2.0 / Float64(M_m * D_m))) * Float64(h * Float64(Float64(D_m / d) / 2.0))) / l))));
	else
		tmp = Float64(w0 * (Float64(1.0 - Float64(D_m * Float64(Float64(M_m * Float64(h / Float64(d * Float64(2.0 * l)))) / Float64(2.0 * Float64(d / Float64(M_m * D_m)))))) ^ 0.5));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (D_m <= 2e+72)
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	else
		tmp = w0 * ((1.0 - (D_m * ((M_m * (h / (d * (2.0 * l)))) / (2.0 * (d / (M_m * D_m)))))) ^ 0.5);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[D$95$m, 2e+72], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] / N[(2.0 / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[(1.0 - N[(D$95$m * N[(N[(M$95$m * N[(h / N[(d * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(d / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 2 \cdot 10^{+72}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot {\left(1 - D\_m \cdot \frac{M\_m \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{2 \cdot \frac{d}{M\_m \cdot D\_m}}\right)}^{0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.99999999999999989e72

    1. Initial program 82.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified81.2%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative81.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/82.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/81.3%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac82.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow282.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num82.2%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times81.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative81.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity81.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative81.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac80.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr80.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative80.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac80.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified80.3%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/87.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times87.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative87.1%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times88.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative88.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative88.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr88.0%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]
    10. Step-by-step derivation
      1. times-frac87.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d \cdot 2}{M \cdot D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
      2. times-frac86.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\color{blue}{\frac{d}{M} \cdot \frac{2}{D}}} \cdot \frac{D}{d \cdot 2}\right) \cdot h}{\ell}} \]
    11. Applied egg-rr86.4%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
    12. Step-by-step derivation
      1. associate-/r*86.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot h}{\ell}} \]
    13. Simplified86.4%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right)} \cdot h}{\ell}} \]
    14. Step-by-step derivation
      1. pow186.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right) \cdot h\right)}^{1}}}{\ell}} \]
      2. associate-*l*87.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}}^{1}}{\ell}} \]
      3. frac-times88.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{\frac{d \cdot 2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      4. associate-/l*88.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{d \cdot \frac{2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      5. associate-/l/88.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\color{blue}{\frac{D}{2 \cdot d}} \cdot h\right)\right)}^{1}}{\ell}} \]
      6. *-commutative88.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{\color{blue}{d \cdot 2}} \cdot h\right)\right)}^{1}}{\ell}} \]
    15. Applied egg-rr88.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)\right)}^{1}}}{\ell}} \]
    16. Step-by-step derivation
      1. unpow188.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}}{\ell}} \]
      2. associate-/r*87.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      3. *-commutative87.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{\color{blue}{D \cdot M}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      4. *-commutative87.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \color{blue}{\left(h \cdot \frac{D}{d \cdot 2}\right)}}{\ell}} \]
      5. associate-/r*87.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right)}{\ell}} \]
    17. Simplified87.3%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}}{\ell}} \]

    if 1.99999999999999989e72 < D

    1. Initial program 64.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified64.8%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative64.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/64.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/63.0%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac64.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow264.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num64.9%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times63.0%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative63.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity63.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative63.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac63.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr63.0%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative63.0%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac59.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified59.1%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. pow1/259.3%

        \[\leadsto w0 \cdot \color{blue}{{\left(1 - \left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot \frac{h}{\ell}\right)}^{0.5}} \]
      2. associate-*l*60.9%

        \[\leadsto w0 \cdot {\left(1 - \color{blue}{\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)}\right)}^{0.5} \]
      3. frac-times62.8%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      4. *-commutative62.8%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D}} \cdot \left(\frac{M}{2 \cdot d} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      5. *-commutative62.8%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{\color{blue}{d \cdot 2}} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
    9. Applied egg-rr62.8%

      \[\leadsto w0 \cdot \color{blue}{{\left(1 - \frac{D}{\frac{d \cdot 2}{M \cdot D}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)\right)}^{0.5}} \]
    10. Step-by-step derivation
      1. frac-times62.8%

        \[\leadsto w0 \cdot {\left(1 - \frac{D}{\color{blue}{\frac{d}{M} \cdot \frac{2}{D}}} \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)\right)}^{0.5} \]
      2. associate-*l/69.9%

        \[\leadsto w0 \cdot {\left(1 - \color{blue}{\frac{D \cdot \left(\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}\right)}{\frac{d}{M} \cdot \frac{2}{D}}}\right)}^{0.5} \]
      3. *-commutative69.9%

        \[\leadsto w0 \cdot {\left(1 - \frac{D \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}}{\frac{d}{M} \cdot \frac{2}{D}}\right)}^{0.5} \]
      4. frac-times68.6%

        \[\leadsto w0 \cdot {\left(1 - \frac{D \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}{\color{blue}{\frac{d \cdot 2}{M \cdot D}}}\right)}^{0.5} \]
      5. associate-/l*68.6%

        \[\leadsto w0 \cdot {\left(1 - \frac{D \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}{\color{blue}{d \cdot \frac{2}{M \cdot D}}}\right)}^{0.5} \]
    11. Applied egg-rr68.6%

      \[\leadsto w0 \cdot {\left(1 - \color{blue}{\frac{D \cdot \left(\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}\right)}{d \cdot \frac{2}{M \cdot D}}}\right)}^{0.5} \]
    12. Step-by-step derivation
      1. associate-/l*68.6%

        \[\leadsto w0 \cdot {\left(1 - \color{blue}{D \cdot \frac{\frac{h}{\ell} \cdot \frac{M}{d \cdot 2}}{d \cdot \frac{2}{M \cdot D}}}\right)}^{0.5} \]
      2. *-commutative68.6%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{\color{blue}{\frac{M}{d \cdot 2} \cdot \frac{h}{\ell}}}{d \cdot \frac{2}{M \cdot D}}\right)}^{0.5} \]
      3. times-frac74.4%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{\color{blue}{\frac{M \cdot h}{\left(d \cdot 2\right) \cdot \ell}}}{d \cdot \frac{2}{M \cdot D}}\right)}^{0.5} \]
      4. associate-/l*74.1%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{\color{blue}{M \cdot \frac{h}{\left(d \cdot 2\right) \cdot \ell}}}{d \cdot \frac{2}{M \cdot D}}\right)}^{0.5} \]
      5. associate-*l*74.1%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{M \cdot \frac{h}{\color{blue}{d \cdot \left(2 \cdot \ell\right)}}}{d \cdot \frac{2}{M \cdot D}}\right)}^{0.5} \]
      6. associate-*r/74.1%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{\color{blue}{\frac{d \cdot 2}{M \cdot D}}}\right)}^{0.5} \]
      7. *-commutative74.1%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{\frac{\color{blue}{2 \cdot d}}{M \cdot D}}\right)}^{0.5} \]
      8. *-commutative74.1%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{\frac{2 \cdot d}{\color{blue}{D \cdot M}}}\right)}^{0.5} \]
      9. associate-*r/74.1%

        \[\leadsto w0 \cdot {\left(1 - D \cdot \frac{M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{\color{blue}{2 \cdot \frac{d}{D \cdot M}}}\right)}^{0.5} \]
    13. Simplified74.1%

      \[\leadsto w0 \cdot {\left(1 - \color{blue}{D \cdot \frac{M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{2 \cdot \frac{d}{D \cdot M}}}\right)}^{0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 2 \cdot 10^{+72}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left(1 - D \cdot \frac{M \cdot \frac{h}{d \cdot \left(2 \cdot \ell\right)}}{2 \cdot \frac{d}{M \cdot D}}\right)}^{0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.0% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 4 \cdot 10^{-163}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{M\_m \cdot D\_m}{\left(d \cdot 2\right) \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= M_m 4e-163)
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* h (/ (* M_m D_m) (* (* d 2.0) (/ (* d 2.0) (* M_m D_m))))) l))))
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* (/ (/ M_m d) (/ 2.0 (* M_m D_m))) (* h (/ (/ D_m d) 2.0))) l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 4e-163) {
		tmp = w0 * sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)));
	} else {
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if (m_m <= 4d-163) then
        tmp = w0 * sqrt((1.0d0 - ((h * ((m_m * d_m) / ((d * 2.0d0) * ((d * 2.0d0) / (m_m * d_m))))) / l)))
    else
        tmp = w0 * sqrt((1.0d0 - ((((m_m / d) / (2.0d0 / (m_m * d_m))) * (h * ((d_m / d) / 2.0d0))) / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (M_m <= 4e-163) {
		tmp = w0 * Math.sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if M_m <= 4e-163:
		tmp = w0 * math.sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)))
	else:
		tmp = w0 * math.sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (M_m <= 4e-163)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(Float64(M_m * D_m) / Float64(Float64(d * 2.0) * Float64(Float64(d * 2.0) / Float64(M_m * D_m))))) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) / Float64(2.0 / Float64(M_m * D_m))) * Float64(h * Float64(Float64(D_m / d) / 2.0))) / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (M_m <= 4e-163)
		tmp = w0 * sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)));
	else
		tmp = w0 * sqrt((1.0 - ((((M_m / d) / (2.0 / (M_m * D_m))) * (h * ((D_m / d) / 2.0))) / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 4e-163], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(N[(d * 2.0), $MachinePrecision] * N[(N[(d * 2.0), $MachinePrecision] / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] / N[(2.0 / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 4 \cdot 10^{-163}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{M\_m \cdot D\_m}{\left(d \cdot 2\right) \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M\_m}{d}}{\frac{2}{M\_m \cdot D\_m}} \cdot \left(h \cdot \frac{\frac{D\_m}{d}}{2}\right)}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 3.99999999999999969e-163

    1. Initial program 83.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified82.7%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative82.7%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/83.3%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/81.5%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac83.3%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow283.3%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num83.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times81.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative81.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity81.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative81.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac80.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr80.6%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative80.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac80.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified80.2%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/86.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times87.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative87.6%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times88.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative88.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative88.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr88.8%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]

    if 3.99999999999999969e-163 < M

    1. Initial program 71.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified70.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/71.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/71.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac71.4%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow271.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num71.4%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr70.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative70.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac69.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified69.5%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/75.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr76.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]
    10. Step-by-step derivation
      1. times-frac76.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d \cdot 2}{M \cdot D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
      2. times-frac75.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\color{blue}{\frac{d}{M} \cdot \frac{2}{D}}} \cdot \frac{D}{d \cdot 2}\right) \cdot h}{\ell}} \]
    11. Applied egg-rr75.8%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
    12. Step-by-step derivation
      1. associate-/r*75.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot h}{\ell}} \]
    13. Simplified75.8%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right)} \cdot h}{\ell}} \]
    14. Step-by-step derivation
      1. pow175.8%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right) \cdot h\right)}^{1}}}{\ell}} \]
      2. associate-*l*79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}}^{1}}{\ell}} \]
      3. frac-times81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{\frac{d \cdot 2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      4. associate-/l*81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{\color{blue}{d \cdot \frac{2}{M \cdot D}}} \cdot \left(\frac{\frac{D}{d}}{2} \cdot h\right)\right)}^{1}}{\ell}} \]
      5. associate-/l/81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\color{blue}{\frac{D}{2 \cdot d}} \cdot h\right)\right)}^{1}}{\ell}} \]
      6. *-commutative81.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{\color{blue}{d \cdot 2}} \cdot h\right)\right)}^{1}}{\ell}} \]
    15. Applied egg-rr81.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{{\left(\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)\right)}^{1}}}{\ell}} \]
    16. Step-by-step derivation
      1. unpow181.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{M}{d \cdot \frac{2}{M \cdot D}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}}{\ell}} \]
      2. associate-/r*79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      3. *-commutative79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{\color{blue}{D \cdot M}}} \cdot \left(\frac{D}{d \cdot 2} \cdot h\right)}{\ell}} \]
      4. *-commutative79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \color{blue}{\left(h \cdot \frac{D}{d \cdot 2}\right)}}{\ell}} \]
      5. associate-/r*79.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right)}{\ell}} \]
    17. Simplified79.7%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{\frac{M}{d}}{\frac{2}{D \cdot M}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}}{\ell}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 4 \cdot 10^{-163}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{M \cdot D}{\left(d \cdot 2\right) \cdot \frac{d \cdot 2}{M \cdot D}}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{M}{d}}{\frac{2}{M \cdot D}} \cdot \left(h \cdot \frac{\frac{D}{d}}{2}\right)}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.8% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+223}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{M\_m \cdot D\_m}{\left(d \cdot 2\right) \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= l -4e+223)
   w0
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* h (/ (* M_m D_m) (* (* d 2.0) (/ (* d 2.0) (* M_m D_m))))) l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (l <= -4e+223) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if (l <= (-4d+223)) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 - ((h * ((m_m * d_m) / ((d * 2.0d0) * ((d * 2.0d0) / (m_m * d_m))))) / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (l <= -4e+223) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if l <= -4e+223:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (l <= -4e+223)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(Float64(M_m * D_m) / Float64(Float64(d * 2.0) * Float64(Float64(d * 2.0) / Float64(M_m * D_m))))) / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (l <= -4e+223)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 - ((h * ((M_m * D_m) / ((d * 2.0) * ((d * 2.0) / (M_m * D_m))))) / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[l, -4e+223], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(N[(d * 2.0), $MachinePrecision] * N[(N[(d * 2.0), $MachinePrecision] / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4 \cdot 10^{+223}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{M\_m \cdot D\_m}{\left(d \cdot 2\right) \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.00000000000000019e223

    1. Initial program 74.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified70.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 88.2%

      \[\leadsto \color{blue}{w0} \]

    if -4.00000000000000019e223 < l

    1. Initial program 79.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified78.8%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative78.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/79.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/78.0%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac79.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow279.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac77.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr77.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative77.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified76.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/83.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr85.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4 \cdot 10^{+223}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \frac{M \cdot D}{\left(d \cdot 2\right) \cdot \frac{d \cdot 2}{M \cdot D}}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 85.0% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+232}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot \frac{M\_m}{\frac{d}{M\_m} \cdot \frac{2}{D\_m}}\right)}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= l -3.2e+232)
   w0
   (*
    w0
    (sqrt
     (-
      1.0
      (/ (* h (* (/ (/ D_m d) 2.0) (/ M_m (* (/ d M_m) (/ 2.0 D_m))))) l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (l <= -3.2e+232) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((h * (((D_m / d) / 2.0) * (M_m / ((d / M_m) * (2.0 / D_m))))) / l)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if (l <= (-3.2d+232)) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 - ((h * (((d_m / d) / 2.0d0) * (m_m / ((d / m_m) * (2.0d0 / d_m))))) / l)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if (l <= -3.2e+232) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((h * (((D_m / d) / 2.0) * (M_m / ((d / M_m) * (2.0 / D_m))))) / l)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if l <= -3.2e+232:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 - ((h * (((D_m / d) / 2.0) * (M_m / ((d / M_m) * (2.0 / D_m))))) / l)))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (l <= -3.2e+232)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(Float64(Float64(D_m / d) / 2.0) * Float64(M_m / Float64(Float64(d / M_m) * Float64(2.0 / D_m))))) / l))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if (l <= -3.2e+232)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 - ((h * (((D_m / d) / 2.0) * (M_m / ((d / M_m) * (2.0 / D_m))))) / l)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[l, -3.2e+232], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * N[(M$95$m / N[(N[(d / M$95$m), $MachinePrecision] * N[(2.0 / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+232}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot \frac{M\_m}{\frac{d}{M\_m} \cdot \frac{2}{D\_m}}\right)}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -3.2000000000000002e232

    1. Initial program 74.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified70.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 88.2%

      \[\leadsto \color{blue}{w0} \]

    if -3.2000000000000002e232 < l

    1. Initial program 79.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified78.8%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative78.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2}}{d} \cdot D\right)}}^{2} \cdot \frac{h}{\ell}} \]
      2. associate-*l/79.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{\frac{M}{2} \cdot D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      3. associate-*r/78.0%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      4. times-frac79.2%

        \[\leadsto w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}} \]
      5. unpow279.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
      6. clear-num79.3%

        \[\leadsto w0 \cdot \sqrt{1 - \left(\frac{M \cdot D}{2 \cdot d} \cdot \color{blue}{\frac{1}{\frac{2 \cdot d}{M \cdot D}}}\right) \cdot \frac{h}{\ell}} \]
      7. frac-times78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot D\right) \cdot 1}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. *-commutative78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1 \cdot \left(M \cdot D\right)}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. *-un-lft-identity78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{M \cdot D}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      10. *-commutative78.2%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot M}}{\left(2 \cdot d\right) \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      11. times-frac77.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\left(2 \cdot d\right) \cdot \color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    5. Applied egg-rr77.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot M}{\left(2 \cdot d\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Step-by-step derivation
      1. *-commutative77.4%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{D \cdot M}{\color{blue}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot \frac{h}{\ell}} \]
      2. times-frac76.7%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    7. Simplified76.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right)} \cdot \frac{h}{\ell}} \]
    8. Step-by-step derivation
      1. associate-*r/83.8%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\frac{D}{\frac{2}{M} \cdot \frac{d}{D}} \cdot \frac{M}{2 \cdot d}\right) \cdot h}{\ell}}} \]
      2. frac-times84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot M}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)}} \cdot h}{\ell}} \]
      3. *-commutative84.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot D}}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      4. frac-times85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\color{blue}{\frac{2 \cdot d}{M \cdot D}} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      5. *-commutative85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{\color{blue}{d \cdot 2}}{M \cdot D} \cdot \left(2 \cdot d\right)} \cdot h}{\ell}} \]
      6. *-commutative85.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \color{blue}{\left(d \cdot 2\right)}} \cdot h}{\ell}} \]
    9. Applied egg-rr85.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{M \cdot D}{\frac{d \cdot 2}{M \cdot D} \cdot \left(d \cdot 2\right)} \cdot h}{\ell}}} \]
    10. Step-by-step derivation
      1. times-frac84.3%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d \cdot 2}{M \cdot D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
      2. times-frac83.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\color{blue}{\frac{d}{M} \cdot \frac{2}{D}}} \cdot \frac{D}{d \cdot 2}\right) \cdot h}{\ell}} \]
    11. Applied egg-rr83.9%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{D}{d \cdot 2}\right)} \cdot h}{\ell}} \]
    12. Step-by-step derivation
      1. associate-/r*83.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \color{blue}{\frac{\frac{D}{d}}{2}}\right) \cdot h}{\ell}} \]
    13. Simplified83.9%

      \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{\frac{d}{M} \cdot \frac{2}{D}} \cdot \frac{\frac{D}{d}}{2}\right)} \cdot h}{\ell}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+232}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(\frac{\frac{D}{d}}{2} \cdot \frac{M}{\frac{d}{M} \cdot \frac{2}{D}}\right)}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.5% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+279}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right) \cdot \left(w0 \cdot h\right)}{\ell \cdot {d}^{2}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (if (<= (* M_m D_m) 5e+279)
   w0
   (* -0.125 (/ (* (* (* M_m D_m) (* M_m D_m)) (* w0 h)) (* l (pow d 2.0))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 5e+279) {
		tmp = w0;
	} else {
		tmp = -0.125 * ((((M_m * D_m) * (M_m * D_m)) * (w0 * h)) / (l * pow(d, 2.0)));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((m_m * d_m) <= 5d+279) then
        tmp = w0
    else
        tmp = (-0.125d0) * ((((m_m * d_m) * (m_m * d_m)) * (w0 * h)) / (l * (d ** 2.0d0)))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	double tmp;
	if ((M_m * D_m) <= 5e+279) {
		tmp = w0;
	} else {
		tmp = -0.125 * ((((M_m * D_m) * (M_m * D_m)) * (w0 * h)) / (l * Math.pow(d, 2.0)));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	tmp = 0
	if (M_m * D_m) <= 5e+279:
		tmp = w0
	else:
		tmp = -0.125 * ((((M_m * D_m) * (M_m * D_m)) * (w0 * h)) / (l * math.pow(d, 2.0)))
	return tmp
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 5e+279)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64(Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) * Float64(w0 * h)) / Float64(l * (d ^ 2.0))));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
	tmp = 0.0;
	if ((M_m * D_m) <= 5e+279)
		tmp = w0;
	else
		tmp = -0.125 * ((((M_m * D_m) * (M_m * D_m)) * (w0 * h)) / (l * (d ^ 2.0)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+279], w0, N[(-0.125 * N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(w0 * h), $MachinePrecision]), $MachinePrecision] / N[(l * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+279}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right) \cdot \left(w0 \cdot h\right)}{\ell \cdot {d}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 5.0000000000000002e279

    1. Initial program 80.2%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified79.4%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 72.2%

      \[\leadsto \color{blue}{w0} \]

    if 5.0000000000000002e279 < (*.f64 M D)

    1. Initial program 54.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified54.5%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 67.2%

      \[\leadsto \color{blue}{w0 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    5. Step-by-step derivation
      1. +-commutative67.2%

        \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell} + w0} \]
      2. fma-define67.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*67.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
      4. unpow267.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      5. unpow267.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      6. swap-sqr67.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      7. unpow267.2%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{{\left(D \cdot M\right)}^{2}} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
    6. Simplified67.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
    7. Taylor expanded in D around inf 67.2%

      \[\leadsto \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    8. Step-by-step derivation
      1. associate-*r*67.2%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell} \]
      2. *-commutative67.2%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left({M}^{2} \cdot {D}^{2}\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      3. unpow267.2%

        \[\leadsto -0.125 \cdot \frac{\left(\color{blue}{\left(M \cdot M\right)} \cdot {D}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      4. unpow267.2%

        \[\leadsto -0.125 \cdot \frac{\left(\left(M \cdot M\right) \cdot \color{blue}{\left(D \cdot D\right)}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      5. swap-sqr67.2%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      6. unpow267.2%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{{\left(M \cdot D\right)}^{2}} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      7. *-commutative67.2%

        \[\leadsto -0.125 \cdot \frac{{\color{blue}{\left(D \cdot M\right)}}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell} \]
      8. *-commutative67.2%

        \[\leadsto -0.125 \cdot \frac{{\left(D \cdot M\right)}^{2} \cdot \color{blue}{\left(w0 \cdot h\right)}}{{d}^{2} \cdot \ell} \]
    9. Simplified67.2%

      \[\leadsto \color{blue}{-0.125 \cdot \frac{{\left(D \cdot M\right)}^{2} \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell}} \]
    10. Step-by-step derivation
      1. unpow267.2%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell} \]
      2. *-commutative67.2%

        \[\leadsto -0.125 \cdot \frac{\left(\color{blue}{\left(M \cdot D\right)} \cdot \left(D \cdot M\right)\right) \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell} \]
      3. *-commutative67.2%

        \[\leadsto -0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \color{blue}{\left(M \cdot D\right)}\right) \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell} \]
    11. Applied egg-rr67.2%

      \[\leadsto -0.125 \cdot \frac{\color{blue}{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)} \cdot \left(w0 \cdot h\right)}{{d}^{2} \cdot \ell} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 5 \cdot 10^{+279}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \left(w0 \cdot h\right)}{\ell \cdot {d}^{2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 68.1% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ w0 \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return w0;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return w0;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
[w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d])
def code(w0, M_m, D_m, h, l, d):
	return w0
M_m = abs(M)
D_m = abs(D)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	return w0
end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
	tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Derivation
  1. Initial program 78.7%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified77.9%

    \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
  3. Add Preprocessing
  4. Taylor expanded in D around 0 68.5%

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024136 
(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))))))