Re: Kernel Quits without error message. (Was: Better recursive method?)
- To: mathgroup at smc.vnet.net
- Subject: [mg72853] Re: Kernel Quits without error message. (Was: Better recursive method?)
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 22 Jan 2007 04:27:19 -0500 (EST)
- References: <eovfnn$rup$1@smc.vnet.net>
Johan Grönqvist schrieb:
> Hi,
>
> When trying to modify the example given by nandan, I arrive at a short
> function that makes the Kernel quit without displaying any error or
> warning message.
>
> With the definition
>
> pi[0, theta_] := 0;
> pi[1, theta_] := 1;
> pi[i_, theta_] :=
> pi[i, theta] = N[(2i - 1)/(i - 1) Cos[theta] pi[i - 1, theta]
> - i/(i - 1) * pi[i - 2, theta]]
>
> and a high value for $RecursionLimit, I can evaluate pi[1000,1] in about
> 0.06 seconds but the kernel quits when attempting pi[10000,1]. There is
> neither warning nor error, and I see the same behaviour several times. I
> have seen this both in my student version, and in my university's full
> version of mathematica 5.2 on Linux.
>
> Thanks in advance.
>
> Johan
>
Hi Johan,
using version 5.2 on Linux:
In[1]:=
pi[i_, t_] = FullSimplify[p[i] /. First[
RSolve[{p[i] == ((2*i - 1)*Cos[t]*p[i - 1] - i*p[i - 2])/(i - 1),
p[0] == 0, p[1] == 1}, p[i], i]], 0 < t < Pi]
Out[1]=
(-Csc[t])*LegendreP[i, 1, 2, Cos[t]]
In[2]:=
Timing[pi[10^3, 1.]]
Out[2]=
{0.012*Second, 20.77108402004459}
In[3]:=
Timing[pi[10^4, 1.]]
Out[3]=
{17.513094*Second, -2.6056199971958973}
but don't try N[pi[integer,exact number]] for large values of i:
Timing[ N[pi[10^4,1]]]
Out[6]={42.446654*Second, 2.414340966343630*10^315}
Peter