Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Piecewise functions definition and usage

  • To: mathgroup at
  • Subject: [mg24098] Piecewise functions definition and usage
  • From: Viorel Ontalus <vio2 at>
  • Date: Tue, 27 Jun 2000 00:51:54 -0400 (EDT)
  • Organization: Lehigh University
  • Sender: owner-wri-mathgroup at

It seems I got into an area where Mathematica has some problems, and I
hope somebody can give me a hint on how to go around these problems.

1.  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

f[x_] := Sqrt[ 1- ( (x-3)/10)^2  ] /;
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 !!

2. For fun I tried the only reference from the book on piecewise
If[Abs[x-3]<10, f[x_]:=Sqrt[1- ( (x-3)/10)^2  ] , f[x_]:=0 ]

This definition does not work !!

  • Prev by Date: Conditionals with multiple tests?
  • Next by Date: Unix Sound Problems
  • Previous by thread: Re: Conditionals with multiple tests?
  • Next by thread: Re: Piecewise functions definition and usage