MathGroup Archive 2007

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

Search the Archive

Re: Cantor Function problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74609] Re: Cantor Function problem
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 28 Mar 2007 01:41:54 -0500 (EST)
  • References: <euanne$duk$1@smc.vnet.net>


Hi Neelaka,

consider:

f[0] = 1;

f[x_] := f[3x]/2   /; x<=1/3;

f[x_] := 1-f[1-x] /; 2/3<=x;

this produces an infinite recursion because in general the end criterion 

is never reached. Here is a working approach. Define f[n,x], that 

converges to the Cantorfunction if n->infinity;

f[0, x_] = x;

f[n_, x_] := Piecewise[{{0.5*f[n - 1, 3*x], Inequality[0, LessEqual, x,

       Less, 1/3]}, {0.5, Inequality[1/3, LessEqual, x, Less, 2/3]},

     {0.5 + 0.5*f[n - 1, 3*(x - 2/3)], 2/3 <= x <= 1}}]

Damiel



Neelaka Seneviratne wrote:

> hi,

> 

> i am not a member of this group. but i have a difficulty in Mathematica that

> you may be able to help with.

> I got the following program from a book but it doesnt work. please help to

> resolve it.

> this is for a friend of mine who wants to generate the cantor function for

> his BSc final year project.

> 

> thank you very much

> neelaka seneviratne

> 

> 

> 

> spawn[{a_Rational, b_rational}] :=

>   Block [{w=(b-a)/3}, {{a-2w, a-w}, {b+w, b+2w}}]

> spawn [intervals_list] := Flatten[Map[spawn, intervals], 1 /;

>               Length[intervals[[1]]] >1

> 

> removedintervals[n_]:=

>   Flatten[NestList[spawn, {{1/3, 2/3}}, n-1], 1]

> 

> f[0] = 1;

> f[x_] := f[3x]/2   /; x<=1/3;

> f[x_] := 1-f[1-x] /; 2/3<=x;

> 

> connect [{a_, b_}] := Block [{y=f[a]}, Line[{{a,y}, {b,y}}]]

> 

> CantorFunction[levels_] := show[Graphics[{Thickness[.001],

>   Map[connect, removedintervals[levels]]}],

>   Axes-> {0,0}, Ticks->{N[Range[0., 1, 1/9], 3], Automatic}]

> 




  • Prev by Date: Re: Thread function now working as expected
  • Next by Date: Re: Cantor Function problem
  • Previous by thread: Cantor Function problem
  • Next by thread: Re: Cantor Function problem