Re: Paul Abbott Chebyshev Article
- To: mathgroup at smc.vnet.net
- Subject: [mg79761] Re: Paul Abbott Chebyshev Article
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 3 Aug 2007 06:37:32 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f8s2kq$161$1@smc.vnet.net>
Angela Kou wrote: > Hi: > > I'm trying to test Paul Abbott's code in his article on integral > equation solving using Chebyshev polynomials (Mathematica Journal 8(4)) > but Mathematica keeps giving me an error when I get to NIntegrate. This > is the code: > n=4; xs = N[Cos[Range[0, 2 n] Pi/(2 n)], 20]; > cs = Thread[Subscript[c, Range[0, n]]]; > lhs = cs.Table[Subscript[T, 2 i] (xs), {i, 0, n}]; > rhs = 1 + 1/Pi cs.Table[NIntegrate[Evaluate[Subscript[T, 2 i] (t)/((xs - > t)^2 + 1)], {t, -1, 1}, WorkingPrecision ->20], {i, 0, n}]; > > the last line of code keeps giving me the error that "NIntegrate::inumr: > The integrand (t Subscript[T,0])/(1+(1.0000000000000000000-t)^2) has > evaluated to non-numerical values for all sampling points in the region > with boundaries {{-1,0}}. >> > > I'm not quite sure why this is the case? > > Thanks, > Angela Kou > Every parameter, variable, symbol must have some explicit numerical values when you evaluate *NIntegrate*. In the code you provided, none of the T_i (i = 0, 1, ..., 4) have numerical values (they are not defined at all, indeed). Compare the results returned by the following expressions: With[{i = 0}, NIntegrate[ Evaluate[Subscript[T, 2 i] (t)/((xs - t)^2 + 1)], {t, -1, 1}, WorkingPrecision -> 20] ] versus With[{i = 0}, NIntegrate[ Evaluate[Subscript[T, 2 i] (t)/((xs - t)^2 + 1)] /. Subscript[T, 0] -> 1, {t, -1, 1}, WorkingPrecision -> 20] ] Regards, Jean-Marc