Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.7% → 92.5%
Time: 22.0s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 80.7% accurate, 1.0× speedup?

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

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

Alternative 1: 92.5% accurate, 0.3× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.99999999999999997e88

    1. Initial program 65.5%

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(\color{blue}{\left(-2 \cdot \log d + \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)} + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}^{3} \]
      2. distribute-lft-neg-in8.1%

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

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

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

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

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

    if -4.99999999999999997e88 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 92.5% accurate, 0.3× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.99999999999999997e88

    1. Initial program 65.5%

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(\color{blue}{\left(-2 \cdot \log d + \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)} + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}^{3} \]
      2. distribute-lft-neg-in8.1%

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

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

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

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

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

    if -4.99999999999999997e88 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 88.9% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;{\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(-2 \cdot \log \left(\frac{1}{D\_m}\right) + \left(-2 \cdot \log d\_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {M\_m}^{2}\right)\right)\right)\right)}\right)}^{3}\\ \mathbf{elif}\;t\_0 \leq 0.02:\\ \;\;\;\;w0 \cdot \sqrt{1 - t\_0}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l))))
   (if (<= t_0 (- INFINITY))
     (pow
      (*
       (cbrt w0)
       (exp
        (*
         0.16666666666666666
         (+
          (* -2.0 (log (/ 1.0 D_m)))
          (+ (* -2.0 (log d_m)) (log (* -0.25 (* (/ h l) (pow M_m 2.0)))))))))
      3.0)
     (if (<= t_0 0.02) (* w0 (sqrt (- 1.0 t_0))) w0))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = pow((cbrt(w0) * exp((0.16666666666666666 * ((-2.0 * log((1.0 / D_m))) + ((-2.0 * log(d_m)) + log((-0.25 * ((h / l) * pow(M_m, 2.0))))))))), 3.0);
	} else if (t_0 <= 0.02) {
		tmp = w0 * sqrt((1.0 - t_0));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double t_0 = Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.cbrt(w0) * Math.exp((0.16666666666666666 * ((-2.0 * Math.log((1.0 / D_m))) + ((-2.0 * Math.log(d_m)) + Math.log((-0.25 * ((h / l) * Math.pow(M_m, 2.0))))))))), 3.0);
	} else if (t_0 <= 0.02) {
		tmp = w0 * Math.sqrt((1.0 - t_0));
	} else {
		tmp = w0;
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(cbrt(w0) * exp(Float64(0.16666666666666666 * Float64(Float64(-2.0 * log(Float64(1.0 / D_m))) + Float64(Float64(-2.0 * log(d_m)) + log(Float64(-0.25 * Float64(Float64(h / l) * (M_m ^ 2.0))))))))) ^ 3.0;
	elseif (t_0 <= 0.02)
		tmp = Float64(w0 * sqrt(Float64(1.0 - t_0)));
	else
		tmp = w0;
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Power[w0, 1/3], $MachinePrecision] * N[Exp[N[(0.16666666666666666 * N[(N[(-2.0 * N[Log[N[(1.0 / D$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[(h / l), $MachinePrecision] * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], If[LessEqual[t$95$0, 0.02], N[(w0 * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(-2 \cdot \log \left(\frac{1}{D\_m}\right) + \left(-2 \cdot \log d\_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {M\_m}^{2}\right)\right)\right)\right)}\right)}^{3}\\

\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0}\\

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


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

    1. Initial program 55.7%

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(\color{blue}{\left(-2 \cdot \log d + \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell}\right)\right)} + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}^{3} \]
      2. distribute-lft-neg-in8.8%

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

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

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

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 0.0200000000000000004

    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 0.0200000000000000004 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 0.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(-2 \cdot \log \left(\frac{1}{D}\right) + \left(-2 \cdot \log d + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {M}^{2}\right)\right)\right)\right)}\right)}^{3}\\ \mathbf{elif}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0.02:\\ \;\;\;\;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 4: 87.1% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))) < 9.9999999999999994e303

    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.9999999999999994e303 < (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))

    1. Initial program 44.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.0% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))) < 4.9999999999999999e294

    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.9999999999999999e294 < (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))

    1. Initial program 46.2%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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^{+294}:\\ \;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.7% accurate, 0.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_1 \cdot \frac{t\_1}{\ell}}\\


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

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < h

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{h}}{1} \cdot \frac{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{h}}{\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 - h \cdot \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{h}\right) \cdot \frac{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \sqrt{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ [w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 7.2 \cdot 10^{-42}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= M_m 7.2e-42) w0 (log (exp w0))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M_m <= 7.2e-42) {
		tmp = w0;
	} else {
		tmp = log(exp(w0));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if (m_m <= 7.2d-42) then
        tmp = w0
    else
        tmp = log(exp(w0))
    end if
    code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M_m <= 7.2e-42) {
		tmp = w0;
	} else {
		tmp = Math.log(Math.exp(w0));
	}
	return tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
[w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m])
def code(w0, M_m, D_m, h, l, d_m):
	tmp = 0
	if M_m <= 7.2e-42:
		tmp = w0
	else:
		tmp = math.log(math.exp(w0))
	return tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m])
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (M_m <= 7.2e-42)
		tmp = w0;
	else
		tmp = log(exp(w0));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (M_m <= 7.2e-42)
		tmp = w0;
	else
		tmp = log(exp(w0));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[M$95$m, 7.2e-42], w0, N[Log[N[Exp[w0], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 7.2 \cdot 10^{-42}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 85.5%

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

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

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

    if 7.2000000000000004e-42 < M

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {w0}^{\color{blue}{1}} \]
      3. pow150.8%

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

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

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

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

Alternative 9: 71.5% accurate, 1.0× speedup?

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

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


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

    1. Initial program 85.0%

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

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

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

    if 1.00000000000000007e-63 < M

    1. Initial program 78.7%

      \[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(M \cdot \frac{D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt40.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {w0}^{\color{blue}{1}} \]
      3. pow153.8%

        \[\leadsto \color{blue}{w0} \]
      4. add-exp-log21.4%

        \[\leadsto \color{blue}{e^{\log w0}} \]
    10. Applied egg-rr21.4%

      \[\leadsto \color{blue}{e^{\log w0}} \]
    11. Step-by-step derivation
      1. rem-exp-log53.8%

        \[\leadsto \color{blue}{w0} \]
      2. log1p-expm1-u54.2%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)} \]
    12. Applied egg-rr54.2%

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

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

Alternative 10: 67.8% accurate, 1.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{{\left(w0 + 1\right)}^{2} + -1}{2 + w0}\\


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

    1. Initial program 85.5%

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

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

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

    if 7.2000000000000006e-30 < M

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {w0}^{\color{blue}{1}} \]
      3. pow150.8%

        \[\leadsto \color{blue}{w0} \]
      4. add-exp-log20.6%

        \[\leadsto \color{blue}{e^{\log w0}} \]
    10. Applied egg-rr20.6%

      \[\leadsto \color{blue}{e^{\log w0}} \]
    11. Step-by-step derivation
      1. rem-exp-log50.8%

        \[\leadsto \color{blue}{w0} \]
      2. expm1-log1p-u36.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0\right)\right)} \]
      3. expm1-define9.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0\right)} - 1} \]
      4. flip--17.9%

        \[\leadsto \color{blue}{\frac{e^{\mathsf{log1p}\left(w0\right)} \cdot e^{\mathsf{log1p}\left(w0\right)} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1}} \]
      5. pow217.9%

        \[\leadsto \frac{\color{blue}{{\left(e^{\mathsf{log1p}\left(w0\right)}\right)}^{2}} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      6. log1p-undefine17.9%

        \[\leadsto \frac{{\left(e^{\color{blue}{\log \left(1 + w0\right)}}\right)}^{2} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      7. rem-exp-log17.9%

        \[\leadsto \frac{{\color{blue}{\left(1 + w0\right)}}^{2} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      8. metadata-eval17.9%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} - \color{blue}{1}}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      9. log1p-undefine17.9%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} - 1}{e^{\color{blue}{\log \left(1 + w0\right)}} + 1} \]
      10. rem-exp-log27.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} - 1}{\color{blue}{\left(1 + w0\right)} + 1} \]
    12. Applied egg-rr27.3%

      \[\leadsto \color{blue}{\frac{{\left(1 + w0\right)}^{2} - 1}{\left(1 + w0\right) + 1}} \]
    13. Step-by-step derivation
      1. sub-neg27.3%

        \[\leadsto \frac{\color{blue}{{\left(1 + w0\right)}^{2} + \left(-1\right)}}{\left(1 + w0\right) + 1} \]
      2. metadata-eval27.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} + \color{blue}{-1}}{\left(1 + w0\right) + 1} \]
      3. +-commutative27.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} + -1}{\color{blue}{1 + \left(1 + w0\right)}} \]
      4. associate-+r+27.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} + -1}{\color{blue}{\left(1 + 1\right) + w0}} \]
      5. metadata-eval27.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} + -1}{\color{blue}{2} + w0} \]
    14. Simplified27.3%

      \[\leadsto \color{blue}{\frac{{\left(1 + w0\right)}^{2} + -1}{2 + w0}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 7.2 \cdot 10^{-30}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(w0 + 1\right)}^{2} + -1}{2 + w0}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 67.9% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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