| Alternative 1 | |
|---|---|
| Error | 17.3 |
| Cost | 30412 |
(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 (* (sqrt (/ (/ c0 w) h)) (/ d D)))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -1e-276)
(* (* (/ d (* w h)) (* c0 d)) (* (pow D -2.0) (/ c0 w)))
(if (<= t_2 0.0)
(* 0.25 (* (/ (* h D) d) (/ M (/ (/ d M) D))))
(if (<= t_2 INFINITY)
(* t_0 (/ t_0 (/ w c0)))
(* 0.25 (/ (* M (* h (/ D d))) (/ (/ d D) M))))))))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 = sqrt(((c0 / w) / h)) * (d / D);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -1e-276) {
tmp = ((d / (w * h)) * (c0 * d)) * (pow(D, -2.0) * (c0 / w));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((h * D) / d) * (M / ((d / M) / D)));
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_0 * (t_0 / (w / c0));
} else {
tmp = 0.25 * ((M * (h * (D / d))) / ((d / D) / M));
}
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 = Math.sqrt(((c0 / w) / h)) * (d / D);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -1e-276) {
tmp = ((d / (w * h)) * (c0 * d)) * (Math.pow(D, -2.0) * (c0 / w));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((h * D) / d) * (M / ((d / M) / D)));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (t_0 / (w / c0));
} else {
tmp = 0.25 * ((M * (h * (D / d))) / ((d / D) / M));
}
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 = math.sqrt(((c0 / w) / h)) * (d / D) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -1e-276: tmp = ((d / (w * h)) * (c0 * d)) * (math.pow(D, -2.0) * (c0 / w)) elif t_2 <= 0.0: tmp = 0.25 * (((h * D) / d) * (M / ((d / M) / D))) elif t_2 <= math.inf: tmp = t_0 * (t_0 / (w / c0)) else: tmp = 0.25 * ((M * (h * (D / d))) / ((d / D) / M)) 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(sqrt(Float64(Float64(c0 / w) / h)) * Float64(d / D)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -1e-276) tmp = Float64(Float64(Float64(d / Float64(w * h)) * Float64(c0 * d)) * Float64((D ^ -2.0) * Float64(c0 / w))); elseif (t_2 <= 0.0) tmp = Float64(0.25 * Float64(Float64(Float64(h * D) / d) * Float64(M / Float64(Float64(d / M) / D)))); elseif (t_2 <= Inf) tmp = Float64(t_0 * Float64(t_0 / Float64(w / c0))); else tmp = Float64(0.25 * Float64(Float64(M * Float64(h * Float64(D / d))) / Float64(Float64(d / D) / M))); 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 = sqrt(((c0 / w) / h)) * (d / D); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -1e-276) tmp = ((d / (w * h)) * (c0 * d)) * ((D ^ -2.0) * (c0 / w)); elseif (t_2 <= 0.0) tmp = 0.25 * (((h * D) / d) * (M / ((d / M) / D))); elseif (t_2 <= Inf) tmp = t_0 * (t_0 / (w / c0)); else tmp = 0.25 * ((M * (h * (D / d))) / ((d / D) / M)); 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[Sqrt[N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-276], N[(N[(N[(d / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(c0 * d), $MachinePrecision]), $MachinePrecision] * N[(N[Power[D, -2.0], $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(0.25 * N[(N[(N[(h * D), $MachinePrecision] / d), $MachinePrecision] * N[(M / N[(N[(d / M), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(t$95$0 * N[(t$95$0 / N[(w / c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(M * N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d / D), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\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 := \sqrt{\frac{\frac{c0}{w}}{h}} \cdot \frac{d}{D}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{-276}:\\
\;\;\;\;\left(\frac{d}{w \cdot h} \cdot \left(c0 \cdot d\right)\right) \cdot \left({D}^{-2} \cdot \frac{c0}{w}\right)\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\frac{h \cdot D}{d} \cdot \frac{M}{\frac{\frac{d}{M}}{D}}\right)\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;t_0 \cdot \frac{t_0}{\frac{w}{c0}}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{M \cdot \left(h \cdot \frac{D}{d}\right)}{\frac{\frac{d}{D}}{M}}\\
\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))))) < -1e-276Initial program 48.4
Simplified45.6
[Start]48.4 | \[ \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)
\] |
|---|---|
times-frac [=>]50.2 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{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)
\] |
fma-def [=>]50.2 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d \cdot d}{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)}
\] |
associate-/r* [=>]50.2 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\color{blue}{\frac{\frac{c0}{w}}{h}}, \frac{d \cdot d}{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)
\] |
times-frac [=>]50.2 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \color{blue}{\frac{d}{D} \cdot \frac{d}{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)
\] |
difference-of-squares [=>]50.2 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}}\right)
\] |
sub-neg [=>]50.2 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \left(-M\right)\right)}}\right)
\] |
Taylor expanded in c0 around inf 42.5
Simplified42.6
[Start]42.5 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
associate-/l/ [<=]42.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\frac{{d}^{2} \cdot c0}{w \cdot h}}{{D}^{2}}}\right)
\] |
associate-/l* [=>]42.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\frac{{d}^{2}}{\frac{w \cdot h}{c0}}}}{{D}^{2}}\right)
\] |
unpow2 [=>]42.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{\color{blue}{d \cdot d}}{\frac{w \cdot h}{c0}}}{{D}^{2}}\right)
\] |
*-commutative [=>]42.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{d \cdot d}{\frac{\color{blue}{h \cdot w}}{c0}}}{{D}^{2}}\right)
\] |
associate-*l/ [<=]46.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{d \cdot d}{\color{blue}{\frac{h}{c0} \cdot w}}}{{D}^{2}}\right)
\] |
associate-/r/ [<=]42.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{d \cdot d}{\color{blue}{\frac{h}{\frac{c0}{w}}}}}{{D}^{2}}\right)
\] |
unpow2 [=>]42.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{d \cdot d}{\frac{h}{\frac{c0}{w}}}}{\color{blue}{D \cdot D}}\right)
\] |
associate-/r* [<=]41.9 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{d \cdot d}{\frac{h}{\frac{c0}{w}} \cdot \left(D \cdot D\right)}}\right)
\] |
times-frac [=>]37.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{d}{\frac{h}{\frac{c0}{w}}} \cdot \frac{d}{D \cdot D}\right)}\right)
\] |
associate-/r/ [=>]42.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d}{\color{blue}{\frac{h}{c0} \cdot w}} \cdot \frac{d}{D \cdot D}\right)\right)
\] |
Applied egg-rr62.4
Simplified37.6
[Start]62.4 | \[ e^{\mathsf{log1p}\left(\left(\frac{d}{\frac{h \cdot w}{d \cdot c0}} \cdot {D}^{-2}\right) \cdot \left(1 \cdot \frac{c0}{w}\right)\right)} - 1
\] |
|---|---|
expm1-def [=>]54.4 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\frac{d}{\frac{h \cdot w}{d \cdot c0}} \cdot {D}^{-2}\right) \cdot \left(1 \cdot \frac{c0}{w}\right)\right)\right)}
\] |
expm1-log1p [=>]38.7 | \[ \color{blue}{\left(\frac{d}{\frac{h \cdot w}{d \cdot c0}} \cdot {D}^{-2}\right) \cdot \left(1 \cdot \frac{c0}{w}\right)}
\] |
associate-*l* [=>]36.8 | \[ \color{blue}{\frac{d}{\frac{h \cdot w}{d \cdot c0}} \cdot \left({D}^{-2} \cdot \left(1 \cdot \frac{c0}{w}\right)\right)}
\] |
associate-/r/ [=>]37.6 | \[ \color{blue}{\left(\frac{d}{h \cdot w} \cdot \left(d \cdot c0\right)\right)} \cdot \left({D}^{-2} \cdot \left(1 \cdot \frac{c0}{w}\right)\right)
\] |
*-commutative [=>]37.6 | \[ \left(\frac{d}{\color{blue}{w \cdot h}} \cdot \left(d \cdot c0\right)\right) \cdot \left({D}^{-2} \cdot \left(1 \cdot \frac{c0}{w}\right)\right)
\] |
*-lft-identity [=>]37.6 | \[ \left(\frac{d}{w \cdot h} \cdot \left(d \cdot c0\right)\right) \cdot \left({D}^{-2} \cdot \color{blue}{\frac{c0}{w}}\right)
\] |
if -1e-276 < (*.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))))) < 0.0Initial program 27.7
Simplified32.0
[Start]27.7 | \[ \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)
\] |
|---|---|
times-frac [=>]38.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{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)
\] |
fma-neg [=>]38.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\color{blue}{\mathsf{fma}\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, -M \cdot M\right)}}\right)
\] |
times-frac [=>]35.5 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, -M \cdot M\right)}\right)
\] |
times-frac [=>]32.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, -M \cdot M\right)}\right)
\] |
Taylor expanded in c0 around -inf 30.7
Simplified26.0
[Start]30.7 | \[ -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w} + 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|
Taylor expanded in w around 0 21.4
Applied egg-rr12.1
Applied egg-rr14.8
if 0.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))))) < +inf.0Initial program 47.7
Simplified49.1
[Start]47.7 | \[ \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)
\] |
|---|---|
times-frac [=>]49.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{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)
\] |
fma-neg [=>]49.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\color{blue}{\mathsf{fma}\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, -M \cdot M\right)}}\right)
\] |
times-frac [=>]49.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, -M \cdot M\right)}\right)
\] |
times-frac [=>]49.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, -M \cdot M\right)}\right)
\] |
Applied egg-rr37.5
Simplified42.2
[Start]37.5 | \[ \frac{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \mathsf{hypot}\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}, M\right)\right)}{2 \cdot \frac{w}{c0}}
\] |
|---|---|
associate-*l/ [=>]41.0 | \[ \frac{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \mathsf{hypot}\left(\color{blue}{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}, M\right)\right)}{2 \cdot \frac{w}{c0}}
\] |
times-frac [=>]42.2 | \[ \frac{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \mathsf{hypot}\left(\color{blue}{\frac{c0}{w} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h}}, M\right)\right)}{2 \cdot \frac{w}{c0}}
\] |
Taylor expanded in c0 around inf 41.5
Simplified43.1
[Start]41.5 | \[ \frac{2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}}{2 \cdot \frac{w}{c0}}
\] |
|---|---|
times-frac [=>]43.1 | \[ \frac{2 \cdot \color{blue}{\left(\frac{{d}^{2}}{{D}^{2}} \cdot \frac{c0}{w \cdot h}\right)}}{2 \cdot \frac{w}{c0}}
\] |
unpow2 [=>]43.1 | \[ \frac{2 \cdot \left(\frac{\color{blue}{d \cdot d}}{{D}^{2}} \cdot \frac{c0}{w \cdot h}\right)}{2 \cdot \frac{w}{c0}}
\] |
unpow2 [=>]43.1 | \[ \frac{2 \cdot \left(\frac{d \cdot d}{\color{blue}{D \cdot D}} \cdot \frac{c0}{w \cdot h}\right)}{2 \cdot \frac{w}{c0}}
\] |
Applied egg-rr22.2
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.3
[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)
\] |
|---|---|
times-frac [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{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)
\] |
fma-neg [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\color{blue}{\mathsf{fma}\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, -M \cdot M\right)}}\right)
\] |
times-frac [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, -M \cdot M\right)}\right)
\] |
times-frac [=>]63.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, -M \cdot M\right)}\right)
\] |
Taylor expanded in c0 around -inf 63.4
Simplified36.5
[Start]63.4 | \[ -0.5 \cdot \frac{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot {c0}^{2}}{w} + 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|
Taylor expanded in w around 0 25.1
Applied egg-rr14.7
Taylor expanded in D around 0 16.3
Simplified14.4
[Start]16.3 | \[ 0 + 0.25 \cdot \frac{\frac{D \cdot \left(M \cdot h\right)}{d}}{\frac{\frac{d}{D}}{M}}
\] |
|---|---|
*-commutative [<=]16.3 | \[ 0 + 0.25 \cdot \frac{\frac{D \cdot \color{blue}{\left(h \cdot M\right)}}{d}}{\frac{\frac{d}{D}}{M}}
\] |
associate-*l/ [<=]14.7 | \[ 0 + 0.25 \cdot \frac{\color{blue}{\frac{D}{d} \cdot \left(h \cdot M\right)}}{\frac{\frac{d}{D}}{M}}
\] |
associate-*r* [=>]14.4 | \[ 0 + 0.25 \cdot \frac{\color{blue}{\left(\frac{D}{d} \cdot h\right) \cdot M}}{\frac{\frac{d}{D}}{M}}
\] |
Final simplification16.5
| Alternative 1 | |
|---|---|
| Error | 17.3 |
| Cost | 30412 |
| Alternative 2 | |
|---|---|
| Error | 19.4 |
| Cost | 1864 |
| Alternative 3 | |
|---|---|
| Error | 19.4 |
| Cost | 1608 |
| Alternative 4 | |
|---|---|
| Error | 30.2 |
| Cost | 1480 |
| Alternative 5 | |
|---|---|
| Error | 29.1 |
| Cost | 1480 |
| Alternative 6 | |
|---|---|
| Error | 18.8 |
| Cost | 1225 |
| Alternative 7 | |
|---|---|
| Error | 18.6 |
| Cost | 1225 |
| Alternative 8 | |
|---|---|
| Error | 18.7 |
| Cost | 1224 |
| Alternative 9 | |
|---|---|
| Error | 18.9 |
| Cost | 1092 |
| Alternative 10 | |
|---|---|
| Error | 18.6 |
| Cost | 960 |
| Alternative 11 | |
|---|---|
| Error | 31.7 |
| Cost | 64 |
herbie shell --seed 2023054
(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))))))