Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 87.9%
Time: 16.8s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 81.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: 87.9% accurate, 1.7× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ w0 \cdot \sqrt{1 + \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot h\right)\right) \cdot \frac{-1}{\ell}} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (*
  w0
  (sqrt
   (+
    1.0
    (* (* (* M (* D (/ 0.5 d))) (* (* M (* 0.5 (/ D d))) h)) (/ -1.0 l))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 + (((M * (D * (0.5 / d))) * ((M * (0.5 * (D / d))) * h)) * (-1.0 / l))));
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 * (0.5d0 / d_1))) * ((m * (0.5d0 * (d / d_1))) * h)) * ((-1.0d0) / l))))
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 + (((M * (D * (0.5 / d))) * ((M * (0.5 * (D / d))) * h)) * (-1.0 / l))));
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 + (((M * (D * (0.5 / d))) * ((M * (0.5 * (D / d))) * h)) * (-1.0 / l))))
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(M * Float64(D * Float64(0.5 / d))) * Float64(Float64(M * Float64(0.5 * Float64(D / d))) * h)) * Float64(-1.0 / l)))))
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 + (((M * (D * (0.5 / d))) * ((M * (0.5 * (D / d))) * h)) * (-1.0 / l))));
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(M * N[(D * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
w0 \cdot \sqrt{1 + \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot h\right)\right) \cdot \frac{-1}{\ell}}
\end{array}
Derivation
  1. Initial program 80.6%

    \[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. Step-by-step derivation
    1. unpow281.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. *-commutative81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 83.1% accurate, 1.7× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-278}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot 0.5\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (/ h l) -2e-278)
   (*
    w0
    (sqrt (- 1.0 (* (/ h l) (* (/ D d) (* (* M (* D (/ 0.5 d))) (* M 0.5)))))))
   w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -2e-278) {
		tmp = w0 * sqrt((1.0 - ((h / l) * ((D / d) * ((M * (D * (0.5 / d))) * (M * 0.5))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 ((h / l) <= (-2d-278)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d / d_1) * ((m * (d * (0.5d0 / d_1))) * (m * 0.5d0))))))
    else
        tmp = w0
    end if
    code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((h / l) <= -2e-278) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * ((D / d) * ((M * (D * (0.5 / d))) * (M * 0.5))))));
	} else {
		tmp = w0;
	}
	return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	tmp = 0
	if (h / l) <= -2e-278:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * ((D / d) * ((M * (D * (0.5 / d))) * (M * 0.5))))))
	else:
		tmp = w0
	return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(h / l) <= -2e-278)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(Float64(D / d) * Float64(Float64(M * Float64(D * Float64(0.5 / d))) * Float64(M * 0.5)))))));
	else
		tmp = w0;
	end
	return tmp
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if ((h / l) <= -2e-278)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((D / d) * ((M * (D * (0.5 / d))) * (M * 0.5))))));
	else
		tmp = w0;
	end
	tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -2e-278], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(N[(M * N[(D * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-278}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right) \cdot \left(M \cdot 0.5\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 h l) < -1.99999999999999988e-278

    1. Initial program 80.4%

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

        \[\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. *-commutative81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999988e-278 < (/.f64 h l)

    1. Initial program 80.8%

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

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

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

Alternative 3: 68.7% accurate, 1.8× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 1.05 \cdot 10^{+58}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{\frac{h}{\ell}}{{d}^{2}} \cdot -0.125\right)\right)\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 1.05e+58)
   w0
   (* w0 (* (* (* M D) (* M D)) (* (/ (/ h l) (pow d 2.0)) -0.125)))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 1.05e+58) {
		tmp = w0;
	} else {
		tmp = w0 * (((M * D) * (M * D)) * (((h / l) / pow(d, 2.0)) * -0.125));
	}
	return tmp;
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 <= 1.05d+58) then
        tmp = w0
    else
        tmp = w0 * (((m * d) * (m * d)) * (((h / l) / (d_1 ** 2.0d0)) * (-0.125d0)))
    end if
    code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 1.05e+58) {
		tmp = w0;
	} else {
		tmp = w0 * (((M * D) * (M * D)) * (((h / l) / Math.pow(d, 2.0)) * -0.125));
	}
	return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 1.05e+58:
		tmp = w0
	else:
		tmp = w0 * (((M * D) * (M * D)) * (((h / l) / math.pow(d, 2.0)) * -0.125))
	return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 1.05e+58)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(Float64(h / l) / (d ^ 2.0)) * -0.125)));
	end
	return tmp
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 1.05e+58)
		tmp = w0;
	else
		tmp = w0 * (((M * D) * (M * D)) * (((h / l) / (d ^ 2.0)) * -0.125));
	end
	tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 1.05e+58], w0, N[(w0 * N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(h / l), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.05 \cdot 10^{+58}:\\
\;\;\;\;w0\\

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


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

    1. Initial program 81.4%

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

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

    if 1.05000000000000006e58 < M

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.4% accurate, 1.8× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ w0 \cdot \sqrt{1 - \frac{h \cdot \left(\left(\frac{0.5}{d} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)\right)}{\ell}} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (*
  w0
  (sqrt (- 1.0 (/ (* h (* (* (/ 0.5 d) (* M D)) (* (/ D d) (* M 0.5)))) l)))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - ((h * (((0.5 / d) * (M * D)) * ((D / d) * (M * 0.5)))) / l)));
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 * (((0.5d0 / d_1) * (m * d)) * ((d / d_1) * (m * 0.5d0)))) / l)))
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - ((h * (((0.5 / d) * (M * D)) * ((D / d) * (M * 0.5)))) / l)));
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - ((h * (((0.5 / d) * (M * D)) * ((D / d) * (M * 0.5)))) / l)))
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(Float64(Float64(0.5 / d) * Float64(M * D)) * Float64(Float64(D / d) * Float64(M * 0.5)))) / l))))
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((h * (((0.5 / d) * (M * D)) * ((D / d) * (M * 0.5)))) / l)));
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[(N[(0.5 / d), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \frac{h \cdot \left(\left(\frac{0.5}{d} \cdot \left(M \cdot D\right)\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)\right)}{\ell}}
\end{array}
Derivation
  1. Initial program 80.6%

    \[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. Step-by-step derivation
    1. unpow281.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. *-commutative81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 68.2% accurate, 18.0× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 1.3 \cdot 10^{+90}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\ell}{w0 \cdot \ell}}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 1.3e+90) w0 (/ 1.0 (/ l (* w0 l)))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 1.3e+90) {
		tmp = w0;
	} else {
		tmp = 1.0 / (l / (w0 * l));
	}
	return tmp;
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 <= 1.3d+90) then
        tmp = w0
    else
        tmp = 1.0d0 / (l / (w0 * l))
    end if
    code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 1.3e+90) {
		tmp = w0;
	} else {
		tmp = 1.0 / (l / (w0 * l));
	}
	return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 1.3e+90:
		tmp = w0
	else:
		tmp = 1.0 / (l / (w0 * l))
	return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 1.3e+90)
		tmp = w0;
	else
		tmp = Float64(1.0 / Float64(l / Float64(w0 * l)));
	end
	return tmp
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 1.3e+90)
		tmp = w0;
	else
		tmp = 1.0 / (l / (w0 * l));
	end
	tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 1.3e+90], w0, N[(1.0 / N[(l / N[(w0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.3 \cdot 10^{+90}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\ell}{w0 \cdot \ell}}\\


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

    1. Initial program 81.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. Taylor expanded in D around 0 75.2%

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

    if 1.2999999999999999e90 < M

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\ell \cdot w0}}{\ell} \]
    11. Step-by-step derivation
      1. clear-num34.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\ell}{\ell \cdot w0}}} \]
      2. inv-pow34.3%

        \[\leadsto \color{blue}{{\left(\frac{\ell}{\ell \cdot w0}\right)}^{-1}} \]
    12. Applied egg-rr34.3%

      \[\leadsto \color{blue}{{\left(\frac{\ell}{\ell \cdot w0}\right)}^{-1}} \]
    13. Step-by-step derivation
      1. unpow-134.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\ell}{\ell \cdot w0}}} \]
      2. *-commutative34.3%

        \[\leadsto \frac{1}{\frac{\ell}{\color{blue}{w0 \cdot \ell}}} \]
    14. Simplified34.3%

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

Alternative 6: 68.1% accurate, 21.6× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 7.8 \cdot 10^{+64}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{w0 \cdot \ell}{\ell}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 7.8e+64) w0 (/ (* w0 l) l)))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 7.8e+64) {
		tmp = w0;
	} else {
		tmp = (w0 * l) / l;
	}
	return tmp;
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 <= 7.8d+64) then
        tmp = w0
    else
        tmp = (w0 * l) / l
    end if
    code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 7.8e+64) {
		tmp = w0;
	} else {
		tmp = (w0 * l) / l;
	}
	return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 7.8e+64:
		tmp = w0
	else:
		tmp = (w0 * l) / l
	return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 7.8e+64)
		tmp = w0;
	else
		tmp = Float64(Float64(w0 * l) / l);
	end
	return tmp
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 7.8e+64)
		tmp = w0;
	else
		tmp = (w0 * l) / l;
	end
	tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 7.8e+64], w0, N[(N[(w0 * l), $MachinePrecision] / l), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 7.8 \cdot 10^{+64}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\frac{w0 \cdot \ell}{\ell}\\


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

    1. Initial program 81.1%

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

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

    if 7.7999999999999996e64 < M

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\ell \cdot w0}}{\ell} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 7.8 \cdot 10^{+64}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{w0 \cdot \ell}{\ell}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.2% accurate, 21.6× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 3.6 \cdot 10^{+25}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \frac{w0}{\ell}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 3.6e+25) w0 (* l (/ w0 l))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 3.6e+25) {
		tmp = w0;
	} else {
		tmp = l * (w0 / l);
	}
	return tmp;
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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 <= 3.6d+25) then
        tmp = w0
    else
        tmp = l * (w0 / l)
    end if
    code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 3.6e+25) {
		tmp = w0;
	} else {
		tmp = l * (w0 / l);
	}
	return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 3.6e+25:
		tmp = w0
	else:
		tmp = l * (w0 / l)
	return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 3.6e+25)
		tmp = w0;
	else
		tmp = Float64(l * Float64(w0 / l));
	end
	return tmp
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 3.6e+25)
		tmp = w0;
	else
		tmp = l * (w0 / l);
	end
	tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3.6e+25], w0, N[(l * N[(w0 / l), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.6 \cdot 10^{+25}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\ell \cdot \frac{w0}{\ell}\\


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

    1. Initial program 81.6%

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

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

    if 3.60000000000000015e25 < M

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\ell \cdot w0}}{\ell} \]
    11. Step-by-step derivation
      1. associate-/l*43.1%

        \[\leadsto \color{blue}{\ell \cdot \frac{w0}{\ell}} \]
    12. Applied egg-rr43.1%

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

Alternative 8: 68.0% accurate, 216.0× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ w0 \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d) :precision binary64 w0)
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
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
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
def code(w0, M, D, h, l, d):
	return w0
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	return w0
end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
w0
\end{array}
Derivation
  1. Initial program 80.6%

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

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

Reproduce

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