First poly(x)-a0 is set in foo1. The constant term a0 can be removed from poly in the following argument, but only be added in logexppoly later.
Make rule "rulepoly" to substitute "poly" for foo1.
Considering
we can calculate as follows, and stored in foo4 up to terms.
Then, we take the expectation of foo4, calculating , and stored in foo5 below.
Considering
we take the log of foo5, and stored in foo8 up to terms below.
This is logeexppoly for b=0.
The following expression may be easier to read for us, but violating the summation convention rule of subscripts.