|
From: Luigi B. <lui...@gm...> - 2015-02-05 11:23:49
|
Apologies for the delay; I didn't find the time to go back and check the math. I see from < http://www.wilmott.com/messageview.cfm?catid=4&threadid=98075&forumid=1> that you solved the issue, though. Is this correct? Luigi On Thu, Jan 29, 2015 at 5:59 AM, Sk Wong <sk...@gm...> wrote: > Hi, > > I have a question on the setup of the tridiagonal system in the cubic > interpolation (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 components of the vector tmp_, the > right hand side vector of tridiagonal system, are caculated as: > > std::vector<Real> dx(n_-1), S(n_-1); > > for (Size <http://quantlib.sourcearchive.com/documentation/1.1-1/namespaceQuantLib_af4cc4ef40b52c17cc455ead2a97aedb3.html#af4cc4ef40b52c17cc455ead2a97aedb3> 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 <http://quantlib.sourcearchive.com/documentation/1.1-1/classQuantLib_1_1CubicInterpolation_a6897ea07ce6993b4df934091a3723d28.html#a6897ea07ce6993b4df934091a3723d28aaa6b6cbb8010b02172412742c21ce2d7>) { > TridiagonalOperator <http://quantlib.sourcearchive.com/documentation/1.1-1/classQuantLib_1_1TridiagonalOperator.html> L(n_); > for (Size <http://quantlib.sourcearchive.com/documentation/1.1-1/namespaceQuantLib_af4cc4ef40b52c17cc455ead2a97aedb3.html#af4cc4ef40b52c17cc455ead2a97aedb3> 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, > > SK > > > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming. The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > QuantLib-dev mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-dev > > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> |