/* Example programs from the book Scientific and Engineering Programming in C++: An Introduction with Advanced Techniques and Examples, Addison-Wesley, 1994. (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1994. ALL RIGHTS RESERVED. See README file for further details. */ template LegendrePolynomial::LegendrePolynomial(int n) : FunctionalAlgebra( recur(n) ) { } template FunctionalAlgebra LegendrePolynomial::recur(int n) { if (n == 0) return D(1); else if (n == 1) return FunctionalAlgebra(); else return D(2*n-1)/D(n) * FunctionalAlgebra() * LegendrePolynomial(n-1) - (D(n-1)/D(n)) * LegendrePolynomial(n-2); }