?

Average Error: 14.1 → 8.4
Time: 19.9s
Precision: binary64
Cost: 27784

?

\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
\[\begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\\ \mathbf{if}\;t_0 \leq 10^{-47}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{elif}\;t_0 \leq 10^{+298}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{D}{d} \cdot \left(\left(\left(M \cdot \frac{D}{\ell}\right) \cdot \frac{h}{d}\right) \cdot \frac{M}{4}\right)}\\ \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 (pow (/ (* M D) (* 2.0 d)) 2.0)))
   (if (<= t_0 1e-47)
     (* w0 (sqrt (- 1.0 (/ (* (pow (* (* M 0.5) (/ D d)) 2.0) h) l))))
     (if (<= t_0 1e+298)
       (* w0 (sqrt (- 1.0 (* t_0 (/ h l)))))
       (*
        w0
        (sqrt (- 1.0 (* (/ D d) (* (* (* M (/ D l)) (/ h d)) (/ M 4.0))))))))))
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 = pow(((M * D) / (2.0 * d)), 2.0);
	double tmp;
	if (t_0 <= 1e-47) {
		tmp = w0 * sqrt((1.0 - ((pow(((M * 0.5) * (D / d)), 2.0) * h) / l)));
	} else if (t_0 <= 1e+298) {
		tmp = w0 * sqrt((1.0 - (t_0 * (h / l))));
	} else {
		tmp = w0 * sqrt((1.0 - ((D / d) * (((M * (D / l)) * (h / d)) * (M / 4.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
    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)) ** 2.0d0
    if (t_0 <= 1d-47) then
        tmp = w0 * sqrt((1.0d0 - (((((m * 0.5d0) * (d / d_1)) ** 2.0d0) * h) / l)))
    else if (t_0 <= 1d+298) then
        tmp = w0 * sqrt((1.0d0 - (t_0 * (h / l))))
    else
        tmp = w0 * sqrt((1.0d0 - ((d / d_1) * (((m * (d / l)) * (h / d_1)) * (m / 4.0d0)))))
    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 = Math.pow(((M * D) / (2.0 * d)), 2.0);
	double tmp;
	if (t_0 <= 1e-47) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow(((M * 0.5) * (D / d)), 2.0) * h) / l)));
	} else if (t_0 <= 1e+298) {
		tmp = w0 * Math.sqrt((1.0 - (t_0 * (h / l))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((D / d) * (((M * (D / l)) * (h / d)) * (M / 4.0)))));
	}
	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 = math.pow(((M * D) / (2.0 * d)), 2.0)
	tmp = 0
	if t_0 <= 1e-47:
		tmp = w0 * math.sqrt((1.0 - ((math.pow(((M * 0.5) * (D / d)), 2.0) * h) / l)))
	elif t_0 <= 1e+298:
		tmp = w0 * math.sqrt((1.0 - (t_0 * (h / l))))
	else:
		tmp = w0 * math.sqrt((1.0 - ((D / d) * (((M * (D / l)) * (h / d)) * (M / 4.0)))))
	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)) ^ 2.0
	tmp = 0.0
	if (t_0 <= 1e-47)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(Float64(M * 0.5) * Float64(D / d)) ^ 2.0) * h) / l))));
	elseif (t_0 <= 1e+298)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(h / l)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D / d) * Float64(Float64(Float64(M * Float64(D / l)) * Float64(h / d)) * Float64(M / 4.0))))));
	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)) ^ 2.0;
	tmp = 0.0;
	if (t_0 <= 1e-47)
		tmp = w0 * sqrt((1.0 - (((((M * 0.5) * (D / d)) ^ 2.0) * h) / l)));
	elseif (t_0 <= 1e+298)
		tmp = w0 * sqrt((1.0 - (t_0 * (h / l))));
	else
		tmp = w0 * sqrt((1.0 - ((D / d) * (((M * (D / l)) * (h / d)) * (M / 4.0)))));
	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[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$0, 1e-47], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+298], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D / d), $MachinePrecision] * N[(N[(N[(M * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] * N[(M / 4.0), $MachinePrecision]), $MachinePrecision]), $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 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\\
\mathbf{if}\;t_0 \leq 10^{-47}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\\

\mathbf{elif}\;t_0 \leq 10^{+298}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{h}{\ell}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 9.9999999999999997e-48

    1. Initial program 6.7

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

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

      [Start]6.7

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

      times-frac [=>]6.6

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

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

    if 9.9999999999999997e-48 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 9.9999999999999996e297

    1. Initial program 8.2

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

    if 9.9999999999999996e297 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 62.7

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

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

      [Start]62.7

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

      times-frac [=>]59.2

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{\frac{M}{d} \cdot D}{\ell \cdot 4} \cdot h\right)} \cdot \left(\frac{M}{d} \cdot D\right)} \]
    6. Applied egg-rr51.6

      \[\leadsto w0 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{1 - D \cdot \frac{\frac{h \cdot \left(M \cdot D\right)}{d} \cdot M}{\left(\ell \cdot 4\right) \cdot d}}\right)} - 1\right)} \]
    7. Simplified49.0

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

      [Start]51.6

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

      expm1-def [=>]51.6

      \[ w0 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{1 - D \cdot \frac{\frac{h \cdot \left(M \cdot D\right)}{d} \cdot M}{\left(\ell \cdot 4\right) \cdot d}}\right)\right)} \]

      expm1-log1p [=>]51.0

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

      associate-*r/ [=>]51.6

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

      *-commutative [=>]51.6

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

      times-frac [=>]53.4

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

      times-frac [=>]51.9

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

      associate-/l/ [=>]52.0

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

      *-commutative [=>]52.0

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

      times-frac [=>]51.9

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

      associate-*r/ [<=]49.0

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

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

Alternatives

Alternative 1
Error11.5
Cost7744
\[w0 \cdot \sqrt{1 - h \cdot \left(\frac{M \cdot D}{d \cdot \ell} \cdot \frac{M \cdot D}{d \cdot 4}\right)} \]
Alternative 2
Error8.4
Cost7744
\[\begin{array}{l} t_0 := D \cdot \frac{M}{d}\\ w0 \cdot \sqrt{1 - t_0 \cdot \left(h \cdot \frac{t_0}{\ell \cdot 4}\right)} \end{array} \]
Alternative 3
Error13.9
Cost64
\[w0 \]

Error

Reproduce?

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