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

MathGroup Archive 1997

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

Search the Archive

Re: Piecewise functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8906] Re: Piecewise functions
  • From: "Stephen P Luttrell" <luttrell at signal.dra.hmg.gb>
  • Date: Thu, 2 Oct 1997 22:56:58 -0400
  • Organization: Defence Evaluation and Research Agency
  • Sender: owner-wri-mathgroup at wolfram.com

Venkateswara Rao Ayyadevara <va2a+ at andrew.cmu.edu> wrote in article
<60s2hp$6mj at smc.vnet.net>...
> I would like to know how to represent piecewise linear functions in
> Mathematica.  I tried searching on-line help but could not find any info
> regarding this.

Here is an example notebook showing two different ways of defining a
piecewise linear function (Mathematica 3):

Notebook[{
Cell["Piecewise linear function using Calculus`DiracDelta`:", "Text"],

Cell[BoxData[
    \(<< Calculus`DiracDelta`\)], "Input"],

Cell[BoxData[
    \(f[x_] := \(-x\)\ UnitStep[\(-x\)] + x\ UnitStep[x]\)], "Input"],

Cell[BoxData[
    \(\(Plot[f[x], {x, \(-1\), 1}]; \)\)], "Input"],

Cell["Alternatively you can do it this way:", "Text"],

Cell[BoxData[{
    \(g[x_] := \(-x\) /; x \[LessEqual] 0\), 
    \(g[x_] := x /; x \[GreaterEqual] 0\)}], "Input"],

Cell[BoxData[
    \(\(Plot[g[x], {x, \(-1\), 1}]; \)\)], "Input"]
},
FrontEndVersion->"Microsoft Windows 3.0",
ScreenRectangle->{{0, 1024}, {0, 712}},
WindowSize->{496, 604},
WindowMargins->{{0, Automatic}, {Automatic, 0}}
]


-- 
Stephen P Luttrell                                      
luttrell at signal.dra.hmg.gb
Adaptive Systems Theory                           01684-894046 (phone)
Room EX21, DERA                                    01684-894384 (fax)      
    
Malvern, Worcs, WR14 3PS, U.K.            
http://www.dra.hmg.gb/cis5pip/Welcome.html



  • Prev by Date: Subscripts??
  • Next by Date: Re: Compiled Functions and Mathgroup Archive
  • Previous by thread: Re: Piecewise functions
  • Next by thread: Re: Piecewise functions