Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.4% → 89.8%
Time: 19.7s
Alternatives: 3
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 3 alternatives:

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

Initial Program: 81.4% accurate, 1.0× speedup?

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

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

Alternative 1: 89.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.9%

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

    if 4.99999999999999967e145 < (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))

    1. Initial program 38.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \color{blue}{e^{\log \left(1 - h \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}\right) \cdot 0.5}} \]
      3. cancel-sign-sub-inv64.4%

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

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

        \[\leadsto w0 \cdot e^{\mathsf{log1p}\left(\left(-h\right) \cdot \frac{{\color{blue}{\left(\frac{D \cdot M}{2 \cdot d}\right)}}^{2}}{\ell}\right) \cdot 0.5} \]
    11. Applied egg-rr59.9%

      \[\leadsto w0 \cdot \color{blue}{e^{\mathsf{log1p}\left(\left(-h\right) \cdot \frac{{\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2}}{\ell}\right) \cdot 0.5}} \]
    12. Step-by-step derivation
      1. associate-/l*64.4%

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

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

        \[\leadsto w0 \cdot e^{\mathsf{log1p}\left(\left(-h\right) \cdot \frac{{\color{blue}{\left(\frac{D \cdot M}{d \cdot 2}\right)}}^{2}}{\ell}\right) \cdot 0.5} \]
      4. unpow259.9%

        \[\leadsto w0 \cdot e^{\mathsf{log1p}\left(\left(-h\right) \cdot \frac{\color{blue}{\frac{D \cdot M}{d \cdot 2} \cdot \frac{D \cdot M}{d \cdot 2}}}{\ell}\right) \cdot 0.5} \]
      5. *-un-lft-identity59.9%

        \[\leadsto w0 \cdot e^{\mathsf{log1p}\left(\left(-h\right) \cdot \frac{\frac{D \cdot M}{d \cdot 2} \cdot \frac{D \cdot M}{d \cdot 2}}{\color{blue}{1 \cdot \ell}}\right) \cdot 0.5} \]
      6. times-frac63.4%

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

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

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

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

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

Alternative 2: 86.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 68.7% 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 80.2%

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

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

    \[\leadsto \color{blue}{w0} \]
  5. Final simplification64.2%

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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