Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.1% → 89.8%
Time: 17.6s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 81.1% 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: 89.8% accurate, 0.3× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ \begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(0.25 \cdot \frac{{\left(M \cdot D\right)}^{2} \cdot \left(-h\right)}{\ell}\right) + -2 \cdot \log d_m\right)}\right)}^{2}\\ \mathbf{elif}\;t_0 \leq 10^{-6}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - t_0}\\ \mathbf{else}:\\ \;\;\;\;w0_m\\ \end{array} \end{array} \end{array} \]
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
 :precision binary64
 (let* ((t_0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l))))
   (*
    w0_s
    (if (<= t_0 (- INFINITY))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (log (* 0.25 (/ (* (pow (* M D) 2.0) (- h)) l)))
           (* -2.0 (log d_m))))))
       2.0)
      (if (<= t_0 1e-6) (* w0_m (sqrt (- 1.0 t_0))) w0_m)))))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	double t_0 = pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = pow((sqrt(w0_m) * exp((0.25 * (log((0.25 * ((pow((M * D), 2.0) * -h) / l))) + (-2.0 * log(d_m)))))), 2.0);
	} else if (t_0 <= 1e-6) {
		tmp = w0_m * sqrt((1.0 - t_0));
	} else {
		tmp = w0_m;
	}
	return w0_s * tmp;
}
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	double t_0 = Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * (Math.log((0.25 * ((Math.pow((M * D), 2.0) * -h) / l))) + (-2.0 * Math.log(d_m)))))), 2.0);
	} else if (t_0 <= 1e-6) {
		tmp = w0_m * Math.sqrt((1.0 - t_0));
	} else {
		tmp = w0_m;
	}
	return w0_s * tmp;
}
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
def code(w0_s, w0_m, M, D, h, l, d_m):
	t_0 = math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * (math.log((0.25 * ((math.pow((M * D), 2.0) * -h) / l))) + (-2.0 * math.log(d_m)))))), 2.0)
	elif t_0 <= 1e-6:
		tmp = w0_m * math.sqrt((1.0 - t_0))
	else:
		tmp = w0_m
	return w0_s * tmp
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
function code(w0_s, w0_m, M, D, h, l, d_m)
	t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(log(Float64(0.25 * Float64(Float64((Float64(M * D) ^ 2.0) * Float64(-h)) / l))) + Float64(-2.0 * log(d_m)))))) ^ 2.0;
	elseif (t_0 <= 1e-6)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - t_0)));
	else
		tmp = w0_m;
	end
	return Float64(w0_s * tmp)
end
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m)
	t_0 = (((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (sqrt(w0_m) * exp((0.25 * (log((0.25 * ((((M * D) ^ 2.0) * -h) / l))) + (-2.0 * log(d_m)))))) ^ 2.0;
	elseif (t_0 <= 1e-6)
		tmp = w0_m * sqrt((1.0 - t_0));
	else
		tmp = w0_m;
	end
	tmp_2 = w0_s * tmp;
end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$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]}, N[(w0$95$s * If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[Log[N[(0.25 * N[(N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] * (-h)), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$0, 1e-6], N[(w0$95$m * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0$95$m]]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)

\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(0.25 \cdot \frac{{\left(M \cdot D\right)}^{2} \cdot \left(-h\right)}{\ell}\right) + -2 \cdot \log d_m\right)}\right)}^{2}\\

\mathbf{elif}\;t_0 \leq 10^{-6}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - t_0}\\

\mathbf{else}:\\
\;\;\;\;w0_m\\


\end{array}
\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 60.7%

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot 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} \]
    6. Step-by-step derivation
      1. expm1-log1p-u10.4%

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

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

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

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

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

        \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(D \cdot M\right)}^{2} \cdot h\right)\right)}}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      2. expm1-log1p19.0%

        \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \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} \]
      3. *-commutative19.0%

        \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \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} \]
    9. Simplified19.0%

      \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \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} \]

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

    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 9.99999999999999955e-7 < (*.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. Simplified28.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\log \left(0.25 \cdot \frac{{\left(M \cdot D\right)}^{2} \cdot \left(-h\right)}{\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 10^{-6}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 89.7% accurate, 0.3× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ \begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\ w0_s \cdot \begin{array}{l} \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot D\right)}^{2}\right)\right)\right)}\right)}^{2}\\ \mathbf{elif}\;t_0 \leq 10^{-6}:\\ \;\;\;\;w0_m \cdot \sqrt{1 - t_0}\\ \mathbf{else}:\\ \;\;\;\;w0_m\\ \end{array} \end{array} \end{array} \]
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
 :precision binary64
 (let* ((t_0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l))))
   (*
    w0_s
    (if (<= t_0 (- INFINITY))
      (pow
       (*
        (sqrt w0_m)
        (exp
         (*
          0.25
          (+
           (* -2.0 (log d_m))
           (log (* -0.25 (* (/ h l) (pow (* M D) 2.0))))))))
       2.0)
      (if (<= t_0 1e-6) (* w0_m (sqrt (- 1.0 t_0))) w0_m)))))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	double t_0 = pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = pow((sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + log((-0.25 * ((h / l) * pow((M * D), 2.0)))))))), 2.0);
	} else if (t_0 <= 1e-6) {
		tmp = w0_m * sqrt((1.0 - t_0));
	} else {
		tmp = w0_m;
	}
	return w0_s * tmp;
}
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	double t_0 = Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * ((-2.0 * Math.log(d_m)) + Math.log((-0.25 * ((h / l) * Math.pow((M * D), 2.0)))))))), 2.0);
	} else if (t_0 <= 1e-6) {
		tmp = w0_m * Math.sqrt((1.0 - t_0));
	} else {
		tmp = w0_m;
	}
	return w0_s * tmp;
}
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
def code(w0_s, w0_m, M, D, h, l, d_m):
	t_0 = math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * ((-2.0 * math.log(d_m)) + math.log((-0.25 * ((h / l) * math.pow((M * D), 2.0)))))))), 2.0)
	elif t_0 <= 1e-6:
		tmp = w0_m * math.sqrt((1.0 - t_0))
	else:
		tmp = w0_m
	return w0_s * tmp
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
function code(w0_s, w0_m, M, D, h, l, d_m)
	t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(Float64(-2.0 * log(d_m)) + log(Float64(-0.25 * Float64(Float64(h / l) * (Float64(M * D) ^ 2.0)))))))) ^ 2.0;
	elseif (t_0 <= 1e-6)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - t_0)));
	else
		tmp = w0_m;
	end
	return Float64(w0_s * tmp)
end
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m)
	t_0 = (((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + log((-0.25 * ((h / l) * ((M * D) ^ 2.0)))))))) ^ 2.0;
	elseif (t_0 <= 1e-6)
		tmp = w0_m * sqrt((1.0 - t_0));
	else
		tmp = w0_m;
	end
	tmp_2 = w0_s * tmp;
end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$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]}, N[(w0$95$s * If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$0, 1e-6], N[(w0$95$m * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0$95$m]]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)

\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot D\right)}^{2}\right)\right)\right)}\right)}^{2}\\

\mathbf{elif}\;t_0 \leq 10^{-6}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - t_0}\\

\mathbf{else}:\\
\;\;\;\;w0_m\\


\end{array}
\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 60.7%

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot 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} \]
    6. Taylor expanded in l around 0 6.1%

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

      \[\leadsto {\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\color{blue}{\log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot M\right)}^{2}\right)\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)) < 9.99999999999999955e-7

    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 9.99999999999999955e-7 < (*.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. Simplified28.6%

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

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

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

Alternative 3: 86.3% accurate, 0.7× speedup?

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

\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq 10^{-6}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{2 \cdot d_m}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;w0_m\\


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

    1. Initial program 88.9%

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

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

    if 9.99999999999999955e-7 < (*.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. Simplified28.6%

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

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

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

Alternative 4: 87.3% accurate, 0.7× speedup?

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

\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d_m}\right)\right)}^{2}}{\ell}}\\

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\ \;\;\;\;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(\frac{D \cdot 0.5}{\frac{d}{M}} \cdot \sqrt{h}\right)}^{2}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 80.7% accurate, 1.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ w0_s \cdot \left(w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d_m}\right)}^{2}}\right) \end{array} \]
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
 :precision binary64
 (*
  w0_s
  (* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* (/ M 2.0) (/ D d_m)) 2.0)))))))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	return w0_s * (w0_m * sqrt((1.0 - ((h / l) * pow(((M / 2.0) * (D / d_m)), 2.0)))));
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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_s * (w0_m * sqrt((1.0d0 - ((h / l) * (((m / 2.0d0) * (d / d_m)) ** 2.0d0)))))
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	return w0_s * (w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow(((M / 2.0) * (D / d_m)), 2.0)))));
}
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
def code(w0_s, w0_m, M, D, h, l, d_m):
	return w0_s * (w0_m * math.sqrt((1.0 - ((h / l) * math.pow(((M / 2.0) * (D / d_m)), 2.0)))))
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
function code(w0_s, w0_m, M, D, h, l, d_m)
	return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / 2.0) * Float64(D / d_m)) ^ 2.0))))))
end
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
function tmp = code(w0_s, w0_m, M, D, h, l, d_m)
	tmp = w0_s * (w0_m * sqrt((1.0 - ((h / l) * (((M / 2.0) * (D / d_m)) ^ 2.0)))));
end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)

\\
w0_s \cdot \left(w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d_m}\right)}^{2}}\right)
\end{array}
Derivation
  1. Initial program 84.1%

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

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

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

Alternative 6: 66.8% accurate, 1.1× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ w0_s \cdot \begin{array}{l} \mathbf{if}\;M \leq 5.8 \cdot 10^{+108}:\\ \;\;\;\;w0_m\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0_m}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
 :precision binary64
 (* w0_s (if (<= M 5.8e+108) w0_m (log (exp w0_m)))))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	double tmp;
	if (M <= 5.8e+108) {
		tmp = w0_m;
	} else {
		tmp = log(exp(w0_m));
	}
	return w0_s * tmp;
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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 <= 5.8d+108) then
        tmp = w0_m
    else
        tmp = log(exp(w0_m))
    end if
    code = w0_s * tmp
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	double tmp;
	if (M <= 5.8e+108) {
		tmp = w0_m;
	} else {
		tmp = Math.log(Math.exp(w0_m));
	}
	return w0_s * tmp;
}
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
def code(w0_s, w0_m, M, D, h, l, d_m):
	tmp = 0
	if M <= 5.8e+108:
		tmp = w0_m
	else:
		tmp = math.log(math.exp(w0_m))
	return w0_s * tmp
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
function code(w0_s, w0_m, M, D, h, l, d_m)
	tmp = 0.0
	if (M <= 5.8e+108)
		tmp = w0_m;
	else
		tmp = log(exp(w0_m));
	end
	return Float64(w0_s * tmp)
end
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m)
	tmp = 0.0;
	if (M <= 5.8e+108)
		tmp = w0_m;
	else
		tmp = log(exp(w0_m));
	end
	tmp_2 = w0_s * tmp;
end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[M, 5.8e+108], w0$95$m, N[Log[N[Exp[w0$95$m], $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)

\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;M \leq 5.8 \cdot 10^{+108}:\\
\;\;\;\;w0_m\\

\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0_m}\right)\\


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

    1. Initial program 83.9%

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

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

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

    if 5.80000000000000015e108 < M

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {w0}^{\color{blue}{1}} \]
      3. pow136.9%

        \[\leadsto \color{blue}{w0} \]
      4. add-log-exp32.8%

        \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
    10. Applied egg-rr32.8%

      \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 5.8 \cdot 10^{+108}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.7% accurate, 216.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ w0_m = \left|w0\right| \\ w0_s = \mathsf{copysign}\left(1, w0\right) \\ w0_s \cdot w0_m \end{array} \]
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m) :precision binary64 (* w0_s w0_m))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	return w0_s * w0_m;
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    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_s * w0_m
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
	return w0_s * w0_m;
}
d_m = math.fabs(d)
w0_m = math.fabs(w0)
w0_s = math.copysign(1.0, w0)
def code(w0_s, w0_m, M, D, h, l, d_m):
	return w0_s * w0_m
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0, w0)
function code(w0_s, w0_m, M, D, h, l, d_m)
	return Float64(w0_s * w0_m)
end
d_m = abs(d);
w0_m = abs(w0);
w0_s = sign(w0) * abs(1.0);
function tmp = code(w0_s, w0_m, M, D, h, l, d_m)
	tmp = w0_s * w0_m;
end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)

\\
w0_s \cdot w0_m
\end{array}
Derivation
  1. Initial program 84.1%

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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