Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 86.1%
Time: 17.3s
Alternatives: 5
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 5 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: 86.1% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* h (/ (pow (* D (/ M (* d 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 * (M / (d * 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 * (m / (d_1 * 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 * (M / (d * 2.0))), 2.0) / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (h * (math.pow((D * (M / (d * 2.0))), 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(d * 2.0))) ^ 2.0) / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - (h * (((D * (M / (d * 2.0))) ^ 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[(d * 2.0), $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}{d \cdot 2}\right)}^{2}}{\ell}}
\end{array}
Derivation
  1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 78.7% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999947e-284 < (/.f64 h l)

    1. Initial program 84.6%

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

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

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

Alternative 4: 71.4% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 2000000000000:\\
\;\;\;\;w0\\

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


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

    1. Initial program 82.0%

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

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

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

    if 2e12 < D

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 67.3% accurate, 216.0× speedup?

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

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

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

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

    \[\leadsto w0 \]
  6. Add Preprocessing

Reproduce

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