Re: Integration of very simple partwise definded functions fails

• To: mathgroup at smc.vnet.net
• Subject: [mg15807] Re: [mg15720] Integration of very simple partwise definded functions fails
• From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
• Date: Sun, 7 Feb 1999 02:04:22 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```On Fri, Feb 5, 1999, D.O. <oberfeld at psych.gp.TU-Berlin.DE> wrote:

>Hi,
>
>I was quite surprised that Mathematica will not evaluate any Integrals
>of simple functions like
>
>f[x_/;x<=2]:=1
>f[x_/;x>2]:=2
>
>Integrate[f[x],{x,0,1}]
>
>
>
>Do I miss something? There must be a fast way out...
>
>Thanks for all suggestions!
>
>
>Daniel Oberfeld
>Institut fuer Psychologie
>Allgemeine Psychologie
>TU Berlin
>FS1, Raum FS105
>Franklinstr. 5-7
>10587 Berlin
>T. 030/314-79541
>Fax. 030/314-25996

NIntegrate works fine, but you need to assign a value at 2. f[2]:= 3
(for example) will do as well as any other real number:

In[29]:=
NIntegrate[f[x],{x,0,1}]
Out[29]=
1.

with no complaints. It is true that Integrate (rather than NIntegrate)
does not work for a piecewise function defined in this way, but you can
make it work by using an If based definition: In[35]:=
g=Function[x,If[x<2,1,2]];

In[36]:=
Integrate[g[x],{x,0,1}]
Out[36]=
1

Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/
http://eri2.tuins.ac.jp/

```

• Prev by Date: Re: Surfacecoloring of a sphere
• Next by Date: Re: FindRoot question (number of variables)
• Previous by thread: Re: Integration of very simple partwise definded functions fails
• Next by thread: accessing large files