Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.9% → 87.3%
Time: 14.9s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 80.9% accurate, 1.0× speedup?

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

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

Alternative 1: 87.3% accurate, 0.5× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq 5 \cdot 10^{+151}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot e^{0.5 \cdot \mathsf{fma}\left(-2, \log d, \log \left(\frac{-0.25 \cdot \left(h \cdot \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right)\right)}{\ell}\right)\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (/ (* M D) (* 2.0 d)) 5e+151)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* M (* 0.5 (/ D d))) 2.0) h) l))))
   (*
    w0
    (exp
     (*
      0.5
      (fma -2.0 (log d) (log (/ (* -0.25 (* h (* (* M D) (* M D)))) l))))))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (((M * D) / (2.0 * d)) <= 5e+151) {
		tmp = w0 * sqrt((1.0 - ((pow((M * (0.5 * (D / d))), 2.0) * h) / l)));
	} else {
		tmp = w0 * exp((0.5 * fma(-2.0, log(d), log(((-0.25 * (h * ((M * D) * (M * D)))) / l)))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(Float64(M * D) / Float64(2.0 * d)) <= 5e+151)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) * h) / l))));
	else
		tmp = Float64(w0 * exp(Float64(0.5 * fma(-2.0, log(d), log(Float64(Float64(-0.25 * Float64(h * Float64(Float64(M * D) * Float64(M * D)))) / l))))));
	end
	return 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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 5e+151], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Exp[N[(0.5 * N[(-2.0 * N[Log[d], $MachinePrecision] + N[Log[N[(N[(-0.25 * N[(h * N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq 5 \cdot 10^{+151}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}\\

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


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

    1. Initial program 87.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 54.6%

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{e^{\mathsf{log1p}\left({\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot \left(-\frac{h}{\ell}\right)\right) \cdot 0.5}} \]
    5. Taylor expanded in d around 0 22.5%

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

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

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

        \[\leadsto w0 \cdot e^{\mathsf{fma}\left(-2, \log d, \log \color{blue}{\left(\frac{-0.25 \cdot \left({D}^{2} \cdot \left(h \cdot {M}^{2}\right)\right)}{\ell}\right)}\right) \cdot 0.5} \]
      4. *-commutative22.5%

        \[\leadsto w0 \cdot e^{\mathsf{fma}\left(-2, \log d, \log \left(\frac{-0.25 \cdot \left({D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}\right)}{\ell}\right)\right) \cdot 0.5} \]
      5. associate-*r*22.5%

        \[\leadsto w0 \cdot e^{\mathsf{fma}\left(-2, \log d, \log \left(\frac{-0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{\ell}\right)\right) \cdot 0.5} \]
      6. unpow222.5%

        \[\leadsto w0 \cdot e^{\mathsf{fma}\left(-2, \log d, \log \left(\frac{-0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{\ell}\right)\right) \cdot 0.5} \]
      7. unpow222.5%

        \[\leadsto w0 \cdot e^{\mathsf{fma}\left(-2, \log d, \log \left(\frac{-0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{\ell}\right)\right) \cdot 0.5} \]
      8. unswap-sqr26.9%

        \[\leadsto w0 \cdot e^{\mathsf{fma}\left(-2, \log d, \log \left(\frac{-0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{\ell}\right)\right) \cdot 0.5} \]
    7. Simplified26.9%

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

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

Alternative 2: 84.8% accurate, 0.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-48}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d}{M} \cdot \frac{\frac{d}{h}}{M}}}{\frac{\ell}{D}}, w0\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) 5e-48)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ M d) (/ D 2.0)) 2.0)))))
   (fma -0.125 (/ (/ (* D w0) (* (/ d M) (/ (/ d h) M))) (/ l D)) w0)))
M = abs(M);
D = abs(D);
d = abs(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-48) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((M / d) * (D / 2.0)), 2.0))));
	} else {
		tmp = fma(-0.125, (((D * w0) / ((d / M) * ((d / h) / M))) / (l / D)), w0);
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(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-48)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / d) * Float64(D / 2.0)) ^ 2.0)))));
	else
		tmp = fma(-0.125, Float64(Float64(Float64(D * w0) / Float64(Float64(d / M) * Float64(Float64(d / h) / M))) / Float64(l / D)), w0);
	end
	return 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
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-48], 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[(-0.125 * N[(N[(N[(D * w0), $MachinePrecision] / N[(N[(d / M), $MachinePrecision] * N[(N[(d / h), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-48}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d}{M} \cdot \frac{\frac{d}{h}}{M}}}{\frac{\ell}{D}}, w0\right)\\


\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.9999999999999999e-48

    1. Initial program 89.8%

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

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

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

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

    if 4.9999999999999999e-48 < (*.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. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{d} \cdot \frac{w0}{d}\right), w0\right) \]
      12. associate-*l*51.3%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{M \cdot \left(M \cdot h\right)}{d} \cdot \frac{w0}{d}\right), w0\right)} \]
    7. Step-by-step derivation
      1. associate-*l/51.3%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{D \cdot \color{blue}{\frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot w0}{d \cdot d}}}{\frac{\ell}{D}}, w0\right) \]
    8. Applied egg-rr43.9%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{D \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot w0}{d \cdot d}}{\frac{\ell}{D}}}, w0\right) \]
    9. Step-by-step derivation
      1. *-commutative43.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}}{\frac{\ell}{D}}, w0\right) \]
    10. Simplified51.0%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{\frac{D \cdot w0}{\frac{d \cdot d}{M \cdot \left(M \cdot h\right)}}}{\frac{\ell}{D}}}, w0\right) \]
    11. Taylor expanded in d around 0 50.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d}{M} \cdot \color{blue}{\frac{\frac{d}{h}}{M}}}}{\frac{\ell}{D}}, w0\right) \]
    13. Simplified72.8%

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

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

Alternative 3: 85.8% accurate, 1.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}} \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
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (/ (* (pow (* M (* 0.5 (/ D d))) 2.0) h) l)))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - ((pow((M * (0.5 * (D / d))), 2.0) * h) / l)));
}
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
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 * (0.5d0 * (d / d_1))) ** 2.0d0) * h) / l)))
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
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 * (0.5 * (D / d))), 2.0) * h) / l)));
}
M = abs(M)
D = abs(D)
d = abs(d)
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - ((math.pow((M * (0.5 * (D / d))), 2.0) * h) / l)))
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) * h) / l))))
end
M = abs(M)
D = abs(D)
d = abs(d)
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * (0.5 * (D / d))) ^ 2.0) * h) / l)));
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
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
w0 \cdot \sqrt{1 - \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}{\ell}}
\end{array}
Derivation
  1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 79.6% accurate, 1.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-160}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \cdot D \leq 2 \cdot 10^{+130}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{\frac{d \cdot \left(d \cdot \ell\right)}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(M \cdot h\right) \cdot \left(M \cdot \left(\frac{D}{d} \cdot \frac{w0}{d}\right)\right)}{\frac{\ell}{D}}, w0\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (* M D) 1e-160)
   w0
   (if (<= (* M D) 2e+130)
     (* w0 (+ 1.0 (* -0.125 (/ (pow (* M D) 2.0) (/ (* d (* d l)) h)))))
     (fma -0.125 (/ (* (* M h) (* M (* (/ D d) (/ w0 d)))) (/ l D)) w0))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((M * D) <= 1e-160) {
		tmp = w0;
	} else if ((M * D) <= 2e+130) {
		tmp = w0 * (1.0 + (-0.125 * (pow((M * D), 2.0) / ((d * (d * l)) / h))));
	} else {
		tmp = fma(-0.125, (((M * h) * (M * ((D / d) * (w0 / d)))) / (l / D)), w0);
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(M * D) <= 1e-160)
		tmp = w0;
	elseif (Float64(M * D) <= 2e+130)
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64((Float64(M * D) ^ 2.0) / Float64(Float64(d * Float64(d * l)) / h)))));
	else
		tmp = fma(-0.125, Float64(Float64(Float64(M * h) * Float64(M * Float64(Float64(D / d) * Float64(w0 / d)))) / Float64(l / D)), w0);
	end
	return 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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(M * D), $MachinePrecision], 1e-160], w0, If[LessEqual[N[(M * D), $MachinePrecision], 2e+130], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[(N[(M * h), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] * N[(w0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 10^{-160}:\\
\;\;\;\;w0\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(M \cdot h\right) \cdot \left(M \cdot \left(\frac{D}{d} \cdot \frac{w0}{d}\right)\right)}{\frac{\ell}{D}}, w0\right)\\


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

    1. Initial program 86.6%

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

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

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

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

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

    if 9.9999999999999999e-161 < (*.f64 M D) < 2.0000000000000001e130

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(1 + \color{blue}{\left(\frac{D \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)} \cdot -0.125\right) \]
    8. Applied egg-rr59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e130 < (*.f64 M D)

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{d} \cdot \frac{w0}{d}\right), w0\right) \]
      12. associate-*l*54.8%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{M \cdot \left(M \cdot h\right)}{d} \cdot \frac{w0}{d}\right), w0\right)} \]
    7. Step-by-step derivation
      1. associate-*l/58.2%

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

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

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{D \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot w0}{d \cdot d}}{\frac{\ell}{D}}}, w0\right) \]
    9. Taylor expanded in D around 0 52.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-160}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \cdot D \leq 2 \cdot 10^{+130}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{\frac{d \cdot \left(d \cdot \ell\right)}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(M \cdot h\right) \cdot \left(M \cdot \left(\frac{D}{d} \cdot \frac{w0}{d}\right)\right)}{\frac{\ell}{D}}, w0\right)\\ \end{array} \]

Alternative 5: 78.0% accurate, 1.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-160}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d}{M} \cdot \frac{d}{M \cdot h}}}{\frac{\ell}{D}}, w0\right)\\ \mathbf{elif}\;M \cdot D \leq 2 \cdot 10^{+130}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{\frac{d \cdot \left(d \cdot \ell\right)}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(M \cdot h\right) \cdot \left(M \cdot \left(\frac{D}{d} \cdot \frac{w0}{d}\right)\right)}{\frac{\ell}{D}}, w0\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (* M D) 1e-160)
   (fma -0.125 (/ (/ (* D w0) (* (/ d M) (/ d (* M h)))) (/ l D)) w0)
   (if (<= (* M D) 2e+130)
     (* w0 (+ 1.0 (* -0.125 (/ (pow (* M D) 2.0) (/ (* d (* d l)) h)))))
     (fma -0.125 (/ (* (* M h) (* M (* (/ D d) (/ w0 d)))) (/ l D)) w0))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((M * D) <= 1e-160) {
		tmp = fma(-0.125, (((D * w0) / ((d / M) * (d / (M * h)))) / (l / D)), w0);
	} else if ((M * D) <= 2e+130) {
		tmp = w0 * (1.0 + (-0.125 * (pow((M * D), 2.0) / ((d * (d * l)) / h))));
	} else {
		tmp = fma(-0.125, (((M * h) * (M * ((D / d) * (w0 / d)))) / (l / D)), w0);
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(M * D) <= 1e-160)
		tmp = fma(-0.125, Float64(Float64(Float64(D * w0) / Float64(Float64(d / M) * Float64(d / Float64(M * h)))) / Float64(l / D)), w0);
	elseif (Float64(M * D) <= 2e+130)
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64((Float64(M * D) ^ 2.0) / Float64(Float64(d * Float64(d * l)) / h)))));
	else
		tmp = fma(-0.125, Float64(Float64(Float64(M * h) * Float64(M * Float64(Float64(D / d) * Float64(w0 / d)))) / Float64(l / D)), w0);
	end
	return 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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(M * D), $MachinePrecision], 1e-160], N[(-0.125 * N[(N[(N[(D * w0), $MachinePrecision] / N[(N[(d / M), $MachinePrecision] * N[(d / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 2e+130], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[(N[(M * h), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] * N[(w0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 10^{-160}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d}{M} \cdot \frac{d}{M \cdot h}}}{\frac{\ell}{D}}, w0\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(M \cdot h\right) \cdot \left(M \cdot \left(\frac{D}{d} \cdot \frac{w0}{d}\right)\right)}{\frac{\ell}{D}}, w0\right)\\


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

    1. Initial program 86.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{d} \cdot \frac{w0}{d}\right), w0\right) \]
      12. associate-*l*66.5%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{M \cdot \left(M \cdot h\right)}{d} \cdot \frac{w0}{d}\right), w0\right)} \]
    7. Step-by-step derivation
      1. associate-*l/69.7%

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

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

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{D \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot w0}{d \cdot d}}{\frac{\ell}{D}}}, w0\right) \]
    9. Step-by-step derivation
      1. *-commutative61.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}}{\frac{\ell}{D}}, w0\right) \]
    10. Simplified62.0%

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{\frac{D \cdot w0}{\frac{d \cdot d}{M \cdot \left(M \cdot h\right)}}}{\frac{\ell}{D}}}, w0\right) \]
    11. Step-by-step derivation
      1. times-frac75.7%

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

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

    if 9.9999999999999999e-161 < (*.f64 M D) < 2.0000000000000001e130

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(1 + \color{blue}{\left(\frac{D \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)} \cdot -0.125\right) \]
    8. Applied egg-rr59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e130 < (*.f64 M D)

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{d} \cdot \frac{w0}{d}\right), w0\right) \]
      12. associate-*l*54.8%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{D}{\frac{\ell}{D}} \cdot \left(\frac{M \cdot \left(M \cdot h\right)}{d} \cdot \frac{w0}{d}\right), w0\right)} \]
    7. Step-by-step derivation
      1. associate-*l/58.2%

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

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

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{D \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot w0}{d \cdot d}}{\frac{\ell}{D}}}, w0\right) \]
    9. Taylor expanded in D around 0 52.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left(\left(\frac{w0}{d} \cdot \frac{D}{d}\right) \cdot M\right) \cdot \left(h \cdot M\right)}}{\frac{\ell}{D}}, w0\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-160}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\frac{D \cdot w0}{\frac{d}{M} \cdot \frac{d}{M \cdot h}}}{\frac{\ell}{D}}, w0\right)\\ \mathbf{elif}\;M \cdot D \leq 2 \cdot 10^{+130}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{\frac{d \cdot \left(d \cdot \ell\right)}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(M \cdot h\right) \cdot \left(M \cdot \left(\frac{D}{d} \cdot \frac{w0}{d}\right)\right)}{\frac{\ell}{D}}, w0\right)\\ \end{array} \]

Alternative 6: 77.4% accurate, 1.7× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} t_0 := d \cdot \left(d \cdot \ell\right)\\ \mathbf{if}\;M \cdot D \leq 10^{-160}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+102}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{\frac{t_0}{h}}\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(D \cdot \frac{D}{t_0}\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)\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
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* d (* d l))))
   (if (<= (* M D) 1e-160)
     w0
     (if (<= (* M D) 5e+102)
       (* w0 (+ 1.0 (* -0.125 (/ (pow (* M D) 2.0) (/ t_0 h)))))
       (* w0 (+ 1.0 (* -0.125 (* (* D (/ D t_0)) (* M (* M h))))))))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = d * (d * l);
	double tmp;
	if ((M * D) <= 1e-160) {
		tmp = w0;
	} else if ((M * D) <= 5e+102) {
		tmp = w0 * (1.0 + (-0.125 * (pow((M * D), 2.0) / (t_0 / h))));
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / t_0)) * (M * (M * h)))));
	}
	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
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_1 * (d_1 * l)
    if ((m * d) <= 1d-160) then
        tmp = w0
    else if ((m * d) <= 5d+102) then
        tmp = w0 * (1.0d0 + ((-0.125d0) * (((m * d) ** 2.0d0) / (t_0 / h))))
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * ((d * (d / t_0)) * (m * (m * h)))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = d * (d * l);
	double tmp;
	if ((M * D) <= 1e-160) {
		tmp = w0;
	} else if ((M * D) <= 5e+102) {
		tmp = w0 * (1.0 + (-0.125 * (Math.pow((M * D), 2.0) / (t_0 / h))));
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / t_0)) * (M * (M * h)))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
def code(w0, M, D, h, l, d):
	t_0 = d * (d * l)
	tmp = 0
	if (M * D) <= 1e-160:
		tmp = w0
	elif (M * D) <= 5e+102:
		tmp = w0 * (1.0 + (-0.125 * (math.pow((M * D), 2.0) / (t_0 / h))))
	else:
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / t_0)) * (M * (M * h)))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	t_0 = Float64(d * Float64(d * l))
	tmp = 0.0
	if (Float64(M * D) <= 1e-160)
		tmp = w0;
	elseif (Float64(M * D) <= 5e+102)
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64((Float64(M * D) ^ 2.0) / Float64(t_0 / h)))));
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(D * Float64(D / t_0)) * Float64(M * Float64(M * h))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = d * (d * l);
	tmp = 0.0;
	if ((M * D) <= 1e-160)
		tmp = w0;
	elseif ((M * D) <= 5e+102)
		tmp = w0 * (1.0 + (-0.125 * (((M * D) ^ 2.0) / (t_0 / h))));
	else
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / t_0)) * (M * (M * h)))));
	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
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 1e-160], w0, If[LessEqual[N[(M * D), $MachinePrecision], 5e+102], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / N[(t$95$0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(D * N[(D / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(M * N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
t_0 := d \cdot \left(d \cdot \ell\right)\\
\mathbf{if}\;M \cdot D \leq 10^{-160}:\\
\;\;\;\;w0\\

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(D \cdot \frac{D}{t_0}\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)\right)\\


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

    1. Initial program 86.6%

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

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

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

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

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

    if 9.9999999999999999e-161 < (*.f64 M D) < 5e102

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5e102 < (*.f64 M D)

    1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(1 + \color{blue}{\left(\frac{D \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)} \cdot -0.125\right) \]
    8. Applied egg-rr44.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.4% accurate, 9.4× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 2.9 \cdot 10^{-154}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\left(D \cdot \frac{D}{d \cdot \left(d \cdot \ell\right)}\right) \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 2.9e-154)
   w0
   (* w0 (+ 1.0 (* -0.125 (* (* D (/ D (* d (* d l)))) (* M (* M h))))))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 2.9e-154) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / (d * (d * l)))) * (M * (M * h)))));
	}
	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
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 <= 2.9d-154) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * ((d * (d / (d_1 * (d_1 * l)))) * (m * (m * h)))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 2.9e-154) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / (d * (d * l)))) * (M * (M * h)))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 2.9e-154:
		tmp = w0
	else:
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / (d * (d * l)))) * (M * (M * h)))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 2.9e-154)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(D * Float64(D / Float64(d * Float64(d * l)))) * Float64(M * Float64(M * h))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 2.9e-154)
		tmp = w0;
	else
		tmp = w0 * (1.0 + (-0.125 * ((D * (D / (d * (d * l)))) * (M * (M * h)))));
	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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 2.9e-154], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(D * N[(D / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M * N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.9 \cdot 10^{-154}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 87.9%

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

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

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

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

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

    if 2.9e-154 < M

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 62.8% accurate, 10.3× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 4.2 \cdot 10^{+72}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{d}{w0} \cdot \frac{\ell}{h \cdot \left(M \cdot M\right)}}\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 4.2e+72)
   w0
   (* -0.125 (* D (/ (/ D d) (* (/ d w0) (/ l (* h (* M M)))))))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 4.2e+72) {
		tmp = w0;
	} else {
		tmp = -0.125 * (D * ((D / d) / ((d / w0) * (l / (h * (M * M))))));
	}
	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
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 <= 4.2d+72) then
        tmp = w0
    else
        tmp = (-0.125d0) * (d * ((d / d_1) / ((d_1 / w0) * (l / (h * (m * m))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 4.2e+72) {
		tmp = w0;
	} else {
		tmp = -0.125 * (D * ((D / d) / ((d / w0) * (l / (h * (M * M))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 4.2e+72:
		tmp = w0
	else:
		tmp = -0.125 * (D * ((D / d) / ((d / w0) * (l / (h * (M * M))))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 4.2e+72)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64(D * Float64(Float64(D / d) / Float64(Float64(d / w0) * Float64(l / Float64(h * Float64(M * M)))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 4.2e+72)
		tmp = w0;
	else
		tmp = -0.125 * (D * ((D / d) / ((d / w0) * (l / (h * (M * M))))));
	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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 4.2e+72], w0, N[(-0.125 * N[(D * N[(N[(D / d), $MachinePrecision] / N[(N[(d / w0), $MachinePrecision] * N[(l / N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.2 \cdot 10^{+72}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 88.3%

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

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

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

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

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

    if 4.2000000000000003e72 < M

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \color{blue}{\left(\frac{D \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)} \cdot -0.125\right) \]
    9. Taylor expanded in D around inf 18.2%

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

      \[\leadsto \color{blue}{-0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{\frac{w0}{\frac{\frac{\frac{d}{h}}{M}}{M}}}}\right)} \]
    11. Taylor expanded in l around 0 21.9%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{d}{w0} \cdot \frac{\ell}{h \cdot \color{blue}{\left(M \cdot M\right)}}}\right) \]
    13. Simplified24.0%

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

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

Alternative 9: 62.9% accurate, 10.3× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 2.1 \cdot 10^{+74}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{\frac{w0}{d} \cdot \left(h \cdot \left(M \cdot M\right)\right)}}\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 2.1e+74)
   w0
   (* -0.125 (* D (/ (/ D d) (/ l (* (/ w0 d) (* h (* M M)))))))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 2.1e+74) {
		tmp = w0;
	} else {
		tmp = -0.125 * (D * ((D / d) / (l / ((w0 / d) * (h * (M * M))))));
	}
	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
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 <= 2.1d+74) then
        tmp = w0
    else
        tmp = (-0.125d0) * (d * ((d / d_1) / (l / ((w0 / d_1) * (h * (m * m))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 2.1e+74) {
		tmp = w0;
	} else {
		tmp = -0.125 * (D * ((D / d) / (l / ((w0 / d) * (h * (M * M))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 2.1e+74:
		tmp = w0
	else:
		tmp = -0.125 * (D * ((D / d) / (l / ((w0 / d) * (h * (M * M))))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 2.1e+74)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64(D * Float64(Float64(D / d) / Float64(l / Float64(Float64(w0 / d) * Float64(h * Float64(M * M)))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 2.1e+74)
		tmp = w0;
	else
		tmp = -0.125 * (D * ((D / d) / (l / ((w0 / d) * (h * (M * M))))));
	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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 2.1e+74], w0, N[(-0.125 * N[(D * N[(N[(D / d), $MachinePrecision] / N[(l / N[(N[(w0 / d), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.1 \cdot 10^{+74}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 88.3%

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

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

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

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

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

    if 2.0999999999999999e74 < M

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \color{blue}{\left(\frac{D \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)} \cdot -0.125\right) \]
    9. Taylor expanded in D around inf 18.2%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{\frac{w0}{\frac{d}{\color{blue}{\left(M \cdot M\right)} \cdot h}}}}\right) \]
      4. associate-*r*24.6%

        \[\leadsto -0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{\frac{w0}{\frac{d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}}}\right) \]
      5. associate-/r/24.6%

        \[\leadsto -0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{\color{blue}{\frac{w0}{d} \cdot \left(M \cdot \left(M \cdot h\right)\right)}}}\right) \]
      6. associate-*r*24.3%

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

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

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

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

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

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

Alternative 10: 63.1% accurate, 10.3× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 9 \cdot 10^{+72}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{M \cdot \frac{w0}{\frac{d}{M \cdot h}}}}\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
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 9e+72)
   w0
   (* -0.125 (* D (/ (/ D d) (/ l (* M (/ w0 (/ d (* M h))))))))))
M = abs(M);
D = abs(D);
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 9e+72) {
		tmp = w0;
	} else {
		tmp = -0.125 * (D * ((D / d) / (l / (M * (w0 / (d / (M * h)))))));
	}
	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
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 <= 9d+72) then
        tmp = w0
    else
        tmp = (-0.125d0) * (d * ((d / d_1) / (l / (m * (w0 / (d_1 / (m * h)))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 9e+72) {
		tmp = w0;
	} else {
		tmp = -0.125 * (D * ((D / d) / (l / (M * (w0 / (d / (M * h)))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
d = abs(d)
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 9e+72:
		tmp = w0
	else:
		tmp = -0.125 * (D * ((D / d) / (l / (M * (w0 / (d / (M * h)))))))
	return tmp
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 9e+72)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64(D * Float64(Float64(D / d) / Float64(l / Float64(M * Float64(w0 / Float64(d / Float64(M * h))))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
d = abs(d)
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 9e+72)
		tmp = w0;
	else
		tmp = -0.125 * (D * ((D / d) / (l / (M * (w0 / (d / (M * h)))))));
	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
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 9e+72], w0, N[(-0.125 * N[(D * N[(N[(D / d), $MachinePrecision] / N[(l / N[(M * N[(w0 / N[(d / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 9 \cdot 10^{+72}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 88.3%

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

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

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

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

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

    if 8.9999999999999997e72 < M

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \color{blue}{\left(\frac{D \cdot D}{\ell \cdot \left(d \cdot d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)} \cdot -0.125\right) \]
    9. Taylor expanded in D around inf 18.2%

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

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

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

        \[\leadsto -0.125 \cdot \left(D \cdot \frac{\frac{D}{d}}{\frac{\ell}{\frac{w0}{\color{blue}{\frac{d}{M \cdot h}}} \cdot M}}\right) \]
    12. Applied egg-rr24.8%

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

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

Alternative 11: 67.3% accurate, 216.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ d = |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
(FPCore (w0 M D h l d) :precision binary64 w0)
M = abs(M);
D = abs(D);
d = abs(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
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);
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)
def code(w0, M, D, h, l, d):
	return w0
M = abs(M)
D = abs(D)
d = abs(d)
function code(w0, M, D, h, l, d)
	return w0
end
M = abs(M)
D = abs(D)
d = abs(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
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
\\
w0
\end{array}
Derivation
  1. Initial program 84.9%

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

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

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification67.9%

    \[\leadsto w0 \]

Reproduce

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