Re: square wave function

• To: mathgroup at smc.vnet.net
• Subject: [mg31694] Re: square wave function
• From: bghiggins at ucdavis.edu (Brian Higgins)
• Date: Sat, 24 Nov 2001 16:44:11 -0500 (EST)
• References: <9tlb73\$pep\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Peter, Try this:

g[x_ /; 0 <= x <= 1] := 1
g[x_ /; 1 <= x <= 2] := -1
g[x_] := g[Mod[x, 2]]
Plot[g[x], {x, -10, 10}]

Cheers,
Brian

peterangelo at mindspring.com (Peter Dimitriou) wrote in message news:<9tlb73\$pep\$1 at smc.vnet.net>...
> To all who responded last time I posted, thank you, I was able to
> resolve that on my own.
>
> My new Question deals with the following lines of Mathematica code:
>
>
> Clear[square]
> square[x_] := 1 /; 0<x<1
> square[x_] := -1 /; -1<x<0
>
> Plot[square[x], {x,-1,1}]
>
> This defines and plots a square wave of period 2 between -1 and 1.
> The question is how do I define this for all x (-inf<x<inf, with
> period 2) in Mathematica?  The Only hint I get is to consider using
> the Mod function.  Scratched my head long enough anyone out there
> willing to help?
>
> Peter

```

• Prev by Date: RE: square wave function
• Next by Date: Re: square wave function
• Previous by thread: RE: square wave function
• Next by thread: Re: square wave function