Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.5% → 86.7%
Time: 15.7s
Alternatives: 11
Speedup: 1.0×

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

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

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

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

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


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

    1. Initial program 50.4%

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}\right)} - 1\right) \]
      4. pow-prod-down44.9%

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{{\left(D \cdot M\right)}^{2} \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right)} - 1\right) \]
    5. Applied egg-rr44.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -3.99999999999999982e-258

    1. Initial program 82.1%

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

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

    if -3.99999999999999982e-258 < (/.f64 h l)

    1. Initial program 85.2%

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

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

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

Alternative 2: 86.9% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 69.7%

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

      \[\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. *-commutative71.0%

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

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

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

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

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

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

    1. Initial program 87.1%

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

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

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

Alternative 3: 86.6% accurate, 0.7× speedup?

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

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

    \[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. Step-by-step derivation
    1. associate-*r/87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 86.4% accurate, 1.0× speedup?

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

\\
w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{{\left(\frac{d}{D \cdot M}\right)}^{2}}}}}
\end{array}
Derivation
  1. Initial program 81.2%

    \[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. Step-by-step derivation
    1. associate-*r/87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{1 - {\left(\frac{\ell}{\left(0.25 \cdot \frac{D}{\frac{\frac{d}{M}}{D} \cdot \frac{d}{M}}\right) \cdot h}\right)}^{-1}}\right)} - 1\right)} \]
  10. Applied egg-rr81.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\frac{\color{blue}{\frac{d}{M} \cdot \frac{d}{M}}}{D \cdot D}}}}} \]
    10. times-frac87.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\color{blue}{\frac{\frac{d}{M}}{D} \cdot \frac{\frac{d}{M}}{D}}}}}} \]
    11. associate-/r*86.2%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\color{blue}{\frac{d}{M \cdot D}} \cdot \frac{\frac{d}{M}}{D}}}}} \]
    12. *-commutative86.2%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\frac{d}{\color{blue}{D \cdot M}} \cdot \frac{\frac{d}{M}}{D}}}}} \]
    13. associate-/r*87.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\frac{d}{D \cdot M} \cdot \color{blue}{\frac{d}{M \cdot D}}}}}} \]
    14. *-commutative87.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\frac{d}{D \cdot M} \cdot \frac{d}{\color{blue}{D \cdot M}}}}}} \]
    15. unpow187.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\color{blue}{{\left(\frac{d}{D \cdot M}\right)}^{1}} \cdot \frac{d}{D \cdot M}}}}} \]
    16. pow-plus87.0%

      \[\leadsto w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot \frac{0.25}{\color{blue}{{\left(\frac{d}{D \cdot M}\right)}^{\left(1 + 1\right)}}}}}} \]
    17. metadata-eval87.0%

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

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

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

Alternative 5: 86.4% accurate, 1.0× speedup?

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

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

    \[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. Step-by-step derivation
    1. associate-*r/87.0%

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

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

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

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

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

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

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

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

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

Alternative 6: 79.8% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 + -0.125 \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \left(w0 \cdot h\right)}{\ell}\\

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

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


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

    1. Initial program 50.4%

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w0\right)}}{{d}^{2} \cdot \ell}\right)} - 1\right) \]
      4. pow-prod-down44.9%

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{{\left(D \cdot M\right)}^{2} \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right)} - 1\right) \]
    5. Applied egg-rr44.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \frac{{D}^{2} \cdot \color{blue}{\frac{h \cdot w0}{\frac{{d}^{2}}{{M}^{2}}}}}{\ell} \]
      4. associate-*r/50.2%

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 h l) < -1e-142

    1. Initial program 82.3%

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

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

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

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

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

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

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

        \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{{\left(D \cdot M\right)}^{2} \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right)} - 1\right) \]
    5. Applied egg-rr32.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-142 < (/.f64 h l)

    1. Initial program 84.5%

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

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

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

Alternative 7: 78.3% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 77.6%

      \[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}}} \]
    3. Taylor expanded in D around 0 41.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-142 < (/.f64 h l)

    1. Initial program 84.5%

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

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

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

Alternative 8: 77.8% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999996e-120 < (/.f64 h l)

    1. Initial program 82.8%

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

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

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

Alternative 9: 81.2% accurate, 1.8× speedup?

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

\\
w0 + -0.125 \cdot \frac{1}{\frac{\frac{\ell}{h \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}}}{w0}}
\end{array}
Derivation
  1. Initial program 81.2%

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

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

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

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

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

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

      \[\leadsto w0 + -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{{\left(D \cdot M\right)}^{2} \cdot \left(h \cdot w0\right)}{\color{blue}{\ell \cdot {d}^{2}}}\right)} - 1\right) \]
  5. Applied egg-rr52.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 72.7% accurate, 9.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := D \cdot \frac{M}{d}\\ \mathbf{if}\;M \leq 2.06 \cdot 10^{-7}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 + -0.125 \cdot \left(\left(t_0 \cdot t_0\right) \cdot \frac{h}{\frac{\ell}{w0}}\right)\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* D (/ M d))))
   (if (<= M 2.06e-7) w0 (+ w0 (* -0.125 (* (* t_0 t_0) (/ h (/ l w0))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (M / d);
	double tmp;
	if (M <= 2.06e-7) {
		tmp = w0;
	} else {
		tmp = w0 + (-0.125 * ((t_0 * t_0) * (h / (l / w0))));
	}
	return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d * (m / d_1)
    if (m <= 2.06d-7) then
        tmp = w0
    else
        tmp = w0 + ((-0.125d0) * ((t_0 * t_0) * (h / (l / w0))))
    end if
    code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (M / d);
	double tmp;
	if (M <= 2.06e-7) {
		tmp = w0;
	} else {
		tmp = w0 + (-0.125 * ((t_0 * t_0) * (h / (l / w0))));
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	t_0 = D * (M / d)
	tmp = 0
	if M <= 2.06e-7:
		tmp = w0
	else:
		tmp = w0 + (-0.125 * ((t_0 * t_0) * (h / (l / w0))))
	return tmp
function code(w0, M, D, h, l, d)
	t_0 = Float64(D * Float64(M / d))
	tmp = 0.0
	if (M <= 2.06e-7)
		tmp = w0;
	else
		tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(t_0 * t_0) * Float64(h / Float64(l / w0)))));
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = D * (M / d);
	tmp = 0.0;
	if (M <= 2.06e-7)
		tmp = w0;
	else
		tmp = w0 + (-0.125 * ((t_0 * t_0) * (h / (l / w0))));
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 2.06e-7], w0, N[(w0 + N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(h / N[(l / w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := D \cdot \frac{M}{d}\\
\mathbf{if}\;M \leq 2.06 \cdot 10^{-7}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(t_0 \cdot t_0\right) \cdot \frac{h}{\frac{\ell}{w0}}\right)\\


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

    1. Initial program 80.9%

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

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

    if 2.05999999999999992e-7 < M

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 69.2% accurate, 216.0× speedup?

\[\begin{array}{l} \\ w0 \end{array} \]
(FPCore (w0 M D h l d) :precision binary64 w0)
double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0;
}
def code(w0, M, D, h, l, d):
	return w0
function code(w0, M, D, h, l, d)
	return w0
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0;
end
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}

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

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

    \[\leadsto \color{blue}{w0} \]
  4. Final simplification66.1%

    \[\leadsto w0 \]

Reproduce

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