Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.0% → 89.0%
Time: 15.3s
Alternatives: 10
Speedup: 1.8×

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 10 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.0% accurate, 1.0× speedup?

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

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

Alternative 1: 89.0% accurate, 0.6× speedup?

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

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

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


\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.9999999999999999e207

    1. Initial program 99.7%

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

    if 4.9999999999999999e207 < (-.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 42.6%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified42.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. Step-by-step derivation
      1. clear-num42.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-inv44.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h \cdot \left(M \cdot M\right)}{\ell}\right) \cdot 0.25}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-233}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \left(\frac{0.5}{d} \cdot \frac{D}{2 \cdot \frac{d}{M}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (/ h l) (- INFINITY))
   (* w0 (sqrt (- 1.0 (* (* (* (/ D d) (/ D d)) (/ (* h (* M M)) l)) 0.25))))
   (if (<= (/ h l) -1e-233)
     (*
      w0
      (sqrt
       (- 1.0 (* (/ h l) (* (* M D) (* (/ 0.5 d) (/ D (* 2.0 (/ d M)))))))))
     w0)))
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - ((((D / d) * (D / d)) * ((h * (M * M)) / l)) * 0.25)));
	} else if ((h / l) <= -1e-233) {
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * D) * ((0.5 / d) * (D / (2.0 * (d / M))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.sqrt((1.0 - ((((D / d) * (D / d)) * ((h * (M * M)) / l)) * 0.25)));
	} else if ((h / l) <= -1e-233) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * ((M * D) * ((0.5 / d) * (D / (2.0 * (d / M))))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	tmp = 0
	if (h / l) <= -math.inf:
		tmp = w0 * math.sqrt((1.0 - ((((D / d) * (D / d)) * ((h * (M * M)) / l)) * 0.25)))
	elif (h / l) <= -1e-233:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * ((M * D) * ((0.5 / d) * (D / (2.0 * (d / M))))))))
	else:
		tmp = w0
	return tmp
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= Float64(-Inf))
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(Float64(h * Float64(M * M)) / l)) * 0.25))));
	elseif (Float64(h / l) <= -1e-233)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(Float64(M * D) * Float64(Float64(0.5 / d) * Float64(D / Float64(2.0 * Float64(d / M)))))))));
	else
		tmp = w0;
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((h / l) <= -Inf)
		tmp = w0 * sqrt((1.0 - ((((D / d) * (D / d)) * ((h * (M * M)) / l)) * 0.25)));
	elseif ((h / l) <= -1e-233)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * D) * ((0.5 / d) * (D / (2.0 * (d / M))))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], (-Infinity)], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -1e-233], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * N[(N[(0.5 / d), $MachinePrecision] * N[(D / N[(2.0 * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}

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

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

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


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

    1. Initial program 30.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -9.99999999999999958e-234

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999958e-234 < (/.f64 h l)

    1. Initial program 86.9%

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

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

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

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

Alternative 3: 69.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 6.5 \cdot 10^{-127}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 81.2%

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

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

    if 6.49999999999999998e-127 < M

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(M \cdot 0.5\right) \cdot \frac{D}{d}\\ w0 \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)} \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* (* M 0.5) (/ D d))))
   (* w0 (sqrt (- 1.0 (* h (* t_0 (/ t_0 l))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * 0.5) * (D / d);
	return w0 * sqrt((1.0 - (h * (t_0 * (t_0 / 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
    real(8) :: t_0
    t_0 = (m * 0.5d0) * (d / d_1)
    code = w0 * sqrt((1.0d0 - (h * (t_0 * (t_0 / l)))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * 0.5) * (D / d);
	return w0 * Math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
}
def code(w0, M, D, h, l, d):
	t_0 = (M * 0.5) * (D / d)
	return w0 * math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))))
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * 0.5) * Float64(D / d))
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l))))))
end
function tmp = code(w0, M, D, h, l, d)
	t_0 = (M * 0.5) * (D / d);
	tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(M \cdot 0.5\right) \cdot \frac{D}{d}\\
w0 \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 78.5%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified77.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. Step-by-step derivation
    1. clear-num77.6%

      \[\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-inv78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \frac{0.5 \cdot \left(D \cdot \frac{M}{d}\right)}{\ell}\right)} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (*
  w0
  (sqrt (- 1.0 (* h (* (* (* M 0.5) (/ D d)) (/ (* 0.5 (* D (/ M d))) l)))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * ((0.5 * (D * (M / d))) / 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 - (h * (((m * 0.5d0) * (d / d_1)) * ((0.5d0 * (d * (m / d_1))) / 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 - (h * (((M * 0.5) * (D / d)) * ((0.5 * (D * (M / d))) / l)))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * ((0.5 * (D * (M / d))) / l)))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(Float64(Float64(M * 0.5) * Float64(D / d)) * Float64(Float64(0.5 * Float64(D * Float64(M / d))) / l))))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * ((0.5 * (D * (M / d))) / l)))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[(N[(M * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \frac{0.5 \cdot \left(D \cdot \frac{M}{d}\right)}{\ell}\right)}
\end{array}
Derivation
  1. Initial program 78.5%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified77.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. Step-by-step derivation
    1. clear-num77.6%

      \[\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-inv78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 83.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \left(D \cdot \frac{M \cdot \frac{0.5}{\ell}}{d}\right)\right)} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (*
  w0
  (sqrt (- 1.0 (* h (* (* (* M 0.5) (/ D d)) (* D (/ (* M (/ 0.5 l)) d))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * (D * ((M * (0.5 / l)) / d))))));
}
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 - (h * (((m * 0.5d0) * (d / d_1)) * (d * ((m * (0.5d0 / l)) / d_1))))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * (D * ((M * (0.5 / l)) / d))))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * (D * ((M * (0.5 / l)) / d))))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(Float64(Float64(M * 0.5) * Float64(D / d)) * Float64(D * Float64(Float64(M * Float64(0.5 / l)) / d)))))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - (h * (((M * 0.5) * (D / d)) * (D * ((M * (0.5 / l)) / d))))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[(N[(M * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(D * N[(N[(M * N[(0.5 / l), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right) \cdot \left(D \cdot \frac{M \cdot \frac{0.5}{\ell}}{d}\right)\right)}
\end{array}
Derivation
  1. Initial program 78.5%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified77.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. Step-by-step derivation
    1. clear-num77.6%

      \[\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-inv78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 72.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 5.6 \cdot 10^{-63}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 81.2%

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

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

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

    if 5.6000000000000005e-63 < M

    1. Initial program 72.0%

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{1 \cdot 1}{\frac{2 \cdot d}{M \cdot D} \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. metadata-eval71.9%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1}}{\frac{2 \cdot d}{M \cdot D} \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. times-frac71.8%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{1}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Taylor expanded in M around 0 38.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}} \]
    7. Step-by-step derivation
      1. +-commutative38.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-define38.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. times-frac37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 62.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.5 \cdot 10^{-20}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 82.4%

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

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

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

    if 4.5000000000000001e-20 < M

    1. Initial program 66.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified65.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. associate-/r*65.3%

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{1 \cdot 1}{\frac{2 \cdot d}{M \cdot D} \cdot \frac{2 \cdot d}{M \cdot D}}} \cdot \frac{h}{\ell}} \]
      8. metadata-eval66.7%

        \[\leadsto w0 \cdot \sqrt{1 - \frac{\color{blue}{1}}{\frac{2 \cdot d}{M \cdot D} \cdot \frac{2 \cdot d}{M \cdot D}} \cdot \frac{h}{\ell}} \]
      9. times-frac66.6%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{1}{\left(\frac{2}{M} \cdot \frac{d}{D}\right) \cdot \left(\frac{2}{M} \cdot \frac{d}{D}\right)}} \cdot \frac{h}{\ell}} \]
    6. Taylor expanded in M around 0 36.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}} \]
    7. Step-by-step derivation
      1. +-commutative36.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-define36.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. times-frac35.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(\left(\left(M \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      9. swap-sqr24.9%

        \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\left(M \cdot \frac{D}{d}\right) \cdot \left(M \cdot \frac{D}{d}\right)\right)} \cdot \frac{h \cdot w0}{\ell}\right) \]
      10. *-commutative24.9%

        \[\leadsto -0.125 \cdot \left(\left(\color{blue}{\left(\frac{D}{d} \cdot M\right)} \cdot \left(M \cdot \frac{D}{d}\right)\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      11. *-commutative24.9%

        \[\leadsto -0.125 \cdot \left(\left(\left(\frac{D}{d} \cdot M\right) \cdot \color{blue}{\left(\frac{D}{d} \cdot M\right)}\right) \cdot \frac{h \cdot w0}{\ell}\right) \]
      12. unpow224.9%

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

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

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

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

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

Alternative 9: 60.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 2.8 \cdot 10^{-35}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{w0 \cdot w0}\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 2.8e-35) w0 (sqrt (* w0 w0))))
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 2.8e-35) {
		tmp = w0;
	} else {
		tmp = sqrt((w0 * w0));
	}
	return tmp;
}
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
    real(8) :: tmp
    if (m <= 2.8d-35) then
        tmp = w0
    else
        tmp = sqrt((w0 * w0))
    end if
    code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 2.8e-35) {
		tmp = w0;
	} else {
		tmp = Math.sqrt((w0 * w0));
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 2.8e-35:
		tmp = w0
	else:
		tmp = math.sqrt((w0 * w0))
	return tmp
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 2.8e-35)
		tmp = w0;
	else
		tmp = sqrt(Float64(w0 * w0));
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 2.8e-35)
		tmp = w0;
	else
		tmp = sqrt((w0 * w0));
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 2.8e-35], w0, N[Sqrt[N[(w0 * w0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.8 \cdot 10^{-35}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 82.0%

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

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

    if 2.8e-35 < M

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{w0 \cdot w0}} \]
    10. Applied egg-rr17.1%

      \[\leadsto \sqrt{\color{blue}{w0 \cdot w0}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 68.6% accurate, 216.0× speedup?

\[\begin{array}{l} \\ w0 \end{array} \]
(FPCore (w0 M D h l d) :precision binary64 w0)
double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
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
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
def code(w0, M, D, h, l, d):
	return w0
function code(w0, M, D, h, l, d)
	return w0
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0;
end
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

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