Message Boards Message Boards

0
|
18137 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Periodic piecewise functions?

Posted 10 years ago

How would one create a piecewise periodic function (without using recursions)?

For example I'd like to make this function Piecewise[{{x, 0 <= x <= Pi}, {x - 2 Pi, Pi < x < 2 Pi}}] repeat itself to infinity...

POSTED BY: Nev Nev
7 Replies
Posted 10 years ago

Something like this?

f[x_] := Switch[Mod[x, 2 Pi] <= Pi, True, 0, False, x - 2 Pi]

Plot[f[x], {x, -Pi, 4 Pi}, PlotStyle -> Thick]

enter image description here

POSTED BY: David Keith
Posted 10 years ago

Hint: Think Mod[x, 2 Pi]

That should be enough.

POSTED BY: Bill Simpson
Posted 10 years ago

This gives the "sawtooth" wave: enter image description here

Which is not what i was hoping for.

POSTED BY: Nev Nev
Posted 10 years ago

This seems to be on the good track....

enter image description here

I don't want it to climb up the y-axis though... :/

POSTED BY: Nev Nev
POSTED BY: Udo Krause
Posted 10 years ago

But that is the expression you posted -- perhaps this?

f[x_] := Switch[Mod[x, 2 Pi] <= Pi, True, 0, False, Mod[x, 2 Pi] - Pi]

Plot[f[x], {x, -Pi, 4 Pi}, PlotStyle -> Thick]

enter image description here

POSTED BY: David Keith

....

POSTED BY: Ambuj Jain
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract