Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.7% → 86.8%
Time: 17.8s
Alternatives: 7
Speedup: 1.8×

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 7 alternatives:

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

Initial Program: 80.7% accurate, 1.0× speedup?

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

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

Alternative 1: 86.8% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := D \cdot \frac{M\_m}{d}\\ \mathbf{if}\;M\_m \leq 1.35 \cdot 10^{-239}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(0.125, h \cdot \frac{t\_0 \cdot t\_0}{-\ell}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(M\_m \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \left(\left(M\_m \cdot 0.5\right) \cdot \frac{\frac{D}{d}}{\ell}\right)\right)}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d)
 :precision binary64
 (let* ((t_0 (* D (/ M_m d))))
   (if (<= M_m 1.35e-239)
     (* w0 (fma 0.125 (* h (/ (* t_0 t_0) (- l))) 1.0))
     (*
      w0
      (sqrt
       (-
        1.0
        (* h (* (* (* M_m 0.5) (/ D d)) (* (* M_m 0.5) (/ (/ D d) l))))))))))
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	double t_0 = D * (M_m / d);
	double tmp;
	if (M_m <= 1.35e-239) {
		tmp = w0 * fma(0.125, (h * ((t_0 * t_0) / -l)), 1.0);
	} else {
		tmp = w0 * sqrt((1.0 - (h * (((M_m * 0.5) * (D / d)) * ((M_m * 0.5) * ((D / d) / l))))));
	}
	return tmp;
}
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	t_0 = Float64(D * Float64(M_m / d))
	tmp = 0.0
	if (M_m <= 1.35e-239)
		tmp = Float64(w0 * fma(0.125, Float64(h * Float64(Float64(t_0 * t_0) / Float64(-l))), 1.0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(Float64(Float64(M_m * 0.5) * Float64(D / d)) * Float64(Float64(M_m * 0.5) * Float64(Float64(D / d) / l)))))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 1.35e-239], N[(w0 * N[(0.125 * N[(h * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / (-l)), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := D \cdot \frac{M\_m}{d}\\
\mathbf{if}\;M\_m \leq 1.35 \cdot 10^{-239}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(0.125, h \cdot \frac{t\_0 \cdot t\_0}{-\ell}, 1\right)\\

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


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

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35e-239 < M

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.0% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D \cdot \frac{M\_m}{2 \cdot d}\right)}^{2}}{\ell}} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* h (/ (pow (* D (/ M_m (* 2.0 d))) 2.0) l))))))
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (h * (pow((D * (M_m / (2.0 * d))), 2.0) / l))));
}
M_m = abs(m)
real(8) function code(w0, m_m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_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 - (h * (((d * (m_m / (2.0d0 * d_1))) ** 2.0d0) / l))))
end function
M_m = Math.abs(M);
public static double code(double w0, double M_m, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (h * (Math.pow((D * (M_m / (2.0 * d))), 2.0) / l))));
}
M_m = math.fabs(M)
def code(w0, M_m, D, h, l, d):
	return w0 * math.sqrt((1.0 - (h * (math.pow((D * (M_m / (2.0 * d))), 2.0) / l))))
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D * Float64(M_m / Float64(2.0 * d))) ^ 2.0) / l)))))
end
M_m = abs(M);
function tmp = code(w0, M_m, D, h, l, d)
	tmp = w0 * sqrt((1.0 - (h * (((D * (M_m / (2.0 * d))) ^ 2.0) / l))));
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D * N[(M$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|

\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D \cdot \frac{M\_m}{2 \cdot d}\right)}^{2}}{\ell}}
\end{array}
Derivation
  1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 78.5% accurate, 1.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := D \cdot \frac{M\_m}{d}\\ \mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-313}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \left(t\_0 \cdot t\_0\right) \cdot \frac{h}{\ell}, 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d)
 :precision binary64
 (let* ((t_0 (* D (/ M_m d))))
   (if (<= (/ h l) -2e-313)
     (* w0 (fma -0.125 (* (* t_0 t_0) (/ h l)) 1.0))
     w0)))
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	double t_0 = D * (M_m / d);
	double tmp;
	if ((h / l) <= -2e-313) {
		tmp = w0 * fma(-0.125, ((t_0 * t_0) * (h / l)), 1.0);
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	t_0 = Float64(D * Float64(M_m / d))
	tmp = 0.0
	if (Float64(h / l) <= -2e-313)
		tmp = Float64(w0 * fma(-0.125, Float64(Float64(t_0 * t_0) * Float64(h / l)), 1.0));
	else
		tmp = w0;
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], -2e-313], N[(w0 * N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := D \cdot \frac{M\_m}{d}\\
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-313}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \left(t\_0 \cdot t\_0\right) \cdot \frac{h}{\ell}, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 h l) < -1.99999999998e-313

    1. Initial program 79.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999998e-313 < (/.f64 h l)

    1. Initial program 84.2%

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

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

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

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

Alternative 4: 88.1% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := \left(M\_m \cdot 0.5\right) \cdot \frac{D}{d}\\ w0 \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)} \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d)
 :precision binary64
 (let* ((t_0 (* (* M_m 0.5) (/ D d))))
   (* w0 (sqrt (- 1.0 (* h (* t_0 (/ t_0 l))))))))
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	double t_0 = (M_m * 0.5) * (D / d);
	return w0 * sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
}
M_m = abs(m)
real(8) function code(w0, m_m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_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
    t_0 = (m_m * 0.5d0) * (d / d_1)
    code = w0 * sqrt((1.0d0 - (h * (t_0 * (t_0 / l)))))
end function
M_m = Math.abs(M);
public static double code(double w0, double M_m, double D, double h, double l, double d) {
	double t_0 = (M_m * 0.5) * (D / d);
	return w0 * Math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
}
M_m = math.fabs(M)
def code(w0, M_m, D, h, l, d):
	t_0 = (M_m * 0.5) * (D / d)
	return w0 * math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))))
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	t_0 = Float64(Float64(M_m * 0.5) * Float64(D / d))
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l))))))
end
M_m = abs(M);
function tmp = code(w0, M_m, D, h, l, d)
	t_0 = (M_m * 0.5) * (D / d);
	tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := \left(M\_m \cdot 0.5\right) \cdot \frac{D}{d}\\
w0 \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.3% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := D \cdot \frac{M\_m}{d}\\ w0 \cdot \mathsf{fma}\left(0.125, h \cdot \frac{t\_0 \cdot t\_0}{-\ell}, 1\right) \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d)
 :precision binary64
 (let* ((t_0 (* D (/ M_m d))))
   (* w0 (fma 0.125 (* h (/ (* t_0 t_0) (- l))) 1.0))))
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	double t_0 = D * (M_m / d);
	return w0 * fma(0.125, (h * ((t_0 * t_0) / -l)), 1.0);
}
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	t_0 = Float64(D * Float64(M_m / d))
	return Float64(w0 * fma(0.125, Float64(h * Float64(Float64(t_0 * t_0) / Float64(-l))), 1.0))
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[(0.125 * N[(h * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / (-l)), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := D \cdot \frac{M\_m}{d}\\
w0 \cdot \mathsf{fma}\left(0.125, h \cdot \frac{t\_0 \cdot t\_0}{-\ell}, 1\right)
\end{array}
\end{array}
Derivation
  1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \mathsf{fma}\left(0.125, h \cdot \frac{\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)}{-\ell}, 1\right) \]
  16. Add Preprocessing

Alternative 6: 62.4% accurate, 1.8× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 9.8 \cdot 10^{+51}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \left({\left(M\_m \cdot \frac{D}{d}\right)}^{2} \cdot \frac{w0 \cdot h}{\ell}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d)
 :precision binary64
 (if (<= M_m 9.8e+51)
   w0
   (* -0.125 (* (pow (* M_m (/ D d)) 2.0) (/ (* w0 h) l)))))
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	double tmp;
	if (M_m <= 9.8e+51) {
		tmp = w0;
	} else {
		tmp = -0.125 * (pow((M_m * (D / d)), 2.0) * ((w0 * h) / l));
	}
	return tmp;
}
M_m = abs(m)
real(8) function code(w0, m_m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_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_m <= 9.8d+51) then
        tmp = w0
    else
        tmp = (-0.125d0) * (((m_m * (d / d_1)) ** 2.0d0) * ((w0 * h) / l))
    end if
    code = tmp
end function
M_m = Math.abs(M);
public static double code(double w0, double M_m, double D, double h, double l, double d) {
	double tmp;
	if (M_m <= 9.8e+51) {
		tmp = w0;
	} else {
		tmp = -0.125 * (Math.pow((M_m * (D / d)), 2.0) * ((w0 * h) / l));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(w0, M_m, D, h, l, d):
	tmp = 0
	if M_m <= 9.8e+51:
		tmp = w0
	else:
		tmp = -0.125 * (math.pow((M_m * (D / d)), 2.0) * ((w0 * h) / l))
	return tmp
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	tmp = 0.0
	if (M_m <= 9.8e+51)
		tmp = w0;
	else
		tmp = Float64(-0.125 * Float64((Float64(M_m * Float64(D / d)) ^ 2.0) * Float64(Float64(w0 * h) / l)));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(w0, M_m, D, h, l, d)
	tmp = 0.0;
	if (M_m <= 9.8e+51)
		tmp = w0;
	else
		tmp = -0.125 * (((M_m * (D / d)) ^ 2.0) * ((w0 * h) / l));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[M$95$m, 9.8e+51], w0, N[(-0.125 * N[(N[Power[N[(M$95$m * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 9.8 \cdot 10^{+51}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 83.1%

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

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

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

    if 9.79999999999999967e51 < M

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 67.2% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ w0 \end{array} \]
M_m = (fabs.f64 M)
(FPCore (w0 M_m D h l d) :precision binary64 w0)
M_m = fabs(M);
double code(double w0, double M_m, double D, double h, double l, double d) {
	return w0;
}
M_m = abs(m)
real(8) function code(w0, m_m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_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_m = Math.abs(M);
public static double code(double w0, double M_m, double D, double h, double l, double d) {
	return w0;
}
M_m = math.fabs(M)
def code(w0, M_m, D, h, l, d):
	return w0
M_m = abs(M)
function code(w0, M_m, D, h, l, d)
	return w0
end
M_m = abs(M);
function tmp = code(w0, M_m, D, h, l, d)
	tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision]
code[w0_, M$95$m_, D_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|

\\
w0
\end{array}
Derivation
  1. Initial program 81.8%

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification70.7%

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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