Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.4% → 86.5%
Time: 14.3s
Alternatives: 11
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.4% 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: 86.5% accurate, 0.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < 5.0000000000000003e271

    1. Initial program 99.4%

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

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

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

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

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

    if 5.0000000000000003e271 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))

    1. Initial program 43.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 83.1% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.69999999999999986e-29

    1. Initial program 80.0%

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

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

    if 1.69999999999999986e-29 < d

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \left(1 + \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{\color{blue}{M \cdot \left(M \cdot h\right)}}{\ell}\right) \cdot -0.125\right) \]
    10. Simplified74.5%

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

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

Alternative 3: 81.2% accurate, 1.8× speedup?

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

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


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

    1. Initial program 82.2%

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

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

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

    if 6.8000000000000005e-151 < M

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.5% accurate, 1.8× speedup?

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

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


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

    1. Initial program 82.2%

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

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

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

    if 9.19999999999999984e-151 < M

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.3% accurate, 1.8× speedup?

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

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


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

    1. Initial program 82.2%

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

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

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

    if 4.30000000000000004e-150 < M

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 75.1% accurate, 9.4× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ \begin{array}{l} \mathbf{if}\;M \leq 76:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(h \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{D \cdot D}{d \cdot \ell}\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 76.0)
   w0
   (* w0 (+ 1.0 (* -0.125 (* h (* (* M (/ M d)) (/ (* D D) (* d l)))))))))
M = abs(M);
D = abs(D);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 76.0) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * (h * ((M * (M / d)) * ((D * D) / (d * l))))));
	}
	return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (m <= 76.0d0) then
        tmp = w0
    else
        tmp = w0 * (1.0d0 + ((-0.125d0) * (h * ((m * (m / d_1)) * ((d * d) / (d_1 * l))))))
    end if
    code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 76.0) {
		tmp = w0;
	} else {
		tmp = w0 * (1.0 + (-0.125 * (h * ((M * (M / d)) * ((D * D) / (d * l))))));
	}
	return tmp;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 76.0:
		tmp = w0
	else:
		tmp = w0 * (1.0 + (-0.125 * (h * ((M * (M / d)) * ((D * D) / (d * l))))))
	return tmp
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 76.0)
		tmp = w0;
	else
		tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(h * Float64(Float64(M * Float64(M / d)) * Float64(Float64(D * D) / Float64(d * l)))))));
	end
	return tmp
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 76.0)
		tmp = w0;
	else
		tmp = w0 * (1.0 + (-0.125 * (h * ((M * (M / d)) * ((D * D) / (d * l))))));
	end
	tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 76.0], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(h * N[(N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[(N[(D * D), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 76:\\
\;\;\;\;w0\\

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


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

    1. Initial program 82.8%

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

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

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

    if 76 < 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. Simplified74.2%

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \left(\frac{D \cdot D}{d \cdot d} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right)} \]
    6. Taylor expanded in D around 0 40.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 76:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(h \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{D \cdot D}{d \cdot \ell}\right)\right)\right)\\ \end{array} \]

Alternative 7: 77.9% accurate, 9.4× speedup?

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

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


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

    1. Initial program 81.9%

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

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

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

    if 1.00000000000000001e-125 < M

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.3% accurate, 9.4× speedup?

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

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


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

    1. Initial program 81.7%

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

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

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

    if 6.20000000000000055e-141 < M

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 72.6% accurate, 10.3× speedup?

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

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


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

    1. Initial program 82.7%

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

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

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

    if 2.10000000000000011e124 < M

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right) \]
    8. Taylor expanded in D around inf 22.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot \left(h \cdot w0\right)\right)}{\left(d \cdot d\right) \cdot \ell}} \]
    11. Step-by-step derivation
      1. times-frac22.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.1 \cdot 10^{+124}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.125}{d \cdot d} \cdot \frac{\left(D \cdot D\right) \cdot \left(M \cdot \left(M \cdot \left(h \cdot w0\right)\right)\right)}{\ell}\\ \end{array} \]

Alternative 10: 72.7% accurate, 10.3× speedup?

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

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


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

    1. Initial program 82.7%

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

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

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

    if 2.2000000000000001e124 < M

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \left(1 + \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \frac{\left(M \cdot M\right) \cdot h}{\ell}\right) \cdot -0.125\right) \]
    8. Taylor expanded in D around inf 22.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot \left(h \cdot w0\right)\right)}{\left(d \cdot d\right) \cdot \ell}} \]
    11. Taylor expanded in d around 0 22.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 2.2 \cdot 10^{+124}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right) \cdot \left(h \cdot w0\right)\right)}{d \cdot \left(d \cdot \ell\right)}\\ \end{array} \]

Alternative 11: 70.1% accurate, 216.0× speedup?

\[\begin{array}{l} M = |M|\\ D = |D|\\ [M, D] = \mathsf{sort}([M, D])\\ \\ w0 \end{array} \]
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d) :precision binary64 w0)
M = abs(M);
D = abs(D);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0
end function
M = Math.abs(M);
D = Math.abs(D);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
M = abs(M)
D = abs(D)
[M, D] = sort([M, D])
def code(w0, M, D, h, l, d):
	return w0
M = abs(M)
D = abs(D)
M, D = sort([M, D])
function code(w0, M, D, h, l, d)
	return w0
end
M = abs(M)
D = abs(D)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
	tmp = w0;
end
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
M = |M|\\
D = |D|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Derivation
  1. Initial program 81.1%

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

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

    \[\leadsto \color{blue}{w0} \]
  4. Final simplification67.6%

    \[\leadsto w0 \]

Reproduce

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