| Alternative 1 | |
|---|---|
| Error | 36.87% |
| Cost | 1488 |
(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 w) (* (/ d D) (* (/ c0 w) (/ d (* h 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-264)
t_0
(if (<= t_2 0.0)
(/ (* (* (* h D) (* M (/ D d))) 0.25) (/ d M))
(if (<= t_2 INFINITY)
t_0
(* 0.25 (/ (* D (* (* h (* D M)) (/ M d))) d)))))))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 / w) * ((d / D) * ((c0 / w) * (d / (h * 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-264) {
tmp = t_0;
} else if (t_2 <= 0.0) {
tmp = (((h * D) * (M * (D / d))) * 0.25) / (d / M);
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = 0.25 * ((D * ((h * (D * M)) * (M / d))) / d);
}
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 / w) * ((d / D) * ((c0 / w) * (d / (h * 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-264) {
tmp = t_0;
} else if (t_2 <= 0.0) {
tmp = (((h * D) * (M * (D / d))) * 0.25) / (d / M);
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = 0.25 * ((D * ((h * (D * M)) * (M / d))) / d);
}
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 / w) * ((d / D) * ((c0 / w) * (d / (h * 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-264: tmp = t_0 elif t_2 <= 0.0: tmp = (((h * D) * (M * (D / d))) * 0.25) / (d / M) elif t_2 <= math.inf: tmp = t_0 else: tmp = 0.25 * ((D * ((h * (D * M)) * (M / d))) / d) 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 / w) * Float64(Float64(d / D) * Float64(Float64(c0 / w) * Float64(d / Float64(h * 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-264) tmp = t_0; elseif (t_2 <= 0.0) tmp = Float64(Float64(Float64(Float64(h * D) * Float64(M * Float64(D / d))) * 0.25) / Float64(d / M)); elseif (t_2 <= Inf) tmp = t_0; else tmp = Float64(0.25 * Float64(Float64(D * Float64(Float64(h * Float64(D * M)) * Float64(M / d))) / d)); 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 / w) * ((d / D) * ((c0 / w) * (d / (h * 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-264) tmp = t_0; elseif (t_2 <= 0.0) tmp = (((h * D) * (M * (D / d))) * 0.25) / (d / M); elseif (t_2 <= Inf) tmp = t_0; else tmp = 0.25 * ((D * ((h * (D * M)) * (M / d))) / d); 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 / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] * N[(d / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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-264], t$95$0, If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(h * D), $MachinePrecision] * N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision] / N[(d / M), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$0, N[(0.25 * N[(N[(D * N[(N[(h * N[(D * M), $MachinePrecision]), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $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 := \frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \left(\frac{c0}{w} \cdot \frac{d}{h \cdot D}\right)\right)\\
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^{-264}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{\left(\left(h \cdot D\right) \cdot \left(M \cdot \frac{D}{d}\right)\right) \cdot 0.25}{\frac{d}{M}}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot \left(\left(h \cdot \left(D \cdot M\right)\right) \cdot \frac{M}{d}\right)}{d}\\
\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-264 or -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 74.54
Simplified76.5
[Start]74.54 | \[ \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 [=>]78.6 | \[ \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 [=>]78.6 | \[ \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 [=>]78.74 | \[ \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 [=>]76.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(\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 66.5
Simplified59.96
[Start]66.5 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
times-frac [=>]68.78 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{{d}^{2}}{{D}^{2}} \cdot \frac{c0}{w \cdot h}\right)}\right)
\] |
unpow2 [=>]68.78 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\color{blue}{d \cdot d}}{{D}^{2}} \cdot \frac{c0}{w \cdot h}\right)\right)
\] |
unpow2 [=>]68.78 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d \cdot d}{\color{blue}{D \cdot D}} \cdot \frac{c0}{w \cdot h}\right)\right)
\] |
associate-/r* [=>]66.21 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{d \cdot d}{D \cdot D} \cdot \color{blue}{\frac{\frac{c0}{w}}{h}}\right)\right)
\] |
times-frac [<=]63.73 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\left(d \cdot d\right) \cdot \frac{c0}{w}}{\left(D \cdot D\right) \cdot h}}\right)
\] |
*-commutative [<=]63.73 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(d \cdot d\right) \cdot \frac{c0}{w}}{\color{blue}{h \cdot \left(D \cdot D\right)}}\right)
\] |
associate-/l* [=>]63.83 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{d \cdot d}{\frac{h \cdot \left(D \cdot D\right)}{\frac{c0}{w}}}}\right)
\] |
*-commutative [=>]63.83 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{d \cdot d}{\frac{\color{blue}{\left(D \cdot D\right) \cdot h}}{\frac{c0}{w}}}\right)
\] |
associate-*l* [=>]59.96 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{d \cdot d}{\frac{\color{blue}{D \cdot \left(D \cdot h\right)}}{\frac{c0}{w}}}\right)
\] |
Applied egg-rr83.57
Simplified45.02
[Start]83.57 | \[ e^{\mathsf{log1p}\left(\left(\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D \cdot h}\right)\right) \cdot \frac{2}{\frac{w}{c0 \cdot 0.5}}\right)} - 1
\] |
|---|---|
expm1-def [=>]72.83 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D \cdot h}\right)\right) \cdot \frac{2}{\frac{w}{c0 \cdot 0.5}}\right)\right)}
\] |
expm1-log1p [=>]56.85 | \[ \color{blue}{\left(\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D \cdot h}\right)\right) \cdot \frac{2}{\frac{w}{c0 \cdot 0.5}}}
\] |
associate-/r/ [=>]56.84 | \[ \left(\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D \cdot h}\right)\right) \cdot \color{blue}{\left(\frac{2}{w} \cdot \left(c0 \cdot 0.5\right)\right)}
\] |
*-commutative [<=]56.84 | \[ \color{blue}{\left(\left(\frac{d}{D} \cdot \frac{d}{D \cdot h}\right) \cdot \frac{c0}{w}\right)} \cdot \left(\frac{2}{w} \cdot \left(c0 \cdot 0.5\right)\right)
\] |
associate-*l* [=>]44.98 | \[ \color{blue}{\left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right)} \cdot \left(\frac{2}{w} \cdot \left(c0 \cdot 0.5\right)\right)
\] |
associate-*l/ [=>]45.02 | \[ \left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right) \cdot \color{blue}{\frac{2 \cdot \left(c0 \cdot 0.5\right)}{w}}
\] |
*-commutative [=>]45.02 | \[ \left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right) \cdot \frac{2 \cdot \color{blue}{\left(0.5 \cdot c0\right)}}{w}
\] |
associate-*r* [=>]45.02 | \[ \left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right) \cdot \frac{\color{blue}{\left(2 \cdot 0.5\right) \cdot c0}}{w}
\] |
metadata-eval [=>]45.02 | \[ \left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right) \cdot \frac{\color{blue}{1} \cdot c0}{w}
\] |
associate-*r/ [<=]45.02 | \[ \left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right) \cdot \color{blue}{\left(1 \cdot \frac{c0}{w}\right)}
\] |
*-lft-identity [=>]45.02 | \[ \left(\frac{d}{D} \cdot \left(\frac{d}{D \cdot h} \cdot \frac{c0}{w}\right)\right) \cdot \color{blue}{\frac{c0}{w}}
\] |
if -1e-264 < (*.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 47.12
Simplified84.13
[Start]47.12 | \[ \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)
\] |
|---|---|
associate-*l/ [<=]55.67 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\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)
\] |
*-commutative [=>]55.67 | \[ \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)
\] |
fma-def [=>]69.48 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot d, \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)}
\] |
associate-*l* [=>]74.27 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{w \cdot \left(h \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)
\] |
associate-/r* [=>]74.67 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \color{blue}{\frac{\frac{c0}{w}}{h \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)
\] |
associate-*r* [=>]76.37 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{\left(h \cdot D\right) \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)
\] |
*-commutative [=>]76.37 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{D \cdot \left(h \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)
\] |
Taylor expanded in c0 around -inf 48.93
Simplified37.89
[Start]48.93 | \[ \frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\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\right)\right)
\] |
|---|---|
fma-def [=>]48.93 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0}, -1 \cdot \left(\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\right)\right)}
\] |
Taylor expanded in c0 around 0 40.93
Simplified35.61
[Start]40.93 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [<=]40.93 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2}}
\] |
associate-*r* [=>]40.14 | \[ 0.25 \cdot \frac{\color{blue}{\left({D}^{2} \cdot h\right) \cdot {M}^{2}}}{{d}^{2}}
\] |
unpow2 [=>]40.14 | \[ 0.25 \cdot \frac{\left({D}^{2} \cdot h\right) \cdot \color{blue}{\left(M \cdot M\right)}}{{d}^{2}}
\] |
unpow2 [=>]40.14 | \[ 0.25 \cdot \frac{\left({D}^{2} \cdot h\right) \cdot \left(M \cdot M\right)}{\color{blue}{d \cdot d}}
\] |
times-frac [=>]35.61 | \[ 0.25 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot h}{d} \cdot \frac{M \cdot M}{d}\right)}
\] |
unpow2 [=>]35.61 | \[ 0.25 \cdot \left(\frac{\color{blue}{\left(D \cdot D\right)} \cdot h}{d} \cdot \frac{M \cdot M}{d}\right)
\] |
*-commutative [=>]35.61 | \[ 0.25 \cdot \left(\frac{\color{blue}{h \cdot \left(D \cdot D\right)}}{d} \cdot \frac{M \cdot M}{d}\right)
\] |
Applied egg-rr20.18
Applied egg-rr19.86
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 100
Simplified99.56
[Start]100 | \[ \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)
\] |
|---|---|
associate-*l/ [<=]100 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\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)
\] |
*-commutative [=>]100 | \[ \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)
\] |
fma-def [=>]100 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot d, \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)}
\] |
associate-*l* [=>]100 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{w \cdot \left(h \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)
\] |
associate-/r* [=>]100 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \color{blue}{\frac{\frac{c0}{w}}{h \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)
\] |
associate-*r* [=>]100 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{\left(h \cdot D\right) \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)
\] |
*-commutative [=>]100 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{D \cdot \left(h \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)
\] |
Taylor expanded in c0 around -inf 98.07
Simplified50.43
[Start]98.07 | \[ \frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\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\right)\right)
\] |
|---|---|
fma-def [=>]98.07 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0}, -1 \cdot \left(\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\right)\right)}
\] |
Taylor expanded in c0 around 0 53.31
Simplified49.93
[Start]53.31 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
unpow2 [=>]53.31 | \[ 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
unpow2 [=>]53.31 | \[ 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot h\right)}{{d}^{2}}
\] |
associate-*r* [<=]49.93 | \[ 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot \left(M \cdot h\right)\right)}}{{d}^{2}}
\] |
*-commutative [<=]49.93 | \[ 0.25 \cdot \frac{\color{blue}{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}}{{d}^{2}}
\] |
unpow2 [=>]49.93 | \[ 0.25 \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}{\color{blue}{d \cdot d}}
\] |
Taylor expanded in M around 0 53.31
Simplified41.92
[Start]53.31 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
associate-*r/ [=>]53.31 | \[ \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2}}}
\] |
*-commutative [=>]53.31 | \[ \frac{\color{blue}{\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right) \cdot 0.25}}{{d}^{2}}
\] |
unpow2 [=>]53.31 | \[ \frac{\left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right) \cdot 0.25}{\color{blue}{d \cdot d}}
\] |
associate-*l/ [<=]53.31 | \[ \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot d} \cdot 0.25}
\] |
unpow2 [=>]53.31 | \[ \frac{\color{blue}{\left(D \cdot D\right)} \cdot \left({M}^{2} \cdot h\right)}{d \cdot d} \cdot 0.25
\] |
unpow2 [=>]53.31 | \[ \frac{\left(D \cdot D\right) \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot h\right)}{d \cdot d} \cdot 0.25
\] |
associate-*r* [<=]49.93 | \[ \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot \left(M \cdot h\right)\right)}}{d \cdot d} \cdot 0.25
\] |
associate-*r/ [<=]50.1 | \[ \color{blue}{\left(\left(D \cdot D\right) \cdot \frac{M \cdot \left(M \cdot h\right)}{d \cdot d}\right)} \cdot 0.25
\] |
associate-*l* [=>]44.88 | \[ \color{blue}{\left(D \cdot \left(D \cdot \frac{M \cdot \left(M \cdot h\right)}{d \cdot d}\right)\right)} \cdot 0.25
\] |
associate-*l/ [<=]41.92 | \[ \left(D \cdot \left(D \cdot \color{blue}{\left(\frac{M}{d \cdot d} \cdot \left(M \cdot h\right)\right)}\right)\right) \cdot 0.25
\] |
*-commutative [=>]41.92 | \[ \left(D \cdot \left(D \cdot \color{blue}{\left(\left(M \cdot h\right) \cdot \frac{M}{d \cdot d}\right)}\right)\right) \cdot 0.25
\] |
*-commutative [=>]41.92 | \[ \left(D \cdot \left(D \cdot \left(\color{blue}{\left(h \cdot M\right)} \cdot \frac{M}{d \cdot d}\right)\right)\right) \cdot 0.25
\] |
Applied egg-rr26.95
Final simplification28.76
| Alternative 1 | |
|---|---|
| Error | 36.87% |
| Cost | 1488 |
| Alternative 2 | |
|---|---|
| Error | 33.67% |
| Cost | 1357 |
| Alternative 3 | |
|---|---|
| Error | 34.11% |
| Cost | 1356 |
| Alternative 4 | |
|---|---|
| Error | 33.91% |
| Cost | 1356 |
| Alternative 5 | |
|---|---|
| Error | 32.93% |
| Cost | 1356 |
| Alternative 6 | |
|---|---|
| Error | 38.13% |
| Cost | 1225 |
| Alternative 7 | |
|---|---|
| Error | 34.33% |
| Cost | 1224 |
| Alternative 8 | |
|---|---|
| Error | 35.92% |
| Cost | 1220 |
| Alternative 9 | |
|---|---|
| Error | 38.4% |
| Cost | 960 |
| Alternative 10 | |
|---|---|
| Error | 50.46% |
| Cost | 64 |
herbie shell --seed 2023089
(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))))))