| Alternative 1 | |
|---|---|
| Accuracy | 63.8% |
| Cost | 44484 |

(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 h)))
(t_1 (* t_0 (pow (/ d D) 2.0)))
(t_2 (/ c0 (* 2.0 w)))
(t_3 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_4 (* t_2 (+ t_3 (sqrt (- (* t_3 t_3) (* M M)))))))
(if (<= t_4 -2e-304)
(*
t_2
(fma t_0 (* (/ d D) (/ d D)) (* (sqrt (+ M t_1)) (sqrt (- t_1 M)))))
(if (or (<= t_4 0.0) (not (<= t_4 INFINITY)))
(* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M))))
(pow (/ d (/ (* D (* w (sqrt h))) c0)) 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 t_0 = c0 / (w * h);
double t_1 = t_0 * pow((d / D), 2.0);
double t_2 = c0 / (2.0 * w);
double t_3 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_4 = t_2 * (t_3 + sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -2e-304) {
tmp = t_2 * fma(t_0, ((d / D) * (d / D)), (sqrt((M + t_1)) * sqrt((t_1 - M))));
} else if ((t_4 <= 0.0) || !(t_4 <= ((double) INFINITY))) {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
} else {
tmp = pow((d / ((D * (w * sqrt(h))) / c0)), 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) t_0 = Float64(c0 / Float64(w * h)) t_1 = Float64(t_0 * (Float64(d / D) ^ 2.0)) t_2 = Float64(c0 / Float64(2.0 * w)) t_3 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_4 = Float64(t_2 * Float64(t_3 + sqrt(Float64(Float64(t_3 * t_3) - Float64(M * M))))) tmp = 0.0 if (t_4 <= -2e-304) tmp = Float64(t_2 * fma(t_0, Float64(Float64(d / D) * Float64(d / D)), Float64(sqrt(Float64(M + t_1)) * sqrt(Float64(t_1 - M))))); elseif ((t_4 <= 0.0) || !(t_4 <= Inf)) tmp = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))); else tmp = Float64(d / Float64(Float64(D * Float64(w * sqrt(h))) / c0)) ^ 2.0; end return 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[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 + N[Sqrt[N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -2e-304], N[(t$95$2 * N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(M + t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t$95$1 - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$4, 0.0], N[Not[LessEqual[t$95$4, Infinity]], $MachinePrecision]], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(d / N[(N[(D * N[(w * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c0), $MachinePrecision]), $MachinePrecision], 2.0], $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 h}\\
t_1 := t_0 \cdot {\left(\frac{d}{D}\right)}^{2}\\
t_2 := \frac{c0}{2 \cdot w}\\
t_3 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_4 := t_2 \cdot \left(t_3 + \sqrt{t_3 \cdot t_3 - M \cdot M}\right)\\
\mathbf{if}\;t_4 \leq -2 \cdot 10^{-304}:\\
\;\;\;\;t_2 \cdot \mathsf{fma}\left(t_0, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{M + t_1} \cdot \sqrt{t_1 - M}\right)\\
\mathbf{elif}\;t_4 \leq 0 \lor \neg \left(t_4 \leq \infty\right):\\
\;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{d}{\frac{D \cdot \left(w \cdot \sqrt{h}\right)}{c0}}\right)}^{2}\\
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
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))))) < -1.99999999999999994e-304Initial program 84.6%
Simplified82.7%
[Start]84.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)
\] |
|---|---|
times-frac [=>]82.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-def [=>]82.6% | \[ \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)}
\] |
times-frac [=>]82.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot 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 [=>]82.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot 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)
\] |
Applied egg-rr77.4%
[Start]82.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)
\] |
|---|---|
associate-*r/ [=>]82.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\left(d \cdot d\right) \cdot c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} - M\right)}\right)
\] |
*-commutative [<=]82.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)
\] |
times-frac [=>]82.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right)
\] |
associate-/l/ [<=]85.0% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\frac{\frac{d \cdot d}{D}}{D}} - M\right)}\right)
\] |
associate-*r/ [=>]85.0% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right)
\] |
associate-/l/ [<=]77.5% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\color{blue}{\frac{\frac{c0}{h}}{w}} \cdot \frac{d \cdot d}{D}}{D} - M\right)}\right)
\] |
associate-/l* [=>]77.5% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \color{blue}{\frac{d}{\frac{D}{d}}}}{D} - M\right)}\right)
\] |
div-inv [=>]77.4% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right)
\] |
clear-num [<=]77.4% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \left(d \cdot \color{blue}{\frac{d}{D}}\right)}{D} - M\right)}\right)
\] |
Simplified84.9%
[Start]77.4% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \left(d \cdot \frac{d}{D}\right)}{D} - M\right)}\right)
\] |
|---|---|
associate-/l* [=>]77.4% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{\frac{c0}{h}}{w}}{\frac{D}{d \cdot \frac{d}{D}}}} - M\right)}\right)
\] |
associate-/l/ [=>]84.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\color{blue}{\frac{c0}{w \cdot h}}}{\frac{D}{d \cdot \frac{d}{D}}} - M\right)}\right)
\] |
Applied egg-rr90.4%
[Start]84.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{c0}{w \cdot h}}{\frac{D}{d \cdot \frac{d}{D}}} - M\right)}\right)
\] |
|---|---|
sqrt-prod [=>]88.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \color{blue}{\sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right)} \cdot \sqrt{\frac{\frac{c0}{w \cdot h}}{\frac{D}{d \cdot \frac{d}{D}}} - M}}\right)
\] |
if -1.99999999999999994e-304 < (*.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.0 or +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 6.4%
Taylor expanded in c0 around -inf 7.5%
Simplified32.4%
[Start]7.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 [=>]7.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)}
\] |
times-frac [=>]8.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \color{blue}{\frac{{D}^{2}}{{d}^{2}} \cdot \frac{w \cdot \left({M}^{2} \cdot h\right)}{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)
\] |
unpow2 [=>]8.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \frac{w \cdot \left({M}^{2} \cdot h\right)}{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)
\] |
unpow2 [=>]8.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \frac{w \cdot \left({M}^{2} \cdot h\right)}{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)
\] |
*-commutative [=>]8.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{d \cdot d} \cdot \frac{w \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{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)
\] |
unpow2 [=>]8.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{d \cdot d} \cdot \frac{w \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)}{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)
\] |
associate-*r* [=>]8.6% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(0.5, \frac{D \cdot D}{d \cdot d} \cdot \frac{w \cdot \left(h \cdot \left(M \cdot M\right)\right)}{c0}, \color{blue}{\left(-1 \cdot \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)\right) \cdot c0}\right)
\] |
Taylor expanded in c0 around 0 44.0%
Simplified57.3%
[Start]44.0% | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}
\] |
|---|---|
unpow2 [=>]44.0% | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\color{blue}{d \cdot d}}
\] |
unpow2 [=>]44.0% | \[ 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot {M}^{2}\right)}{d \cdot d}
\] |
unpow2 [=>]44.0% | \[ 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)}{d \cdot d}
\] |
associate-/l* [=>]42.9% | \[ 0.25 \cdot \color{blue}{\frac{D \cdot D}{\frac{d \cdot d}{h \cdot \left(M \cdot M\right)}}}
\] |
associate-/r/ [=>]44.0% | \[ 0.25 \cdot \color{blue}{\left(\frac{D \cdot D}{d \cdot d} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}
\] |
times-frac [=>]57.3% | \[ 0.25 \cdot \left(\color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)
\] |
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 72.0%
Simplified71.9%
[Start]72.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 [=>]71.9% | \[ \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 [=>]71.9% | \[ \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)}
\] |
times-frac [=>]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot 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 [=>]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot 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)
\] |
Applied egg-rr68.7%
[Start]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)
\] |
|---|---|
associate-*r/ [=>]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\left(d \cdot d\right) \cdot c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} - M\right)}\right)
\] |
*-commutative [<=]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}\right)
\] |
times-frac [=>]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} - M\right)}\right)
\] |
associate-/l/ [<=]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\frac{\frac{d \cdot d}{D}}{D}} - M\right)}\right)
\] |
associate-*r/ [=>]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D}}{D}} - M\right)}\right)
\] |
associate-/l/ [<=]68.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\color{blue}{\frac{\frac{c0}{h}}{w}} \cdot \frac{d \cdot d}{D}}{D} - M\right)}\right)
\] |
associate-/l* [=>]68.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \color{blue}{\frac{d}{\frac{D}{d}}}}{D} - M\right)}\right)
\] |
div-inv [=>]68.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \color{blue}{\left(d \cdot \frac{1}{\frac{D}{d}}\right)}}{D} - M\right)}\right)
\] |
clear-num [<=]68.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \left(d \cdot \color{blue}{\frac{d}{D}}\right)}{D} - M\right)}\right)
\] |
Simplified71.9%
[Start]68.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\frac{\frac{c0}{h}}{w} \cdot \left(d \cdot \frac{d}{D}\right)}{D} - M\right)}\right)
\] |
|---|---|
associate-/l* [=>]68.7% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\color{blue}{\frac{\frac{\frac{c0}{h}}{w}}{\frac{D}{d \cdot \frac{d}{D}}}} - M\right)}\right)
\] |
associate-/l/ [=>]71.9% | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{d}{\frac{D}{d}}, M\right) \cdot \left(\frac{\color{blue}{\frac{c0}{w \cdot h}}}{\frac{D}{d \cdot \frac{d}{D}}} - M\right)}\right)
\] |
Taylor expanded in c0 around inf 61.8%
Simplified80.9%
[Start]61.8% | \[ \frac{{d}^{2} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
|---|---|
unpow2 [=>]61.8% | \[ \frac{\color{blue}{\left(d \cdot d\right)} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
unpow2 [=>]61.8% | \[ \frac{\left(d \cdot d\right) \cdot \color{blue}{\left(c0 \cdot c0\right)}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
swap-sqr [<=]77.7% | \[ \frac{\color{blue}{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
unpow2 [<=]77.7% | \[ \frac{\color{blue}{{\left(d \cdot c0\right)}^{2}}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
*-commutative [=>]77.7% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{{D}^{2} \cdot \color{blue}{\left(h \cdot {w}^{2}\right)}}
\] |
unpow2 [=>]77.7% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot {w}^{2}\right)}
\] |
unpow2 [=>]77.7% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \color{blue}{\left(w \cdot w\right)}\right)}
\] |
associate-*l* [=>]77.7% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{D \cdot \left(D \cdot \left(h \cdot \left(w \cdot w\right)\right)\right)}}
\] |
associate-*r* [=>]80.9% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{D \cdot \left(D \cdot \color{blue}{\left(\left(h \cdot w\right) \cdot w\right)}\right)}
\] |
*-commutative [<=]80.9% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{D \cdot \left(D \cdot \left(\color{blue}{\left(w \cdot h\right)} \cdot w\right)\right)}
\] |
Taylor expanded in d around 0 61.8%
Simplified80.9%
[Start]61.8% | \[ \frac{{d}^{2} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
|---|---|
unpow2 [=>]61.8% | \[ \frac{\color{blue}{\left(d \cdot d\right)} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
unpow2 [=>]61.8% | \[ \frac{\left(d \cdot d\right) \cdot \color{blue}{\left(c0 \cdot c0\right)}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
swap-sqr [<=]77.7% | \[ \frac{\color{blue}{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
unpow2 [=>]77.7% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left({w}^{2} \cdot h\right)}
\] |
unpow2 [=>]77.7% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot D\right) \cdot \left(\color{blue}{\left(w \cdot w\right)} \cdot h\right)}
\] |
associate-*r* [<=]80.9% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot D\right) \cdot \color{blue}{\left(w \cdot \left(w \cdot h\right)\right)}}
\] |
*-commutative [=>]80.9% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(w \cdot \left(w \cdot h\right)\right) \cdot \left(D \cdot D\right)}}
\] |
unpow2 [<=]80.9% | \[ \frac{\color{blue}{{\left(d \cdot c0\right)}^{2}}}{\left(w \cdot \left(w \cdot h\right)\right) \cdot \left(D \cdot D\right)}
\] |
associate-*r* [=>]77.7% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{\left(\left(w \cdot w\right) \cdot h\right)} \cdot \left(D \cdot D\right)}
\] |
unpow2 [<=]77.7% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\left(\color{blue}{{w}^{2}} \cdot h\right) \cdot \left(D \cdot D\right)}
\] |
associate-*l* [=>]80.9% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{{w}^{2} \cdot \left(h \cdot \left(D \cdot D\right)\right)}}
\] |
unpow2 [=>]80.9% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{\left(w \cdot w\right)} \cdot \left(h \cdot \left(D \cdot D\right)\right)}
\] |
Applied egg-rr88.4%
[Start]80.9% | \[ \frac{{\left(d \cdot c0\right)}^{2}}{\left(w \cdot w\right) \cdot \left(h \cdot \left(D \cdot D\right)\right)}
\] |
|---|---|
pow2 [<=]80.9% | \[ \frac{\color{blue}{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}}{\left(w \cdot w\right) \cdot \left(h \cdot \left(D \cdot D\right)\right)}
\] |
*-commutative [=>]80.9% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(h \cdot \left(D \cdot D\right)\right) \cdot \left(w \cdot w\right)}}
\] |
*-commutative [=>]80.9% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right)} \cdot \left(w \cdot w\right)}
\] |
associate-*r* [<=]77.7% | \[ \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}}
\] |
expm1-log1p-u [=>]76.4% | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}\right)\right)}
\] |
expm1-udef [=>]76.4% | \[ \color{blue}{e^{\mathsf{log1p}\left(\frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}\right)} - 1}
\] |
Simplified96.5%
[Start]88.4% | \[ e^{\mathsf{log1p}\left({\left(\frac{d \cdot c0}{D \cdot \left(w \cdot \sqrt{h}\right)}\right)}^{2}\right)} - 1
\] |
|---|---|
expm1-def [=>]94.7% | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{d \cdot c0}{D \cdot \left(w \cdot \sqrt{h}\right)}\right)}^{2}\right)\right)}
\] |
expm1-log1p [=>]96.5% | \[ \color{blue}{{\left(\frac{d \cdot c0}{D \cdot \left(w \cdot \sqrt{h}\right)}\right)}^{2}}
\] |
associate-/l* [=>]96.5% | \[ {\color{blue}{\left(\frac{d}{\frac{D \cdot \left(w \cdot \sqrt{h}\right)}{c0}}\right)}}^{2}
\] |
Final simplification68.5%
| Alternative 1 | |
|---|---|
| Accuracy | 63.8% |
| Cost | 44484 |
| Alternative 2 | |
|---|---|
| Accuracy | 62.8% |
| Cost | 32904 |
| Alternative 3 | |
|---|---|
| Accuracy | 62.9% |
| Cost | 32904 |
| Alternative 4 | |
|---|---|
| Accuracy | 61.0% |
| Cost | 20552 |
| Alternative 5 | |
|---|---|
| Accuracy | 42.6% |
| Cost | 7561 |
| Alternative 6 | |
|---|---|
| Accuracy | 42.6% |
| Cost | 2648 |
| Alternative 7 | |
|---|---|
| Accuracy | 43.3% |
| Cost | 2389 |
| Alternative 8 | |
|---|---|
| Accuracy | 43.4% |
| Cost | 2388 |
| Alternative 9 | |
|---|---|
| Accuracy | 40.9% |
| Cost | 1616 |
| Alternative 10 | |
|---|---|
| Accuracy | 40.8% |
| Cost | 1616 |
| Alternative 11 | |
|---|---|
| Accuracy | 41.4% |
| Cost | 1353 |
| Alternative 12 | |
|---|---|
| Accuracy | 41.9% |
| Cost | 1352 |
| Alternative 13 | |
|---|---|
| Accuracy | 41.4% |
| Cost | 960 |
| Alternative 14 | |
|---|---|
| Accuracy | 32.4% |
| Cost | 64 |
herbie shell --seed 2023165
(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))))))