ArticleslgStudy

mathematics

Piecewise function

Piecewise function is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Piecewise function rather than just read about it. In short: In mathematics, a piecewise function (also called a piecewise-defined function, a hybrid function, or a function defined by cases) is a function whose domain is partitioned into several intervals ("subdomains") on which the function may be defined differently. Piecewise definition is actually a way of specifying the function, rather than a characteristic of the resulting function itself, as every function whose doma…

Piecewise function — main illustration
Piecewise function — illustration

Key takeaways

  • Piecewise function belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Piecewise function to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Piecewise function from memory before moving on to harder problems.

Reference excerpt

In mathematics, a piecewise function (also called a piecewise-defined function, a hybrid function, or a function defined by cases) is a function whose domain is partitioned into several intervals ("subdomains") on which the function may be defined differently. Piecewise definition is actually a way of specifying the function, rather than a characteristic of the resulting function itself, as every function whose domain contains at least two points can be rewritten as a piecewise function. The first three paragraphs of this article only deal with this first meaning of "piecewise". Terms like piecewise linear, piecewise smooth, piecewise continuous, and others are also very common. The meaning of a function being piecewise P {\displaystyle P} , for a property P {\displaystyle P} , is roughly that the domain of the function can be partitioned into pieces on which the property P {\displaystyle P} holds, but this term is used slightly differently by different authors. Unlike the first meaning, this is a property of the function itself and not only a way to specify it. Sometimes the term is used in a more global sense involving triangulations; see Piecewise linear manifold.

Notation and interpretation

Piecewise functions can be defined using the common functional notation, where the body of the function is an array of functions and associated subdomains. A semicolon or comma may follow the subfunction or subdomain columns. The if {\displaystyle {\text{if}}} or for {\displaystyle {\text{for}}} is rarely omitted at the start of the right column. The subdomains together must cover the whole domain; sometimes it is also required that they are pairwise disjoint, i.e. form a partition of the domain. This is enough for a function to be "defined by cases", but in order for the overall function to be "piecewise", the subdomains are typically required to be nonempty intervals (some may be degenerate intervals, i.e. single points or unbounded intervals) and they are often not allowed to have infinitely many subdomains in any bounded interval. This means that functions with bounded domains will only have finitely many subdomains, while functions with unbounded domains can have infinitely many subdomains, as long as they are appropriately spread out. As an example, consider the piecewise definition of the absolute value function:

| x | = { − x , if x < 0 + x , if x ≥ 0. {\displaystyle |x|={\begin{cases}-x,&{\text{if }}x<0\\+x,&{\text{if }}x\geq 0.\end{cases}}}

For all values of x {\displaystyle x} less than zero, the first sub-function ( − x {\displaystyle -x} ) is used, which negates the sign of the input value, making negative numbers positive. For all values of x {\displaystyle x} greater than or equal to zero, the second sub-function ( x {\displaystyle x} ) is used, which evaluates trivially to the input value itself. The following table documents the absolute value function at certain values of x {\displaystyle x} :

In order to evaluate a piecewise-defined function at a given input value, the appropriate subdomain needs to be chosen in order to select the correct sub-function—and produce the correct output value.

Examples A step function or piecewise constant function, composed of constant sub-functions Piecewise linear function, composed of linear sub-functions Piecewise smooth function, composed of smooth sub-functions Broken power law, a function composed of power-law sub-functions Spline, a function composed of polynomial sub-functions, often constrained to be smooth at the joints between pieces B-spline

f ( x ) = { exp ⁡ ( − 1 1 − x 2 ) , x ∈ ( − 1 , 1 ) 0 , otherwise {\displaystyle f(x)={\begin{cases}\exp \left(-{\frac {1}{1-x^{2}}}\right),&x\in (-1,1)\\0,&{\text{otherwise}}\end{cases}}} and some other common Bump functions. These are infinitely differentiable, but analyticity holds only piecewise.

Continuity and differentiability of piecewise-defined functions

A piecewise-defined function is continuous on a given interval in its domain if the following conditions are met:

… excerpt ends here. Continue reading the full article.

Illustrations

Piecewise function: Plot of the piecewise linear function 
  
    
      
        f
        (
        x
        )
        =
        
          {
          
            
              
                
                  −
                  3
                  −
                  x
                
                
                  
                    if
                  
                
                
                  x
                  ≤
                  −
                  3
                
              
              
                
                  x
                  +
                  3
                
                
                  
                    if
                  
                
                
                  −
                  3
                  ≤
                  x
                  ≤
                  0
                
              
              
                
                  3
                  −
                  2
                  x
                
                
                  
                    if
                  
                
                
                  0
                  ≤
                  x
                  ≤
                  3
                
              
              
                
                  0.5
                  x
                  −
                  4.5
                
                
                  
                    if
                  
                
                
                  3
                  ≤
                  x
                
              
            
          
          
        
      
    
    {\displaystyle f(x)=\left\{{\begin{array}{lll}-3-x&{\text{if}}&x\leq -3\\x+3&{\text{if}}&-3\leq x\leq 0\\3-2x&{\text{if}}&0\leq x\leq 3\\0.5x-4.5&{\text{if}}&3\leq x\\\end{array}}\right.}
Plot of the piecewise linear function f ( x ) = { − 3 − x if x ≤ − 3 x + 3 if − 3 ≤ x ≤ 0 3 − 2 x if 0 ≤ x ≤ 3 0.5 x − 4.5 if 3 ≤ x {\displaystyle f(x)=\left\{{\begin{array}{lll}-3-x&{\text{if}}&x\leq -3\\x+3&{\text{if}}&-3\leq x\leq 0\\3-2x&{\text{if}}&0\leq x\leq 3\\0.5x-4.5&{\text{if}}&3\leq x\\\end{array}}\right.}
Piecewise function: Graph of the absolute value function, ⁠
  
    
      
        y
        =
        |
        x
        |
      
    
    {\displaystyle y=\vert x\vert }
  
⁠
Graph of the absolute value function, ⁠ y = | x | {\displaystyle y=\vert x\vert } ⁠
Piecewise function: The function ⁠
  
    
      
        f
        (
        x
        )
        =
        min
        (
        1
        ,
        
          x
          
            2
          
        
        )
      
    
    {\displaystyle f(x)=\min(1,x^{2})}
  
⁠ is piecewise monotonic (subdomains 
  
    
      
        (
        −
        ∞
        ,
        0
        ]
      
    
    {\displaystyle (-\infty ,0]}
  
, ⁠
  
    
      
        [
        0
        ,
        +
        ∞
        )
      
    
    {\displaystyle [0,+\infty )}
  
⁠) and piecewise differentiable (subdomains ⁠
  
    
      
        (
        −
        ∞
        ,
        −
        1
        ]
      
    
    {\displaystyle (-\infty ,-1]}
  
⁠, ⁠
  
    
      
        [
        −
        1
        ,
        +
        1
        ]
      
    
    {\displaystyle [-1,+1]}
  
⁠, and ⁠
  
    
      
        [
        +
        1
        ,
        +
        ∞
        )
      
    
    {\displaystyle [+1,+\infty )}
  
⁠).
The function ⁠ f ( x ) = min ( 1 , x 2 ) {\displaystyle f(x)=\min(1,x^{2})} ⁠ is piecewise monotonic (subdomains ( − ∞ , 0 ] {\displaystyle (-\infty ,0]} , ⁠ [ 0 , + ∞ ) {\displaystyle [0,+\infty )} ⁠) and piecewise differentiable (subdomains ⁠ ( − ∞ , − 1 ] {\displaystyle (-\infty ,-1]} ⁠, ⁠ [ − 1 , + 1 ] {\displaystyle [-1,+1]} ⁠, and ⁠ [ + 1 , + ∞ ) {\displaystyle [+1,+\infty )} ⁠).
Piecewise function: Plot of the piecewise-quadratic function 
  
    
      
        f
        (
        x
        )
        =
        
          {
          
            
              
                
                  
                    x
                    
                      2
                    
                  
                
                
                  
                    if
                  
                
                
                  x
                  <
                  0.707
                
              
              
                
                  1.5
                  −
                  (
                  x
                  −
                  1.414
                  
                    )
                    
                      2
                    
                  
                
                
                  
                    if
                  
                
                
                  0.707
                  ≤
                  x
                
              
            
          
          
        
      
    
    {\displaystyle f(x)=\left\{{\begin{array}{lll}x^{2}&{\text{if}}&x<0.707\\1.5-(x-1.414)^{2}&{\text{if}}&0.707\leq x\\\end{array}}\right.}
  
 Its only discontinuity is at 
  
    
      
        
          x
          
            0
          
        
        =
        0.707
      
    
    {\displaystyle x_{0}=0.707}
  
.
Plot of the piecewise-quadratic function f ( x ) = { x 2 if x < 0.707 1.5 − ( x − 1.414 ) 2 if 0.707 ≤ x {\displaystyle f(x)=\left\{{\begin{array}{lll}x^{2}&{\text{if}}&x<0.707\\1.5-(x-1.414)^{2}&{\text{if}}&0.707\leq x\\\end{array}}\right.} Its only discontinuity is at x 0 = 0.707 {\displaystyle x_{0}=0.707} .

Worked examples

Example 1 — a first encounter with Piecewise function

Start with the simplest possible case. Write down what Piecewise function claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Piecewise function before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Piecewise function ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Piecewise function

In research
Piecewise function appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Piecewise function in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Piecewise function is common in secondary-school and first-year university syllabi. It links to neighbouring topics Functions and mappings, so understanding it makes those chapters shorter.
In everyday life
Look for Piecewise function outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Piecewise function in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Piecewise function means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Piecewise function out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Piecewise function in simple terms?

In mathematics, a piecewise function (also called a piecewise-defined function, a hybrid function, or a function defined by cases) is a function whose domain is partitioned into several intervals ("subdomains") on which the function may be defined differently. Piecewise definition is actually a way…

Why does Piecewise function matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Piecewise function?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Piecewise function.

Tags

  • Functions and mappings

Keep exploring