| Alternative 1 | |
|---|---|
| Error | 29.8 |
| Cost | 23236 |
(FPCore (c0 w h D d M)
:precision binary64
(*
(/ c0 (* 2.0 w))
(+
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(sqrt
(-
(*
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(/ (* c0 (* d d)) (* (* w h) (* D D))))
(* M M))))))(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(/ (/ (/ 1.0 h) (pow (* D w) 2.0)) (/ 1.0 (pow (* d c0) 2.0)))
0.0)))double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))));
}
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = ((1.0 / h) / pow((D * w), 2.0)) / (1.0 / pow((d * c0), 2.0));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + Math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))));
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = ((1.0 / h) / Math.pow((D * w), 2.0)) / (1.0 / Math.pow((d * c0), 2.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))))
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = ((1.0 / h) / math.pow((D * w), 2.0)) / (1.0 / math.pow((d * c0), 2.0)) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) + sqrt(Float64(Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) * Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))) - Float64(M * M))))) end
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf) tmp = Float64(Float64(Float64(1.0 / h) / (Float64(D * w) ^ 2.0)) / Float64(1.0 / (Float64(d * c0) ^ 2.0))); else tmp = 0.0; end return tmp end
function tmp = code(c0, w, h, D, d, M) tmp = (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M)))); end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = ((1.0 / h) / ((D * w) ^ 2.0)) / (1.0 / ((d * c0) ^ 2.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(1.0 / h), $MachinePrecision] / N[Power[N[(D * w), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[Power[N[(d * c0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;\frac{\frac{\frac{1}{h}}{{\left(D \cdot w\right)}^{2}}}{\frac{1}{{\left(d \cdot c0\right)}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
Results
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 41.6
Simplified43.5
[Start]41.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
|---|---|
rational.json-simplify-49 [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-2 [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\color{blue}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-2 [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(D \cdot D\right) \cdot \color{blue}{\left(h \cdot w\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-43 [=>]47.4 | \[ \frac{c0}{2 \cdot w} \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\color{blue}{h \cdot \left(w \cdot \left(D \cdot D\right)\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
Taylor expanded in c0 around inf 50.6
Simplified39.5
[Start]50.6 | \[ \frac{{d}^{2} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
|---|---|
exponential.json-simplify-27 [=>]45.0 | \[ \frac{\color{blue}{{\left(d \cdot c0\right)}^{2}}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
rational.json-simplify-43 [=>]46.1 | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{{w}^{2} \cdot \left(h \cdot {D}^{2}\right)}}
\] |
rational.json-simplify-43 [=>]44.3 | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{h \cdot \left({D}^{2} \cdot {w}^{2}\right)}}
\] |
exponential.json-simplify-27 [=>]39.5 | \[ \frac{{\left(d \cdot c0\right)}^{2}}{h \cdot \color{blue}{{\left(D \cdot w\right)}^{2}}}
\] |
Applied egg-rr38.5
Applied egg-rr39.6
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 64.0
Simplified63.0
[Start]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
|---|---|
rational.json-simplify-46 [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{\frac{c0 \cdot \left(d \cdot d\right)}{w \cdot h}}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-2 [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{\color{blue}{\left(d \cdot d\right) \cdot c0}}{w \cdot h}}{D \cdot D} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-49 [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \frac{d \cdot d}{w \cdot h}}}{D \cdot D} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-49 [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{d \cdot d}{w \cdot h} \cdot \frac{c0}{D \cdot D}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
rational.json-simplify-46 [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{\frac{d \cdot d}{w}}{h}} \cdot \frac{c0}{D \cdot D} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
Taylor expanded in c0 around -inf 63.9
Simplified63.4
[Start]63.9 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + -1 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
rational.json-simplify-2 [=>]63.9 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \color{blue}{\frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)} \cdot -1}\right)
\] |
rational.json-simplify-9 [=>]63.9 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \color{blue}{\left(-\frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)}\right)
\] |
rational.json-simplify-46 [=>]63.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \left(-\color{blue}{\frac{\frac{{d}^{2} \cdot c0}{{D}^{2}}}{w \cdot h}}\right)\right)
\] |
rational.json-simplify-44 [=>]63.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \left(-\color{blue}{\frac{\frac{{d}^{2} \cdot c0}{w \cdot h}}{{D}^{2}}}\right)\right)
\] |
rational.json-simplify-2 [=>]63.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \left(-\frac{\frac{\color{blue}{c0 \cdot {d}^{2}}}{w \cdot h}}{{D}^{2}}\right)\right)
\] |
rational.json-simplify-49 [=>]63.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \left(-\frac{\color{blue}{{d}^{2} \cdot \frac{c0}{w \cdot h}}}{{D}^{2}}\right)\right)
\] |
rational.json-simplify-46 [=>]63.4 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{\frac{d \cdot d}{w}}{h} \cdot \frac{c0}{D \cdot D} + \left(-\frac{{d}^{2} \cdot \color{blue}{\frac{\frac{c0}{w}}{h}}}{{D}^{2}}\right)\right)
\] |
Taylor expanded in d around 0 33.0
Taylor expanded in c0 around 0 27.8
Final simplification30.1
| Alternative 1 | |
|---|---|
| Error | 29.8 |
| Cost | 23236 |
| Alternative 2 | |
|---|---|
| Error | 30.0 |
| Cost | 23236 |
| Alternative 3 | |
|---|---|
| Error | 30.5 |
| Cost | 19396 |
| Alternative 4 | |
|---|---|
| Error | 30.5 |
| Cost | 19396 |
| Alternative 5 | |
|---|---|
| Error | 30.2 |
| Cost | 19396 |
| Alternative 6 | |
|---|---|
| Error | 31.5 |
| Cost | 64 |
herbie shell --seed 2023068
(FPCore (c0 w h D d M)
:name "Henrywood and Agarwal, Equation (13)"
:precision binary64
(* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))