Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.0% → 90.8%
Time: 20.0s
Alternatives: 6
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 6 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: 80.0% 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: 90.8% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+237}:\\ \;\;\;\;{\left(\sqrt{w0\_m \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D\_m \cdot \frac{M\_m}{d\_m}\right)\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) -1e+237)
    (pow (sqrt (* w0_m (* (sqrt (* h (/ -0.25 l))) (* D_m (/ M_m d_m))))) 2.0)
    (*
     w0_m
     (sqrt (- 1.0 (* h (/ (pow (* D_m (* M_m (/ 0.5 d_m))) 2.0) l))))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -1e+237) {
		tmp = pow(sqrt((w0_m * (sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))), 2.0);
	} else {
		tmp = w0_m * sqrt((1.0 - (h * (pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))));
	}
	return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if (((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) * (h / l)) <= (-1d+237)) then
        tmp = sqrt((w0_m * (sqrt((h * ((-0.25d0) / l))) * (d_m * (m_m / d_m_1))))) ** 2.0d0
    else
        tmp = w0_m * sqrt((1.0d0 - (h * (((d_m * (m_m * (0.5d0 / d_m_1))) ** 2.0d0) / l))))
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -1e+237) {
		tmp = Math.pow(Math.sqrt((w0_m * (Math.sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))), 2.0);
	} else {
		tmp = w0_m * Math.sqrt((1.0 - (h * (Math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -1e+237:
		tmp = math.pow(math.sqrt((w0_m * (math.sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))), 2.0)
	else:
		tmp = w0_m * math.sqrt((1.0 - (h * (math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= -1e+237)
		tmp = sqrt(Float64(w0_m * Float64(sqrt(Float64(h * Float64(-0.25 / l))) * Float64(D_m * Float64(M_m / d_m))))) ^ 2.0;
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d_m))) ^ 2.0) / l)))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -1e+237)
		tmp = sqrt((w0_m * (sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))) ^ 2.0;
	else
		tmp = w0_m * sqrt((1.0 - (h * (((D_m * (M_m * (0.5 / d_m))) ^ 2.0) / l))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e+237], N[Power[N[Sqrt[N[(w0$95$m * N[(N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D$95$m * N[(M$95$m / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+237}:\\
\;\;\;\;{\left(\sqrt{w0\_m \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D\_m \cdot \frac{M\_m}{d\_m}\right)\right)}\right)}^{2}\\

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


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

    1. Initial program 64.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified65.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. Step-by-step derivation
      1. add-sqr-sqrt26.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 88.8%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified88.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. Step-by-step derivation
      1. clear-num88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 67.4% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;D\_m \leq 2.6 \cdot 10^{+251} \lor \neg \left(D\_m \leq 5.6 \cdot 10^{+269}\right) \land D\_m \leq 2.6 \cdot 10^{+284}:\\ \;\;\;\;w0\_m\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0\_m}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (if (or (<= D_m 2.6e+251) (and (not (<= D_m 5.6e+269)) (<= D_m 2.6e+284)))
    w0_m
    (log (exp w0_m)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((D_m <= 2.6e+251) || (!(D_m <= 5.6e+269) && (D_m <= 2.6e+284))) {
		tmp = w0_m;
	} else {
		tmp = log(exp(w0_m));
	}
	return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if ((d_m <= 2.6d+251) .or. (.not. (d_m <= 5.6d+269)) .and. (d_m <= 2.6d+284)) then
        tmp = w0_m
    else
        tmp = log(exp(w0_m))
    end if
    code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if ((D_m <= 2.6e+251) || (!(D_m <= 5.6e+269) && (D_m <= 2.6e+284))) {
		tmp = w0_m;
	} else {
		tmp = Math.log(Math.exp(w0_m));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if (D_m <= 2.6e+251) or (not (D_m <= 5.6e+269) and (D_m <= 2.6e+284)):
		tmp = w0_m
	else:
		tmp = math.log(math.exp(w0_m))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if ((D_m <= 2.6e+251) || (!(D_m <= 5.6e+269) && (D_m <= 2.6e+284)))
		tmp = w0_m;
	else
		tmp = log(exp(w0_m));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0;
	if ((D_m <= 2.6e+251) || (~((D_m <= 5.6e+269)) && (D_m <= 2.6e+284)))
		tmp = w0_m;
	else
		tmp = log(exp(w0_m));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[Or[LessEqual[D$95$m, 2.6e+251], And[N[Not[LessEqual[D$95$m, 5.6e+269]], $MachinePrecision], LessEqual[D$95$m, 2.6e+284]]], w0$95$m, N[Log[N[Exp[w0$95$m], $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;D\_m \leq 2.6 \cdot 10^{+251} \lor \neg \left(D\_m \leq 5.6 \cdot 10^{+269}\right) \land D\_m \leq 2.6 \cdot 10^{+284}:\\
\;\;\;\;w0\_m\\

\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0\_m}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 2.6000000000000002e251 or 5.59999999999999956e269 < D < 2.5999999999999998e284

    1. Initial program 81.4%

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

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

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

    if 2.6000000000000002e251 < D < 5.59999999999999956e269 or 2.5999999999999998e284 < D

    1. Initial program 81.1%

      \[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(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt50.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0}\right)}}^{2} \]
    7. Step-by-step derivation
      1. unpow24.2%

        \[\leadsto \color{blue}{\sqrt{w0} \cdot \sqrt{w0}} \]
      2. add-sqr-sqrt5.8%

        \[\leadsto \color{blue}{w0} \]
      3. add-log-exp60.8%

        \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
    8. Applied egg-rr60.8%

      \[\leadsto \color{blue}{\log \left(e^{w0}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 2.6 \cdot 10^{+251} \lor \neg \left(D \leq 5.6 \cdot 10^{+269}\right) \land D \leq 2.6 \cdot 10^{+284}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{w0}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.9% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\right) \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (*
  w0_s
  (* w0_m (sqrt (- 1.0 (* h (/ (pow (* D_m (* M_m (/ 0.5 d_m))) 2.0) l)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	return w0_s * (w0_m * sqrt((1.0 - (h * (pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))));
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    code = w0_s * (w0_m * sqrt((1.0d0 - (h * (((d_m * (m_m * (0.5d0 / d_m_1))) ** 2.0d0) / l)))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	return w0_s * (w0_m * Math.sqrt((1.0 - (h * (Math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))));
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	return w0_s * (w0_m * math.sqrt((1.0 - (h * (math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))))
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d_m))) ^ 2.0) / l))))))
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = w0_s * (w0_m * sqrt((1.0 - (h * (((D_m * (M_m * (0.5 / d_m))) ^ 2.0) / l)))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\right)
\end{array}
Derivation
  1. Initial program 81.4%

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

    \[\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. clear-num81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 69.3% accurate, 1.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;D\_m \leq 9 \cdot 10^{+211}:\\ \;\;\;\;w0\_m\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\_m\right)\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
 :precision binary64
 (* w0_s (if (<= D_m 9e+211) w0_m (log1p (expm1 w0_m)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (D_m <= 9e+211) {
		tmp = w0_m;
	} else {
		tmp = log1p(expm1(w0_m));
	}
	return w0_s * tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	double tmp;
	if (D_m <= 9e+211) {
		tmp = w0_m;
	} else {
		tmp = Math.log1p(Math.expm1(w0_m));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	tmp = 0
	if D_m <= 9e+211:
		tmp = w0_m
	else:
		tmp = math.log1p(math.expm1(w0_m))
	return w0_s * tmp
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = 0.0
	if (D_m <= 9e+211)
		tmp = w0_m;
	else
		tmp = log1p(expm1(w0_m));
	end
	return Float64(w0_s * tmp)
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[D$95$m, 9e+211], w0$95$m, N[Log[1 + N[(Exp[w0$95$m] - 1), $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;D\_m \leq 9 \cdot 10^{+211}:\\
\;\;\;\;w0\_m\\

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\_m\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 9e211

    1. Initial program 81.5%

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

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

    if 9e211 < D

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0}\right)}}^{2} \]
    7. Step-by-step derivation
      1. unpow210.0%

        \[\leadsto \color{blue}{\sqrt{w0} \cdot \sqrt{w0}} \]
      2. add-sqr-sqrt25.9%

        \[\leadsto \color{blue}{w0} \]
      3. add-exp-log9.5%

        \[\leadsto \color{blue}{e^{\log w0}} \]
    8. Applied egg-rr9.5%

      \[\leadsto \color{blue}{e^{\log w0}} \]
    9. Step-by-step derivation
      1. rem-exp-log25.9%

        \[\leadsto \color{blue}{w0} \]
      2. log1p-expm1-u58.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)} \]
    10. Applied egg-rr58.8%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 66.7% accurate, 1.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 2.29999999999999988e251

    1. Initial program 81.3%

      \[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(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Taylor expanded in D around 0 67.5%

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

    if 2.29999999999999988e251 < D

    1. Initial program 84.3%

      \[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(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt50.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0}\right)}}^{2} \]
    7. Step-by-step derivation
      1. unpow211.7%

        \[\leadsto \color{blue}{\sqrt{w0} \cdot \sqrt{w0}} \]
      2. add-sqr-sqrt21.5%

        \[\leadsto \color{blue}{w0} \]
      3. add-exp-log11.1%

        \[\leadsto \color{blue}{e^{\log w0}} \]
    8. Applied egg-rr11.1%

      \[\leadsto \color{blue}{e^{\log w0}} \]
    9. Step-by-step derivation
      1. rem-exp-log21.5%

        \[\leadsto \color{blue}{w0} \]
      2. expm1-log1p-u20.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(w0\right)\right)} \]
      3. expm1-define11.8%

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

        \[\leadsto \color{blue}{\frac{e^{\mathsf{log1p}\left(w0\right)} \cdot e^{\mathsf{log1p}\left(w0\right)} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1}} \]
      5. pow250.3%

        \[\leadsto \frac{\color{blue}{{\left(e^{\mathsf{log1p}\left(w0\right)}\right)}^{2}} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      6. log1p-undefine50.3%

        \[\leadsto \frac{{\left(e^{\color{blue}{\log \left(1 + w0\right)}}\right)}^{2} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      7. rem-exp-log50.3%

        \[\leadsto \frac{{\color{blue}{\left(1 + w0\right)}}^{2} - 1 \cdot 1}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      8. metadata-eval50.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} - \color{blue}{1}}{e^{\mathsf{log1p}\left(w0\right)} + 1} \]
      9. log1p-undefine50.3%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} - 1}{e^{\color{blue}{\log \left(1 + w0\right)}} + 1} \]
      10. rem-exp-log59.4%

        \[\leadsto \frac{{\left(1 + w0\right)}^{2} - 1}{\color{blue}{\left(1 + w0\right)} + 1} \]
    10. Applied egg-rr59.4%

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

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

Alternative 6: 67.7% accurate, 216.0× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ D_m = \left|D\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\ \\ w0\_s \cdot w0\_m \end{array} \]
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s w0_m))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	return w0_s * w0_m;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m_1
    code = w0_s * w0_m
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
	return w0_s * w0_m;
}
M_m = math.fabs(M)
D_m = math.fabs(D)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m])
def code(w0_s, w0_m, M_m, D_m, h, l, d_m):
	return w0_s * w0_m
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m])
function code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	return Float64(w0_s * w0_m)
end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
	tmp = w0_s * w0_m;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot w0\_m
\end{array}
Derivation
  1. Initial program 81.4%

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

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