Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 87.8%
Time: 19.7s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 81.3% accurate, 1.0× speedup?

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

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

Alternative 1: 87.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{h}\\ \mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D}{\frac{d}{M} \cdot 2}\right)}^{2}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \frac{t\_0}{\ell}}\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* (* D (* 0.5 (/ M d))) (sqrt h))))
   (if (<= h -4e-310)
     (* w0 (sqrt (- 1.0 (/ (* h (pow (/ D (* (/ d M) 2.0)) 2.0)) l))))
     (* w0 (sqrt (- 1.0 (* t_0 (/ t_0 l))))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (D * (0.5 * (M / d))) * sqrt(h);
	double tmp;
	if (h <= -4e-310) {
		tmp = w0 * sqrt((1.0 - ((h * pow((D / ((d / M) * 2.0)), 2.0)) / l)));
	} else {
		tmp = w0 * sqrt((1.0 - (t_0 * (t_0 / l))));
	}
	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 * (0.5d0 * (m / d_1))) * sqrt(h)
    if (h <= (-4d-310)) then
        tmp = w0 * sqrt((1.0d0 - ((h * ((d / ((d_1 / m) * 2.0d0)) ** 2.0d0)) / l)))
    else
        tmp = w0 * sqrt((1.0d0 - (t_0 * (t_0 / l))))
    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 * (0.5 * (M / d))) * Math.sqrt(h);
	double tmp;
	if (h <= -4e-310) {
		tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((D / ((d / M) * 2.0)), 2.0)) / l)));
	} else {
		tmp = w0 * Math.sqrt((1.0 - (t_0 * (t_0 / l))));
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	t_0 = (D * (0.5 * (M / d))) * math.sqrt(h)
	tmp = 0
	if h <= -4e-310:
		tmp = w0 * math.sqrt((1.0 - ((h * math.pow((D / ((d / M) * 2.0)), 2.0)) / l)))
	else:
		tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 / l))))
	return tmp
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(D * Float64(0.5 * Float64(M / d))) * sqrt(h))
	tmp = 0.0
	if (h <= -4e-310)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D / Float64(Float64(d / M) * 2.0)) ^ 2.0)) / l))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_0 / l)))));
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = (D * (0.5 * (M / d))) * sqrt(h);
	tmp = 0.0;
	if (h <= -4e-310)
		tmp = w0 * sqrt((1.0 - ((h * ((D / ((d / M) * 2.0)) ^ 2.0)) / l)));
	else
		tmp = w0 * sqrt((1.0 - (t_0 * (t_0 / l))));
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D * N[(0.5 * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D / N[(N[(d / M), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \frac{t\_0}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -3.999999999999988e-310

    1. Initial program 74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < h

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.1% 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 -2 \cdot 10^{-13}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\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)) -2e-13)
   (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D (/ (/ M 2.0) d)) 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)) <= -2e-13) {
		tmp = w0 * sqrt((1.0 - ((h / l) * pow((D * ((M / 2.0) / d)), 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)) <= (-2d-13)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d * ((m / 2.0d0) / d_1)) ** 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)) <= -2e-13) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D * ((M / 2.0) / d)), 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)) <= -2e-13:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D * ((M / 2.0) / d)), 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)) <= -2e-13)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D * Float64(Float64(M / 2.0) / d)) ^ 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)) <= -2e-13)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((D * ((M / 2.0) / d)) ^ 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], -2e-13], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(N[(M / 2.0), $MachinePrecision] / d), $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 -2 \cdot 10^{-13}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\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)) < -2.0000000000000001e-13

    1. Initial program 57.1%

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

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

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

    1. Initial program 84.3%

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

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

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

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

Alternative 3: 87.0% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -3.999999999999988e-310

    1. Initial program 74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < h

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 86.1% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 64.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 3000000000000:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(w0 \cdot \left(1 + w0 \cdot \left(w0 \cdot 0.3333333333333333 - 0.5\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 3000000000000.0)
   w0
   (expm1 (* w0 (+ 1.0 (* w0 (- (* w0 0.3333333333333333) 0.5)))))))
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 3000000000000.0) {
		tmp = w0;
	} else {
		tmp = expm1((w0 * (1.0 + (w0 * ((w0 * 0.3333333333333333) - 0.5)))));
	}
	return tmp;
}
public static double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 3000000000000.0) {
		tmp = w0;
	} else {
		tmp = Math.expm1((w0 * (1.0 + (w0 * ((w0 * 0.3333333333333333) - 0.5)))));
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 3000000000000.0:
		tmp = w0
	else:
		tmp = math.expm1((w0 * (1.0 + (w0 * ((w0 * 0.3333333333333333) - 0.5)))))
	return tmp
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 3000000000000.0)
		tmp = w0;
	else
		tmp = expm1(Float64(w0 * Float64(1.0 + Float64(w0 * Float64(Float64(w0 * 0.3333333333333333) - 0.5)))));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3000000000000.0], w0, N[(Exp[N[(w0 * N[(1.0 + N[(w0 * N[(N[(w0 * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 3000000000000:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(w0 \cdot \left(1 + w0 \cdot \left(w0 \cdot 0.3333333333333333 - 0.5\right)\right)\right)\\


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

    1. Initial program 76.5%

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

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

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

    if 3e12 < M

    1. Initial program 68.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \sqrt{1 - h \cdot \frac{{\color{blue}{\left(\frac{\frac{D}{d}}{\frac{2}{M}}\right)}}^{2}}{\ell}}\right)\right) \]
      9. associate-/r/47.2%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + w0\right)}\right) \]
    8. Step-by-step derivation
      1. log1p-define30.6%

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(w0\right)}\right) \]
    9. Simplified30.6%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(w0\right)}\right) \]
    10. Taylor expanded in w0 around 0 37.6%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{w0 \cdot \left(1 + w0 \cdot \left(0.3333333333333333 \cdot w0 - 0.5\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3000000000000:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(w0 \cdot \left(1 + w0 \cdot \left(w0 \cdot 0.3333333333333333 - 0.5\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.7% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 3.2 \cdot 10^{+95}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(w0 + -1\right) \cdot \left(1 - w0\right)}{2 - w0}\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= M 3.2e+95) w0 (/ (+ 1.0 (* (+ w0 -1.0) (- 1.0 w0))) (- 2.0 w0))))
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if (M <= 3.2e+95) {
		tmp = w0;
	} else {
		tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - 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 (m <= 3.2d+95) then
        tmp = w0
    else
        tmp = (1.0d0 + ((w0 + (-1.0d0)) * (1.0d0 - w0))) / (2.0d0 - 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 (M <= 3.2e+95) {
		tmp = w0;
	} else {
		tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0);
	}
	return tmp;
}
def code(w0, M, D, h, l, d):
	tmp = 0
	if M <= 3.2e+95:
		tmp = w0
	else:
		tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0)
	return tmp
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (M <= 3.2e+95)
		tmp = w0;
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(w0 + -1.0) * Float64(1.0 - w0))) / Float64(2.0 - w0));
	end
	return tmp
end
function tmp_2 = code(w0, M, D, h, l, d)
	tmp = 0.0;
	if (M <= 3.2e+95)
		tmp = w0;
	else
		tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0);
	end
	tmp_2 = tmp;
end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3.2e+95], w0, N[(N[(1.0 + N[(N[(w0 + -1.0), $MachinePrecision] * N[(1.0 - w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 - w0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.2 \cdot 10^{+95}:\\
\;\;\;\;w0\\

\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(w0 + -1\right) \cdot \left(1 - w0\right)}{2 - w0}\\


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

    1. Initial program 74.9%

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

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

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

    if 3.2000000000000001e95 < M

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(w0 \cdot \sqrt{1 - h \cdot \frac{{\color{blue}{\left(\frac{\frac{D}{d}}{\frac{2}{M}}\right)}}^{2}}{\ell}}\right)\right) \]
      9. associate-/r/51.1%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + w0\right)}\right) \]
    8. Step-by-step derivation
      1. log1p-define28.6%

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(w0\right)}\right) \]
    9. Simplified28.6%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(w0\right)}\right) \]
    10. Step-by-step derivation
      1. expm1-undefine8.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(w0\right)} - 1} \]
      2. log1p-undefine8.2%

        \[\leadsto e^{\color{blue}{\log \left(1 + w0\right)}} - 1 \]
      3. rem-exp-log19.1%

        \[\leadsto \color{blue}{\left(1 + w0\right)} - 1 \]
    11. Applied egg-rr19.1%

      \[\leadsto \color{blue}{\left(1 + w0\right) - 1} \]
    12. Step-by-step derivation
      1. associate--l+19.1%

        \[\leadsto \color{blue}{1 + \left(w0 - 1\right)} \]
      2. flip-+19.2%

        \[\leadsto \color{blue}{\frac{1 \cdot 1 - \left(w0 - 1\right) \cdot \left(w0 - 1\right)}{1 - \left(w0 - 1\right)}} \]
      3. metadata-eval19.2%

        \[\leadsto \frac{\color{blue}{1} - \left(w0 - 1\right) \cdot \left(w0 - 1\right)}{1 - \left(w0 - 1\right)} \]
      4. sub-neg19.2%

        \[\leadsto \frac{1 - \color{blue}{\left(w0 + \left(-1\right)\right)} \cdot \left(w0 - 1\right)}{1 - \left(w0 - 1\right)} \]
      5. metadata-eval19.2%

        \[\leadsto \frac{1 - \left(w0 + \color{blue}{-1}\right) \cdot \left(w0 - 1\right)}{1 - \left(w0 - 1\right)} \]
      6. sub-neg19.2%

        \[\leadsto \frac{1 - \left(w0 + -1\right) \cdot \color{blue}{\left(w0 + \left(-1\right)\right)}}{1 - \left(w0 - 1\right)} \]
      7. metadata-eval19.2%

        \[\leadsto \frac{1 - \left(w0 + -1\right) \cdot \left(w0 + \color{blue}{-1}\right)}{1 - \left(w0 - 1\right)} \]
      8. sub-neg19.2%

        \[\leadsto \frac{1 - \left(w0 + -1\right) \cdot \left(w0 + -1\right)}{1 - \color{blue}{\left(w0 + \left(-1\right)\right)}} \]
      9. metadata-eval19.2%

        \[\leadsto \frac{1 - \left(w0 + -1\right) \cdot \left(w0 + -1\right)}{1 - \left(w0 + \color{blue}{-1}\right)} \]
    13. Applied egg-rr19.2%

      \[\leadsto \color{blue}{\frac{1 - \left(w0 + -1\right) \cdot \left(w0 + -1\right)}{1 - \left(w0 + -1\right)}} \]
    14. Step-by-step derivation
      1. sub-neg19.2%

        \[\leadsto \frac{\color{blue}{1 + \left(-\left(w0 + -1\right) \cdot \left(w0 + -1\right)\right)}}{1 - \left(w0 + -1\right)} \]
      2. distribute-rgt-neg-in19.2%

        \[\leadsto \frac{1 + \color{blue}{\left(w0 + -1\right) \cdot \left(-\left(w0 + -1\right)\right)}}{1 - \left(w0 + -1\right)} \]
      3. +-commutative19.2%

        \[\leadsto \frac{1 + \color{blue}{\left(-1 + w0\right)} \cdot \left(-\left(w0 + -1\right)\right)}{1 - \left(w0 + -1\right)} \]
      4. +-commutative19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \left(-\color{blue}{\left(-1 + w0\right)}\right)}{1 - \left(w0 + -1\right)} \]
      5. distribute-neg-in19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \color{blue}{\left(\left(--1\right) + \left(-w0\right)\right)}}{1 - \left(w0 + -1\right)} \]
      6. metadata-eval19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \left(\color{blue}{1} + \left(-w0\right)\right)}{1 - \left(w0 + -1\right)} \]
      7. sub-neg19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \color{blue}{\left(1 - w0\right)}}{1 - \left(w0 + -1\right)} \]
      8. +-commutative19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \left(1 - w0\right)}{1 - \color{blue}{\left(-1 + w0\right)}} \]
      9. associate--r+19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \left(1 - w0\right)}{\color{blue}{\left(1 - -1\right) - w0}} \]
      10. metadata-eval19.2%

        \[\leadsto \frac{1 + \left(-1 + w0\right) \cdot \left(1 - w0\right)}{\color{blue}{2} - w0} \]
    15. Simplified19.2%

      \[\leadsto \color{blue}{\frac{1 + \left(-1 + w0\right) \cdot \left(1 - w0\right)}{2 - w0}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3.2 \cdot 10^{+95}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(w0 + -1\right) \cdot \left(1 - w0\right)}{2 - w0}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 67.4% 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 74.7%

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification63.4%

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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