6

I've tried several approaches, such as defining a function f(t) at certain values, and then using f(t) in my equation, but nothing has worked for me thus far. I love using wolfram alpha, it is an invaluable resource for helping me to better understand my advanced differential equations homework. I am trying to graph a piecewise square wave from 0 to 5pi
The equation is x'' + 2x' + x = f(t) where

__{0, (2n+1)*pi < t < (2n+2)*pi}

f(t) =

 __{5, 2n*pi < t < (2n+1)*pi} n = 0,1,2,3,4...etc  

f(t) is a square wave with a value of 5 between 0 and pi, then 0 between pi and 2*pi, then 5 between 2*pi and 3*pi... etc. f(t) is the driving function of the ODE. What does the graph look like between 0 < t < 5*pi Any help inputting this into a plotter, such as wolfram alpha would be greatly appreciated, ty!

amesh
  • 1,311
  • 3
  • 21
  • 51
Nate G
  • 63
  • 1
  • 1
  • 4

2 Answers2

3

As @ogerard has pointed out you can often input Mathematica expressions to Wolfram Alpha. In your case you may be interested in the SquareWave function. For example, the expression

Plot[2.5 + 2.5 (SquareWave[x/(2 \[Pi])]), {x, -1, 6}]

produces the plot

enter image description here

which, rather unhelpfully, obscures half the graphic along the x-axis.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
  • oh this makes sense, much easier than the way i was trying haha, tyvm, i never thought of just using a squarewave function – Nate G Oct 26 '12 at 03:56
2

In your case, it is easy to build your driving function from elementary ones, such as integer part and modulo.

Also with Wolfram Alpha, you can use Mathematica notation to be explicit.

To visualize your function f, just try

5 *Mod[Ceiling[x/Pi], 2]

or

5 ceiling(x/pi) mod 2

in Wolfram Alpha.

By entering

plot | 5 ceiling(x/pi) mod 2 | x = -3 pi  to  3 pi

You will get something like this:

f

ogerard
  • 735
  • 9
  • 15
  • Thanks =D i wish i was better with mathematica, unfortunately the new version just came out so its hard to get good advice on how to use it. – Nate G Oct 26 '12 at 03:57