Average Error: 14.1 → 10.8
Time: 19.4s
Precision: binary64
Cost: 27588
\[ \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} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 4 \cdot 10^{+152}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot {\left({\left(-0.25 \cdot \left(\left(\frac{M}{d} \cdot \frac{M}{d}\right) \cdot \frac{h}{\ell}\right)\right)}^{0.25} \cdot {\left(\frac{1}{D}\right)}^{-0.5}\right)}^{2}\\ \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
 (if (<= (pow (/ (* M D) (* 2.0 d)) 2.0) 4e+152)
   (* w0 (sqrt (- 1.0 (/ (* (pow (* (* M D) (/ 0.5 d)) 2.0) h) l))))
   (*
    w0
    (pow
     (*
      (pow (* -0.25 (* (* (/ M d) (/ M d)) (/ h l))) 0.25)
      (pow (/ 1.0 D) -0.5))
     2.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 tmp;
	if (pow(((M * D) / (2.0 * d)), 2.0) <= 4e+152) {
		tmp = w0 * sqrt((1.0 - ((pow(((M * D) * (0.5 / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * pow((pow((-0.25 * (((M / d) * (M / d)) * (h / l))), 0.25) * pow((1.0 / D), -0.5)), 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
    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) :: tmp
    if ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) <= 4d+152) then
        tmp = w0 * sqrt((1.0d0 - (((((m * d) * (0.5d0 / d_1)) ** 2.0d0) * h) / l)))
    else
        tmp = w0 * (((((-0.25d0) * (((m / d_1) * (m / d_1)) * (h / l))) ** 0.25d0) * ((1.0d0 / d) ** (-0.5d0))) ** 2.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 tmp;
	if (Math.pow(((M * D) / (2.0 * d)), 2.0) <= 4e+152) {
		tmp = w0 * Math.sqrt((1.0 - ((Math.pow(((M * D) * (0.5 / d)), 2.0) * h) / l)));
	} else {
		tmp = w0 * Math.pow((Math.pow((-0.25 * (((M / d) * (M / d)) * (h / l))), 0.25) * Math.pow((1.0 / D), -0.5)), 2.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):
	tmp = 0
	if math.pow(((M * D) / (2.0 * d)), 2.0) <= 4e+152:
		tmp = w0 * math.sqrt((1.0 - ((math.pow(((M * D) * (0.5 / d)), 2.0) * h) / l)))
	else:
		tmp = w0 * math.pow((math.pow((-0.25 * (((M / d) * (M / d)) * (h / l))), 0.25) * math.pow((1.0 / D), -0.5)), 2.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)
	tmp = 0.0
	if ((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) <= 4e+152)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(Float64(M * D) * Float64(0.5 / d)) ^ 2.0) * h) / l))));
	else
		tmp = Float64(w0 * (Float64((Float64(-0.25 * Float64(Float64(Float64(M / d) * Float64(M / d)) * Float64(h / l))) ^ 0.25) * (Float64(1.0 / D) ^ -0.5)) ^ 2.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)
	tmp = 0.0;
	if ((((M * D) / (2.0 * d)) ^ 2.0) <= 4e+152)
		tmp = w0 * sqrt((1.0 - (((((M * D) * (0.5 / d)) ^ 2.0) * h) / l)));
	else
		tmp = w0 * ((((-0.25 * (((M / d) * (M / d)) * (h / l))) ^ 0.25) * ((1.0 / D) ^ -0.5)) ^ 2.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_] := If[LessEqual[N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 4e+152], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(N[(M * D), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[(N[Power[N[(-0.25 * N[(N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.25], $MachinePrecision] * N[Power[N[(1.0 / D), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 4 \cdot 10^{+152}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot h}{\ell}}\\

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


\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 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 4.0000000000000002e152

    1. Initial program 6.4

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

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

    if 4.0000000000000002e152 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)

    1. Initial program 48.2

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

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

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

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

      \[\leadsto w0 \cdot {\left({\left(1 - \color{blue}{\left(\left(\frac{h}{d} \cdot \frac{D \cdot D}{d}\right) \cdot \frac{M}{\frac{\ell}{M}}\right) \cdot 0.25}\right)}^{0.25}\right)}^{2} \]
      Proof
      (*.f64 (*.f64 (*.f64 (/.f64 h d) (/.f64 (*.f64 D D) d)) (/.f64 M (/.f64 l M))) 1/4): 0 points increase in error, 0 points decrease in error
      (*.f64 (*.f64 (*.f64 (/.f64 h d) (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 D 2)) d)) (/.f64 M (/.f64 l M))) 1/4): 0 points increase in error, 0 points decrease in error
      (*.f64 (*.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 h (pow.f64 D 2)) (*.f64 d d))) (/.f64 M (/.f64 l M))) 1/4): 29 points increase in error, 11 points decrease in error
      (*.f64 (*.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (pow.f64 D 2) h)) (*.f64 d d)) (/.f64 M (/.f64 l M))) 1/4): 0 points increase in error, 0 points decrease in error
      (*.f64 (*.f64 (/.f64 (*.f64 (pow.f64 D 2) h) (Rewrite<= unpow2_binary64 (pow.f64 d 2))) (/.f64 M (/.f64 l M))) 1/4): 0 points increase in error, 0 points decrease in error
      (*.f64 (*.f64 (/.f64 (*.f64 (pow.f64 D 2) h) (pow.f64 d 2)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 M M) l))) 1/4): 12 points increase in error, 3 points decrease in error
      (*.f64 (*.f64 (/.f64 (*.f64 (pow.f64 D 2) h) (pow.f64 d 2)) (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 M 2)) l)) 1/4): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (*.f64 (pow.f64 D 2) h) (pow.f64 M 2)) (*.f64 (pow.f64 d 2) l))) 1/4): 10 points increase in error, 10 points decrease in error
      (*.f64 (/.f64 (Rewrite<= associate-*r*_binary64 (*.f64 (pow.f64 D 2) (*.f64 h (pow.f64 M 2)))) (*.f64 (pow.f64 d 2) l)) 1/4): 9 points increase in error, 11 points decrease in error
      (*.f64 (/.f64 (*.f64 (pow.f64 D 2) (Rewrite<= *-commutative_binary64 (*.f64 (pow.f64 M 2) h))) (*.f64 (pow.f64 d 2) l)) 1/4): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 (*.f64 (pow.f64 D 2) (*.f64 (pow.f64 M 2) h)) (Rewrite<= *-commutative_binary64 (*.f64 l (pow.f64 d 2)))) 1/4): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 D 2) (*.f64 (pow.f64 M 2) h)) (*.f64 l (pow.f64 d 2))))): 0 points increase in error, 0 points decrease in error
    6. Taylor expanded in D around inf 57.5

      \[\leadsto w0 \cdot {\color{blue}{\left(e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell \cdot {d}^{2}}\right) + -2 \cdot \log \left(\frac{1}{D}\right)\right)}\right)}}^{2} \]
    7. Simplified49.8

      \[\leadsto w0 \cdot {\color{blue}{\left({\left(-0.25 \cdot \left(\left(\frac{M}{d} \cdot \frac{M}{d}\right) \cdot \frac{h}{\ell}\right)\right)}^{0.25} \cdot {\left(\frac{1}{D}\right)}^{-0.5}\right)}}^{2} \]
      Proof
      (*.f64 (pow.f64 (*.f64 -1/4 (*.f64 (*.f64 (/.f64 M d) (/.f64 M d)) (/.f64 h l))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (pow.f64 (*.f64 (Rewrite<= metadata-eval (neg.f64 1/4)) (*.f64 (*.f64 (/.f64 M d) (/.f64 M d)) (/.f64 h l))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (pow.f64 (*.f64 (neg.f64 1/4) (*.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 M M) (*.f64 d d))) (/.f64 h l))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 19 points increase in error, 8 points decrease in error
      (*.f64 (pow.f64 (*.f64 (neg.f64 1/4) (*.f64 (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 M 2)) (*.f64 d d)) (/.f64 h l))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (pow.f64 (*.f64 (neg.f64 1/4) (*.f64 (/.f64 (pow.f64 M 2) (Rewrite<= unpow2_binary64 (pow.f64 d 2))) (/.f64 h l))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (pow.f64 (*.f64 (neg.f64 1/4) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 (pow.f64 d 2) l)))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 9 points increase in error, 16 points decrease in error
      (*.f64 (pow.f64 (*.f64 (neg.f64 1/4) (/.f64 (*.f64 (pow.f64 M 2) h) (Rewrite=> *-commutative_binary64 (*.f64 l (pow.f64 d 2))))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (pow.f64 (Rewrite<= distribute-lft-neg-in_binary64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4) (pow.f64 (/.f64 1 D) -1/2)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4))) (pow.f64 (/.f64 1 D) -1/2)): 5 points increase in error, 8 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4)) (pow.f64 (/.f64 1 D) (Rewrite<= metadata-eval (*.f64 -2 1/4)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4)) (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 1 D)) (*.f64 -2 1/4))))): 7 points increase in error, 7 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4)) (exp.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (log.f64 (/.f64 1 D)) -2) 1/4)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (exp.f64 (*.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4)) (exp.f64 (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 -2 (log.f64 (/.f64 1 D)))) 1/4))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= exp-sum_binary64 (exp.f64 (+.f64 (*.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) 1/4) (*.f64 (*.f64 -2 (log.f64 (/.f64 1 D))) 1/4)))): 7 points increase in error, 3 points decrease in error
      (exp.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 1/4 (+.f64 (log.f64 (neg.f64 (*.f64 1/4 (/.f64 (*.f64 (pow.f64 M 2) h) (*.f64 l (pow.f64 d 2)))))) (*.f64 -2 (log.f64 (/.f64 1 D))))))): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification10.8

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

Alternatives

Alternative 1
Error10.8
Cost14344
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(\left(M \cdot \left(M \cdot h\right)\right) \cdot \frac{D \cdot D}{d \cdot d}\right)}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -5 \cdot 10^{-59}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 2
Error10.9
Cost13824
\[w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2} \cdot h}{\ell}} \]
Alternative 3
Error13.7
Cost64
\[w0 \]

Error

Reproduce

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