       Re: simple sequence problem

• To: mathgroup at smc.vnet.net
• Subject: [mg74423] Re: simple sequence problem
• From: "dimitris" <dimmechan at yahoo.com>
• Date: Wed, 21 Mar 2007 02:44:10 -0500 (EST)
• References: <etnkfe\$gqo\$1@smc.vnet.net>

```=CF/=C7 traz =DD=E3=F1=E1=F8=E5:
> Hi, this might be a silly question, but how do you do this in mathematica.
>
> x1 == Cos;
> x2 == Cos[x1];
> x3 == Cos[x2];
>
> and so on ... ... so basically x(n)= Cos[x(n - 1)]
>
> I want to plot n against x(n). How do you do the code for this type of se=
quence in mathematica?

>I want to plot n against x(n). How do you do the code for this type of seq=
uence in mathematica?

Are you interested in cosine iterations?

In:=
(*change some default settrings*)
s = Options[Plot];
\$TextStyle = {FontFamily -> "Times"};
SetOptions[Plot, Frame -> {True, True, False, False}, Axes -> {True,
False}, AxesStyle -> GrayLevel[0.6], ImageSize -> 400, PlotRange ->
All];

In:=
f[x_][i_] := Nest[Cos, x, i]

In:=
Print["example of application of f"]
f[4*(Pi/7)]

In:=
Print["another example of application of f"]
(f[2.][#1] & ) /@ Range

In:=
Show[Block[{\$DisplayFunction = Identity}, (Plot[f[x][#1], {x, -Pi,
Pi}, PlotStyle -> Hue[#1/7]] & ) /@ Range[1, 6]],
PlotLabel -> StyleForm["Cosine Iteration", FontSize -> 14],
FrameTicks -> {Range[-Pi, Pi, Pi/2], Range[-1, 1, 1/2]}]

Note that

In:=
(f[#1] & ) /@ Range[1., 100, 10]
Out=
{0.739085,0.739085,0.739085,0.739085,0.739085,0.739085,0.739085,0.739085,0.\
739085,0.739085}

because cos(x)=x has a fixed point at x ~ 0.73908513.

In:=
({#1, Cos[#1]} & )[FixedPoint[Cos, 10.]]
Out=
{0.739085,0.739085}

In:=
(*restore original settings of Plot*)
\$TextStyle ={};
(SetOptions[Plot,#1]&)/@s;

Best Regards
Dimitris

```

• Prev by Date: RE: Using legend with FilledPlot
• Next by Date: Re: Normal for Limit : Example
• Previous by thread: Re: simple sequence problem
• Next by thread: Re: Slots & Ampersands