?

Average Error: 14.4 → 9.7
Time: 23.1s
Precision: binary64
Cost: 14857

?

\[ \begin{array}{c}[M, D] = \mathsf{sort}([M, D])\\ \end{array} \]
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
\[\begin{array}{l} t_0 := \frac{M \cdot D}{2 \cdot d}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+115} \lor \neg \left(t_0 \leq 2 \cdot 10^{+137}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{M}{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D \cdot \left(M \cdot 0.5\right)}{d}\right)}^{2}}{\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))))))
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (/ (* M D) (* 2.0 d))))
   (if (or (<= t_0 -1e+115) (not (<= t_0 2e+137)))
     (*
      w0
      (sqrt (+ 1.0 (* (/ M (* (* (/ d D) (/ d D)) (/ l (* M h)))) -0.25))))
     (* w0 (sqrt (- 1.0 (/ (* h (pow (/ (* D (* M 0.5)) d) 2.0)) 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))));
}
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (2.0 * d);
	double tmp;
	if ((t_0 <= -1e+115) || !(t_0 <= 2e+137)) {
		tmp = w0 * sqrt((1.0 + ((M / (((d / D) * (d / D)) * (l / (M * h)))) * -0.25)));
	} else {
		tmp = w0 * sqrt((1.0 - ((h * pow(((D * (M * 0.5)) / d), 2.0)) / l)));
	}
	return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (m * d) / (2.0d0 * d_1)
    if ((t_0 <= (-1d+115)) .or. (.not. (t_0 <= 2d+137))) then
        tmp = w0 * sqrt((1.0d0 + ((m / (((d_1 / d) * (d_1 / d)) * (l / (m * h)))) * (-0.25d0))))
    else
        tmp = w0 * sqrt((1.0d0 - ((h * (((d * (m * 0.5d0)) / d_1) ** 2.0d0)) / l)))
    end if
    code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (2.0 * d);
	double tmp;
	if ((t_0 <= -1e+115) || !(t_0 <= 2e+137)) {
		tmp = w0 * Math.sqrt((1.0 + ((M / (((d / D) * (d / D)) * (l / (M * h)))) * -0.25)));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow(((D * (M * 0.5)) / d), 2.0)) / l)));
	}
	return tmp;
}
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))))
def code(w0, M, D, h, l, d):
	t_0 = (M * D) / (2.0 * d)
	tmp = 0
	if (t_0 <= -1e+115) or not (t_0 <= 2e+137):
		tmp = w0 * math.sqrt((1.0 + ((M / (((d / D) * (d / D)) * (l / (M * h)))) * -0.25)))
	else:
		tmp = w0 * math.sqrt((1.0 - ((h * math.pow(((D * (M * 0.5)) / d), 2.0)) / l)))
	return tmp
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 code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * D) / Float64(2.0 * d))
	tmp = 0.0
	if ((t_0 <= -1e+115) || !(t_0 <= 2e+137))
		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(M / Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(l / Float64(M * h)))) * -0.25))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(D * Float64(M * 0.5)) / d) ^ 2.0)) / l))));
	end
	return tmp
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
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = (M * D) / (2.0 * d);
	tmp = 0.0;
	if ((t_0 <= -1e+115) || ~((t_0 <= 2e+137)))
		tmp = w0 * sqrt((1.0 + ((M / (((d / D) * (d / D)) * (l / (M * h)))) * -0.25)));
	else
		tmp = w0 * sqrt((1.0 - ((h * (((D * (M * 0.5)) / d) ^ 2.0)) / l)));
	end
	tmp_2 = tmp;
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]
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e+115], N[Not[LessEqual[t$95$0, 2e+137]], $MachinePrecision]], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(M / N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(l / N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(D * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := \frac{M \cdot D}{2 \cdot d}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+115} \lor \neg \left(t_0 \leq 2 \cdot 10^{+137}\right):\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{M}{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 2 d)) < -1e115 or 2.0000000000000001e137 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 58.0

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

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

      [Start]58.0

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

      associate-*l/ [<=]55.3

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

      *-commutative [=>]55.3

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

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

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

      [Start]60.7

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

      *-commutative [=>]60.7

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

      *-commutative [=>]60.7

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

      associate-/r* [=>]61.5

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

      *-commutative [<=]61.5

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

      associate-/r* [<=]60.7

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

      times-frac [=>]61.7

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

      unpow2 [=>]61.7

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

      unpow2 [=>]61.7

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

      unpow2 [=>]61.7

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

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

    if -1e115 < (/.f64 (*.f64 M D) (*.f64 2 d)) < 2.0000000000000001e137

    1. Initial program 6.9

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

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

      [Start]6.9

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

      associate-*l/ [<=]7.5

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

      *-commutative [=>]7.5

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

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

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

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

Alternatives

Alternative 1
Error10.1
Cost14088
\[\begin{array}{l} t_0 := \frac{M \cdot D}{d}\\ \mathbf{if}\;\ell \leq -4 \cdot 10^{+122}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0 \cdot \frac{h \cdot \left(M \cdot D\right)}{\ell}}{d \cdot 4}}\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+136}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0 \cdot \left(M \cdot \left(D \cdot \frac{h}{\ell}\right)\right)}{d \cdot 4}}\\ \end{array} \]
Alternative 2
Error15.3
Cost8524
\[\begin{array}{l} t_0 := w0 \cdot \sqrt{1 + \frac{M}{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\ \mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{+296}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-13}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot \left(4 \cdot \frac{\ell}{h}\right)}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error10.7
Cost8264
\[\begin{array}{l} \mathbf{if}\;2 \cdot d \leq -2 \cdot 10^{+52}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{D \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d \cdot 4}{M}\right)}}\\ \mathbf{elif}\;2 \cdot d \leq 5 \cdot 10^{+125}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \frac{h \cdot \left(M \cdot D\right)}{\ell}}{d \cdot 4}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Error16.1
Cost8141
\[\begin{array}{l} \mathbf{if}\;d \leq 1.18 \cdot 10^{-66} \lor \neg \left(d \leq 24000000\right) \land d \leq 5 \cdot 10^{+74}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{M}{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 5
Error16.1
Cost8140
\[\begin{array}{l} \mathbf{if}\;d \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{M}{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{+15}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq 1.58 \cdot 10^{+71}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{D \cdot \left(M \cdot \left(M \cdot h\right)\right)}{\ell \cdot \frac{d}{\frac{D}{d}}} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 6
Error12.4
Cost8009
\[\begin{array}{l} \mathbf{if}\;M \leq -1.9 \cdot 10^{-105} \lor \neg \left(M \leq 3.3 \cdot 10^{-155}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell}{D \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d \cdot 4}{M}\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 7
Error13.9
Cost8008
\[\begin{array}{l} t_0 := \frac{\ell}{D \cdot h}\\ \mathbf{if}\;d \leq -8.8 \cdot 10^{+21}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{t_0 \cdot \left(\frac{d}{D} \cdot \frac{d \cdot 4}{M}\right)}}\\ \mathbf{elif}\;d \leq 7.6 \cdot 10^{-123}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M \cdot D}{d} \cdot \left(D \cdot \left(M \cdot \frac{h}{\ell}\right)\right)}{d \cdot 4}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot \left(\frac{M}{d \cdot d} \cdot \frac{D}{4}\right)}{t_0}}\\ \end{array} \]
Alternative 8
Error13.0
Cost8004
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-232}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot \frac{M \cdot D}{d}}{\left(d \cdot 4\right) \cdot \frac{\ell}{D \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 9
Error16.8
Cost7876
\[\begin{array}{l} \mathbf{if}\;d \leq 1.9 \cdot 10^{-125}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{M}{\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot \left(\frac{M}{d \cdot d} \cdot \frac{D}{4}\right)}{\frac{\ell}{D \cdot h}}}\\ \end{array} \]
Alternative 10
Error14.0
Cost64
\[w0 \]

Error

Reproduce?

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