Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6560

Re: NIntegrate to compute LegendreP approximations to functions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!feed.xsnews.nl!border-1.ams.xsnews.nl!newspump.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: NIntegrate to compute LegendreP approximations to functions
Date Sun, 20 Nov 2011 10:41:32 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <jaalgs$18e$1@smc.vnet.net> (permalink)
Lines 127
NNTP-Posting-Date 20 Nov 2011 09:45:46 GMT
NNTP-Posting-Host a95be246.news.twtelecom.net
X-Trace DXC=3JPHY4XfG5YSW6MMT7Gj0ZC_A=>8kQj6]m^eQlV`f18WYCG^DNIn^LSEFiONJ7[GoV074Fh]j=j<W
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:6560

Show key headers only | View raw


Disregard everything after hello. I keep pushing SEND too soon. I had a 
plot that looked correct only because I started the Sum at k = 1, not 0.

The problem is that Simplify is giving a result that's invalid for k ==  0:

u = Sign[t];
c[k_] = Simplify[(2 k + 1)/2 Integrate[u LegendreP[k, t], {t, -1, 1}],
    Element[k, Integers]]
c[0]
(2 0 + 1) Integrate[u LegendreP[0, t], {t, -1, 1}]

((1 + 2 k) Sqrt[\[Pi]])/(2 Gamma[1 - k/2] Gamma[(3 + k)/2])

1

0

The correct result is zero, of course:

Integrate[u LegendreP[0, t], {t, -1, 1}]
Plot[u LegendreP[0, t], {t, -1, 1}]

0

This sort of "failure" in Simplify not uncommon or unexpected. There was 
another thread, recently, where Simplify failed to cancel like terms in 
the numerator and nominator, yielding a result that was discontinuous at 
the point where those terms are zero.

We have to be aware that these things can happen, and take care to guard 
against it.

Bobby

On Sat, 19 Nov 2011 14:50:13 -0600, DrMajorBob <btreat1@austin.rr.com> 
wrote:

> Like you (I assume), I was getting a plot that showed the constant term 
> was wrong.
>
> But now, when I Quit and recompute, the plot is right (without 
> subtracting 1 as I did in an earlier, too-hasty reply).
>
> There's something strange going on!
>
> Bobby
>
> On Sat, 19 Nov 2011 05:46:10 -0600, J. Jes=FAs Rico Melgoza 
> <jerico@umich.mx> wrote:
>
>> Thanks for the advise. Though, I don't see why the constant term is not 
>> calculated properly.
>>  The resulting approximation in
>>
>> Plot[{u, Sum[c[k] LegendreP[k, t], {k, 0, 20}]}, {t, -1, 1}]
>>
>> has a different c[0].
>> J. Rico
>>
>>
>> El 18/11/2011, a las 06:50, Bob Hanlon escribi=F3:
>>
>>> Do the integration once.
>>>
>>> u = Sign[t];
>>>
>>> c[k_] = Simplify[
>>>  (2 k + 1)/2 Integrate[u LegendreP[k, t], {t, -1, 1}],
>>>  Element[k, Integers]]
>>>
>>> ((1 + 2*k)*Sqrt[Pi])/(2*Gamma[1 - k/2]*Gamma[(3 + k)/2])
>>>
>>>
>>> Bob Hanlon
>>>
>>>
>>> 2011/11/18 "J. Jes=FAs Rico Melgoza" <jerico@umich.mx>:
>>>>
>>>> Hello
>>>> I am approximating general scalar functions via orthogonal series. I 
>>>> am
>>>> using LegendreP polynomials.
>>>> As an example, I have approximated a Sign function. The coefficients
>>>> have been calculated as follows:
>>>>
>>>> n = 20;
>>>> u = Sign[t];
>>>> N[Table[(2 k + 1)/2 Integrate[u LegendreP[k, t], {t, -1, 1}], {k, 0,
>>>> n}]]
>>>>
>>>> Everything works well but I would like to speed up computations since
>>>> for large values of n, Integrate takes long computations times. I need
>>>> to speed up the process since in general I will be approximating
>>>> multi-variable functions. I have tried NIntegrate but I get multiple
>>>> messages such as
>>>>
>>>> NIntegrate::slwcon :  "Numerical integration converging too slowly;
>>>> suspect \
>>>> one of the following: singularity, value of the integration is 0, 
>>>> highly
>>>> \
>>>> oscillatory integrand, or WorkingPrecision too small. 
>>>> =91=99=98ButtonBox["
>>>> ",
>>>> Appearance->{Automatic, None},
>>>> BaseStyle->"Link",
>>>> ButtonData:>"paclet:ref/message/NIntegrate/slwcon",
>>>> ButtonNote->"NIntegrate::slwcon"]"
>>>>
>>>> NIntegrate is a very complete function in Mathematica, so much that it
>>>> has been rather difficult to find an adequate combination of  a method
>>>> and a strategy of integration that would improve the timing of
>>>> Integrate.
>>>>
>>>> Could anyone give me some advice?
>>>>
>>>> Jesus Rico-Melgoza
>>>
>>
>>
>
>


--
DrMajorBob@yahoo.com

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: NIntegrate to compute LegendreP approximations to functions DrMajorBob <btreat1@austin.rr.com> - 2011-11-20 10:41 +0000

csiph-web