| Alternative 1 | |
|---|---|
| Error | 25.8 |
| Cost | 8656 |
(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
(if (<= h -2.15e-110)
(* 0.25 (* M (* (pow (/ D d) 2.0) (* h M))))
(if (<= h 2e-287)
(* 0.25 (/ D (* (/ d (* M (* h M))) (/ d D))))
(* 0.25 (pow (* M (* (/ D d) (sqrt h))) 2.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 tmp;
if (h <= -2.15e-110) {
tmp = 0.25 * (M * (pow((D / d), 2.0) * (h * M)));
} else if (h <= 2e-287) {
tmp = 0.25 * (D / ((d / (M * (h * M))) * (d / D)));
} else {
tmp = 0.25 * pow((M * ((D / d) * sqrt(h))), 2.0);
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
code = (c0 / (2.0d0 * w)) * (((c0 * (d_1 * d_1)) / ((w * h) * (d * d))) + sqrt(((((c0 * (d_1 * d_1)) / ((w * h) * (d * d))) * ((c0 * (d_1 * d_1)) / ((w * h) * (d * d)))) - (m * m))))
end function
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if (h <= (-2.15d-110)) then
tmp = 0.25d0 * (m * (((d / d_1) ** 2.0d0) * (h * m)))
else if (h <= 2d-287) then
tmp = 0.25d0 * (d / ((d_1 / (m * (h * m))) * (d_1 / d)))
else
tmp = 0.25d0 * ((m * ((d / d_1) * sqrt(h))) ** 2.0d0)
end if
code = tmp
end function
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 tmp;
if (h <= -2.15e-110) {
tmp = 0.25 * (M * (Math.pow((D / d), 2.0) * (h * M)));
} else if (h <= 2e-287) {
tmp = 0.25 * (D / ((d / (M * (h * M))) * (d / D)));
} else {
tmp = 0.25 * Math.pow((M * ((D / d) * Math.sqrt(h))), 2.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): tmp = 0 if h <= -2.15e-110: tmp = 0.25 * (M * (math.pow((D / d), 2.0) * (h * M))) elif h <= 2e-287: tmp = 0.25 * (D / ((d / (M * (h * M))) * (d / D))) else: tmp = 0.25 * math.pow((M * ((D / d) * math.sqrt(h))), 2.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) tmp = 0.0 if (h <= -2.15e-110) tmp = Float64(0.25 * Float64(M * Float64((Float64(D / d) ^ 2.0) * Float64(h * M)))); elseif (h <= 2e-287) tmp = Float64(0.25 * Float64(D / Float64(Float64(d / Float64(M * Float64(h * M))) * Float64(d / D)))); else tmp = Float64(0.25 * (Float64(M * Float64(Float64(D / d) * sqrt(h))) ^ 2.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) tmp = 0.0; if (h <= -2.15e-110) tmp = 0.25 * (M * (((D / d) ^ 2.0) * (h * M))); elseif (h <= 2e-287) tmp = 0.25 * (D / ((d / (M * (h * M))) * (d / D))); else tmp = 0.25 * ((M * ((D / d) * sqrt(h))) ^ 2.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_] := If[LessEqual[h, -2.15e-110], N[(0.25 * N[(M * N[(N[Power[N[(D / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 2e-287], N[(0.25 * N[(D / N[(N[(d / N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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}
\mathbf{if}\;h \leq -2.15 \cdot 10^{-110}:\\
\;\;\;\;0.25 \cdot \left(M \cdot \left({\left(\frac{D}{d}\right)}^{2} \cdot \left(h \cdot M\right)\right)\right)\\
\mathbf{elif}\;h \leq 2 \cdot 10^{-287}:\\
\;\;\;\;0.25 \cdot \frac{D}{\frac{d}{M \cdot \left(h \cdot M\right)} \cdot \frac{d}{D}}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot {\left(M \cdot \left(\frac{D}{d} \cdot \sqrt{h}\right)\right)}^{2}\\
\end{array}
Results
if h < -2.15000000000000012e-110Initial program 59.9
Simplified62.2
[Start]59.9 | \[ \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/ [<=]60.3 | \[ \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 [=>]60.3 | \[ \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 [=>]61.0 | \[ \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* [=>]61.2 | \[ \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* [=>]61.2 | \[ \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* [=>]61.2 | \[ \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 [=>]61.2 | \[ \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 59.9
Simplified38.6
[Start]59.9 | \[ \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 [=>]59.9 | \[ \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 35.7
Simplified30.2
[Start]35.7 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [<=]35.7 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2}}
\] |
associate-/l* [=>]35.7 | \[ 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}}
\] |
unpow2 [=>]35.7 | \[ 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}
\] |
unpow2 [=>]35.7 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{h \cdot {M}^{2}}}
\] |
*-commutative [=>]35.7 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{{M}^{2} \cdot h}}}
\] |
unpow2 [=>]35.7 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}}
\] |
associate-*r* [<=]35.2 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}
\] |
associate-/r/ [=>]35.3 | \[ 0.25 \cdot \color{blue}{\left(\frac{D \cdot D}{d \cdot d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)}
\] |
associate-/r* [=>]33.1 | \[ 0.25 \cdot \left(\color{blue}{\frac{\frac{D \cdot D}{d}}{d}} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
associate-*r/ [<=]30.2 | \[ 0.25 \cdot \left(\frac{\color{blue}{D \cdot \frac{D}{d}}}{d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
Taylor expanded in D around 0 35.7
Simplified26.2
[Start]35.7 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [<=]35.7 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{{d}^{2}}
\] |
associate-/l* [=>]35.7 | \[ 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}}
\] |
unpow2 [=>]35.7 | \[ 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{{M}^{2} \cdot h}}
\] |
unpow2 [=>]35.7 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{{M}^{2} \cdot h}}
\] |
unpow2 [=>]35.7 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}}
\] |
associate-*r* [<=]35.2 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}
\] |
associate-*l/ [<=]33.4 | \[ 0.25 \cdot \frac{D \cdot D}{\color{blue}{\frac{d}{M \cdot \left(M \cdot h\right)} \cdot d}}
\] |
times-frac [=>]28.4 | \[ 0.25 \cdot \color{blue}{\left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \frac{D}{d}\right)}
\] |
*-rgt-identity [<=]28.4 | \[ 0.25 \cdot \left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \color{blue}{\left(\frac{D}{d} \cdot 1\right)}\right)
\] |
*-commutative [=>]28.4 | \[ 0.25 \cdot \left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \color{blue}{\left(1 \cdot \frac{D}{d}\right)}\right)
\] |
metadata-eval [<=]28.4 | \[ 0.25 \cdot \left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \left(\color{blue}{\frac{-1}{-1}} \cdot \frac{D}{d}\right)\right)
\] |
times-frac [<=]28.4 | \[ 0.25 \cdot \left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \color{blue}{\frac{-1 \cdot D}{-1 \cdot d}}\right)
\] |
neg-mul-1 [<=]28.4 | \[ 0.25 \cdot \left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \frac{\color{blue}{-D}}{-1 \cdot d}\right)
\] |
neg-mul-1 [<=]28.4 | \[ 0.25 \cdot \left(\frac{D}{\frac{d}{M \cdot \left(M \cdot h\right)}} \cdot \frac{-D}{\color{blue}{-d}}\right)
\] |
times-frac [<=]33.4 | \[ 0.25 \cdot \color{blue}{\frac{D \cdot \left(-D\right)}{\frac{d}{M \cdot \left(M \cdot h\right)} \cdot \left(-d\right)}}
\] |
associate-*l/ [=>]35.2 | \[ 0.25 \cdot \frac{D \cdot \left(-D\right)}{\color{blue}{\frac{d \cdot \left(-d\right)}{M \cdot \left(M \cdot h\right)}}}
\] |
associate-/r/ [=>]35.3 | \[ 0.25 \cdot \color{blue}{\left(\frac{D \cdot \left(-D\right)}{d \cdot \left(-d\right)} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)}
\] |
if -2.15000000000000012e-110 < h < 2.00000000000000004e-287Initial program 60.2
Simplified62.3
[Start]60.2 | \[ \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/ [<=]60.8 | \[ \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 [=>]60.8 | \[ \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 [=>]61.1 | \[ \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* [=>]61.6 | \[ \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* [=>]61.6 | \[ \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* [=>]61.8 | \[ \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 [=>]61.8 | \[ \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 60.5
Simplified30.4
[Start]60.5 | \[ \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 [=>]60.5 | \[ \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 34.5
Simplified23.2
[Start]34.5 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [<=]34.5 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2}}
\] |
associate-/l* [=>]34.6 | \[ 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}}
\] |
unpow2 [=>]34.6 | \[ 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}
\] |
unpow2 [=>]34.6 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{h \cdot {M}^{2}}}
\] |
*-commutative [=>]34.6 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{{M}^{2} \cdot h}}}
\] |
unpow2 [=>]34.6 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}}
\] |
associate-*r* [<=]31.1 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}
\] |
associate-/r/ [=>]31.0 | \[ 0.25 \cdot \color{blue}{\left(\frac{D \cdot D}{d \cdot d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)}
\] |
associate-/r* [=>]27.8 | \[ 0.25 \cdot \left(\color{blue}{\frac{\frac{D \cdot D}{d}}{d}} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
associate-*r/ [<=]23.2 | \[ 0.25 \cdot \left(\frac{\color{blue}{D \cdot \frac{D}{d}}}{d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
Applied egg-rr21.8
if 2.00000000000000004e-287 < h Initial program 59.4
Simplified61.8
[Start]59.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)
\] |
|---|---|
associate-*l/ [<=]59.8 | \[ \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 [=>]59.8 | \[ \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 [=>]60.4 | \[ \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* [=>]60.9 | \[ \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* [=>]60.9 | \[ \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* [=>]61.0 | \[ \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 [=>]61.0 | \[ \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 59.9
Simplified35.4
[Start]59.9 | \[ \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 [=>]59.9 | \[ \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 36.4
Simplified27.8
[Start]36.4 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [<=]36.4 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2}}
\] |
associate-/l* [=>]36.6 | \[ 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}}
\] |
unpow2 [=>]36.6 | \[ 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}
\] |
unpow2 [=>]36.6 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{h \cdot {M}^{2}}}
\] |
*-commutative [=>]36.6 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{{M}^{2} \cdot h}}}
\] |
unpow2 [=>]36.6 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}}
\] |
associate-*r* [<=]34.9 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}
\] |
associate-/r/ [=>]34.7 | \[ 0.25 \cdot \color{blue}{\left(\frac{D \cdot D}{d \cdot d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)}
\] |
associate-/r* [=>]31.9 | \[ 0.25 \cdot \left(\color{blue}{\frac{\frac{D \cdot D}{d}}{d}} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
associate-*r/ [<=]27.8 | \[ 0.25 \cdot \left(\frac{\color{blue}{D \cdot \frac{D}{d}}}{d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
Applied egg-rr27.7
Simplified17.3
[Start]27.7 | \[ 0.25 \cdot \left(e^{\mathsf{log1p}\left({\left(\frac{D}{d} \cdot \left(M \cdot \sqrt{h}\right)\right)}^{2}\right)} - 1\right)
\] |
|---|---|
expm1-def [=>]17.6 | \[ 0.25 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{D}{d} \cdot \left(M \cdot \sqrt{h}\right)\right)}^{2}\right)\right)}
\] |
expm1-log1p [=>]17.2 | \[ 0.25 \cdot \color{blue}{{\left(\frac{D}{d} \cdot \left(M \cdot \sqrt{h}\right)\right)}^{2}}
\] |
*-commutative [=>]17.2 | \[ 0.25 \cdot {\color{blue}{\left(\left(M \cdot \sqrt{h}\right) \cdot \frac{D}{d}\right)}}^{2}
\] |
associate-*l* [=>]17.3 | \[ 0.25 \cdot {\color{blue}{\left(M \cdot \left(\sqrt{h} \cdot \frac{D}{d}\right)\right)}}^{2}
\] |
Final simplification21.0
| Alternative 1 | |
|---|---|
| Error | 25.8 |
| Cost | 8656 |
| Alternative 2 | |
|---|---|
| Error | 25.8 |
| Cost | 8656 |
| Alternative 3 | |
|---|---|
| Error | 26.0 |
| Cost | 8392 |
| Alternative 4 | |
|---|---|
| Error | 24.0 |
| Cost | 7433 |
| Alternative 5 | |
|---|---|
| Error | 27.6 |
| Cost | 1225 |
| Alternative 6 | |
|---|---|
| Error | 26.5 |
| Cost | 1225 |
| Alternative 7 | |
|---|---|
| Error | 32.1 |
| Cost | 64 |
herbie shell --seed 2023012
(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))))))