Serving the Quantitative Finance Community

 
User avatar
tw813
Topic Author
Posts: 5
Joined: August 26th, 2005, 12:15 am

cubic interpolation in quantlib

February 2nd, 2015, 11:52 pm

Hi,I wonder if any of you can help me on the setup of the tridiagonal system in the cubic interpolation in Quantlib *under the choice 'Spline' for derivative approximation). The tridiagonal system looks a bit different from the one suggested in the literature. In particular, the middle elements of the vector tmp_ (tmp_ is the target right hand side vector in the tridiagonal system), are caculated as: std::vector<Real> dx(n_-1), S(n_-1); for (Size i=0; i<n_-1; ++i) { dx(i) = this->xBegin_(i+1) - this->xBegin_(i); S(i) = (this->yBegin_(i+1) - this->yBegin_(i))/dx(i); } // first derivative approximation if (da_==CubicInterpolation::Spline) { TridiagonalOperator L(n_); for (Size i=1; i<n_-1; ++i) { L.setMidRow(i, dx(i), 2.0*(dx(i)+dx(i-1)), dx(i-1)); tmp(i) = 3.0*(dx(i)*S(i-1) + dx(i-1)*S(i)); }Following the literature, one instead has (e.g. see Eq. 6.62 in Piterbarg-Andersen book V1 Chapter 6 Appendix):tmp(i) = 6.0*(S(i) - S(i-1));Am I missing something here? Or any reference you can point me to which derive what Quantlib implements?Thanks.
Last edited by tw813 on February 2nd, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
tw813
Topic Author
Posts: 5
Joined: August 26th, 2005, 12:15 am

cubic interpolation in quantlib

February 3rd, 2015, 3:33 pm

I guess I got the answer. Basically both are subject to the same set of constraints. But it is up to one to take which are the unknowns, either first or second derivatives at the knots. The two different choices will give you a different system of equations obviously while solving for the same spline essentially