Re: MathKernel crashes
- To: mathgroup at smc.vnet.net
- Subject: [mg72850] Re: MathKernel crashes
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 22 Jan 2007 04:15:15 -0500 (EST)
- References: <eosgop$9ai$1@smc.vnet.net>
nandan schrieb:
> Hallo:
>
> MathKernel crashes, since I use recursive function for calculation. I
> have 2 of the important functions for my calculation as given below:
> $RecursionLimit=Infinity;
>
> pi[0, \[Theta]_] := 0;
> pi[1, \[Theta]_] := 1;
> pi[i_, \[Theta]_]\ := pi[i, \[Theta]] = ((2 i - 1)/(i - 1))
> Cos[\[Theta]] pi[i - 1, \[Theta]] - (i/(i - 1)) pi[i - 2,\[Theta]]);
> \[Tau][i_, \[Theta]_] := \[Tau][i, \[Theta]] = i Cos[\[Theta]] pi[i,
> \[Theta]] - (i + 1)pi[i - 1, \[Theta]];
>
> In this case, I can get solution to any numerical value like pi[14,
> \[Pi]/3]. But quite a few times, it happened that MathKernel quitted, I
> started again, but it started another processor parallel to that. Later
> I wanted to calculate another function as follows:
> S1Temp[i_, \[Theta]_] := ((2 l + 1)/(l (l + 1))) (an[l] pi[l, \[Theta]]
> + bn[l] \[Tau][l, \[Theta]]);
>
> But in this case, whenever I try to calculate S1Temp[14, \[Pi]/3], it
> simply quits and, sometimes crashes. I have to always restart
> Mathematica to start over again.
>
> I do not know what is exactly going wrong. If any better solution is
> possible for this recursive solution, will also be appreciated.
>
> Regards,
> nandan
>
Hi Nandan,
why don't you simply use RSolve?
Needs["DiscreteMath`RSolve`"];
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]
]] /. ((x_)^2)^(-2^(-1)) :> 1/Abs[x]
--> -(LegendreP[i, 1, 2, Cos[t]]/Abs[Sin[t]])
pi[14, Pi/3]
--> 30439185/8388608