Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 87.8%
Time: 14.6s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 81.3% accurate, 1.0× speedup?

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

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

Alternative 1: 87.8% accurate, 0.3× speedup?

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

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


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

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999996e296 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 49.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.4% accurate, 0.7× speedup?

\[\begin{array}{l} d = |d|\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0.0001:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
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)) 0.0001)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D 2.0) (/ M d)) 2.0)))))
   w0))
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)) <= 0.0001) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D / 2.0) * (M / d)), 2.0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
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 * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= 0.0001d0) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * (((d / 2.0d0) * (m / d_1)) ** 2.0d0))))
    else
        tmp = w0
    end if
    code = tmp
end function
d = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0001) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((D / 2.0) * (M / d)), 2.0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
d = abs(d)
def code(w0, M, D, h, l, d):
	tmp = 0
	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0001:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((D / 2.0) * (M / d)), 2.0))))
	else:
		tmp = w0
	return tmp
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)) <= 0.0001)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D / 2.0) * Float64(M / d)) ^ 2.0)))));
	else
		tmp = w0;
	end
	return tmp
end
d = abs(d)
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= 0.0001)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((D / 2.0) * (M / d)) ^ 2.0))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
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], 0.0001], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / 2.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0.0001:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\\

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


\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)) < 1.00000000000000005e-4

    1. Initial program 88.2%

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

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

    if 1.00000000000000005e-4 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    1. Initial program 0.0%

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

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

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

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

Alternative 3: 86.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 86.4% accurate, 1.0× speedup?

\[\begin{array}{l} d = |d|\\ \\ w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot h}{\ell}} \end{array} \]
NOTE: d should be positive before calling this function
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M D) d)) 2.0) h) l)))))
d = abs(d);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - ((pow((0.5 * ((M * D) / d)), 2.0) * h) / l)));
}
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 - ((((0.5d0 * ((m * d) / d_1)) ** 2.0d0) * h) / l)))
end function
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((0.5 * ((M * D) / d)), 2.0) * h) / l)));
}
d = abs(d)
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M * D) / d)), 2.0) * h) / l)))
d = abs(d)
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M * D) / d)) ^ 2.0) * h) / l))))
end
d = abs(d)
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((0.5 * ((M * D) / d)) ^ 2.0) * h) / l)));
end
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[(0.5 * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d = |d|\\
\\
w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2} \cdot h}{\ell}}
\end{array}
Derivation
  1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.1% accurate, 1.9× speedup?

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

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

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

    \[\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)} \]
  4. Step-by-step derivation
    1. expm1-log1p-u42.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 73.9% accurate, 8.6× speedup?

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

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


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

    1. Initial program 83.9%

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

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

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

    if 2.40000000000000002e-22 < (*.f64 M D)

    1. Initial program 69.0%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Taylor expanded in D around 0 41.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)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u14.2%

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

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

        \[\leadsto w0 \cdot \left(1 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)} - 1\right)\right) \]
      4. unpow-prod-down24.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 73.9% accurate, 8.6× speedup?

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

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


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

    1. Initial program 83.9%

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

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

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

    if 2.0000000000000001e-22 < (*.f64 M D)

    1. Initial program 69.0%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Taylor expanded in D around 0 41.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)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u14.2%

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

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

        \[\leadsto w0 \cdot \left(1 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)} - 1\right)\right) \]
      4. unpow-prod-down24.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 68.4% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]

Reproduce

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