Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.1% → 89.9%
Time: 13.8s
Alternatives: 14
Speedup: 2.1×

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 14 alternatives:

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

Initial Program: 81.1% accurate, 1.0× speedup?

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

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

Alternative 1: 89.9% accurate, 1.6× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \sqrt{\mathsf{fma}\left(\frac{\frac{M\_m \cdot -0.5}{d} \cdot D\_m}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\_m\right) \cdot D\_m}{\frac{1}{h}}, 1\right)} \cdot w0 \end{array} \]
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
 :precision binary64
 (*
  (sqrt
   (fma
    (/ (* (/ (* M_m -0.5) d) D_m) l)
    (/ (* (* (/ 0.5 d) M_m) D_m) (/ 1.0 h))
    1.0))
  w0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
	return sqrt(fma(((((M_m * -0.5) / d) * D_m) / l), ((((0.5 / d) * M_m) * D_m) / (1.0 / h)), 1.0)) * w0;
}
D_m = abs(D)
M_m = abs(M)
w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
function code(w0, M_m, D_m, h, l, d)
	return Float64(sqrt(fma(Float64(Float64(Float64(Float64(M_m * -0.5) / d) * D_m) / l), Float64(Float64(Float64(Float64(0.5 / d) * M_m) * D_m) / Float64(1.0 / h)), 1.0)) * w0)
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(N[Sqrt[N[(N[(N[(N[(N[(M$95$m * -0.5), $MachinePrecision] / d), $MachinePrecision] * D$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(1.0 / h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\sqrt{\mathsf{fma}\left(\frac{\frac{M\_m \cdot -0.5}{d} \cdot D\_m}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\_m\right) \cdot D\_m}{\frac{1}{h}}, 1\right)} \cdot w0
\end{array}
Derivation
  1. Initial program 78.0%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

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

      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
    3. +-commutativeN/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
    4. lift-*.f64N/A

      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
    5. distribute-lft-neg-inN/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1} \]
    6. lift-/.f64N/A

      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1} \]
    7. clear-numN/A

      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1} \]
    8. un-div-invN/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\frac{\ell}{h}}} + 1} \]
    9. lift-pow.f64N/A

      \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)}{\frac{\ell}{h}} + 1} \]
    10. unpow2N/A

      \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{h}} + 1} \]
    11. distribute-lft-neg-inN/A

      \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}}{\frac{\ell}{h}} + 1} \]
    12. div-invN/A

      \[\leadsto w0 \cdot \sqrt{\frac{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1} \]
    13. times-fracN/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}} + 1} \]
    14. lower-fma.f64N/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell}, \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}, 1\right)}} \]
  4. Applied rewrites88.5%

    \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)}} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    2. lift-*.f64N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    3. lift-*.f64N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    4. associate-*l*N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{D \cdot \left(M \cdot \frac{-1}{2}\right)}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    5. associate-/l*N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    6. lower-*.f64N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    7. lower-/.f64N/A

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \color{blue}{\frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    8. *-commutativeN/A

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

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

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

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

Alternative 2: 88.6% accurate, 0.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{t\_0}{\ell}, \left(\left(M\_m \cdot D\_m\right) \cdot h\right) \cdot \frac{0.5}{d}, 1\right)} \cdot w0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.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.0000000000000001e241

    1. Initial program 92.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right)} + 1} \]
      7. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      8. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)\right) + 1} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)} + 1} \]
      10. associate-*r*N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}} + 1} \]
      11. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right), \frac{M \cdot D}{2 \cdot d}, 1\right)}} \]
    4. Applied rewrites91.7%

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

    if 1.0000000000000001e241 < (*.f64 w0 (sqrt.f64 (-.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 34.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1} \]
      6. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1} \]
      7. clear-numN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1} \]
      8. un-div-invN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\frac{\ell}{h}}} + 1} \]
      9. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)}{\frac{\ell}{h}} + 1} \]
      10. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{h}} + 1} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}}{\frac{\ell}{h}} + 1} \]
      12. div-invN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1} \]
      13. times-fracN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}} + 1} \]
      14. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell}, \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}, 1\right)}} \]
    4. Applied rewrites74.6%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}}, 1\right)} \]
      2. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\color{blue}{\frac{1}{h}}}, 1\right)} \]
      3. associate-/r/N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{1} \cdot h}, 1\right)} \]
      4. /-rgt-identityN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\left(\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D\right)} \cdot h, 1\right)} \]
      5. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\left(\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D\right)} \cdot h, 1\right)} \]
      6. lift-*.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\left(\frac{\frac{1}{2}}{d} \cdot \left(M \cdot D\right)\right)} \cdot h, 1\right)} \]
      8. associate-*l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\frac{\frac{1}{2}}{d} \cdot \left(\left(M \cdot D\right) \cdot h\right)}, 1\right)} \]
      9. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \color{blue}{\frac{\frac{1}{2}}{d} \cdot \left(\left(M \cdot D\right) \cdot h\right)}, 1\right)} \]
      10. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\frac{1}{2}}{d} \cdot \color{blue}{\left(\left(M \cdot D\right) \cdot h\right)}, 1\right)} \]
      11. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\frac{1}{2}}{d} \cdot \left(\color{blue}{\left(D \cdot M\right)} \cdot h\right), 1\right)} \]
      12. lift-*.f6474.3

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{0.5}{d} \cdot \left(\color{blue}{\left(D \cdot M\right)} \cdot h\right), 1\right)} \]
    6. Applied rewrites74.3%

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

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

Alternative 3: 88.7% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.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))))) < 2.00000000000000011e301

    1. Initial program 92.4%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right)} + 1} \]
      7. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      8. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)\right) + 1} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)} + 1} \]
      10. associate-*r*N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}} + 1} \]
      11. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right), \frac{M \cdot D}{2 \cdot d}, 1\right)}} \]
    4. Applied rewrites91.7%

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

    if 2.00000000000000011e301 < (*.f64 w0 (sqrt.f64 (-.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 24.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1} \]
      6. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1} \]
      7. clear-numN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1} \]
      8. un-div-invN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\frac{\ell}{h}}} + 1} \]
      9. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)}{\frac{\ell}{h}} + 1} \]
      10. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{h}} + 1} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}}{\frac{\ell}{h}} + 1} \]
      12. div-invN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1} \]
      13. times-fracN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}} + 1} \]
      14. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell}, \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}, 1\right)}} \]
    4. Applied rewrites72.0%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      2. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      3. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      4. associate-*l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{D \cdot \left(M \cdot \frac{-1}{2}\right)}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      5. associate-/l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      6. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      7. lower-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \color{blue}{\frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      8. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\color{blue}{\frac{-1}{2} \cdot M}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      9. lower-*.f6472.0

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\color{blue}{-0.5 \cdot M}}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    6. Applied rewrites72.0%

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{-0.5 \cdot M}{d}}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \color{blue}{\frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}}, 1\right)} \]
      2. lift-*.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \color{blue}{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot \frac{D}{\frac{1}{h}}}, 1\right)} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \color{blue}{\left(\frac{\frac{1}{2}}{d} \cdot M\right)} \cdot \frac{D}{\frac{1}{h}}, 1\right)} \]
      5. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \left(\color{blue}{\frac{\frac{1}{2}}{d}} \cdot M\right) \cdot \frac{D}{\frac{1}{h}}, 1\right)} \]
      6. associate-*l/N/A

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

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \color{blue}{\frac{\left(\frac{1}{2} \cdot M\right) \cdot \frac{D}{\frac{1}{h}}}{d}}, 1\right)} \]
      8. lower-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \color{blue}{\frac{\left(\frac{1}{2} \cdot M\right) \cdot \frac{D}{\frac{1}{h}}}{d}}, 1\right)} \]
      9. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \frac{\color{blue}{\left(\frac{1}{2} \cdot M\right) \cdot \frac{D}{\frac{1}{h}}}}{d}, 1\right)} \]
      10. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \frac{\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{\frac{1}{h}}}{d}, 1\right)} \]
      11. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \frac{\color{blue}{\left(M \cdot \frac{1}{2}\right)} \cdot \frac{D}{\frac{1}{h}}}{d}, 1\right)} \]
      12. div-invN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \frac{\left(M \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(D \cdot \frac{1}{\frac{1}{h}}\right)}}{d}, 1\right)} \]
      13. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \frac{\left(M \cdot \frac{1}{2}\right) \cdot \left(D \cdot \frac{1}{\color{blue}{\frac{1}{h}}}\right)}{d}, 1\right)} \]
      14. remove-double-divN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}, \frac{\left(M \cdot \frac{1}{2}\right) \cdot \left(D \cdot \color{blue}{h}\right)}{d}, 1\right)} \]
      15. lower-*.f6470.0

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

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

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

Alternative 4: 87.8% accurate, 0.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(D\_m, \left(t\_0 \cdot \left(h \cdot D\_m\right)\right) \cdot \frac{M\_m \cdot -0.5}{\ell \cdot d}, 1\right)} \cdot w0\\


\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))) < 2.00000000000000009e248

    1. Initial program 99.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right)} + 1} \]
      7. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)\right) + 1} \]
      8. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)\right) + 1} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{h}{\ell} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)} + 1} \]
      10. associate-*r*N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}} + 1} \]
      11. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right), \frac{M \cdot D}{2 \cdot d}, 1\right)}} \]
    4. Applied rewrites98.9%

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

    if 2.00000000000000009e248 < (-.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 34.6%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1} \]
      6. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1} \]
      7. clear-numN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1} \]
      8. un-div-invN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\frac{\ell}{h}}} + 1} \]
      9. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)}{\frac{\ell}{h}} + 1} \]
      10. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{h}} + 1} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}}{\frac{\ell}{h}} + 1} \]
      12. div-invN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1} \]
      13. times-fracN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}} + 1} \]
      14. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell}, \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}, 1\right)}} \]
    4. Applied rewrites69.1%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      2. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      3. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      4. associate-*l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{D \cdot \left(M \cdot \frac{-1}{2}\right)}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      5. associate-/l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      6. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      7. lower-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \color{blue}{\frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      8. *-commutativeN/A

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

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

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{-0.5 \cdot M}{d}}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}} + 1}} \]
      2. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}} + 1} \]
      3. lift-*.f64N/A

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

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{D \cdot \left(\frac{\frac{\frac{-1}{2} \cdot M}{d}}{\ell} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}\right)} + 1} \]
      6. lower-fma.f64N/A

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

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

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

Alternative 5: 86.7% accurate, 0.7× speedup?

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

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


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

    1. Initial program 99.9%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
    4. Applied rewrites84.4%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{-h}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot 0.25\right)\right), \frac{D}{d}, 1\right)}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \color{blue}{\left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right)}, \frac{D}{d}, 1\right)} \]
      2. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\frac{D}{d} \cdot \color{blue}{\left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)}\right), \frac{D}{d}, 1\right)} \]
      3. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{1}{4}\right)\right), \frac{D}{d}, 1\right)} \]
      4. associate-*l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \left(M \cdot \frac{1}{4}\right)\right)}\right), \frac{D}{d}, 1\right)} \]
      5. associate-*r*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \color{blue}{\left(\left(\frac{D}{d} \cdot M\right) \cdot \left(M \cdot \frac{1}{4}\right)\right)}, \frac{D}{d}, 1\right)} \]
      6. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \color{blue}{\left(\left(\frac{D}{d} \cdot M\right) \cdot \left(M \cdot \frac{1}{4}\right)\right)}, \frac{D}{d}, 1\right)} \]
      7. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\color{blue}{\left(\frac{D}{d} \cdot M\right)} \cdot \left(M \cdot \frac{1}{4}\right)\right), \frac{D}{d}, 1\right)} \]
      8. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\left(\frac{D}{d} \cdot M\right) \cdot \color{blue}{\left(\frac{1}{4} \cdot M\right)}\right), \frac{D}{d}, 1\right)} \]
      9. lower-*.f6497.0

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-h}{\ell} \cdot \left(\left(\frac{D}{d} \cdot M\right) \cdot \color{blue}{\left(0.25 \cdot M\right)}\right), \frac{D}{d}, 1\right)} \]
    6. Applied rewrites97.0%

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

    if 9.9999999999999992e248 < (-.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 33.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1} \]
      6. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1} \]
      7. clear-numN/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1} \]
      8. un-div-invN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\frac{\ell}{h}}} + 1} \]
      9. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)}{\frac{\ell}{h}} + 1} \]
      10. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{h}} + 1} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}}{\frac{\ell}{h}} + 1} \]
      12. div-invN/A

        \[\leadsto w0 \cdot \sqrt{\frac{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1} \]
      13. times-fracN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}} + 1} \]
      14. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell}, \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}, 1\right)}} \]
    4. Applied rewrites68.7%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      2. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      3. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      4. associate-*l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{D \cdot \left(M \cdot \frac{-1}{2}\right)}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      5. associate-/l*N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      6. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      7. lower-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \color{blue}{\frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
      8. *-commutativeN/A

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

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

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{-0.5 \cdot M}{d}}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}} + 1}} \]
      2. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}} + 1} \]
      3. lift-*.f64N/A

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

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{D \cdot \left(\frac{\frac{\frac{-1}{2} \cdot M}{d}}{\ell} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}\right)} + 1} \]
      6. lower-fma.f64N/A

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

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

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

Alternative 6: 85.2% accurate, 0.7× speedup?

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

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


\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))) < 2

    1. Initial program 100.0%

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

      \[\leadsto w0 \cdot \color{blue}{1} \]
    4. Step-by-step derivation
      1. Applied rewrites99.8%

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

      if 2 < (-.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 45.2%

        \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

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

          \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
        3. +-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. Applied rewrites37.1%

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{-h}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot 0.25\right)\right), \frac{D}{d}, 1\right)}} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right)}, \frac{D}{d}, 1\right)} \]
        2. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right) \cdot \frac{\mathsf{neg}\left(h\right)}{\ell}}, \frac{D}{d}, 1\right)} \]
        3. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right)} \cdot \frac{\mathsf{neg}\left(h\right)}{\ell}, \frac{D}{d}, 1\right)} \]
        4. lift-/.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\color{blue}{\frac{D}{d}} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right) \cdot \frac{\mathsf{neg}\left(h\right)}{\ell}, \frac{D}{d}, 1\right)} \]
        5. associate-*l/N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)}{d}} \cdot \frac{\mathsf{neg}\left(h\right)}{\ell}, \frac{D}{d}, 1\right)} \]
        6. lift-/.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)}{d} \cdot \color{blue}{\frac{\mathsf{neg}\left(h\right)}{\ell}}, \frac{D}{d}, 1\right)} \]
        7. frac-timesN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{d \cdot \ell}}, \frac{D}{d}, 1\right)} \]
        8. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{\color{blue}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
        9. lower-/.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
        10. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        11. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\left(\left(M \cdot M\right) \cdot \frac{1}{4}\right) \cdot D\right)} \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        12. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\left(\left(M \cdot M\right) \cdot \frac{1}{4}\right) \cdot D\right)} \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        13. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\color{blue}{\left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)} \cdot D\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        14. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\color{blue}{\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right)} \cdot D\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        15. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\color{blue}{\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right)} \cdot D\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        16. lower-*.f6451.3

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\left(0.25 \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot \left(-h\right)}{\color{blue}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
      6. Applied rewrites51.3%

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\left(0.25 \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot \left(-h\right)}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
      7. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
        2. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot \left(\mathsf{neg}\left(h\right)\right)}}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        3. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\mathsf{neg}\left(h\right)\right) \cdot \left(\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D\right)}}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
        4. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\mathsf{neg}\left(h\right)\right) \cdot \left(\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D\right)}{\color{blue}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
        5. frac-timesN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D}{d}}, \frac{D}{d}, 1\right)} \]
        6. lift-neg.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\mathsf{neg}\left(h\right)}}{\ell} \cdot \frac{\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D}{d}, \frac{D}{d}, 1\right)} \]
        7. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{\color{blue}{\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right) \cdot D}}{d}, \frac{D}{d}, 1\right)} \]
        8. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{\color{blue}{\left(\frac{1}{4} \cdot \left(M \cdot M\right)\right)} \cdot D}{d}, \frac{D}{d}, 1\right)} \]
        9. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{\color{blue}{\left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)} \cdot D}{d}, \frac{D}{d}, 1\right)} \]
        10. lift-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{\left(\color{blue}{\left(M \cdot M\right)} \cdot \frac{1}{4}\right) \cdot D}{d}, \frac{D}{d}, 1\right)} \]
        11. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{\color{blue}{D \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)}}{d}, \frac{D}{d}, 1\right)} \]
        12. associate-*l/N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \color{blue}{\left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right)}, \frac{D}{d}, 1\right)} \]
        13. lift-/.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \left(\color{blue}{\frac{D}{d}} \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)\right), \frac{D}{d}, 1\right)} \]
        14. associate-*r*N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{D}{d}\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{1}{4}\right)}, \frac{D}{d}, 1\right)} \]
        15. associate-*l*N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{D}{d}\right) \cdot \color{blue}{\left(M \cdot \left(M \cdot \frac{1}{4}\right)\right)}, \frac{D}{d}, 1\right)} \]
        16. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{D}{d}\right) \cdot \left(M \cdot \color{blue}{\left(\frac{1}{4} \cdot M\right)}\right), \frac{D}{d}, 1\right)} \]
        17. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{D}{d}\right) \cdot \color{blue}{\left(\left(\frac{1}{4} \cdot M\right) \cdot M\right)}, \frac{D}{d}, 1\right)} \]
        18. associate-*r*N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{D}{d}\right) \cdot \left(\frac{1}{4} \cdot M\right)\right) \cdot M}, \frac{D}{d}, 1\right)} \]
        19. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\left(\frac{\mathsf{neg}\left(h\right)}{\ell} \cdot \frac{D}{d}\right) \cdot \left(\frac{1}{4} \cdot M\right)\right) \cdot M}, \frac{D}{d}, 1\right)} \]
      8. Applied rewrites53.3%

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{h \cdot D}{\left(-\ell\right) \cdot d} \cdot \left(0.25 \cdot M\right)\right) \cdot M}, \frac{D}{d}, 1\right)} \]
      9. Taylor expanded in h around 0

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{4} \cdot \frac{D \cdot \left(M \cdot h\right)}{d \cdot \ell}\right)} \cdot M, \frac{D}{d}, 1\right)} \]
      10. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{D \cdot \left(M \cdot h\right)}{d \cdot \ell} \cdot \frac{-1}{4}\right)} \cdot M, \frac{D}{d}, 1\right)} \]
        2. associate-*l/N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \left(M \cdot h\right)\right) \cdot \frac{-1}{4}}{d \cdot \ell}} \cdot M, \frac{D}{d}, 1\right)} \]
        3. lower-/.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(D \cdot \left(M \cdot h\right)\right) \cdot \frac{-1}{4}}{d \cdot \ell}} \cdot M, \frac{D}{d}, 1\right)} \]
        4. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(D \cdot \left(M \cdot h\right)\right) \cdot \frac{-1}{4}}}{d \cdot \ell} \cdot M, \frac{D}{d}, 1\right)} \]
        5. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\left(M \cdot h\right) \cdot D\right)} \cdot \frac{-1}{4}}{d \cdot \ell} \cdot M, \frac{D}{d}, 1\right)} \]
        6. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\left(M \cdot h\right) \cdot D\right)} \cdot \frac{-1}{4}}{d \cdot \ell} \cdot M, \frac{D}{d}, 1\right)} \]
        7. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\color{blue}{\left(h \cdot M\right)} \cdot D\right) \cdot \frac{-1}{4}}{d \cdot \ell} \cdot M, \frac{D}{d}, 1\right)} \]
        8. lower-*.f64N/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\color{blue}{\left(h \cdot M\right)} \cdot D\right) \cdot \frac{-1}{4}}{d \cdot \ell} \cdot M, \frac{D}{d}, 1\right)} \]
        9. *-commutativeN/A

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\left(h \cdot M\right) \cdot D\right) \cdot \frac{-1}{4}}{\color{blue}{\ell \cdot d}} \cdot M, \frac{D}{d}, 1\right)} \]
        10. lower-*.f6455.1

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\left(h \cdot M\right) \cdot D\right) \cdot -0.25}{\color{blue}{\ell \cdot d}} \cdot M, \frac{D}{d}, 1\right)} \]
      11. Applied rewrites55.1%

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\left(h \cdot M\right) \cdot D\right) \cdot -0.25}{\ell \cdot d}} \cdot M, \frac{D}{d}, 1\right)} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification81.8%

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

    Alternative 7: 80.2% accurate, 0.8× speedup?

    \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+105}:\\ \;\;\;\;\mathsf{fma}\left(-0.125 \cdot \left(D\_m \cdot D\_m\right), \left(\left(\frac{h}{\left(\ell \cdot d\right) \cdot d} \cdot M\_m\right) \cdot M\_m\right) \cdot w0, w0\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot w0\\ \end{array} \end{array} \]
    D_m = (fabs.f64 D)
    M_m = (fabs.f64 M)
    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
    (FPCore (w0 M_m D_m h l d)
     :precision binary64
     (if (<= (* (/ h l) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) -1e+105)
       (fma (* -0.125 (* D_m D_m)) (* (* (* (/ h (* (* l d) d)) M_m) M_m) w0) w0)
       (* 1.0 w0)))
    D_m = fabs(D);
    M_m = fabs(M);
    assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
    double code(double w0, double M_m, double D_m, double h, double l, double d) {
    	double tmp;
    	if (((h / l) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) <= -1e+105) {
    		tmp = fma((-0.125 * (D_m * D_m)), ((((h / ((l * d) * d)) * M_m) * M_m) * w0), w0);
    	} else {
    		tmp = 1.0 * w0;
    	}
    	return tmp;
    }
    
    D_m = abs(D)
    M_m = abs(M)
    w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
    function code(w0, M_m, D_m, h, l, d)
    	tmp = 0.0
    	if (Float64(Float64(h / l) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) <= -1e+105)
    		tmp = fma(Float64(-0.125 * Float64(D_m * D_m)), Float64(Float64(Float64(Float64(h / Float64(Float64(l * d) * d)) * M_m) * M_m) * w0), w0);
    	else
    		tmp = Float64(1.0 * w0);
    	end
    	return tmp
    end
    
    D_m = N[Abs[D], $MachinePrecision]
    M_m = N[Abs[M], $MachinePrecision]
    NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
    code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -1e+105], N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(h / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * w0), $MachinePrecision] + w0), $MachinePrecision], N[(1.0 * w0), $MachinePrecision]]
    
    \begin{array}{l}
    D_m = \left|D\right|
    \\
    M_m = \left|M\right|
    \\
    [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq -1 \cdot 10^{+105}:\\
    \;\;\;\;\mathsf{fma}\left(-0.125 \cdot \left(D\_m \cdot D\_m\right), \left(\left(\frac{h}{\left(\ell \cdot d\right) \cdot d} \cdot M\_m\right) \cdot M\_m\right) \cdot w0, w0\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;1 \cdot w0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -9.9999999999999994e104

      1. Initial program 54.0%

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

        \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

          \[\leadsto \color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + w0 \]
        4. associate-*r*N/A

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

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

          \[\leadsto \color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}} + w0 \]
        7. lower-fma.f64N/A

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

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

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

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

        1. Initial program 86.7%

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

          \[\leadsto w0 \cdot \color{blue}{1} \]
        4. Step-by-step derivation
          1. Applied rewrites90.6%

            \[\leadsto w0 \cdot \color{blue}{1} \]
        5. Recombined 2 regimes into one program.
        6. Final simplification76.9%

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

        Alternative 8: 79.8% accurate, 0.8× speedup?

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

          1. Initial program 54.0%

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

            \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

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

              \[\leadsto \color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + w0 \]
            4. associate-*r*N/A

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

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

              \[\leadsto \color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}} + w0 \]
            7. lower-fma.f64N/A

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

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

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

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

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

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

              1. Initial program 86.7%

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

                \[\leadsto w0 \cdot \color{blue}{1} \]
              4. Step-by-step derivation
                1. Applied rewrites90.6%

                  \[\leadsto w0 \cdot \color{blue}{1} \]
              5. Recombined 2 regimes into one program.
              6. Final simplification76.5%

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

              Alternative 9: 76.8% accurate, 1.6× speedup?

              \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 4 \cdot 10^{-67}:\\ \;\;\;\;1 \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(D\_m, \left(\left(\frac{0.5}{d} \cdot M\_m\right) \cdot \left(h \cdot D\_m\right)\right) \cdot \frac{M\_m \cdot -0.5}{\ell \cdot d}, 1\right)} \cdot w0\\ \end{array} \end{array} \]
              D_m = (fabs.f64 D)
              M_m = (fabs.f64 M)
              NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
              (FPCore (w0 M_m D_m h l d)
               :precision binary64
               (if (<= (/ (* M_m D_m) (* 2.0 d)) 4e-67)
                 (* 1.0 w0)
                 (*
                  (sqrt
                   (fma
                    D_m
                    (* (* (* (/ 0.5 d) M_m) (* h D_m)) (/ (* M_m -0.5) (* l d)))
                    1.0))
                  w0)))
              D_m = fabs(D);
              M_m = fabs(M);
              assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
              double code(double w0, double M_m, double D_m, double h, double l, double d) {
              	double tmp;
              	if (((M_m * D_m) / (2.0 * d)) <= 4e-67) {
              		tmp = 1.0 * w0;
              	} else {
              		tmp = sqrt(fma(D_m, ((((0.5 / d) * M_m) * (h * D_m)) * ((M_m * -0.5) / (l * d))), 1.0)) * w0;
              	}
              	return tmp;
              }
              
              D_m = abs(D)
              M_m = abs(M)
              w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
              function code(w0, M_m, D_m, h, l, d)
              	tmp = 0.0
              	if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 4e-67)
              		tmp = Float64(1.0 * w0);
              	else
              		tmp = Float64(sqrt(fma(D_m, Float64(Float64(Float64(Float64(0.5 / d) * M_m) * Float64(h * D_m)) * Float64(Float64(M_m * -0.5) / Float64(l * d))), 1.0)) * w0);
              	end
              	return tmp
              end
              
              D_m = N[Abs[D], $MachinePrecision]
              M_m = N[Abs[M], $MachinePrecision]
              NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
              code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 4e-67], N[(1.0 * w0), $MachinePrecision], N[(N[Sqrt[N[(D$95$m * N[(N[(N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * -0.5), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
              
              \begin{array}{l}
              D_m = \left|D\right|
              \\
              M_m = \left|M\right|
              \\
              [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 4 \cdot 10^{-67}:\\
              \;\;\;\;1 \cdot w0\\
              
              \mathbf{else}:\\
              \;\;\;\;\sqrt{\mathsf{fma}\left(D\_m, \left(\left(\frac{0.5}{d} \cdot M\_m\right) \cdot \left(h \cdot D\_m\right)\right) \cdot \frac{M\_m \cdot -0.5}{\ell \cdot d}, 1\right)} \cdot w0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 3.99999999999999977e-67

                1. Initial program 81.8%

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

                  \[\leadsto w0 \cdot \color{blue}{1} \]
                4. Step-by-step derivation
                  1. Applied rewrites76.0%

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

                  if 3.99999999999999977e-67 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d))

                  1. Initial program 61.1%

                    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                  2. Add Preprocessing
                  3. Step-by-step derivation
                    1. lift--.f64N/A

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

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
                    3. +-commutativeN/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
                    4. lift-*.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
                    5. distribute-lft-neg-inN/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \frac{h}{\ell}} + 1} \]
                    6. lift-/.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{h}{\ell}} + 1} \]
                    7. clear-numN/A

                      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}} + 1} \]
                    8. un-div-invN/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right)}{\frac{\ell}{h}}} + 1} \]
                    9. lift-pow.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right)}{\frac{\ell}{h}} + 1} \]
                    10. unpow2N/A

                      \[\leadsto w0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}}\right)}{\frac{\ell}{h}} + 1} \]
                    11. distribute-lft-neg-inN/A

                      \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}}{\frac{\ell}{h}} + 1} \]
                    12. div-invN/A

                      \[\leadsto w0 \cdot \sqrt{\frac{\left(\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{M \cdot D}{2 \cdot d}}{\color{blue}{\ell \cdot \frac{1}{h}}} + 1} \]
                    13. times-fracN/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell} \cdot \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}} + 1} \]
                    14. lower-fma.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(\frac{M \cdot D}{2 \cdot d}\right)}{\ell}, \frac{\frac{M \cdot D}{2 \cdot d}}{\frac{1}{h}}, 1\right)}} \]
                  4. Applied rewrites65.4%

                    \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{\left(D \cdot M\right) \cdot -0.5}{d}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)}} \]
                  5. Step-by-step derivation
                    1. lift-/.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\left(D \cdot M\right) \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    2. lift-*.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    3. lift-*.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    4. associate-*l*N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{D \cdot \left(M \cdot \frac{-1}{2}\right)}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    5. associate-/l*N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    6. lower-*.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    7. lower-/.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \color{blue}{\frac{M \cdot \frac{-1}{2}}{d}}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    8. *-commutativeN/A

                      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \frac{\color{blue}{\frac{-1}{2} \cdot M}}{d}}{\ell}, \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                    9. lower-*.f6467.5

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

                    \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{D \cdot \frac{-0.5 \cdot M}{d}}}{\ell}, \frac{\left(\frac{0.5}{d} \cdot M\right) \cdot D}{\frac{1}{h}}, 1\right)} \]
                  7. Step-by-step derivation
                    1. lift-fma.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}} + 1}} \]
                    2. lift-/.f64N/A

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{D \cdot \frac{\frac{-1}{2} \cdot M}{d}}{\ell}} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}} + 1} \]
                    3. lift-*.f64N/A

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

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

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{D \cdot \left(\frac{\frac{\frac{-1}{2} \cdot M}{d}}{\ell} \cdot \frac{\left(\frac{\frac{1}{2}}{d} \cdot M\right) \cdot D}{\frac{1}{h}}\right)} + 1} \]
                    6. lower-fma.f64N/A

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

                    \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(D, \frac{-0.5 \cdot M}{\ell \cdot d} \cdot \left(\left(D \cdot h\right) \cdot \left(M \cdot \frac{0.5}{d}\right)\right), 1\right)}} \]
                5. Recombined 2 regimes into one program.
                6. Final simplification73.7%

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

                Alternative 10: 83.1% accurate, 2.1× speedup?

                \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 10^{-193}:\\ \;\;\;\;\mathsf{fma}\left(-0.125 \cdot \left(D\_m \cdot D\_m\right), \frac{\frac{\frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell} \cdot w0}{d}}{d}, w0\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(-0.25 \cdot D\_m\right) \cdot \left(\left(\frac{h}{\left(\ell \cdot d\right) \cdot d} \cdot M\_m\right) \cdot M\_m\right), D\_m, 1\right)} \cdot w0\\ \end{array} \end{array} \]
                D_m = (fabs.f64 D)
                M_m = (fabs.f64 M)
                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                (FPCore (w0 M_m D_m h l d)
                 :precision binary64
                 (if (<= (* M_m D_m) 1e-193)
                   (fma (* -0.125 (* D_m D_m)) (/ (/ (* (/ (* (* M_m M_m) h) l) w0) d) d) w0)
                   (*
                    (sqrt (fma (* (* -0.25 D_m) (* (* (/ h (* (* l d) d)) M_m) M_m)) D_m 1.0))
                    w0)))
                D_m = fabs(D);
                M_m = fabs(M);
                assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                double code(double w0, double M_m, double D_m, double h, double l, double d) {
                	double tmp;
                	if ((M_m * D_m) <= 1e-193) {
                		tmp = fma((-0.125 * (D_m * D_m)), ((((((M_m * M_m) * h) / l) * w0) / d) / d), w0);
                	} else {
                		tmp = sqrt(fma(((-0.25 * D_m) * (((h / ((l * d) * d)) * M_m) * M_m)), D_m, 1.0)) * w0;
                	}
                	return tmp;
                }
                
                D_m = abs(D)
                M_m = abs(M)
                w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                function code(w0, M_m, D_m, h, l, d)
                	tmp = 0.0
                	if (Float64(M_m * D_m) <= 1e-193)
                		tmp = fma(Float64(-0.125 * Float64(D_m * D_m)), Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) / l) * w0) / d) / d), w0);
                	else
                		tmp = Float64(sqrt(fma(Float64(Float64(-0.25 * D_m) * Float64(Float64(Float64(h / Float64(Float64(l * d) * d)) * M_m) * M_m)), D_m, 1.0)) * w0);
                	end
                	return tmp
                end
                
                D_m = N[Abs[D], $MachinePrecision]
                M_m = N[Abs[M], $MachinePrecision]
                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-193], N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision] * w0), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] + w0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(-0.25 * D$95$m), $MachinePrecision] * N[(N[(N[(h / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
                
                \begin{array}{l}
                D_m = \left|D\right|
                \\
                M_m = \left|M\right|
                \\
                [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                \\
                \begin{array}{l}
                \mathbf{if}\;M\_m \cdot D\_m \leq 10^{-193}:\\
                \;\;\;\;\mathsf{fma}\left(-0.125 \cdot \left(D\_m \cdot D\_m\right), \frac{\frac{\frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell} \cdot w0}{d}}{d}, w0\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\sqrt{\mathsf{fma}\left(\left(-0.25 \cdot D\_m\right) \cdot \left(\left(\frac{h}{\left(\ell \cdot d\right) \cdot d} \cdot M\_m\right) \cdot M\_m\right), D\_m, 1\right)} \cdot w0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (*.f64 M D) < 1e-193

                  1. Initial program 76.4%

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

                    \[\leadsto \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

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

                      \[\leadsto \color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + w0 \]
                    4. associate-*r*N/A

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

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

                      \[\leadsto \color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot \left(h \cdot w0\right)}{{d}^{2} \cdot \ell}} + w0 \]
                    7. lower-fma.f64N/A

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

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

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

                    if 1e-193 < (*.f64 M D)

                    1. Initial program 81.7%

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

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \frac{-1}{4} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}} \]
                    4. Step-by-step derivation
                      1. +-commutativeN/A

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

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

                        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{-1}{4} \cdot {D}^{2}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1} \]
                      4. lower-fma.f64N/A

                        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{4} \cdot {D}^{2}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)}} \]
                      5. lower-*.f64N/A

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

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(D \cdot D\right)}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                      7. lower-*.f64N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(D \cdot D\right)}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                      8. associate-/l*N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{{M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                      9. lower-*.f64N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{{M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                      10. unpow2N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{\left(M \cdot M\right)} \cdot \frac{h}{{d}^{2} \cdot \ell}, 1\right)} \]
                      11. lower-*.f64N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{\left(M \cdot M\right)} \cdot \frac{h}{{d}^{2} \cdot \ell}, 1\right)} \]
                      12. lower-/.f64N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \color{blue}{\frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                      13. *-commutativeN/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\color{blue}{\ell \cdot {d}^{2}}}, 1\right)} \]
                      14. lower-*.f64N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\color{blue}{\ell \cdot {d}^{2}}}, 1\right)} \]
                      15. unpow2N/A

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\ell \cdot \color{blue}{\left(d \cdot d\right)}}, 1\right)} \]
                      16. lower-*.f6448.1

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

                      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-0.25 \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\ell \cdot \left(d \cdot d\right)}, 1\right)}} \]
                    6. Step-by-step derivation
                      1. Applied rewrites52.1%

                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(-0.25 \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\left(\ell \cdot d\right) \cdot \color{blue}{d}}, 1\right)} \]
                      2. Step-by-step derivation
                        1. Applied rewrites74.8%

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

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

                      Alternative 11: 82.6% accurate, 2.1× speedup?

                      \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \leq 9.5 \cdot 10^{-208}:\\ \;\;\;\;1 \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\left(h \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25\right) \cdot D\_m}{\ell \cdot d}, \frac{D\_m}{d}, 1\right)} \cdot w0\\ \end{array} \end{array} \]
                      D_m = (fabs.f64 D)
                      M_m = (fabs.f64 M)
                      NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                      (FPCore (w0 M_m D_m h l d)
                       :precision binary64
                       (if (<= M_m 9.5e-208)
                         (* 1.0 w0)
                         (*
                          (sqrt (fma (/ (* (* (* (* h M_m) M_m) -0.25) D_m) (* l d)) (/ D_m d) 1.0))
                          w0)))
                      D_m = fabs(D);
                      M_m = fabs(M);
                      assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                      double code(double w0, double M_m, double D_m, double h, double l, double d) {
                      	double tmp;
                      	if (M_m <= 9.5e-208) {
                      		tmp = 1.0 * w0;
                      	} else {
                      		tmp = sqrt(fma((((((h * M_m) * M_m) * -0.25) * D_m) / (l * d)), (D_m / d), 1.0)) * w0;
                      	}
                      	return tmp;
                      }
                      
                      D_m = abs(D)
                      M_m = abs(M)
                      w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                      function code(w0, M_m, D_m, h, l, d)
                      	tmp = 0.0
                      	if (M_m <= 9.5e-208)
                      		tmp = Float64(1.0 * w0);
                      	else
                      		tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(Float64(h * M_m) * M_m) * -0.25) * D_m) / Float64(l * d)), Float64(D_m / d), 1.0)) * w0);
                      	end
                      	return tmp
                      end
                      
                      D_m = N[Abs[D], $MachinePrecision]
                      M_m = N[Abs[M], $MachinePrecision]
                      NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                      code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 9.5e-208], N[(1.0 * w0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(N[(N[(N[(h * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
                      
                      \begin{array}{l}
                      D_m = \left|D\right|
                      \\
                      M_m = \left|M\right|
                      \\
                      [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;M\_m \leq 9.5 \cdot 10^{-208}:\\
                      \;\;\;\;1 \cdot w0\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\left(h \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25\right) \cdot D\_m}{\ell \cdot d}, \frac{D\_m}{d}, 1\right)} \cdot w0\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if M < 9.5000000000000001e-208

                        1. Initial program 79.4%

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

                          \[\leadsto w0 \cdot \color{blue}{1} \]
                        4. Step-by-step derivation
                          1. Applied rewrites72.0%

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

                          if 9.5000000000000001e-208 < M

                          1. Initial program 75.8%

                            \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                          2. Add Preprocessing
                          3. Step-by-step derivation
                            1. lift--.f64N/A

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

                              \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
                            3. +-commutativeN/A

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

                            \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{-h}{\ell} \cdot \left(\frac{D}{d} \cdot \left(\left(M \cdot M\right) \cdot 0.25\right)\right), \frac{D}{d}, 1\right)}} \]
                          5. Taylor expanded in h around 0

                            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \frac{D \cdot \left({M}^{2} \cdot h\right)}{d \cdot \ell}}, \frac{D}{d}, 1\right)} \]
                          6. Step-by-step derivation
                            1. associate-*r/N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{-1}{4} \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)}{d \cdot \ell}}, \frac{D}{d}, 1\right)} \]
                            2. lower-/.f64N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{-1}{4} \cdot \left(D \cdot \left({M}^{2} \cdot h\right)\right)}{d \cdot \ell}}, \frac{D}{d}, 1\right)} \]
                            3. *-commutativeN/A

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

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\frac{-1}{4} \cdot \left({M}^{2} \cdot h\right)\right) \cdot D}}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            5. lower-*.f64N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\frac{-1}{4} \cdot \left({M}^{2} \cdot h\right)\right) \cdot D}}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            6. lower-*.f64N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\left(\frac{-1}{4} \cdot \left({M}^{2} \cdot h\right)\right)} \cdot D}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            7. *-commutativeN/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{-1}{4} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}\right) \cdot D}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            8. lower-*.f64N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{-1}{4} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}\right) \cdot D}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            9. unpow2N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{-1}{4} \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right) \cdot D}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            10. lower-*.f64N/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{-1}{4} \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right) \cdot D}{d \cdot \ell}, \frac{D}{d}, 1\right)} \]
                            11. *-commutativeN/A

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{-1}{4} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \cdot D}{\color{blue}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
                            12. lower-*.f6466.2

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

                            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(-0.25 \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \cdot D}{\ell \cdot d}}, \frac{D}{d}, 1\right)} \]
                          8. Step-by-step derivation
                            1. Applied rewrites73.7%

                              \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(-0.25 \cdot \left(\left(h \cdot M\right) \cdot M\right)\right) \cdot D}{\ell \cdot d}, \frac{D}{d}, 1\right)} \]
                          9. Recombined 2 regimes into one program.
                          10. Final simplification72.7%

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

                          Alternative 12: 83.1% accurate, 2.1× speedup?

                          \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 10^{-193}:\\ \;\;\;\;1 \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(-0.25 \cdot D\_m\right) \cdot \left(\left(\frac{h}{\left(\ell \cdot d\right) \cdot d} \cdot M\_m\right) \cdot M\_m\right), D\_m, 1\right)} \cdot w0\\ \end{array} \end{array} \]
                          D_m = (fabs.f64 D)
                          M_m = (fabs.f64 M)
                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                          (FPCore (w0 M_m D_m h l d)
                           :precision binary64
                           (if (<= (* M_m D_m) 1e-193)
                             (* 1.0 w0)
                             (*
                              (sqrt (fma (* (* -0.25 D_m) (* (* (/ h (* (* l d) d)) M_m) M_m)) D_m 1.0))
                              w0)))
                          D_m = fabs(D);
                          M_m = fabs(M);
                          assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                          double code(double w0, double M_m, double D_m, double h, double l, double d) {
                          	double tmp;
                          	if ((M_m * D_m) <= 1e-193) {
                          		tmp = 1.0 * w0;
                          	} else {
                          		tmp = sqrt(fma(((-0.25 * D_m) * (((h / ((l * d) * d)) * M_m) * M_m)), D_m, 1.0)) * w0;
                          	}
                          	return tmp;
                          }
                          
                          D_m = abs(D)
                          M_m = abs(M)
                          w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                          function code(w0, M_m, D_m, h, l, d)
                          	tmp = 0.0
                          	if (Float64(M_m * D_m) <= 1e-193)
                          		tmp = Float64(1.0 * w0);
                          	else
                          		tmp = Float64(sqrt(fma(Float64(Float64(-0.25 * D_m) * Float64(Float64(Float64(h / Float64(Float64(l * d) * d)) * M_m) * M_m)), D_m, 1.0)) * w0);
                          	end
                          	return tmp
                          end
                          
                          D_m = N[Abs[D], $MachinePrecision]
                          M_m = N[Abs[M], $MachinePrecision]
                          NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                          code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-193], N[(1.0 * w0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(-0.25 * D$95$m), $MachinePrecision] * N[(N[(N[(h / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
                          
                          \begin{array}{l}
                          D_m = \left|D\right|
                          \\
                          M_m = \left|M\right|
                          \\
                          [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;M\_m \cdot D\_m \leq 10^{-193}:\\
                          \;\;\;\;1 \cdot w0\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\sqrt{\mathsf{fma}\left(\left(-0.25 \cdot D\_m\right) \cdot \left(\left(\frac{h}{\left(\ell \cdot d\right) \cdot d} \cdot M\_m\right) \cdot M\_m\right), D\_m, 1\right)} \cdot w0\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (*.f64 M D) < 1e-193

                            1. Initial program 76.4%

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

                              \[\leadsto w0 \cdot \color{blue}{1} \]
                            4. Step-by-step derivation
                              1. Applied rewrites72.8%

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

                              if 1e-193 < (*.f64 M D)

                              1. Initial program 81.7%

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

                                \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \frac{-1}{4} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}} \]
                              4. Step-by-step derivation
                                1. +-commutativeN/A

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

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

                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{-1}{4} \cdot {D}^{2}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1} \]
                                4. lower-fma.f64N/A

                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{4} \cdot {D}^{2}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)}} \]
                                5. lower-*.f64N/A

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

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(D \cdot D\right)}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                7. lower-*.f64N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(D \cdot D\right)}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                8. associate-/l*N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{{M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                                9. lower-*.f64N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{{M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                                10. unpow2N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{\left(M \cdot M\right)} \cdot \frac{h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                11. lower-*.f64N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{\left(M \cdot M\right)} \cdot \frac{h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                12. lower-/.f64N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \color{blue}{\frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                                13. *-commutativeN/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\color{blue}{\ell \cdot {d}^{2}}}, 1\right)} \]
                                14. lower-*.f64N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\color{blue}{\ell \cdot {d}^{2}}}, 1\right)} \]
                                15. unpow2N/A

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\ell \cdot \color{blue}{\left(d \cdot d\right)}}, 1\right)} \]
                                16. lower-*.f6448.1

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

                                \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-0.25 \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\ell \cdot \left(d \cdot d\right)}, 1\right)}} \]
                              6. Step-by-step derivation
                                1. Applied rewrites52.1%

                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(-0.25 \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\left(\ell \cdot d\right) \cdot \color{blue}{d}}, 1\right)} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites74.8%

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

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

                                Alternative 13: 81.0% accurate, 2.1× speedup?

                                \[\begin{array}{l} D_m = \left|D\right| \\ M_m = \left|M\right| \\ [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 10^{-193}:\\ \;\;\;\;1 \cdot w0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{h}{\left(d \cdot d\right) \cdot \ell} \cdot M\_m\right) \cdot M\_m\right) \cdot \left(-0.25 \cdot D\_m\right), D\_m, 1\right)} \cdot w0\\ \end{array} \end{array} \]
                                D_m = (fabs.f64 D)
                                M_m = (fabs.f64 M)
                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                (FPCore (w0 M_m D_m h l d)
                                 :precision binary64
                                 (if (<= (* M_m D_m) 1e-193)
                                   (* 1.0 w0)
                                   (*
                                    (sqrt (fma (* (* (* (/ h (* (* d d) l)) M_m) M_m) (* -0.25 D_m)) D_m 1.0))
                                    w0)))
                                D_m = fabs(D);
                                M_m = fabs(M);
                                assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
                                double code(double w0, double M_m, double D_m, double h, double l, double d) {
                                	double tmp;
                                	if ((M_m * D_m) <= 1e-193) {
                                		tmp = 1.0 * w0;
                                	} else {
                                		tmp = sqrt(fma(((((h / ((d * d) * l)) * M_m) * M_m) * (-0.25 * D_m)), D_m, 1.0)) * w0;
                                	}
                                	return tmp;
                                }
                                
                                D_m = abs(D)
                                M_m = abs(M)
                                w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d])
                                function code(w0, M_m, D_m, h, l, d)
                                	tmp = 0.0
                                	if (Float64(M_m * D_m) <= 1e-193)
                                		tmp = Float64(1.0 * w0);
                                	else
                                		tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(h / Float64(Float64(d * d) * l)) * M_m) * M_m) * Float64(-0.25 * D_m)), D_m, 1.0)) * w0);
                                	end
                                	return tmp
                                end
                                
                                D_m = N[Abs[D], $MachinePrecision]
                                M_m = N[Abs[M], $MachinePrecision]
                                NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
                                code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-193], N[(1.0 * w0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(N[(N[(h / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(-0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
                                
                                \begin{array}{l}
                                D_m = \left|D\right|
                                \\
                                M_m = \left|M\right|
                                \\
                                [w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;M\_m \cdot D\_m \leq 10^{-193}:\\
                                \;\;\;\;1 \cdot w0\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{h}{\left(d \cdot d\right) \cdot \ell} \cdot M\_m\right) \cdot M\_m\right) \cdot \left(-0.25 \cdot D\_m\right), D\_m, 1\right)} \cdot w0\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if (*.f64 M D) < 1e-193

                                  1. Initial program 76.4%

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

                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites72.8%

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

                                    if 1e-193 < (*.f64 M D)

                                    1. Initial program 81.7%

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

                                      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \frac{-1}{4} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}} \]
                                    4. Step-by-step derivation
                                      1. +-commutativeN/A

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

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

                                        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\frac{-1}{4} \cdot {D}^{2}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1} \]
                                      4. lower-fma.f64N/A

                                        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{-1}{4} \cdot {D}^{2}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)}} \]
                                      5. lower-*.f64N/A

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

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(D \cdot D\right)}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                      7. lower-*.f64N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(D \cdot D\right)}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                      8. associate-/l*N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{{M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                                      9. lower-*.f64N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{{M}^{2} \cdot \frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                                      10. unpow2N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{\left(M \cdot M\right)} \cdot \frac{h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                      11. lower-*.f64N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \color{blue}{\left(M \cdot M\right)} \cdot \frac{h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                      12. lower-/.f64N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \color{blue}{\frac{h}{{d}^{2} \cdot \ell}}, 1\right)} \]
                                      13. *-commutativeN/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\color{blue}{\ell \cdot {d}^{2}}}, 1\right)} \]
                                      14. lower-*.f64N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\color{blue}{\ell \cdot {d}^{2}}}, 1\right)} \]
                                      15. unpow2N/A

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \left(D \cdot D\right), \left(M \cdot M\right) \cdot \frac{h}{\ell \cdot \color{blue}{\left(d \cdot d\right)}}, 1\right)} \]
                                      16. lower-*.f6448.1

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

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

                                        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\left(\frac{h}{\left(d \cdot d\right) \cdot \ell} \cdot M\right) \cdot M\right) \cdot \left(-0.25 \cdot D\right), \color{blue}{D}, 1\right)} \]
                                    7. Recombined 2 regimes into one program.
                                    8. Final simplification72.2%

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

                                    Alternative 14: 68.8% accurate, 26.2× speedup?

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

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

                                      \[\leadsto w0 \cdot \color{blue}{1} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites67.8%

                                        \[\leadsto w0 \cdot \color{blue}{1} \]
                                      2. Final simplification67.8%

                                        \[\leadsto 1 \cdot w0 \]
                                      3. Add Preprocessing

                                      Reproduce

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