Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: piecewise definition of a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43897] Re: piecewise definition of a function
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
  • Date: Fri, 10 Oct 2003 03:06:14 -0400 (EDT)
  • References: <bm2ub8$6s1$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nathan Moore <nmoore at physics.umn.edu> wrote:
> I'd like to define a function in a piecewise manner.  As of yet I've
> been unsuccessful with even the simplest example.  Consider the
> following:
>
> first define a 1-d bump,
>
> f[x_] = If[x < 0, 0,If[x > 1, 0, 1]]
>   Mathematica doesn't seem to mind this, as f[0.1] evaluates 1 and
> f[-23] evaluates 0.
> The problem comes when I try to integrate the function.  The
> following command which should evaluate to 1 doesn't work AT ALL!
>
> Integrate[f[x], {x, -50, 50}]
>
> What is the proper technique here?

There may be more than one "proper" technique.

Using version 5, if you define your function to be either

  UnitStep[x] - UnitStep[x - 1]

or

  If[0 < x < 1, 1, 0]

the integration evaluates to 1, as desired.

David Cantrell


  • Prev by Date: Re: Perform an assigment
  • Next by Date: Re: piecewise definition of a function
  • Previous by thread: Re: piecewise definition of a function
  • Next by thread: Re: piecewise definition of a function