?

Average Error: 21.93% → 14.27%
Time: 17.8s
Precision: binary64
Cost: 20612

?

\[ \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}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot e^{\mathsf{log1p}\left(\left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(h \cdot {\left(\frac{M}{d}\right)}^{2}\right)\right) \cdot -0.25\right) \cdot 0.5}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-247}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \frac{D \cdot \frac{M}{d}}{\frac{\ell}{h}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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 (<= (/ h l) (- INFINITY))
   (*
    w0
    (exp (* (log1p (* (* (* D (/ D l)) (* h (pow (/ M d) 2.0))) -0.25)) 0.5)))
   (if (<= (/ h l) -2e-247)
     (* w0 (sqrt (- 1.0 (* (/ (/ M d) (/ 4.0 D)) (/ (* D (/ M d)) (/ l h))))))
     w0)))
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 ((h / l) <= -((double) INFINITY)) {
		tmp = w0 * exp((log1p((((D * (D / l)) * (h * pow((M / d), 2.0))) * -0.25)) * 0.5));
	} else if ((h / l) <= -2e-247) {
		tmp = w0 * sqrt((1.0 - (((M / d) / (4.0 / D)) * ((D * (M / d)) / (l / h)))));
	} else {
		tmp = w0;
	}
	return tmp;
}
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 ((h / l) <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.exp((Math.log1p((((D * (D / l)) * (h * Math.pow((M / d), 2.0))) * -0.25)) * 0.5));
	} else if ((h / l) <= -2e-247) {
		tmp = w0 * Math.sqrt((1.0 - (((M / d) / (4.0 / D)) * ((D * (M / d)) / (l / h)))));
	} else {
		tmp = w0;
	}
	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 (h / l) <= -math.inf:
		tmp = w0 * math.exp((math.log1p((((D * (D / l)) * (h * math.pow((M / d), 2.0))) * -0.25)) * 0.5))
	elif (h / l) <= -2e-247:
		tmp = w0 * math.sqrt((1.0 - (((M / d) / (4.0 / D)) * ((D * (M / d)) / (l / h)))))
	else:
		tmp = w0
	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(h / l) <= Float64(-Inf))
		tmp = Float64(w0 * exp(Float64(log1p(Float64(Float64(Float64(D * Float64(D / l)) * Float64(h * (Float64(M / d) ^ 2.0))) * -0.25)) * 0.5)));
	elseif (Float64(h / l) <= -2e-247)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(M / d) / Float64(4.0 / D)) * Float64(Float64(D * Float64(M / d)) / Float64(l / h))))));
	else
		tmp = w0;
	end
	return 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[(h / l), $MachinePrecision], (-Infinity)], N[(w0 * N[Exp[N[(N[Log[1 + N[(N[(N[(D * N[(D / l), $MachinePrecision]), $MachinePrecision] * N[(h * N[Power[N[(M / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -2e-247], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(M / d), $MachinePrecision] / N[(4.0 / D), $MachinePrecision]), $MachinePrecision] * N[(N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot e^{\mathsf{log1p}\left(\left(\left(D \cdot \frac{D}{\ell}\right) \cdot \left(h \cdot {\left(\frac{M}{d}\right)}^{2}\right)\right) \cdot -0.25\right) \cdot 0.5}\\

\mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-247}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \frac{D \cdot \frac{M}{d}}{\frac{\ell}{h}}}\\

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


\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 (/.f64 h l) < -inf.0

    1. Initial program 100

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

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

      [Start]100

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

      times-frac [=>]100

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

      \[\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. Simplified69.2

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

      [Start]67.32

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

      times-frac [=>]69.2

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

      unpow2 [=>]69.2

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

      unpow2 [=>]69.2

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

      unpow2 [=>]69.2

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

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

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

    if -inf.0 < (/.f64 h l) < -2e-247

    1. Initial program 20.86

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

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

      [Start]20.86

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

      times-frac [=>]21.02

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

      \[\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-rr18.3

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

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

    if -2e-247 < (/.f64 h l)

    1. Initial program 13.18

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

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

      [Start]13.18

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

      associate-*l/ [<=]13.06

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

      *-commutative [=>]13.06

      \[ 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 5.64

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification14.27

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

Alternatives

Alternative 1
Error14.61%
Cost14980
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} \leq 10^{-30}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \frac{D \cdot \frac{M}{d}}{\frac{\ell}{h}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \left(M \cdot \left(\left(h \cdot M\right) \cdot \frac{\frac{\frac{D}{d}}{\ell}}{d}\right)\right)\right)}\\ \end{array} \]
Alternative 2
Error14.55%
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(\frac{D \cdot D}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{h \cdot M}{d}\right)\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-247}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \left(\frac{h}{\ell} \cdot \left(D \cdot \frac{M}{d}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error20.76%
Cost8008
\[\begin{array}{l} \mathbf{if}\;d \leq 4.8 \cdot 10^{-98}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{+129}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left(D \cdot \left(M \cdot \left(\left(h \cdot M\right) \cdot \frac{\frac{\frac{D}{d}}{\ell}}{d}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Error21.5%
Cost64
\[w0 \]

Error

Reproduce?

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