MathGroup Archive 2008

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

Search the Archive

Re: Modulus / Absolute Value

Felipe Mannshardt wrote:

> i have been searching the way to tell Mathematica to use Modulus / Absolute Value.  I have been unable to find.
> \left(\int_0^{\frac{\pi }{2}} f[x] \, dx+\int_{\frac{\pi }{2}}^{\pi } f[x] \, dx\right)+\int_0^{\pi } g[x] \, dx
> I should be subtracting the upper Integral from the lower Integral,
> but since i could not find a way to tell Mathematica to use Modulus /Absolute Value.  I had to add the upper to the lower . . .
> my functions are, f and g
> f[\text{x$\_$}]\text{:=}\text{Sin}[2*x]g[\text{x$\_$}]\text{:=}x^2-(\pi *x)
> So, can some1 help me out with this one? How to use Modulus/Absolute Value (German, Betrag) with Mathematica.

My understanding is that you want to do a piecewise integration. Knowing 

1) the absolute value is called *Abs[]* in Mathematica

2) Mathematica does not handle very well piecewise integration

3) fortunately Maxim Rytin's package does manage it very well

the way to go is to get and familiarize yourself with this package.

For instance,

     PiecewiseIntegrate[Abs[f[x]] + g[x], {x, 0, Pi}]

     1/6 (12 - \[Pi]^3)

See "Integration of Piecewise Functions with Applications" at

"The notebook contains the implementation of four functions 
PiecewiseIntegrate, PiecewiseSum, NPiecewiseIntegrate, NPiecewiseSum. 
They are intended for working with piecewise continuous functions, and 
also generalized functions in the case of PiecewiseIntegrate. They 
support all the standard Mathematica piecewise functions such as 
UnitStep, Abs, Max, as well as Floor and other arithmetic piecewise 
functions. PiecewiseIntegrate supports the multidimensional DiracDelta 
function and its derivatives. The arguments of the piecewise functions 
can be non-algebraic and contain symbolic parameters."

-- Jean-Marc

  • Prev by Date: Re: Re: Inequality not documented in 6.0
  • Next by Date: Re: Re: Problem with NMaximize
  • Previous by thread: Re: Modulus / Absolute Value
  • Next by thread: ContourPlot problem