MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: help: recursive functions


You need to give the base cases (in order to stop the recursion). Try, for
example,

In[1]:=
f[n_]:=Sin[Pi*n*(0.05+(0.0005*n))];
y[n_]:=1.5*y[n-1]-0.85*y[n-2]+f[n];
y[1]=0;
y[2]=0;

In[2]:=
ListPlot[Table[y[n],{n,1,20}]];

The default depth for recursion is 256. If you need more (like 320), modify
your $RecursionLimit. For fillings, use

In[1]:=
<< "Graphics`FilledPlot`"
In[2]:=
FilledPlot[Sin[x], {x, 0, Pi}]

Tomas Garza
Mexico City

----- Original Message -----
From: "Okke" <Okke at tref.nl>
To: mathgroup at smc.vnet.net
Subject: [mg32644] [mg32616] help: recursive functions


> Hello,
>
> I'm having some problems with a recursive function.
> Could somebody please help me by telling me how I
> should enter such a function?
>
> tia,
>
> This is what I've done so far:
>
> f[n_]:=Sin[Pi*n*(0.05+(0.0005*n))]
> y[n_]:=1.5*y[n-1]-0.85*y[n-2]+f[n]
>
> I'm trying to Plot[y[n],{n,0,320}] but that gives me
> an error: $RecursionLimit::reclim: Recursion depth of 256 exceeded.
>
> btw, is there an option to fill the area under the sine?
>
> --
> Okke
>
> remove NOSPAM from my email address to reply
>



  • Prev by Date: Re: TeXForm and negative exponents
  • Next by Date: Re: help: recursive functions
  • Previous by thread: Re: help: recursive functions
  • Next by thread: Re: help: recursive functions