Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.7% → 87.7%
Time: 19.0s
Alternatives: 8
Speedup: 0.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 81.7% accurate, 1.0× speedup?

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

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

Alternative 1: 87.7% accurate, 0.3× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := {\left(M \cdot D\right)}^{2}\\ t_1 := {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot t\_0}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{2}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-39}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t\_1}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{t\_0}{\ell} \cdot \frac{h}{{d\_m}^{2}}\right)}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (w0 M D h l d_m)
 :precision binary64
 (let* ((t_0 (pow (* M D) 2.0))
        (t_1 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l))))
   (if (<= t_1 (- INFINITY))
     (*
      w0
      (pow
       (pow (exp 0.25) (+ (log (* -0.25 (/ (* h t_0) l))) (* -2.0 (log d_m))))
       2.0))
     (if (<= t_1 5e-39)
       (* w0 (sqrt (- 1.0 t_1)))
       (* w0 (sqrt (- 1.0 (* 0.25 (* (/ t_0 l) (/ h (pow d_m 2.0)))))))))))
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
	double t_0 = pow((M * D), 2.0);
	double t_1 = pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = w0 * pow(pow(exp(0.25), (log((-0.25 * ((h * t_0) / l))) + (-2.0 * log(d_m)))), 2.0);
	} else if (t_1 <= 5e-39) {
		tmp = w0 * sqrt((1.0 - t_1));
	} else {
		tmp = w0 * sqrt((1.0 - (0.25 * ((t_0 / l) * (h / pow(d_m, 2.0))))));
	}
	return tmp;
}
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	double t_0 = Math.pow((M * D), 2.0);
	double t_1 = Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.pow(Math.pow(Math.exp(0.25), (Math.log((-0.25 * ((h * t_0) / l))) + (-2.0 * Math.log(d_m)))), 2.0);
	} else if (t_1 <= 5e-39) {
		tmp = w0 * Math.sqrt((1.0 - t_1));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (0.25 * ((t_0 / l) * (h / Math.pow(d_m, 2.0))))));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(w0, M, D, h, l, d_m):
	t_0 = math.pow((M * D), 2.0)
	t_1 = math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = w0 * math.pow(math.pow(math.exp(0.25), (math.log((-0.25 * ((h * t_0) / l))) + (-2.0 * math.log(d_m)))), 2.0)
	elif t_1 <= 5e-39:
		tmp = w0 * math.sqrt((1.0 - t_1))
	else:
		tmp = w0 * math.sqrt((1.0 - (0.25 * ((t_0 / l) * (h / math.pow(d_m, 2.0))))))
	return tmp
d_m = abs(d)
function code(w0, M, D, h, l, d_m)
	t_0 = Float64(M * D) ^ 2.0
	t_1 = Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(w0 * ((exp(0.25) ^ Float64(log(Float64(-0.25 * Float64(Float64(h * t_0) / l))) + Float64(-2.0 * log(d_m)))) ^ 2.0));
	elseif (t_1 <= 5e-39)
		tmp = Float64(w0 * sqrt(Float64(1.0 - t_1)));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(t_0 / l) * Float64(h / (d_m ^ 2.0)))))));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(w0, M, D, h, l, d_m)
	t_0 = (M * D) ^ 2.0;
	t_1 = (((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = w0 * ((exp(0.25) ^ (log((-0.25 * ((h * t_0) / l))) + (-2.0 * log(d_m)))) ^ 2.0);
	elseif (t_1 <= 5e-39)
		tmp = w0 * sqrt((1.0 - t_1));
	else
		tmp = w0 * sqrt((1.0 - (0.25 * ((t_0 / l) * (h / (d_m ^ 2.0))))));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-39], N[(w0 * N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(t$95$0 / l), $MachinePrecision] * N[(h / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := {\left(M \cdot D\right)}^{2}\\
t_1 := {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot t\_0}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{2}\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-39}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_1}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{t\_0}{\ell} \cdot \frac{h}{{d\_m}^{2}}\right)}\\


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

    1. Initial program 54.3%

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

      \[\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 49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{w0 \cdot {\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}} \]
    9. Step-by-step derivation
      1. exp-prod34.7%

        \[\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. associate-*r*34.7%

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 4.9999999999999998e-39

    1. Initial program 99.9%

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

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

    1. Initial program 3.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified7.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 51.5%

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

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

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

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

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

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

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

Alternative 2: 86.9% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d\_m}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (w0 M D h l d_m)
 :precision binary64
 (if (<=
      (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l)))))
      INFINITY)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D 2.0) (/ M d_m)) 2.0)))))
   w0))
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
	double tmp;
	if ((w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l))))) <= ((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D / 2.0) * (M / d_m)), 2.0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	double tmp;
	if ((w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l))))) <= Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((D / 2.0) * (M / d_m)), 2.0))));
	} else {
		tmp = w0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(w0, M, D, h, l, d_m):
	tmp = 0
	if (w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l))))) <= math.inf:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((D / 2.0) * (M / d_m)), 2.0))))
	else:
		tmp = w0
	return tmp
d_m = abs(d)
function code(w0, M, D, h, l, d_m)
	tmp = 0.0
	if (Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))))) <= Inf)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D / 2.0) * Float64(M / d_m)) ^ 2.0)))));
	else
		tmp = w0;
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(w0, M, D, h, l, d_m)
	tmp = 0.0;
	if ((w0 * sqrt((1.0 - ((((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l))))) <= Inf)
		tmp = w0 * sqrt((1.0 - ((h / l) * (((D / 2.0) * (M / d_m)) ^ 2.0))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M_, D_, h_, l_, d$95$m_] := If[LessEqual[N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / 2.0), $MachinePrecision] * N[(M / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d\_m}\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) < +inf.0

    1. Initial program 88.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified87.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

    if +inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.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. Simplified4.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. Taylor expanded in D around 0 68.9%

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

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

Alternative 3: 85.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := 1 - {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+257}:\\
\;\;\;\;w0 \cdot \sqrt{t\_0}\\

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


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

    1. Initial program 99.9%

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

    if 5.00000000000000028e257 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))

    1. Initial program 39.7%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified42.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. Taylor expanded in D around 0 48.5%

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

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

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

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

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

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

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

Alternative 4: 87.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-309}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -1.9999999999999988e-309

    1. Initial program 79.5%

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

      \[\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. *-commutative80.4%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999988e-309 < h

    1. Initial program 79.4%

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

      \[\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. *-commutative77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-309}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -1.9999999999999988e-309

    1. Initial program 79.5%

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

      \[\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. *-commutative80.4%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999988e-309 < h

    1. Initial program 79.4%

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

      \[\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. *-commutative77.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 70.1% accurate, 1.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;D \leq 8 \cdot 10^{+16} \lor \neg \left(D \leq 8 \cdot 10^{+114}\right) \land D \leq 2.4 \cdot 10^{+203}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 + w0 \cdot \left(-0.125 \cdot \left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell} \cdot \left(h \cdot {d\_m}^{-2}\right)\right)\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (w0 M D h l d_m)
 :precision binary64
 (if (or (<= D 8e+16) (and (not (<= D 8e+114)) (<= D 2.4e+203)))
   w0
   (+
    w0
    (* w0 (* -0.125 (* (/ (* (* M D) (* M D)) l) (* h (pow d_m -2.0))))))))
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
	double tmp;
	if ((D <= 8e+16) || (!(D <= 8e+114) && (D <= 2.4e+203))) {
		tmp = w0;
	} else {
		tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * pow(d_m, -2.0)))));
	}
	return tmp;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
    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_m
    real(8) :: tmp
    if ((d <= 8d+16) .or. (.not. (d <= 8d+114)) .and. (d <= 2.4d+203)) then
        tmp = w0
    else
        tmp = w0 + (w0 * ((-0.125d0) * ((((m * d) * (m * d)) / l) * (h * (d_m ** (-2.0d0))))))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
	double tmp;
	if ((D <= 8e+16) || (!(D <= 8e+114) && (D <= 2.4e+203))) {
		tmp = w0;
	} else {
		tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * Math.pow(d_m, -2.0)))));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(w0, M, D, h, l, d_m):
	tmp = 0
	if (D <= 8e+16) or (not (D <= 8e+114) and (D <= 2.4e+203)):
		tmp = w0
	else:
		tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * math.pow(d_m, -2.0)))))
	return tmp
d_m = abs(d)
function code(w0, M, D, h, l, d_m)
	tmp = 0.0
	if ((D <= 8e+16) || (!(D <= 8e+114) && (D <= 2.4e+203)))
		tmp = w0;
	else
		tmp = Float64(w0 + Float64(w0 * Float64(-0.125 * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) / l) * Float64(h * (d_m ^ -2.0))))));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(w0, M, D, h, l, d_m)
	tmp = 0.0;
	if ((D <= 8e+16) || (~((D <= 8e+114)) && (D <= 2.4e+203)))
		tmp = w0;
	else
		tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * (d_m ^ -2.0)))));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M_, D_, h_, l_, d$95$m_] := If[Or[LessEqual[D, 8e+16], And[N[Not[LessEqual[D, 8e+114]], $MachinePrecision], LessEqual[D, 2.4e+203]]], w0, N[(w0 + N[(w0 * N[(-0.125 * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(h * N[Power[d$95$m, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;D \leq 8 \cdot 10^{+16} \lor \neg \left(D \leq 8 \cdot 10^{+114}\right) \land D \leq 2.4 \cdot 10^{+203}:\\
\;\;\;\;w0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 8e16 or 8e114 < D < 2.4000000000000001e203

    1. Initial program 79.6%

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

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

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

    if 8e16 < D < 8e114 or 2.4000000000000001e203 < D

    1. Initial program 78.6%

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

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

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 8 \cdot 10^{+16} \lor \neg \left(D \leq 8 \cdot 10^{+114}\right) \land D \leq 2.4 \cdot 10^{+203}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 + w0 \cdot \left(-0.125 \cdot \left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell} \cdot \left(h \cdot {d}^{-2}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 65.7% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.05 \cdot 10^{+75}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 79.5%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified79.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. Taylor expanded in D around 0 70.5%

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

    if 1.04999999999999999e75 < M

    1. Initial program 79.7%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified79.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 32.7%

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative32.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 68.5% accurate, 216.0× speedup?

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

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

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

    \[\leadsto \color{blue}{w0 \cdot \sqrt{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 67.8%

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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