Re: MathKernel crashes

• To: mathgroup at smc.vnet.net
• Subject: [mg72861] Re: MathKernel crashes
• From: "nandan" <joshi.nandan at gmail.com>
• Date: Tue, 23 Jan 2007 04:35:07 -0500 (EST)
• References: <eosgop\$9ai\$1@smc.vnet.net><ep1t7a\$ga7\$1@smc.vnet.net>

```Hi:

I'm aware that these are recursive functions for this Legendre
Polynomial, but they were taking lot of time, so I went for recursion.
But in fact, it is take more time and my kernel quits. But I think, you
have replied to this problem in this post:

Thanx again!

Regards,
nandan

On Jan 22, 9:39 am, Peter Pein <pet... at dordos.net> wrote:
> 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

```

• Prev by Date: Re: MathKernel crashes
• Next by Date: Databaselink and MySQL
• Previous by thread: Re: MathKernel crashes
• Next by thread: General Mathematica and Financial Mathematics Courses