Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.6% → 87.0%
Time: 17.3s
Alternatives: 5
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 5 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.6% 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.0% accurate, 0.4× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M \cdot D_m}{2 \cdot d_m} \leq 10^{-72}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left({\left(\sqrt[3]{\left(M \cdot 0.5\right) \cdot \frac{D_m}{d_m}}\right)}^{2} \cdot \sqrt[3]{h}\right)}^{3}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{D_m}{2} \cdot \frac{M}{d_m}\right)}^{2} \cdot \frac{h}{\ell}}\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d_m)
 :precision binary64
 (if (<= (/ (* M D_m) (* 2.0 d_m)) 1e-72)
   (*
    w0
    (sqrt
     (-
      1.0
      (/
       (pow (* (pow (cbrt (* (* M 0.5) (/ D_m d_m))) 2.0) (cbrt h)) 3.0)
       l))))
   (* w0 (sqrt (- 1.0 (* (pow (* (/ D_m 2.0) (/ M d_m)) 2.0) (/ h l)))))))
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
	double tmp;
	if (((M * D_m) / (2.0 * d_m)) <= 1e-72) {
		tmp = w0 * sqrt((1.0 - (pow((pow(cbrt(((M * 0.5) * (D_m / d_m))), 2.0) * cbrt(h)), 3.0) / l)));
	} else {
		tmp = w0 * sqrt((1.0 - (pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l))));
	}
	return tmp;
}
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
	double tmp;
	if (((M * D_m) / (2.0 * d_m)) <= 1e-72) {
		tmp = w0 * Math.sqrt((1.0 - (Math.pow((Math.pow(Math.cbrt(((M * 0.5) * (D_m / d_m))), 2.0) * Math.cbrt(h)), 3.0) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (Math.pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l))));
	}
	return tmp;
}
D_m = abs(D)
d_m = abs(d)
w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m])
function code(w0, M, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64(Float64(M * D_m) / Float64(2.0 * d_m)) <= 1e-72)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64((cbrt(Float64(Float64(M * 0.5) * Float64(D_m / d_m))) ^ 2.0) * cbrt(h)) ^ 3.0) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(D_m / 2.0) * Float64(M / d_m)) ^ 2.0) * Float64(h / l)))));
	end
	return tmp
end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e-72], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[Power[N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[h, 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M \cdot D_m}{2 \cdot d_m} \leq 10^{-72}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left({\left(\sqrt[3]{\left(M \cdot 0.5\right) \cdot \frac{D_m}{d_m}}\right)}^{2} \cdot \sqrt[3]{h}\right)}^{3}}{\ell}}\\

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


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

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999997e-73 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 69.9%

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

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

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

Alternative 2: 85.9% accurate, 1.0× speedup?

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

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


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

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999997e-73 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 69.9%

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

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

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

Alternative 3: 85.1% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\ \\ w0 \cdot \sqrt{1 + \frac{\left(h \cdot {\left(M \cdot \frac{D_m}{d_m}\right)}^{2}\right) \cdot -0.25}{\ell}} \end{array} \]
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d_m)
 :precision binary64
 (* w0 (sqrt (+ 1.0 (/ (* (* h (pow (* M (/ D_m d_m)) 2.0)) -0.25) l)))))
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
	return w0 * sqrt((1.0 + (((h * pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)));
}
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    code = w0 * sqrt((1.0d0 + (((h * ((m * (d_m / d_m_1)) ** 2.0d0)) * (-0.25d0)) / l)))
end function
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
	return w0 * Math.sqrt((1.0 + (((h * Math.pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)));
}
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m])
def code(w0, M, D_m, h, l, d_m):
	return w0 * math.sqrt((1.0 + (((h * math.pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)))
D_m = abs(D)
d_m = abs(d)
w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m])
function code(w0, M, D_m, h, l, d_m)
	return Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * (Float64(M * Float64(D_m / d_m)) ^ 2.0)) * -0.25) / l))))
end
D_m = abs(D);
d_m = abs(d);
w0, M, D_m, h, l, d_m = num2cell(sort([w0, M, D_m, h, l, d_m])){:}
function tmp = code(w0, M, D_m, h, l, d_m)
	tmp = w0 * sqrt((1.0 + (((h * ((M * (D_m / d_m)) ^ 2.0)) * -0.25) / l)));
end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[Power[N[(M * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
w0 \cdot \sqrt{1 + \frac{\left(h \cdot {\left(M \cdot \frac{D_m}{d_m}\right)}^{2}\right) \cdot -0.25}{\ell}}
\end{array}
Derivation
  1. Initial program 81.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 68.4% accurate, 1.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 2.05 \cdot 10^{-17}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)\\ \end{array} \end{array} \]
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d_m)
 :precision binary64
 (if (<= M 2.05e-17) w0 (log1p (expm1 w0))))
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M <= 2.05e-17) {
		tmp = w0;
	} else {
		tmp = log1p(expm1(w0));
	}
	return tmp;
}
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M <= 2.05e-17) {
		tmp = w0;
	} else {
		tmp = Math.log1p(Math.expm1(w0));
	}
	return tmp;
}
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m])
def code(w0, M, D_m, h, l, d_m):
	tmp = 0
	if M <= 2.05e-17:
		tmp = w0
	else:
		tmp = math.log1p(math.expm1(w0))
	return tmp
D_m = abs(D)
d_m = abs(d)
w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m])
function code(w0, M, D_m, h, l, d_m)
	tmp = 0.0
	if (M <= 2.05e-17)
		tmp = w0;
	else
		tmp = log1p(expm1(w0));
	end
	return tmp
end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[M, 2.05e-17], w0, N[Log[1 + N[(Exp[w0] - 1), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.05 \cdot 10^{-17}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)\\


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

    1. Initial program 82.7%

      \[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. Add Preprocessing
    4. Taylor expanded in D around 0 73.7%

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

    if 2.05e-17 < M

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{w0} \]
      4. log1p-expm1-u37.6%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)} \]
    8. Applied egg-rr37.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.05 \cdot 10^{-17}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 66.7% accurate, 216.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\ \\ w0 \end{array} \]
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d_m) :precision binary64 w0)
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
	return w0;
}
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    code = w0
end function
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
	return w0;
}
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m])
def code(w0, M, D_m, h, l, d_m):
	return w0
D_m = abs(D)
d_m = abs(d)
w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m])
function code(w0, M, D_m, h, l, d_m)
	return w0
end
D_m = abs(D);
d_m = abs(d);
w0, M, D_m, h, l, d_m = num2cell(sort([w0, M, D_m, h, l, d_m])){:}
function tmp = code(w0, M, D_m, h, l, d_m)
	tmp = w0;
end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := w0
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
w0
\end{array}
Derivation
  1. Initial program 81.5%

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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