Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.8% → 87.8%
Time: 22.0s
Alternatives: 10
Speedup: 1.0×

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.8% 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: 87.8% 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 \cdot D\_m \leq 10^{-57}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+150}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \left(\frac{h}{d} \cdot \frac{\frac{1}{d}}{\ell}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{\left(h \cdot {M\_m}^{2}\right) \cdot {\left(\frac{D\_m}{d}\right)}^{2}}{\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 D_m) 1e-57)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
   (if (<= (* M_m D_m) 5e+150)
     (*
      w0
      (sqrt
       (+
        1.0
        (* -0.25 (* (pow (* M_m D_m) 2.0) (* (/ h d) (/ (/ 1.0 d) l)))))))
     (*
      w0
      (sqrt
       (- 1.0 (* 0.25 (/ (* (* h (pow M_m 2.0)) (pow (/ 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 * D_m) <= 1e-57) {
		tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else if ((M_m * D_m) <= 5e+150) {
		tmp = w0 * sqrt((1.0 + (-0.25 * (pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
	} else {
		tmp = w0 * sqrt((1.0 - (0.25 * (((h * pow(M_m, 2.0)) * pow((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 * d_m) <= 1d-57) then
        tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
    else if ((m_m * d_m) <= 5d+150) then
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (((m_m * d_m) ** 2.0d0) * ((h / d) * ((1.0d0 / d) / l))))))
    else
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (((h * (m_m ** 2.0d0)) * ((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 * D_m) <= 1e-57) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else if ((M_m * D_m) <= 5e+150) {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * (Math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (((h * Math.pow(M_m, 2.0)) * Math.pow((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 * D_m) <= 1e-57:
		tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
	elif (M_m * D_m) <= 5e+150:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * (math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))))
	else:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (((h * math.pow(M_m, 2.0)) * math.pow((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 (Float64(M_m * D_m) <= 1e-57)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l))));
	elseif (Float64(M_m * D_m) <= 5e+150)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(Float64(h / d) * Float64(Float64(1.0 / d) / l)))))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(Float64(h * (M_m ^ 2.0)) * (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 * D_m) <= 1e-57)
		tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
	elseif ((M_m * D_m) <= 5e+150)
		tmp = w0 * sqrt((1.0 + (-0.25 * (((M_m * D_m) ^ 2.0) * ((h / d) * ((1.0 / d) / l))))));
	else
		tmp = w0 * sqrt((1.0 - (0.25 * (((h * (M_m ^ 2.0)) * ((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[N[(M$95$m * D$95$m), $MachinePrecision], 1e-57], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+150], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / d), $MachinePrecision] * N[(N[(1.0 / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(N[(h * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(D$95$m / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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 10^{-57}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\

\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+150}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \left(\frac{h}{d} \cdot \frac{\frac{1}{d}}{\ell}\right)\right)}\\

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


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

    1. Initial program 79.4%

      \[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(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/88.1%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999955e-58 < (*.f64 M D) < 5.00000000000000009e150

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{{\left(D \cdot M\right)}^{2}}{d \cdot \sqrt{\ell}} \cdot \frac{\frac{h}{d}}{\sqrt{\ell}}\right)}\right)} \]
      2. cancel-sign-sub-inv47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000009e150 < (*.f64 M D)

    1. Initial program 61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.4% accurate, 0.3× 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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 2 \cdot 10^{+298}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \left({M\_m}^{2} \cdot \frac{h}{\ell \cdot {d}^{2}}\right)\right) - -2 \cdot \log D\_m\right)}\right)}^{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 (<= (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) 2e+298)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
   (*
    w0
    (pow
     (pow
      (exp 0.25)
      (-
       (log (* -0.25 (* (pow M_m 2.0) (/ h (* l (pow d 2.0))))))
       (* -2.0 (log D_m))))
     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 (pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 2e+298) {
		tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * pow(pow(exp(0.25), (log((-0.25 * (pow(M_m, 2.0) * (h / (l * pow(d, 2.0)))))) - (-2.0 * log(D_m)))), 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) / (2.0d0 * d)) ** 2.0d0) <= 2d+298) then
        tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
    else
        tmp = w0 * ((exp(0.25d0) ** (log(((-0.25d0) * ((m_m ** 2.0d0) * (h / (l * (d ** 2.0d0)))))) - ((-2.0d0) * log(d_m)))) ** 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 (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 2e+298) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * Math.pow(Math.pow(Math.exp(0.25), (Math.log((-0.25 * (Math.pow(M_m, 2.0) * (h / (l * Math.pow(d, 2.0)))))) - (-2.0 * Math.log(D_m)))), 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 math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 2e+298:
		tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
	else:
		tmp = w0 * math.pow(math.pow(math.exp(0.25), (math.log((-0.25 * (math.pow(M_m, 2.0) * (h / (l * math.pow(d, 2.0)))))) - (-2.0 * math.log(D_m)))), 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(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) <= 2e+298)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l))));
	else
		tmp = Float64(w0 * ((exp(0.25) ^ Float64(log(Float64(-0.25 * Float64((M_m ^ 2.0) * Float64(h / Float64(l * (d ^ 2.0)))))) - Float64(-2.0 * log(D_m)))) ^ 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) / (2.0 * d)) ^ 2.0) <= 2e+298)
		tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
	else
		tmp = w0 * ((exp(0.25) ^ (log((-0.25 * ((M_m ^ 2.0) * (h / (l * (d ^ 2.0)))))) - (-2.0 * log(D_m)))) ^ 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[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 2e+298], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[Power[M$95$m, 2.0], $MachinePrecision] * N[(h / N[(l * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(-2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 2 \cdot 10^{+298}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 1.9999999999999999e298

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e298 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 44.8%

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{{\left({\left(1 - {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot \frac{h}{\ell}\right)}^{0.25}\right)}^{2}} \]
    6. Taylor expanded in D around inf 23.3%

      \[\leadsto w0 \cdot {\color{blue}{\left(e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right) + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}}^{2} \]
    7. Step-by-step derivation
      1. exp-prod23.2%

        \[\leadsto w0 \cdot {\color{blue}{\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right) + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}}^{2} \]
      2. distribute-lft-neg-in23.2%

        \[\leadsto w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \color{blue}{\left(\left(-0.25\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}^{2} \]
      3. metadata-eval23.2%

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

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

        \[\leadsto w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \left({M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}\right)\right) + -2 \cdot \color{blue}{\left(-\log D\right)}\right)}\right)}^{2} \]
    8. Simplified23.0%

      \[\leadsto w0 \cdot {\color{blue}{\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \left({M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}\right)\right) + -2 \cdot \left(-\log D\right)\right)}\right)}}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.8%

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

Alternative 3: 85.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} \mathbf{if}\;1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M\_m}{2 \cdot \frac{d}{D\_m}}\right)}^{2}}\\ \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
 (if (<= (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))) INFINITY)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ M_m (* 2.0 (/ d D_m))) 2.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 tmp;
	if ((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))) <= ((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((M_m / (2.0 * (d / D_m))), 2.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 tmp;
	if ((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))) <= Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((M_m / (2.0 * (d / D_m))), 2.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):
	tmp = 0
	if (1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))) <= math.inf:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((M_m / (2.0 * (d / D_m))), 2.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)
	tmp = 0.0
	if (Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))) <= Inf)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(M_m / Float64(2.0 * Float64(d / D_m))) ^ 2.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)
	tmp = 0.0;
	if ((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l))) <= Inf)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M_m / (2.0 * (d / D_m))) ^ 2.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_] := If[LessEqual[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m / N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.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}
\mathbf{if}\;1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M\_m}{2 \cdot \frac{d}{D\_m}}\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < +inf.0

    1. Initial program 84.0%

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

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

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

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

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

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

    if +inf.0 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))

    1. Initial program 0.0%

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

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.9%

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

Alternative 4: 86.6% 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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 5 \cdot 10^{+230}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \frac{\frac{h}{d}}{d \cdot \ell}\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 (<= (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) 5e+230)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
   (*
    w0
    (sqrt (+ 1.0 (* -0.25 (* (pow (* M_m D_m) 2.0) (/ (/ h d) (* d 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 (pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 5e+230) {
		tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * sqrt((1.0 + (-0.25 * (pow((M_m * D_m), 2.0) * ((h / d) / (d * 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 * d_m) / (2.0d0 * d)) ** 2.0d0) <= 5d+230) then
        tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
    else
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (((m_m * d_m) ** 2.0d0) * ((h / d) / (d * 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 (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 5e+230) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * (Math.pow((M_m * D_m), 2.0) * ((h / d) / (d * 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 math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 5e+230:
		tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
	else:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * (math.pow((M_m * D_m), 2.0) * ((h / d) / (d * 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 ((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) <= 5e+230)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(Float64(h / d) / Float64(d * 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 * D_m) / (2.0 * d)) ^ 2.0) <= 5e+230)
		tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
	else
		tmp = w0 * sqrt((1.0 + (-0.25 * (((M_m * D_m) ^ 2.0) * ((h / d) / (d * 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[N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 5e+230], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / d), $MachinePrecision] / N[(d * l), $MachinePrecision]), $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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 5 \cdot 10^{+230}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 5.0000000000000003e230

    1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e230 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 47.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{{\left(D \cdot M\right)}^{2}}{d \cdot \sqrt{\ell}} \cdot \frac{\frac{h}{d}}{\sqrt{\ell}}\right)}\right)} \]
      2. cancel-sign-sub-inv26.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\sqrt{1 + -0.25 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{\frac{h}{d}}{d \cdot \left(\sqrt{\ell} \cdot \sqrt{\ell}\right)}\right)}} \]
    13. Taylor expanded in l around 0 58.0%

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

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

Alternative 5: 87.5% accurate, 0.9× 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 10^{-57}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+150}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \left(\frac{h}{d} \cdot \frac{\frac{1}{d}}{\ell}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{\left(h \cdot {M\_m}^{2}\right) \cdot \frac{D\_m}{d \cdot \frac{d}{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 (<= (* M_m D_m) 1e-57)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
   (if (<= (* M_m D_m) 5e+150)
     (*
      w0
      (sqrt
       (+
        1.0
        (* -0.25 (* (pow (* M_m D_m) 2.0) (* (/ h d) (/ (/ 1.0 d) l)))))))
     (*
      w0
      (sqrt
       (-
        1.0
        (* 0.25 (/ (* (* h (pow M_m 2.0)) (/ D_m (* d (/ d 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 ((M_m * D_m) <= 1e-57) {
		tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else if ((M_m * D_m) <= 5e+150) {
		tmp = w0 * sqrt((1.0 + (-0.25 * (pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
	} else {
		tmp = w0 * sqrt((1.0 - (0.25 * (((h * pow(M_m, 2.0)) * (D_m / (d * (d / 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 ((m_m * d_m) <= 1d-57) then
        tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
    else if ((m_m * d_m) <= 5d+150) then
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (((m_m * d_m) ** 2.0d0) * ((h / d) * ((1.0d0 / d) / l))))))
    else
        tmp = w0 * sqrt((1.0d0 - (0.25d0 * (((h * (m_m ** 2.0d0)) * (d_m / (d * (d / 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 ((M_m * D_m) <= 1e-57) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else if ((M_m * D_m) <= 5e+150) {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * (Math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * (((h * Math.pow(M_m, 2.0)) * (D_m / (d * (d / 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 (M_m * D_m) <= 1e-57:
		tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
	elif (M_m * D_m) <= 5e+150:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * (math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))))
	else:
		tmp = w0 * math.sqrt((1.0 - (0.25 * (((h * math.pow(M_m, 2.0)) * (D_m / (d * (d / 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 (Float64(M_m * D_m) <= 1e-57)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l))));
	elseif (Float64(M_m * D_m) <= 5e+150)
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(Float64(h / d) * Float64(Float64(1.0 / d) / l)))))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(Float64(h * (M_m ^ 2.0)) * Float64(D_m / Float64(d * Float64(d / 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 ((M_m * D_m) <= 1e-57)
		tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
	elseif ((M_m * D_m) <= 5e+150)
		tmp = w0 * sqrt((1.0 + (-0.25 * (((M_m * D_m) ^ 2.0) * ((h / d) * ((1.0 / d) / l))))));
	else
		tmp = w0 * sqrt((1.0 - (0.25 * (((h * (M_m ^ 2.0)) * (D_m / (d * (d / 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[N[(M$95$m * D$95$m), $MachinePrecision], 1e-57], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+150], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / d), $MachinePrecision] * N[(N[(1.0 / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(N[(h * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * N[(D$95$m / N[(d * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $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 10^{-57}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\

\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+150}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \left(\frac{h}{d} \cdot \frac{\frac{1}{d}}{\ell}\right)\right)}\\

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


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

    1. Initial program 79.4%

      \[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(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-*r/88.1%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999955e-58 < (*.f64 M D) < 5.00000000000000009e150

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \color{blue}{\left(1 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{{\left(D \cdot M\right)}^{2}}{d \cdot \sqrt{\ell}} \cdot \frac{\frac{h}{d}}{\sqrt{\ell}}\right)}\right)} \]
      2. cancel-sign-sub-inv47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000009e150 < (*.f64 M D)

    1. Initial program 61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 86.3% accurate, 0.9× 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}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 2 \cdot 10^{+115}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2} \cdot \frac{h}{d}}{d \cdot \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 D_m) (* 2.0 d)) 2e+115)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
   (*
    w0
    (sqrt (+ 1.0 (* -0.25 (/ (* (pow (* M_m D_m) 2.0) (/ h d)) (* d 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 * D_m) / (2.0 * d)) <= 2e+115) {
		tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * sqrt((1.0 + (-0.25 * ((pow((M_m * D_m), 2.0) * (h / d)) / (d * 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 * d_m) / (2.0d0 * d)) <= 2d+115) then
        tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
    else
        tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * ((((m_m * d_m) ** 2.0d0) * (h / d)) / (d * 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 * D_m) / (2.0 * d)) <= 2e+115) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 + (-0.25 * ((Math.pow((M_m * D_m), 2.0) * (h / d)) / (d * 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 * D_m) / (2.0 * d)) <= 2e+115:
		tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
	else:
		tmp = w0 * math.sqrt((1.0 + (-0.25 * ((math.pow((M_m * D_m), 2.0) * (h / d)) / (d * 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 (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 2e+115)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(Float64((Float64(M_m * D_m) ^ 2.0) * Float64(h / d)) / Float64(d * 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 * D_m) / (2.0 * d)) <= 2e+115)
		tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
	else
		tmp = w0 * sqrt((1.0 + (-0.25 * ((((M_m * D_m) ^ 2.0) * (h / d)) / (d * 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[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2e+115], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] / N[(d * l), $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}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 2 \cdot 10^{+115}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\

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


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

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e115 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 82.1% accurate, 1.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])\\ \\ \begin{array}{l} \mathbf{if}\;D\_m \leq 6.8 \cdot 10^{-43}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D\_m}{2 \cdot d}\right)}^{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 (<= D_m 6.8e-43)
   w0
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* M_m (/ D_m (* 2.0 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 (D_m <= 6.8e-43) {
		tmp = w0;
	} else {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((M_m * (D_m / (2.0 * 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 (d_m <= 6.8d-43) then
        tmp = w0
    else
        tmp = w0 * sqrt((1.0d0 - ((h / l) * ((m_m * (d_m / (2.0d0 * 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 (D_m <= 6.8e-43) {
		tmp = w0;
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((M_m * (D_m / (2.0 * 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 D_m <= 6.8e-43:
		tmp = w0
	else:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((M_m * (D_m / (2.0 * 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 (D_m <= 6.8e-43)
		tmp = w0;
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(M_m * Float64(D_m / Float64(2.0 * 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 (D_m <= 6.8e-43)
		tmp = w0;
	else
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M_m * (D_m / (2.0 * 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[D$95$m, 6.8e-43], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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}\;D\_m \leq 6.8 \cdot 10^{-43}:\\
\;\;\;\;w0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 6.8000000000000001e-43

    1. Initial program 77.1%

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

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

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

    if 6.8000000000000001e-43 < D

    1. Initial program 74.3%

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

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

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

Alternative 8: 85.8% accurate, 1.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 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}} \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 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) 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) {
	return w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
}
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 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
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 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
}
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 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
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 Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l))))
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 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
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_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $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])\\
\\
w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}
\end{array}
Derivation
  1. Initial program 76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 70.5% accurate, 1.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])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 170000:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0}\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 170000.0) w0 (log (exp 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 tmp;
	if (M_m <= 170000.0) {
		tmp = w0;
	} else {
		tmp = log(exp(w0));
	}
	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 <= 170000.0d0) then
        tmp = w0
    else
        tmp = log(exp(w0))
    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 <= 170000.0) {
		tmp = w0;
	} else {
		tmp = Math.log(Math.exp(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):
	tmp = 0
	if M_m <= 170000.0:
		tmp = w0
	else:
		tmp = math.log(math.exp(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)
	tmp = 0.0
	if (M_m <= 170000.0)
		tmp = w0;
	else
		tmp = log(exp(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)
	tmp = 0.0;
	if (M_m <= 170000.0)
		tmp = w0;
	else
		tmp = log(exp(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_] := If[LessEqual[M$95$m, 170000.0], w0, N[Log[N[Exp[w0], $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 170000:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.7e5

    1. Initial program 78.2%

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

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

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

    if 1.7e5 < M

    1. Initial program 69.9%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\color{blue}{{w0}^{2}}} \]
    7. Step-by-step derivation
      1. sqrt-pow149.7%

        \[\leadsto \color{blue}{{w0}^{\left(\frac{2}{2}\right)}} \]
      2. metadata-eval49.7%

        \[\leadsto {w0}^{\color{blue}{1}} \]
      3. pow149.7%

        \[\leadsto \color{blue}{w0} \]
      4. add-log-exp28.3%

        \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
    8. Applied egg-rr28.3%

      \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 170000:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 67.9% 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 76.4%

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification63.8%

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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