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: [mg8921] Re: Piecewise functions
  • From: "William F. Campbell" <valentin at wam.umd.edu>
  • Date: Sat, 4 Oct 1997 22:08:01 -0400
  • Organization: UMD Dept. of Meteorology
  • Sender: owner-wri-mathgroup at wolfram.com

Venkateswara Rao Ayyadevara wrote:

> Hi !
>
> 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.
>
> Thanks for your help
>
> Venkat

  I do this all the time, albeit in an inelegant fashion.  Here's an
example:

myabs[x_ /; x<0] := -x
myabs[x_ /; x>=0] := x

This trivially generalizes to more complex functions -- just specify the
valid domain using the /; conditional operator.  However, suppose one
has a spline fit on, say 100 or 1000 subdomains.  How can I avoid typing
100 or 1000 separate function definitions?

--
Bill Campbell                          Correlation is not cause.




  • Prev by Date: Re: Order of execution of initialization cells
  • Next by Date: Re: trig expansion
  • Previous by thread: Re: Piecewise functions
  • Next by thread: Re: Piecewise functions