Piecewise plot in Mathematica returning blank graph

3 replies · 3K views · last reply
kevmac
Messages
6
Reaction score
2

Homework Statement


I've entered the following piecewise equation into Mathematica:

Plot[Piecewise[{{sin (t), 0 <= t < \[Pi]}, {5 + 5 cos (t) + sin (t), \[Pi] <= t < 4*\[Pi]}, {10 cos (t) + sin (t), 4*\[Pi] <= t}}], {t, 0, 20*\[Pi]}]

But I am getting a blank graph in return. I've proofread my input many times and can't find anything wrong with it. Can anyone help me get a graph generated?

Homework Equations

The Attempt at a Solution

 
kevmac said:

Homework Statement


I've entered the following piecewise equation into Mathematica:

Plot[Piecewise[{{sin (t), 0 <= t < \[Pi]}, {5 + 5 cos (t) + sin (t), \[Pi] <= t < 4*\[Pi]}, {10 cos (t) + sin (t), 4*\[Pi] <= t}}], {t, 0, 20*\[Pi]}]

But I am getting a blank graph in return. I've proofread my input many times and can't find anything wrong with it. Can anyone help me get a graph generated?

Homework Equations

The Attempt at a Solution


jedishrfu is correct. You should also use square brackets, not round brackets in functions. Sin[t] is the correct syntax. If you make those two modifications, it will work, as shown below.
Mathematica notebook showing input Plot[Piecewise[...]] of a piecewise function over t from 0 to 20π, with output a blue plot of oscillating curves reaching about +10 and -10 on the y-axis, x-axis ticks 10 to 60.
 
Thanks to both of you! This ended up working just fine and I got the same graph that you did e.bar.goum
 
  • Like
Likes   Reactions: e.bar.goum