Often, I want to have a polynomial that meets certain criteria. For most applications in the past, I figured it all out by hand.
Today, I was having trouble getting the conditions specified enough to get the sort of polynomial that I was expecting. After finding the coefficients for several sixth degree polynomials in a row, I figured I should instead be able to do something like this with the proper lisp:
(calculate-polynomial-subject-to
(value :at 0 :equals 0)
(derivative :at 0 :equals 0)
(nth-derivative 2 :at 0 :equals 0)
(value :at 1 :equals 1)
(derivative :at 1 :equals 0)
(nth-derivative 2 :at 1 :equals 0)
(value :at 1/2 :equals 3/4))
(value :at 0 :equals 0)
(derivative :at 0 :equals 0)
(nth-derivative 2 :at 0 :equals 0)
(value :at 1 :equals 1)
(derivative :at 1 :equals 0)
(nth-derivative 2 :at 1 :equals 0)
(value :at 1/2 :equals 3/4))
That’s all done now (polynomials.lisp). So, for the record, the above is: . That is still not quite the polynomial I want for this application, but it’s close. A few minutes of Lisp saved me hours of whiteboard work.
[…] a previous post, I mentioned looking for a polynomial for an application. I am working on an application that […]
[…] time ago, I wrote a small domain-specific language for finding polynomials given their value or the value of their derivatives at particular […]