Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to graph the zig-zag function at the top of this page: http://www.math.ubc.ca/~feldman/m321/nondiffble.pdf

I have a little bit of experience with Mathematica but not a ton. Any suggestions?

share|improve this question
4  
Plot[Abs@TriangleWave[x/4], {x, -4, 4}, AspectRatio -> 1/8] –  belisarius Apr 21 at 18:16
    
You are amazing thank you. –  Jacob Saltsky Apr 21 at 18:41
    
Almost exactly the way it's defined in the PDF: f[x_] := Piecewise[{{Abs[x], -1 <= x <= 1}, {f[x + 2], x < 0}, {f[x - 2], x > 0}}] –  Rahul Narain Apr 21 at 18:43
add comment

1 Answer 1

This is using the definition of $\phi(x)$ in the paper. Granted a bit more cumbersome than the triangle wave.

Plot[Piecewise[{
{Abs[x + 4], -5 < x < -3}, 
{Abs[x + 2], -3 < x < -1},
{Abs[x], -1 < x < 1}, 
{Abs[x - 2], 1 < x < 3},
{Abs[x - 4], 3 < x < 5}}], 
{x, -4.15, 4.15}, PlotRange -> {0, 1}, AxesLabel -> {"x", "\[CurlyPhi](x)"}, 
LabelStyle -> Directive[Black, Bold, Medium], 
Ticks -> {{-4, -3, -2, -1, 0, 1, 2, 3, 4}, {0, 1}}, 
AspectRatio -> 2/17, PlotStyle -> {Black, Thickness[.0025]}, 
ImageSize -> 500]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.