MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Integration of "Which" function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32112] RE: [mg32100] Integration of "Which" function
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 27 Dec 2001 03:34:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Doron,

This is a frequent question on MathGroup, and rightly so, since The
Mathematica Book leads users down the garden path of multiple definitions
for piecewise functions. While occasionally convenient, this is mostly a
relic of earlier versions of Mathematica. So here is the rule:

TO DO ANALYTICAL WORK WITH PIECEWISE FUNCTIONS DEFINE THEM WITH UnitStep!

Mathematica knows all about UnitStep as a function and can integrate it,
differentiate it, plot it and generally do all kinds of things with it.

Here is your example somewhat extended. I defined the function to be a
square pulse between 1/2 and 1, and integrated and plotted between 0 and 2.

f[x_] := 2(UnitStep[x - 1/2] - UnitStep[x - 1])

Plot[f[x], {x, 0, 2}];

F[x_] = Integrate[f[x], x]
2*((-(-1 + x))*UnitStep[-1 + x] +
   (-(1/2) + x)*UnitStep[-(1/2) + x])

Plot[F[x], {x, 0, 2}];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/




> From: Doron [mailto:klepachd at yahoo.com]
To: mathgroup at smc.vnet.net
>
> Hello ,
> I am trying to integrate :
> Integrate[Which[0 <= x <= 1/2, 0, 1/2 < x <= 1, 2], {x, 0, 1}]
>
> Why doesn`t it work ?
> Thank you for your help .
>



  • Prev by Date: Front end problems!
  • Next by Date: Re: Re: Find many Roots
  • Previous by thread: RE: Integration of "Which" function
  • Next by thread: Re: Integration of "Which" function