Sei sulla pagina 1di 5

In[1]:=

subf[x_, k_] := Piecewise[{


{Abs[x - k], k - 1 / 2 x k + 1 / 2}
}, 0];
f[x_, K_] := Sum[subf[x, k], {k, - K, K}];

In[3]:=

Manipulate[
Plot[f[2 ^ j x, k], {x, - 1, 1}],
{k, 2, 10, 1},
{j, 0, 10, 1}]

k
j

0.5

0.4
Out[3]=

0.3

0.2

0.1

-1.0

-0.5

0.5

1.0

so f is just a triangular wave, lets use the built in version which should be faster

Printed by Wolfram Mathematica Student Edition

WaerdenFunction.nb

In[4]:=

f2[x_] := 1 / 2 Abs[TriangleWave[1 / 2 x]];


Manipulate[
Plot[f2[2 ^ j x], {x, - 1, 1}],
{j, 0, 10, 1}]

0.5

0.4

Out[5]=

0.3

0.2

0.1

-1.0

In[6]:=

0.5

-0.5

1.0

Wstep[x_, b_, n_] := b ^ (- n) f2[x b ^ n ];


Wgen[x_, b_, N_] := Sum[Wstep[x, b, j], {j, 0, N}];
W[x_, N_] := Wgen[x, 10, N];
Takagi[x_, N_] := Wgen[x, 2, N];

Just like above each step increases the frequency of the triangular wave, but also decreases its height.
This plot is useful for problem 1.32 in terms of coming up with a candidate for convergence.

Printed by Wolfram Mathematica Student Edition

WaerdenFunction.nb

In[10]:=

Manipulate[
Plot[Wstep[x, 2, n], {x, 0, 1}],
{n, 0, 10, 1}]

0.5

0.4

Out[10]=

0.3

0.2

0.1

0.2

In[11]:=

0.4

0.6

0.8

1.0

0.6

0.8

1.0

Manipulate[
Plot[Takagi[x, n], {x, 0, 1}],
{n, 0, 10, 1}]

0.5

0.4

Out[11]=

0.3

0.2

0.1

0.2

0.4

The van der Waerden function is not as pretty

Printed by Wolfram Mathematica Student Edition

WaerdenFunction.nb

In[12]:=

Manipulate[
Plot[W[x, n], {x, 0, 1}],
{n, 0, 10, 1}]

0.5

0.4

Out[12]=

0.3

0.2

0.1

0.2

0.4

0.6

0.8

1.0

It still has a recursive structure though


In[13]:=

Manipulate[
Plot[W[x, n], {x, 1 / 4, 3 / 4}],
{n, 0, 10, 1}]

0.50

0.45

Out[13]=

0.40

0.35

0.30

0.3

0.4

0.5

0.6

0.7

Play around with different bases

Printed by Wolfram Mathematica Student Edition

WaerdenFunction.nb

In[14]:=

Manipulate[
Plot[Wgen[x, b, 10], {x, 0, 1}],
{b, 2, 10, 1 / 4}]

0.7
0.6
0.5
Out[14]=

0.4
0.3
0.2
0.1

0.2

0.4

0.6

0.8

1.0

Printed by Wolfram Mathematica Student Edition

Potrebbero piacerti anche