Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 88.3%
Time: 20.6s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 81.3% accurate, 1.0× speedup?

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

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

Alternative 1: 88.3% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot \left(e^{\log \left(-0.25 \cdot \frac{h \cdot {\left(M\_m \cdot D\_m\right)}^{2}}{\ell}\right) \cdot 0.16666666666666666} \cdot e^{0.16666666666666666 \cdot \left(-2 \cdot \log d\_m\right)}\right)\right)}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 1.9999999999999999e163

    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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e163 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d))

    1. Initial program 44.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.8% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;1 - \frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \leq 5 \cdot 10^{+295}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{2}}{d\_m}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot {\left({\left(\sqrt[3]{0.5 \cdot \left(M\_m \cdot \frac{D\_m}{d\_m}\right)}\right)}^{2} \cdot \sqrt[3]{\frac{1}{\ell}}\right)}^{3}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= (- 1.0 (* (/ h l) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))) 5e+295)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ (/ M_m 2.0) d_m)) 2.0)))))
   (*
    w0
    (sqrt
     (-
      1.0
      (*
       h
       (pow
        (* (pow (cbrt (* 0.5 (* M_m (/ D_m d_m)))) 2.0) (cbrt (/ 1.0 l)))
        3.0)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((1.0 - ((h / l) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0))) <= 5e+295) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((D_m * ((M_m / 2.0) / d_m)), 2.0))));
	} else {
		tmp = w0 * sqrt((1.0 - (h * pow((pow(cbrt((0.5 * (M_m * (D_m / d_m)))), 2.0) * cbrt((1.0 / l))), 3.0))));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((1.0 - ((h / l) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0))) <= 5e+295) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * ((M_m / 2.0) / d_m)), 2.0))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (h * Math.pow((Math.pow(Math.cbrt((0.5 * (M_m * (D_m / d_m)))), 2.0) * Math.cbrt((1.0 / l))), 3.0))));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0))) <= 5e+295)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(Float64(M_m / 2.0) / d_m)) ^ 2.0)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * (Float64((cbrt(Float64(0.5 * Float64(M_m * Float64(D_m / d_m)))) ^ 2.0) * cbrt(Float64(1.0 / l))) ^ 3.0)))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+295], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / 2.0), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[Power[N[(N[Power[N[Power[N[(0.5 * N[(M$95$m * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(1.0 / l), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|

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

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


\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.99999999999999991e295

    1. Initial program 99.6%

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

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

    if 4.99999999999999991e295 < (-.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 37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - \frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 5 \cdot 10^{+295}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot {\left({\left(\sqrt[3]{0.5 \cdot \left(M \cdot \frac{D}{d}\right)}\right)}^{2} \cdot \sqrt[3]{\frac{1}{\ell}}\right)}^{3}}\\ \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| \\ \begin{array}{l} \mathbf{if}\;1 - \frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \leq 10^{+306}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{2}}{d\_m}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot {\left(\frac{{\left(\sqrt[3]{0.5 \cdot \left(M\_m \cdot \frac{D\_m}{d\_m}\right)}\right)}^{2}}{\sqrt[3]{\ell}}\right)}^{3}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= (- 1.0 (* (/ h l) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))) 1e+306)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ (/ M_m 2.0) d_m)) 2.0)))))
   (*
    w0
    (sqrt
     (-
      1.0
      (*
       h
       (pow
        (/ (pow (cbrt (* 0.5 (* M_m (/ D_m d_m)))) 2.0) (cbrt l))
        3.0)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((1.0 - ((h / l) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0))) <= 1e+306) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((D_m * ((M_m / 2.0) / d_m)), 2.0))));
	} else {
		tmp = w0 * sqrt((1.0 - (h * pow((pow(cbrt((0.5 * (M_m * (D_m / d_m)))), 2.0) / cbrt(l)), 3.0))));
	}
	return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((1.0 - ((h / l) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0))) <= 1e+306) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * ((M_m / 2.0) / d_m)), 2.0))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (h * Math.pow((Math.pow(Math.cbrt((0.5 * (M_m * (D_m / d_m)))), 2.0) / Math.cbrt(l)), 3.0))));
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0))) <= 1e+306)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(Float64(M_m / 2.0) / d_m)) ^ 2.0)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * (Float64((cbrt(Float64(0.5 * Float64(M_m * Float64(D_m / d_m)))) ^ 2.0) / cbrt(l)) ^ 3.0)))));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+306], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / 2.0), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[Power[N[(N[Power[N[Power[N[(0.5 * N[(M$95$m * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[l, 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|

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

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


\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))) < 1.00000000000000002e306

    1. Initial program 99.6%

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

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

    if 1.00000000000000002e306 < (-.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 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.3% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(-2 \cdot \log d\_m + \log \left(0.25 \cdot \frac{h \cdot {\left(M\_m \cdot D\_m\right)}^{2}}{-\ell}\right)\right)}\right)}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 1.9999999999999999e163

    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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e163 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d))

    1. Initial program 44.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.7% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot \left({\left(-0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}^{0.16666666666666666} \cdot e^{\log d\_m \cdot -0.3333333333333333}\right)\right)}^{3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 4.99999999999999995e131

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999995e131 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d))

    1. Initial program 47.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt[3]{w0} \cdot \left({\left(e^{0.16666666666666666}\right)}^{\log \left(-0.25 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{\ell}\right)} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(-2 \cdot \log d\right)}\right)\right)}^{3} \]
      6. unpow-prod-down33.6%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt[3]{w0} \cdot \left({\left(-0.25 \cdot \left({\left(D \cdot M\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}^{0.16666666666666666} \cdot e^{\color{blue}{-0.3333333333333333} \cdot \log d}\right)\right)}^{3} \]
    10. Simplified30.0%

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

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

Alternative 6: 73.9% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;D\_m \leq 1.95 \cdot 10^{+164}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot {\left(D\_m \cdot \frac{M\_m}{d\_m}\right)}^{2}, w0\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= D_m 1.95e+164)
   w0
   (fma -0.125 (* (* h (/ w0 l)) (pow (* D_m (/ M_m d_m)) 2.0)) w0)))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (D_m <= 1.95e+164) {
		tmp = w0;
	} else {
		tmp = fma(-0.125, ((h * (w0 / l)) * pow((D_m * (M_m / d_m)), 2.0)), w0);
	}
	return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (D_m <= 1.95e+164)
		tmp = w0;
	else
		tmp = fma(-0.125, Float64(Float64(h * Float64(w0 / l)) * (Float64(D_m * Float64(M_m / d_m)) ^ 2.0)), w0);
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[D$95$m, 1.95e+164], w0, N[(-0.125 * N[(N[(h * N[(w0 / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 1.95 \cdot 10^{+164}:\\
\;\;\;\;w0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.94999999999999993e164

    1. Initial program 82.2%

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

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

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

    if 1.94999999999999993e164 < D

    1. Initial program 70.9%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
      3. associate-*r*18.0%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      5. unpow218.0%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right)} \]
    7. Taylor expanded in D around 0 17.8%

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}, w0\right) \]
      3. unpow218.0%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{{\left(D \cdot M\right)}^{2} \cdot \frac{h \cdot w0}{\ell \cdot {d}^{2}}}, w0\right) \]
      8. associate-/r*57.4%

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

      \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{{\left(D \cdot M\right)}^{2} \cdot \frac{\frac{h \cdot w0}{\ell}}{{d}^{2}}}, w0\right) \]
    10. Taylor expanded in D around 0 17.8%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}, w0\right) \]
      2. *-commutative18.0%

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}}, w0\right) \]
      3. unpow218.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \color{blue}{\frac{h \cdot w0}{\ell} \cdot \frac{{\left(D \cdot M\right)}^{2}}{{d}^{2}}}, w0\right) \]
      9. associate-*r/53.1%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{{d}^{2}}, w0\right) \]
      11. unpow253.1%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}}, w0\right) \]
      12. times-frac66.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot \color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)}, w0\right) \]
      13. unpow166.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot \left(\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{1}} \cdot \frac{D \cdot M}{d}\right), w0\right) \]
      14. pow-plus66.6%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot \color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{\left(1 + 1\right)}}, w0\right) \]
      15. associate-/l*66.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{\left(1 + 1\right)}, w0\right) \]
      16. metadata-eval66.8%

        \[\leadsto \mathsf{fma}\left(-0.125, \left(h \cdot \frac{w0}{\ell}\right) \cdot {\left(D \cdot \frac{M}{d}\right)}^{\color{blue}{2}}, w0\right) \]
    12. Simplified66.8%

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

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

Alternative 7: 86.4% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* h (/ (pow (* D_m (* M_m (/ 0.5 d_m))) 2.0) l))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	return w0 * sqrt((1.0 - (h * (pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))));
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
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 * (((d_m * (m_m * (0.5d0 / d_m_1))) ** 2.0d0) / l))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
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((D_m * (M_m * (0.5 / d_m))), 2.0) / l))));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
def code(w0, M_m, D_m, h, l, d_m):
	return w0 * math.sqrt((1.0 - (h * (math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))))
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
function code(w0, M_m, D_m, h, l, d_m)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d_m))) ^ 2.0) / l)))))
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
function tmp = code(w0, M_m, D_m, h, l, d_m)
	tmp = w0 * sqrt((1.0 - (h * (((D_m * (M_m * (0.5 / d_m))) ^ 2.0) / l))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
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[(D$95$m * N[(M$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $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 \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}
\end{array}
Derivation
  1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 63.1% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 1.1 \cdot 10^{+78}:\\ \;\;\;\;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)
(FPCore (w0 M_m D_m h l d_m)
 :precision binary64
 (if (<= M_m 1.1e+78) w0 (log (exp w0))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M_m <= 1.1e+78) {
		tmp = w0;
	} else {
		tmp = log(exp(w0));
	}
	return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
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 <= 1.1d+78) 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);
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (M_m <= 1.1e+78) {
		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)
def code(w0, M_m, D_m, h, l, d_m):
	tmp = 0
	if M_m <= 1.1e+78:
		tmp = w0
	else:
		tmp = math.log(math.exp(w0))
	return tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
function code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (M_m <= 1.1e+78)
		tmp = w0;
	else
		tmp = log(exp(w0));
	end
	return tmp
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (M_m <= 1.1e+78)
		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]
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[M$95$m, 1.1e+78], 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|

\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1.1 \cdot 10^{+78}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 84.8%

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

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

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

    if 1.10000000000000007e78 < M

    1. Initial program 62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
    9. Applied egg-rr18.3%

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

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

Alternative 9: 68.8% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0 \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(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);
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)
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);
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)
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)
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);
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]
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
\end{array}
Derivation
  1. Initial program 81.2%

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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