## Finding Better PolynomialsMay 12th, 2009 Patrick Stein

Some time ago, I wrote a small domain-specific language for finding polynomials given their value or the value of their derivatives at particular points.

It occurred to me shortly after writing that code that I could easily extend it to include the value of its integral over a certain range. I didn’t get to tackling that right away, and that was a Good Thing. In the intervening time, it occurred to me that I could extend it to moments as well.

So, are you looking for a polynomial that is zero at both zero and one, has a derivative of zero at one, has a second derivative of negative one at one, whose integral from zero to one is one, and whose mean (first moment centered at zero) on the interval zero to one is one fourth?

(polynomial-to-string
(calculate-polynomial-subject-to
(value :at 0 :equals 0)
(value :at 1 :equals 0)
(derivative :at 1 :equals 0)
(nth-derivative 2 :at 1 :equals -1)
(integral :from 0 :to 1 :equals 1)
(mean :from 0 :to 1 :equals 1/4)))

Well, that would be $f(x) = \frac{149}{4}x - 163x^2 + 265x^3 - 190x^4 + \frac{203}{4}x^5$. (For some reason though, gnuplot thinks $f(x) = -1$, so no graph for you…)

Here is the source file.

Edit: I realized that gnuplot was off by one because it was truncating the fractions. So, I just changed the 4’s in the denominators to 4.0’s and Bob’s your uncle.

Email:

l