[Date Index]
[Thread Index]
[Author Index]
Re: Piecewise functions definition and usage
*To*: mathgroup at smc.vnet.net
*Subject*: [mg24130] Re: [mg24098] Piecewise functions definition and usage
*From*: BobHanlon at aol.com
*Date*: Wed, 28 Jun 2000 02:11:48 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
In a message dated 6/27/2000 1:06:55 AM, vio2 at mail.lehigh.edu writes:
>I am trying to define a piecewise function and do some computations
>with it. When I integrate mathematica does not behave. Here is an simple
>example you can run and see what I am talking about
>
>Clear[f,x}
>f[x_] := Sqrt[ 1- ( (x-3)/10)^2 ] /;
>Abs[x-3]<10
>f[x_] := 0 /;
>Abs[x-3]>3 ; (*this is a very simple piecewise function but one
>must be sure the Sqrt is from a positive # )
>
>NIntegrate[f[x],{x,-1,17}] (* Here Mathematica goes nuts !!!*)
>
>Of course it gives an answer but if your program is more complex, then
>you never get an answer !!
>( I tried to make the upper limit a variable etc !!)
>Does anybody know how to avoid the error , or non convergence messages
>I get !!
>
Needs["Algebra`InequalitySolve`"]
InequalitySolve[Abs[x - 3] < 10, x]
-7 < x < 13
f[x_] := Sqrt[
1 - ( (x - 3)/10)^2 ] * (UnitStep[(x + 7)] - UnitStep[(x - 13)])
Plot[f[x], {x, -10, 15},
PlotStyle -> {AbsoluteThickness[2], RGBColor[1, 0, 0]}];
Integrate[f[x], {x, -1, 17}]
(2*Sqrt[21])/5 + (5*Pi)/2 + 5*ArcSin[2/5]
% // N
11.74459614229426
Bob Hanlon
Prev by Date:
**Re: Plots with Variable Limits?**
Next by Date:
**Re: Output cell linebreaks**
Previous by thread:
**Piecewise functions definition and usage**
Next by thread:
**Re: Piecewise functions definition and usage**
| |