Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.7% → 91.6%
Time: 14.6s
Alternatives: 8
Speedup: 0.7×

Specification

?
\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 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: 81.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 91.6% accurate, 0.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\ t_1 := D \cdot \frac{M}{d}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+295}:\\ \;\;\;\;w0 \cdot \left(t_1 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \mathbf{elif}\;t_0 \leq 0.002:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{\frac{M}{d}}{\frac{2}{D}}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 + -0.125 \cdot \frac{h \cdot \left(w0 \cdot {t_1}^{2}\right)}{\ell}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))) (t_1 (* D (/ M d))))
   (if (<= t_0 -5e+295)
     (* w0 (* t_1 (sqrt (* h (/ -0.25 l)))))
     (if (<= t_0 0.002)
       (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ (/ M d) (/ 2.0 D)) 2.0)))))
       (+ w0 (* -0.125 (/ (* h (* w0 (pow t_1 2.0))) l)))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
	double t_1 = D * (M / d);
	double tmp;
	if (t_0 <= -5e+295) {
		tmp = w0 * (t_1 * sqrt((h * (-0.25 / l))));
	} else if (t_0 <= 0.002) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((M / d) / (2.0 / D)), 2.0))));
	} else {
		tmp = w0 + (-0.125 * ((h * (w0 * pow(t_1, 2.0))) / l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)
    t_1 = d * (m / d_1)
    if (t_0 <= (-5d+295)) then
        tmp = w0 * (t_1 * sqrt((h * ((-0.25d0) / l))))
    else if (t_0 <= 0.002d0) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * (((m / d_1) / (2.0d0 / d)) ** 2.0d0))))
    else
        tmp = w0 + ((-0.125d0) * ((h * (w0 * (t_1 ** 2.0d0))) / l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
	double t_1 = D * (M / d);
	double tmp;
	if (t_0 <= -5e+295) {
		tmp = w0 * (t_1 * Math.sqrt((h * (-0.25 / l))));
	} else if (t_0 <= 0.002) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((M / d) / (2.0 / D)), 2.0))));
	} else {
		tmp = w0 + (-0.125 * ((h * (w0 * Math.pow(t_1, 2.0))) / l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)
	t_1 = D * (M / d)
	tmp = 0
	if t_0 <= -5e+295:
		tmp = w0 * (t_1 * math.sqrt((h * (-0.25 / l))))
	elif t_0 <= 0.002:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((M / d) / (2.0 / D)), 2.0))))
	else:
		tmp = w0 + (-0.125 * ((h * (w0 * math.pow(t_1, 2.0))) / l))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))
	t_1 = Float64(D * Float64(M / d))
	tmp = 0.0
	if (t_0 <= -5e+295)
		tmp = Float64(w0 * Float64(t_1 * sqrt(Float64(h * Float64(-0.25 / l)))));
	elseif (t_0 <= 0.002)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / d) / Float64(2.0 / D)) ^ 2.0)))));
	else
		tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(h * Float64(w0 * (t_1 ^ 2.0))) / l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = (((M * D) / (2.0 * d)) ^ 2.0) * (h / l);
	t_1 = D * (M / d);
	tmp = 0.0;
	if (t_0 <= -5e+295)
		tmp = w0 * (t_1 * sqrt((h * (-0.25 / l))));
	elseif (t_0 <= 0.002)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((M / d) / (2.0 / D)) ^ 2.0))));
	else
		tmp = w0 + (-0.125 * ((h * (w0 * (t_1 ^ 2.0))) / l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+295], N[(w0 * N[(t$95$1 * N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.002], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / d), $MachinePrecision] / N[(2.0 / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 + N[(-0.125 * N[(N[(h * N[(w0 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
t_1 := D \cdot \frac{M}{d}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+295}:\\
\;\;\;\;w0 \cdot \left(t_1 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\

\mathbf{elif}\;t_0 \leq 0.002:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{\frac{M}{d}}{\frac{2}{D}}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{h \cdot \left(w0 \cdot {t_1}^{2}\right)}{\ell}\\


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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot {\color{blue}{\left(\left(\frac{-0.25}{\ell} \cdot h\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)}}^{0.5} \]
      3. unpow-prod-down58.2%

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{D \cdot \frac{M}{d}}\right|\right) \]
    12. Simplified76.6%

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u43.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef33.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)} - 1} \]
      3. *-commutative33.4%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr14.4%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)} - 1} \]
    15. Step-by-step derivation
      1. expm1-def19.6%

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

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

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

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

    if -4.99999999999999991e295 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 2e-3

    1. Initial program 99.9%

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

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

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

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

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

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

    if 2e-3 < (*.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(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Taylor expanded in D around 0 53.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac47.4%

        \[\leadsto w0 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      8. associate-/l*47.4%

        \[\leadsto w0 + -0.125 \cdot \left(\left(\frac{D \cdot M}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. associate-/l*47.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)\right)} \]
      2. expm1-udef36.8%

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)} - 1\right)} \]
      3. *-commutative36.8%

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \color{blue}{\frac{h}{\frac{\ell}{w0}}}\right)} - 1\right) \]
    10. Applied egg-rr36.8%

      \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}\right)} - 1\right)} \]
    11. Step-by-step derivation
      1. expm1-def36.8%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.6% accurate, 0.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\ t_1 := D \cdot \frac{M}{d}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+295}:\\ \;\;\;\;w0 \cdot \left(t_1 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \mathbf{elif}\;t_0 \leq 0.002:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 + -0.125 \cdot \frac{h \cdot \left(w0 \cdot {t_1}^{2}\right)}{\ell}\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))) (t_1 (* D (/ M d))))
   (if (<= t_0 -5e+295)
     (* w0 (* t_1 (sqrt (* h (/ -0.25 l)))))
     (if (<= t_0 0.002)
       (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ M d) (/ D 2.0)) 2.0)))))
       (+ w0 (* -0.125 (/ (* h (* w0 (pow t_1 2.0))) l)))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
	double t_1 = D * (M / d);
	double tmp;
	if (t_0 <= -5e+295) {
		tmp = w0 * (t_1 * sqrt((h * (-0.25 / l))));
	} else if (t_0 <= 0.002) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((M / d) * (D / 2.0)), 2.0))));
	} else {
		tmp = w0 + (-0.125 * ((h * (w0 * pow(t_1, 2.0))) / l));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)
    t_1 = d * (m / d_1)
    if (t_0 <= (-5d+295)) then
        tmp = w0 * (t_1 * sqrt((h * ((-0.25d0) / l))))
    else if (t_0 <= 0.002d0) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * (((m / d_1) * (d / 2.0d0)) ** 2.0d0))))
    else
        tmp = w0 + ((-0.125d0) * ((h * (w0 * (t_1 ** 2.0d0))) / l))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
	double t_1 = D * (M / d);
	double tmp;
	if (t_0 <= -5e+295) {
		tmp = w0 * (t_1 * Math.sqrt((h * (-0.25 / l))));
	} else if (t_0 <= 0.002) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((M / d) * (D / 2.0)), 2.0))));
	} else {
		tmp = w0 + (-0.125 * ((h * (w0 * Math.pow(t_1, 2.0))) / l));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)
	t_1 = D * (M / d)
	tmp = 0
	if t_0 <= -5e+295:
		tmp = w0 * (t_1 * math.sqrt((h * (-0.25 / l))))
	elif t_0 <= 0.002:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((M / d) * (D / 2.0)), 2.0))))
	else:
		tmp = w0 + (-0.125 * ((h * (w0 * math.pow(t_1, 2.0))) / l))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))
	t_1 = Float64(D * Float64(M / d))
	tmp = 0.0
	if (t_0 <= -5e+295)
		tmp = Float64(w0 * Float64(t_1 * sqrt(Float64(h * Float64(-0.25 / l)))));
	elseif (t_0 <= 0.002)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / d) * Float64(D / 2.0)) ^ 2.0)))));
	else
		tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(h * Float64(w0 * (t_1 ^ 2.0))) / l)));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = (((M * D) / (2.0 * d)) ^ 2.0) * (h / l);
	t_1 = D * (M / d);
	tmp = 0.0;
	if (t_0 <= -5e+295)
		tmp = w0 * (t_1 * sqrt((h * (-0.25 / l))));
	elseif (t_0 <= 0.002)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((M / d) * (D / 2.0)) ^ 2.0))));
	else
		tmp = w0 + (-0.125 * ((h * (w0 * (t_1 ^ 2.0))) / l));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+295], N[(w0 * N[(t$95$1 * N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.002], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 + N[(-0.125 * N[(N[(h * N[(w0 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
t_1 := D \cdot \frac{M}{d}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+295}:\\
\;\;\;\;w0 \cdot \left(t_1 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\

\mathbf{elif}\;t_0 \leq 0.002:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{h \cdot \left(w0 \cdot {t_1}^{2}\right)}{\ell}\\


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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot {\color{blue}{\left(\left(\frac{-0.25}{\ell} \cdot h\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)}}^{0.5} \]
      3. unpow-prod-down58.2%

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{D \cdot \frac{M}{d}}\right|\right) \]
    12. Simplified76.6%

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u43.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef33.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)} - 1} \]
      3. *-commutative33.4%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr14.4%

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)} - 1} \]
    15. Step-by-step derivation
      1. expm1-def19.6%

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

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

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

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

    if -4.99999999999999991e295 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 2e-3

    1. Initial program 99.9%

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

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

    if 2e-3 < (*.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(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Taylor expanded in D around 0 53.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac47.4%

        \[\leadsto w0 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      8. associate-/l*47.4%

        \[\leadsto w0 + -0.125 \cdot \left(\left(\frac{D \cdot M}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. associate-/l*47.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)\right)} \]
      2. expm1-udef36.8%

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)} - 1\right)} \]
      3. *-commutative36.8%

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \color{blue}{\frac{h}{\frac{\ell}{w0}}}\right)} - 1\right) \]
    10. Applied egg-rr36.8%

      \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}\right)} - 1\right)} \]
    11. Step-by-step derivation
      1. expm1-def36.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 91.5% accurate, 0.7× speedup?

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

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


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

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{D \cdot \frac{M}{d}}\right|\right) \]
    12. Simplified80.0%

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u49.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef31.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)} - 1} \]
      3. *-commutative31.9%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\frac{M}{d} \cdot D}\right|\right)\right)} - 1 \]
      4. add-sqr-sqrt15.5%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr15.5%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}\right)\right)} - 1 \]
      7. *-commutative15.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)} - 1} \]
    15. Step-by-step derivation
      1. expm1-def25.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)\right)} \]
      2. expm1-log1p41.2%

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

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

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

    if -4.99999999999999992e72 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 78.8% accurate, 1.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-10}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+188}:\\ \;\;\;\;w0 + -0.125 \cdot \left({\left(\frac{M \cdot D}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (* M D) 1e-10)
   w0
   (if (<= (* M D) 5e+188)
     (+ w0 (* -0.125 (* (pow (/ (* M D) d) 2.0) (/ (* h w0) l))))
     (* w0 (* (* D (/ M d)) (sqrt (* h (/ -0.25 l))))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((M * D) <= 1e-10) {
		tmp = w0;
	} else if ((M * D) <= 5e+188) {
		tmp = w0 + (-0.125 * (pow(((M * D) / d), 2.0) * ((h * w0) / l)));
	} else {
		tmp = w0 * ((D * (M / d)) * sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if ((m * d) <= 1d-10) then
        tmp = w0
    else if ((m * d) <= 5d+188) then
        tmp = w0 + ((-0.125d0) * ((((m * d) / d_1) ** 2.0d0) * ((h * w0) / l)))
    else
        tmp = w0 * ((d * (m / d_1)) * sqrt((h * ((-0.25d0) / l))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((M * D) <= 1e-10) {
		tmp = w0;
	} else if ((M * D) <= 5e+188) {
		tmp = w0 + (-0.125 * (Math.pow(((M * D) / d), 2.0) * ((h * w0) / l)));
	} else {
		tmp = w0 * ((D * (M / d)) * Math.sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if (M * D) <= 1e-10:
		tmp = w0
	elif (M * D) <= 5e+188:
		tmp = w0 + (-0.125 * (math.pow(((M * D) / d), 2.0) * ((h * w0) / l)))
	else:
		tmp = w0 * ((D * (M / d)) * math.sqrt((h * (-0.25 / l))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(M * D) <= 1e-10)
		tmp = w0;
	elseif (Float64(M * D) <= 5e+188)
		tmp = Float64(w0 + Float64(-0.125 * Float64((Float64(Float64(M * D) / d) ^ 2.0) * Float64(Float64(h * w0) / l))));
	else
		tmp = Float64(w0 * Float64(Float64(D * Float64(M / d)) * sqrt(Float64(h * Float64(-0.25 / l)))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((M * D) <= 1e-10)
		tmp = w0;
	elseif ((M * D) <= 5e+188)
		tmp = w0 + (-0.125 * ((((M * D) / d) ^ 2.0) * ((h * w0) / l)));
	else
		tmp = w0 * ((D * (M / d)) * sqrt((h * (-0.25 / l))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(M * D), $MachinePrecision], 1e-10], w0, If[LessEqual[N[(M * D), $MachinePrecision], 5e+188], N[(w0 + N[(-0.125 * N[(N[Power[N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h * w0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * N[(N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 10^{-10}:\\
\;\;\;\;w0\\

\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+188}:\\
\;\;\;\;w0 + -0.125 \cdot \left({\left(\frac{M \cdot D}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)\\

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


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

    1. Initial program 85.8%

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

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

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

    if 1.00000000000000004e-10 < (*.f64 M D) < 5.0000000000000001e188

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac61.4%

        \[\leadsto w0 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      8. associate-/l*58.3%

        \[\leadsto w0 + -0.125 \cdot \left(\left(\frac{D \cdot M}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. associate-/l*58.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e188 < (*.f64 M D)

    1. Initial program 47.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot {\color{blue}{\left(\left(\frac{-0.25}{\ell} \cdot h\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)}}^{0.5} \]
      3. unpow-prod-down47.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u28.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef16.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)} - 1} \]
      3. *-commutative16.8%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\frac{M}{d} \cdot D}\right|\right)\right)} - 1 \]
      4. add-sqr-sqrt16.3%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr16.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}\right)\right)} - 1 \]
      7. *-commutative16.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)} - 1} \]
    15. Step-by-step derivation
      1. expm1-def24.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)\right)} \]
      2. expm1-log1p46.8%

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

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

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

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

Alternative 5: 78.3% accurate, 1.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := D \cdot \frac{M}{d}\\ \mathbf{if}\;M \leq 4 \cdot 10^{-128}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq 9 \cdot 10^{+29}:\\ \;\;\;\;w0 + -0.125 \cdot \left(\frac{h}{\ell} \cdot \left(w0 \cdot {t_0}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(t_0 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* D (/ M d))))
   (if (<= M 4e-128)
     w0
     (if (<= M 9e+29)
       (+ w0 (* -0.125 (* (/ h l) (* w0 (pow t_0 2.0)))))
       (* w0 (* t_0 (sqrt (* h (/ -0.25 l)))))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (M / d);
	double tmp;
	if (M <= 4e-128) {
		tmp = w0;
	} else if (M <= 9e+29) {
		tmp = w0 + (-0.125 * ((h / l) * (w0 * pow(t_0, 2.0))));
	} else {
		tmp = w0 * (t_0 * sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d * (m / d_1)
    if (m <= 4d-128) then
        tmp = w0
    else if (m <= 9d+29) then
        tmp = w0 + ((-0.125d0) * ((h / l) * (w0 * (t_0 ** 2.0d0))))
    else
        tmp = w0 * (t_0 * sqrt((h * ((-0.25d0) / l))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (M / d);
	double tmp;
	if (M <= 4e-128) {
		tmp = w0;
	} else if (M <= 9e+29) {
		tmp = w0 + (-0.125 * ((h / l) * (w0 * Math.pow(t_0, 2.0))));
	} else {
		tmp = w0 * (t_0 * Math.sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = D * (M / d)
	tmp = 0
	if M <= 4e-128:
		tmp = w0
	elif M <= 9e+29:
		tmp = w0 + (-0.125 * ((h / l) * (w0 * math.pow(t_0, 2.0))))
	else:
		tmp = w0 * (t_0 * math.sqrt((h * (-0.25 / l))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64(D * Float64(M / d))
	tmp = 0.0
	if (M <= 4e-128)
		tmp = w0;
	elseif (M <= 9e+29)
		tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(h / l) * Float64(w0 * (t_0 ^ 2.0)))));
	else
		tmp = Float64(w0 * Float64(t_0 * sqrt(Float64(h * Float64(-0.25 / l)))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = D * (M / d);
	tmp = 0.0;
	if (M <= 4e-128)
		tmp = w0;
	elseif (M <= 9e+29)
		tmp = w0 + (-0.125 * ((h / l) * (w0 * (t_0 ^ 2.0))));
	else
		tmp = w0 * (t_0 * sqrt((h * (-0.25 / l))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 4e-128], w0, If[LessEqual[M, 9e+29], N[(w0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[(w0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * N[(t$95$0 * N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := D \cdot \frac{M}{d}\\
\mathbf{if}\;M \leq 4 \cdot 10^{-128}:\\
\;\;\;\;w0\\

\mathbf{elif}\;M \leq 9 \cdot 10^{+29}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\frac{h}{\ell} \cdot \left(w0 \cdot {t_0}^{2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(t_0 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 4.00000000000000022e-128

    1. Initial program 83.6%

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

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

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

    if 4.00000000000000022e-128 < M < 9.0000000000000005e29

    1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{h \cdot w0}{\ell}\right) \]
      7. times-frac63.4%

        \[\leadsto w0 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      8. associate-/l*63.4%

        \[\leadsto w0 + -0.125 \cdot \left(\left(\frac{D \cdot M}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. associate-/l*63.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)} - 1\right)} \]
      3. *-commutative62.6%

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \color{blue}{\frac{h}{\frac{\ell}{w0}}}\right)} - 1\right) \]
    10. Applied egg-rr62.6%

      \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}\right)} - 1\right)} \]
    11. Step-by-step derivation
      1. expm1-def62.6%

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

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

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

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

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

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

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

    if 9.0000000000000005e29 < M

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left|\frac{M}{d} \cdot D\right|}\right) \]
      5. *-commutative32.6%

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{D \cdot \frac{M}{d}}\right|\right) \]
    12. Simplified32.6%

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u20.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef13.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\frac{M}{d} \cdot D}\right|\right)\right)} - 1 \]
      4. add-sqr-sqrt8.1%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr8.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 4 \cdot 10^{-128}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq 9 \cdot 10^{+29}:\\ \;\;\;\;w0 + -0.125 \cdot \left(\frac{h}{\ell} \cdot \left(w0 \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \end{array} \]

Alternative 6: 80.4% accurate, 1.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} t_0 := D \cdot \frac{M}{d}\\ \mathbf{if}\;M \cdot D \leq 5 \cdot 10^{+188}:\\ \;\;\;\;w0 + -0.125 \cdot \frac{h \cdot \left(w0 \cdot {t_0}^{2}\right)}{\ell}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(t_0 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* D (/ M d))))
   (if (<= (* M D) 5e+188)
     (+ w0 (* -0.125 (/ (* h (* w0 (pow t_0 2.0))) l)))
     (* w0 (* t_0 (sqrt (* h (/ -0.25 l))))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (M / d);
	double tmp;
	if ((M * D) <= 5e+188) {
		tmp = w0 + (-0.125 * ((h * (w0 * pow(t_0, 2.0))) / l));
	} else {
		tmp = w0 * (t_0 * sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d * (m / d_1)
    if ((m * d) <= 5d+188) then
        tmp = w0 + ((-0.125d0) * ((h * (w0 * (t_0 ** 2.0d0))) / l))
    else
        tmp = w0 * (t_0 * sqrt((h * ((-0.25d0) / l))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (M / d);
	double tmp;
	if ((M * D) <= 5e+188) {
		tmp = w0 + (-0.125 * ((h * (w0 * Math.pow(t_0, 2.0))) / l));
	} else {
		tmp = w0 * (t_0 * Math.sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	t_0 = D * (M / d)
	tmp = 0
	if (M * D) <= 5e+188:
		tmp = w0 + (-0.125 * ((h * (w0 * math.pow(t_0, 2.0))) / l))
	else:
		tmp = w0 * (t_0 * math.sqrt((h * (-0.25 / l))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	t_0 = Float64(D * Float64(M / d))
	tmp = 0.0
	if (Float64(M * D) <= 5e+188)
		tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(h * Float64(w0 * (t_0 ^ 2.0))) / l)));
	else
		tmp = Float64(w0 * Float64(t_0 * sqrt(Float64(h * Float64(-0.25 / l)))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = D * (M / d);
	tmp = 0.0;
	if ((M * D) <= 5e+188)
		tmp = w0 + (-0.125 * ((h * (w0 * (t_0 ^ 2.0))) / l));
	else
		tmp = w0 * (t_0 * sqrt((h * (-0.25 / l))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 5e+188], N[(w0 + N[(-0.125 * N[(N[(h * N[(w0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * N[(t$95$0 * N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := D \cdot \frac{M}{d}\\
\mathbf{if}\;M \cdot D \leq 5 \cdot 10^{+188}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{h \cdot \left(w0 \cdot {t_0}^{2}\right)}{\ell}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(t_0 \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\


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

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      8. associate-/l*71.8%

        \[\leadsto w0 + -0.125 \cdot \left(\left(\frac{D \cdot M}{d} \cdot \color{blue}{\frac{D}{\frac{d}{M}}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. associate-/l*71.8%

        \[\leadsto w0 + -0.125 \cdot \left(\left(\color{blue}{\frac{D}{\frac{d}{M}}} \cdot \frac{D}{\frac{d}{M}}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      10. unpow271.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)} - 1\right)} \]
      3. *-commutative65.5%

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \color{blue}{\frac{h}{\frac{\ell}{w0}}}\right)} - 1\right) \]
    10. Applied egg-rr67.6%

      \[\leadsto w0 + -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\frac{M}{d} \cdot D\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}\right)} - 1\right)} \]
    11. Step-by-step derivation
      1. expm1-def67.8%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e188 < (*.f64 M D)

    1. Initial program 47.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot {\color{blue}{\left(\left(\frac{-0.25}{\ell} \cdot h\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)}}^{0.5} \]
      3. unpow-prod-down47.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u28.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef16.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)} - 1} \]
      3. *-commutative16.8%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\frac{M}{d} \cdot D}\right|\right)\right)} - 1 \]
      4. add-sqr-sqrt16.3%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr16.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}\right)\right)} - 1 \]
      7. *-commutative16.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)} - 1} \]
    15. Step-by-step derivation
      1. expm1-def24.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)\right)} \]
      2. expm1-log1p46.8%

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

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

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

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

Alternative 7: 75.0% accurate, 1.8× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 1.32 \cdot 10^{-30} \lor \neg \left(M \leq 8 \cdot 10^{-12}\right) \land M \leq 3.15 \cdot 10^{+29}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (or (<= M 1.32e-30) (and (not (<= M 8e-12)) (<= M 3.15e+29)))
   w0
   (* w0 (* (* D (/ M d)) (sqrt (* h (/ -0.25 l)))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((M <= 1.32e-30) || (!(M <= 8e-12) && (M <= 3.15e+29))) {
		tmp = w0;
	} else {
		tmp = w0 * ((D * (M / d)) * sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
    real(8) :: tmp
    if ((m <= 1.32d-30) .or. (.not. (m <= 8d-12)) .and. (m <= 3.15d+29)) then
        tmp = w0
    else
        tmp = w0 * ((d * (m / d_1)) * sqrt((h * ((-0.25d0) / l))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((M <= 1.32e-30) || (!(M <= 8e-12) && (M <= 3.15e+29))) {
		tmp = w0;
	} else {
		tmp = w0 * ((D * (M / d)) * Math.sqrt((h * (-0.25 / l))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if (M <= 1.32e-30) or (not (M <= 8e-12) and (M <= 3.15e+29)):
		tmp = w0
	else:
		tmp = w0 * ((D * (M / d)) * math.sqrt((h * (-0.25 / l))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if ((M <= 1.32e-30) || (!(M <= 8e-12) && (M <= 3.15e+29)))
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(Float64(D * Float64(M / d)) * sqrt(Float64(h * Float64(-0.25 / l)))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((M <= 1.32e-30) || (~((M <= 8e-12)) && (M <= 3.15e+29)))
		tmp = w0;
	else
		tmp = w0 * ((D * (M / d)) * sqrt((h * (-0.25 / l))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[Or[LessEqual[M, 1.32e-30], And[N[Not[LessEqual[M, 8e-12]], $MachinePrecision], LessEqual[M, 3.15e+29]]], w0, N[(w0 * N[(N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.32 \cdot 10^{-30} \lor \neg \left(M \leq 8 \cdot 10^{-12}\right) \land M \leq 3.15 \cdot 10^{+29}:\\
\;\;\;\;w0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.32e-30 or 7.99999999999999984e-12 < M < 3.1499999999999999e29

    1. Initial program 83.6%

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

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

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

    if 1.32e-30 < M < 7.99999999999999984e-12 or 3.1499999999999999e29 < M

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \sqrt{\color{blue}{\left(\frac{M}{d} \cdot D\right) \cdot \left(\frac{M}{d} \cdot D\right)}}\right) \]
      4. rem-sqrt-square33.3%

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left|\frac{M}{d} \cdot D\right|}\right) \]
      5. *-commutative33.3%

        \[\leadsto w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{D \cdot \frac{M}{d}}\right|\right) \]
    12. Simplified33.3%

      \[\leadsto w0 \cdot \color{blue}{\left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)} \]
    13. Step-by-step derivation
      1. expm1-log1p-u20.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|D \cdot \frac{M}{d}\right|\right)\right)\right)} \]
      2. expm1-udef14.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\frac{M}{d} \cdot D}\right|\right)\right)} - 1 \]
      4. add-sqr-sqrt7.8%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left|\color{blue}{\sqrt{\frac{M}{d} \cdot D} \cdot \sqrt{\frac{M}{d} \cdot D}}\right|\right)\right)} - 1 \]
      5. fabs-sqr7.8%

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

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}\right)\right)} - 1 \]
      7. *-commutative7.9%

        \[\leadsto e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right)\right)} - 1 \]
    14. Applied egg-rr7.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)} - 1} \]
    15. Step-by-step derivation
      1. expm1-def12.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)\right)} \]
      2. expm1-log1p16.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.32 \cdot 10^{-30} \lor \neg \left(M \leq 8 \cdot 10^{-12}\right) \land M \leq 3.15 \cdot 10^{+29}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \sqrt{h \cdot \frac{-0.25}{\ell}}\right)\\ \end{array} \]

Alternative 8: 68.1% accurate, 216.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d) :precision binary64 w0)
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
M = abs(M)
D = abs(D)
d = abs(d)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0
M = abs(M)
D = abs(D)
d = abs(d)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	return w0
end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Derivation
  1. Initial program 82.1%

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

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

    \[\leadsto \color{blue}{w0} \]
  4. Final simplification69.2%

    \[\leadsto w0 \]

Reproduce

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