Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 82.2% → 88.7%
Time: 17.4s
Alternatives: 9
Speedup: 0.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 82.2% accurate, 1.0× speedup?

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

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

Alternative 1: 88.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{M \cdot D}{2 \cdot d}\\ \mathbf{if}\;{t\_0}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{h}{\ell} \cdot \frac{M \cdot D}{d \cdot -2}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (/ (* M D) (* 2.0 d))))
   (if (<= (* (pow t_0 2.0) (/ h l)) 5e-10)
     (* w0 (sqrt (fma t_0 (* (/ h l) (/ (* M D) (* d -2.0))) 1.0)))
     (*
      w0
      (sqrt
       (fma (* (* M h) (/ D (* -2.0 (* d l)))) (* 0.5 (* D (/ M d))) 1.0))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (2.0 * d);
	double tmp;
	if ((pow(t_0, 2.0) * (h / l)) <= 5e-10) {
		tmp = w0 * sqrt(fma(t_0, ((h / l) * ((M * D) / (d * -2.0))), 1.0));
	} else {
		tmp = w0 * sqrt(fma(((M * h) * (D / (-2.0 * (d * l)))), (0.5 * (D * (M / d))), 1.0));
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * D) / Float64(2.0 * d))
	tmp = 0.0
	if (Float64((t_0 ^ 2.0) * Float64(h / l)) <= 5e-10)
		tmp = Float64(w0 * sqrt(fma(t_0, Float64(Float64(h / l) * Float64(Float64(M * D) / Float64(d * -2.0))), 1.0)));
	else
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * h) * Float64(D / Float64(-2.0 * Float64(d * l)))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0)));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 5e-10], N[(w0 * N[Sqrt[N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(M * h), $MachinePrecision] * N[(D / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\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)) < 5.00000000000000031e-10

    1. Initial program 87.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. 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-pow.f64N/A

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := M \cdot \frac{D}{d}\\ \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0 \cdot -0.5, \frac{h}{\ell} \cdot \left(0.5 \cdot t\_0\right), 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* M (/ D d))))
   (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) 5e-10)
     (* w0 (sqrt (fma (* t_0 -0.5) (* (/ h l) (* 0.5 t_0)) 1.0)))
     (*
      w0
      (sqrt
       (fma (* (* M h) (/ D (* -2.0 (* d l)))) (* 0.5 (* D (/ M d))) 1.0))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (D / d);
	double tmp;
	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 5e-10) {
		tmp = w0 * sqrt(fma((t_0 * -0.5), ((h / l) * (0.5 * t_0)), 1.0));
	} else {
		tmp = w0 * sqrt(fma(((M * h) * (D / (-2.0 * (d * l)))), (0.5 * (D * (M / d))), 1.0));
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	t_0 = Float64(M * Float64(D / d))
	tmp = 0.0
	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 5e-10)
		tmp = Float64(w0 * sqrt(fma(Float64(t_0 * -0.5), Float64(Float64(h / l) * Float64(0.5 * t_0)), 1.0)));
	else
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * h) * Float64(D / Float64(-2.0 * Float64(d * l)))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0)));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 5e-10], N[(w0 * N[Sqrt[N[(N[(t$95$0 * -0.5), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(M * h), $MachinePrecision] * N[(D / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\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)) < 5.00000000000000031e-10

    1. Initial program 87.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. 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-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 83.9% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 67.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. 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-pow.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 89.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 rewrites97.9%

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

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

    Alternative 4: 83.2% accurate, 0.8× speedup?

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

      1. Initial program 66.1%

        \[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 inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            1. Initial program 89.1%

              \[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 rewrites96.9%

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

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

            Alternative 5: 79.8% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+188}:\\ \;\;\;\;\mathsf{fma}\left(D \cdot D, \left(M \cdot -0.125\right) \cdot \left(M \cdot \frac{h \cdot w0}{d \cdot \left(d \cdot \ell\right)}\right), w0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
            (FPCore (w0 M D h l d)
             :precision binary64
             (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -4e+188)
               (fma (* D D) (* (* M -0.125) (* M (/ (* h w0) (* d (* d l))))) w0)
               (* w0 1.0)))
            double code(double w0, double M, double D, double h, double l, double d) {
            	double tmp;
            	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188) {
            		tmp = fma((D * D), ((M * -0.125) * (M * ((h * w0) / (d * (d * l))))), w0);
            	} else {
            		tmp = w0 * 1.0;
            	}
            	return tmp;
            }
            
            function code(w0, M, D, h, l, d)
            	tmp = 0.0
            	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -4e+188)
            		tmp = fma(Float64(D * D), Float64(Float64(M * -0.125) * Float64(M * Float64(Float64(h * w0) / Float64(d * Float64(d * l))))), w0);
            	else
            		tmp = Float64(w0 * 1.0);
            	end
            	return tmp
            end
            
            code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -4e+188], N[(N[(D * D), $MachinePrecision] * N[(N[(M * -0.125), $MachinePrecision] * N[(M * N[(N[(h * w0), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+188}:\\
            \;\;\;\;\mathsf{fma}\left(D \cdot D, \left(M \cdot -0.125\right) \cdot \left(M \cdot \frac{h \cdot w0}{d \cdot \left(d \cdot \ell\right)}\right), w0\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;w0 \cdot 1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000001e188

              1. Initial program 61.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. lower-fma.f64N/A

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

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

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

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

                1. Initial program 89.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 rewrites91.0%

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

                Alternative 6: 80.6% accurate, 0.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+188}:\\ \;\;\;\;D \cdot \left(\left(D \cdot -0.125\right) \cdot \frac{M \cdot \left(M \cdot \left(h \cdot w0\right)\right)}{d \cdot \left(d \cdot \ell\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
                (FPCore (w0 M D h l d)
                 :precision binary64
                 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -4e+188)
                   (* D (* (* D -0.125) (/ (* M (* M (* h w0))) (* d (* d l)))))
                   (* w0 1.0)))
                double code(double w0, double M, double D, double h, double l, double d) {
                	double tmp;
                	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188) {
                		tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l))));
                	} else {
                		tmp = w0 * 1.0;
                	}
                	return tmp;
                }
                
                real(8) function code(w0, m, d, h, l, d_1)
                    real(8), intent (in) :: w0
                    real(8), intent (in) :: m
                    real(8), intent (in) :: d
                    real(8), intent (in) :: h
                    real(8), intent (in) :: l
                    real(8), intent (in) :: d_1
                    real(8) :: tmp
                    if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-4d+188)) then
                        tmp = d * ((d * (-0.125d0)) * ((m * (m * (h * w0))) / (d_1 * (d_1 * l))))
                    else
                        tmp = w0 * 1.0d0
                    end if
                    code = tmp
                end function
                
                public static double code(double w0, double M, double D, double h, double l, double d) {
                	double tmp;
                	if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188) {
                		tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l))));
                	} else {
                		tmp = w0 * 1.0;
                	}
                	return tmp;
                }
                
                def code(w0, M, D, h, l, d):
                	tmp = 0
                	if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188:
                		tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l))))
                	else:
                		tmp = w0 * 1.0
                	return tmp
                
                function code(w0, M, D, h, l, d)
                	tmp = 0.0
                	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -4e+188)
                		tmp = Float64(D * Float64(Float64(D * -0.125) * Float64(Float64(M * Float64(M * Float64(h * w0))) / Float64(d * Float64(d * l)))));
                	else
                		tmp = Float64(w0 * 1.0);
                	end
                	return tmp
                end
                
                function tmp_2 = code(w0, M, D, h, l, d)
                	tmp = 0.0;
                	if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -4e+188)
                		tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l))));
                	else
                		tmp = w0 * 1.0;
                	end
                	tmp_2 = tmp;
                end
                
                code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -4e+188], N[(D * N[(N[(D * -0.125), $MachinePrecision] * N[(N[(M * N[(M * N[(h * w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+188}:\\
                \;\;\;\;D \cdot \left(\left(D \cdot -0.125\right) \cdot \frac{M \cdot \left(M \cdot \left(h \cdot w0\right)\right)}{d \cdot \left(d \cdot \ell\right)}\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;w0 \cdot 1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000001e188

                  1. Initial program 61.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. lower-fma.f64N/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(D \cdot D, \frac{\left(-0.125 \cdot \left(M \cdot M\right)\right) \cdot \left(w0 \cdot h\right)}{\left(d \cdot d\right) \cdot \ell}, 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 rewrites42.5%

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

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

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

                      1. Initial program 89.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 rewrites91.0%

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

                      Alternative 7: 78.8% accurate, 1.9× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 5 \cdot 10^{-141}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \left(M \cdot h\right)}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\left(\left(M \cdot M\right) \cdot 0.25\right) \cdot \frac{D}{-d}\right), \frac{D}{d}, 1\right)}\\ \end{array} \end{array} \]
                      (FPCore (w0 M D h l d)
                       :precision binary64
                       (if (<= M 5e-141)
                         (*
                          w0
                          (sqrt (fma (/ (* D (* M h)) (* -2.0 (* d l))) (* 0.5 (* D (/ M d))) 1.0)))
                         (*
                          w0
                          (sqrt (fma (* (/ h l) (* (* (* M M) 0.25) (/ D (- d)))) (/ D d) 1.0)))))
                      double code(double w0, double M, double D, double h, double l, double d) {
                      	double tmp;
                      	if (M <= 5e-141) {
                      		tmp = w0 * sqrt(fma(((D * (M * h)) / (-2.0 * (d * l))), (0.5 * (D * (M / d))), 1.0));
                      	} else {
                      		tmp = w0 * sqrt(fma(((h / l) * (((M * M) * 0.25) * (D / -d))), (D / d), 1.0));
                      	}
                      	return tmp;
                      }
                      
                      function code(w0, M, D, h, l, d)
                      	tmp = 0.0
                      	if (M <= 5e-141)
                      		tmp = Float64(w0 * sqrt(fma(Float64(Float64(D * Float64(M * h)) / Float64(-2.0 * Float64(d * l))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0)));
                      	else
                      		tmp = Float64(w0 * sqrt(fma(Float64(Float64(h / l) * Float64(Float64(Float64(M * M) * 0.25) * Float64(D / Float64(-d)))), Float64(D / d), 1.0)));
                      	end
                      	return tmp
                      end
                      
                      code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 5e-141], N[(w0 * N[Sqrt[N[(N[(N[(D * N[(M * h), $MachinePrecision]), $MachinePrecision] / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * 0.25), $MachinePrecision] * N[(D / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;M \leq 5 \cdot 10^{-141}:\\
                      \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \left(M \cdot h\right)}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\left(\left(M \cdot M\right) \cdot 0.25\right) \cdot \frac{D}{-d}\right), \frac{D}{d}, 1\right)}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if M < 4.9999999999999999e-141

                        1. Initial program 82.5%

                          \[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-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        if 4.9999999999999999e-141 < M

                        1. Initial program 78.3%

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

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

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

                      Alternative 8: 81.6% accurate, 2.1× speedup?

                      \[\begin{array}{l} \\ w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)} \end{array} \]
                      (FPCore (w0 M D h l d)
                       :precision binary64
                       (*
                        w0
                        (sqrt (fma (* (* M h) (/ D (* -2.0 (* d l)))) (* 0.5 (* D (/ M d))) 1.0))))
                      double code(double w0, double M, double D, double h, double l, double d) {
                      	return w0 * sqrt(fma(((M * h) * (D / (-2.0 * (d * l)))), (0.5 * (D * (M / d))), 1.0));
                      }
                      
                      function code(w0, M, D, h, l, d)
                      	return Float64(w0 * sqrt(fma(Float64(Float64(M * h) * Float64(D / Float64(-2.0 * Float64(d * l)))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0)))
                      end
                      
                      code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(N[(M * h), $MachinePrecision] * N[(D / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}
                      \end{array}
                      
                      Derivation
                      1. Initial program 81.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-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 9: 69.1% accurate, 26.2× speedup?

                      \[\begin{array}{l} \\ w0 \cdot 1 \end{array} \]
                      (FPCore (w0 M D h l d) :precision binary64 (* w0 1.0))
                      double code(double w0, double M, double D, double h, double l, double d) {
                      	return w0 * 1.0;
                      }
                      
                      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 * 1.0d0
                      end function
                      
                      public static double code(double w0, double M, double D, double h, double l, double d) {
                      	return w0 * 1.0;
                      }
                      
                      def code(w0, M, D, h, l, d):
                      	return w0 * 1.0
                      
                      function code(w0, M, D, h, l, d)
                      	return Float64(w0 * 1.0)
                      end
                      
                      function tmp = code(w0, M, D, h, l, d)
                      	tmp = w0 * 1.0;
                      end
                      
                      code[w0_, M_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      w0 \cdot 1
                      \end{array}
                      
                      Derivation
                      1. Initial program 81.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 rewrites64.6%

                          \[\leadsto w0 \cdot \color{blue}{1} \]
                        2. Add Preprocessing

                        Reproduce

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