Non-Linear Functions

3. Piecewise and Step Functions

Learning outcomes
  • I can recognize piecewise functions.
  • I can interpret step graphs.
  • I can determine outputs from piecewise graphs.
  • I can explain why piecewise functions are useful.
  • I can describe real-life examples.

Piecewise and Step Functions

In mathematics, many relationships can be described using a single equation. However, some situations require different rules depending on the input value.

For example, a parking garage might charge $5 for the first two hours, $8 for up to four hours, and $12 for longer stays.

The price does not increase continuously. Instead, it changes according to different conditions.

Piecewise functions allow us to represent these situations mathematically.

What Is a Piecewise Function?

A piecewise function is a function defined using two or more rules, with each rule applying to a particular interval of input values.

Consider the following function:

f(x) = x + 2 when x < 3

f(x) = 2x − 1 when x ≥ 3

This function has two different rules.

  • When x is less than 3, we use f(x) = x + 2.
  • When x is greater than or equal to 3, we use f(x) = 2x − 1.

For example, when x = 1:

f(1) = 1 + 2 = 3

When x = 5:

f(5) = 2(5) − 1 = 9

The most important step when working with piecewise functions is choosing the correct rule before calculating the output.

Recognizing Piecewise Functions

A piecewise function can often be recognized by examining its graph.

Unlike a simple linear function, which follows one straight line, a piecewise function may contain several different sections.

These sections might include:

  • Straight lines with different slopes
  • Horizontal line segments
  • Curved sections
  • Sudden jumps between values
  • Open and closed endpoints
https://images.openai.com/static-rsc-4/NJthYP7-wZ1tRhVk1F-cQtgfaZI9jntKhUXumcUi4gNTsPaFWqgUrzQMHub2SoEx8ouEWKdFwJw6IE3_TiqV8oJOLjGvXWOI9uBZuEVUponn6HvXQ42CTPZdT3zkqxXgufMR9jXuPnDVzsSRJicKp0UVBcNrgl78NCigIJsxngqmMR7GPqLR_kiWnMsGWq1Y?purpose=fullsize
 
https://images.openai.com/static-rsc-4/Iric4arAcgG6aA1PZNZfGK8lGAYx1HXwVLCefRF_XDgS4fLXnBBJ0jY--rsgAlIEqiDT5a8QYN40gdiCR9WGy0VbS5LNYx530XC2Q5lgP6nu6uZEQWnZxIVunUwsWebZY2j8prU3Mnsma4BqcCLK622deW-JUghlDQult5MV9R_jduqZpoeyFFzWiveXSscP?purpose=fullsize
 
https://images.openai.com/static-rsc-4/fJl2XDxaMJTQnswBUzuhQpEM_f3v4Ie_LaaXnyulksyGA3iSmtP_gTXh3Cql6mnpZ3LaAojPHpgyEfJHAMV2hzPrNBMcn74x9gQse8I2P2tTn25DLjE1vi0Km6Q38_Z2gLXK7Q9i-npz3ymOIa8tBW8HK4shHjAGsLz0vbF_3JnvaDc5arnk1GYIxIEG1xm1?purpose=fullsize
 
8

Each section of the graph represents a different mathematical rule.

For example, a graph might increase steadily for negative x-values, remain constant for a short interval, and then decrease for positive x-values.

Although the graph contains several sections, it can still represent one function.

Remember: A function must assign exactly one output to every input in its domain.

The Vertical Line Test

The vertical line test helps determine whether a graph represents a function.

Imagine drawing vertical lines through different positions on the graph.

If a vertical line intersects the graph at more than one included point, the graph does not represent a function.

If every vertical line intersects the graph at no more than one included point, the graph represents a function.

This rule applies to piecewise functions just as it does to other functions.

Understanding Conditions and Intervals

Each rule in a piecewise function has a condition that determines when it applies.

Common conditions include:

Symbol Meaning
x < 3 x is less than 3
x > 3 x is greater than 3
x ≤ 3 x is less than or equal to 3
x ≥ 3 x is greater than or equal to 3

Consider:

f(x) = 2x when x < 4

f(x) = x + 5 when x ≥ 4

If x = 2, use the first rule:

f(2) = 2(2) = 4

If x = 6, use the second rule:

f(6) = 6 + 5 = 11

But what happens when x = 4?

Since the second condition includes equality, we use:

f(4) = 4 + 5 = 9

The boundary value belongs to the second section.

Open and Closed Circles

Piecewise graphs frequently use open and closed circles to indicate whether endpoints are included.

https://images.openai.com/static-rsc-4/NJthYP7-wZ1tRhVk1F-cQtgfaZI9jntKhUXumcUi4gNTsPaFWqgUrzQMHub2SoEx8ouEWKdFwJw6IE3_TiqV8oJOLjGvXWOI9uBZuEVUponn6HvXQ42CTPZdT3zkqxXgufMR9jXuPnDVzsSRJicKp0UVBcNrgl78NCigIJsxngqmMR7GPqLR_kiWnMsGWq1Y?purpose=fullsize
 
https://images.openai.com/static-rsc-4/Q2MNCvxBP_RNSqWtLUhMMQEFWIK4pXDgzVJ92QVHMHrPfyaj_-aFFiXtcA7VrecgpUzMPUYEcXyckDa3T0146-7TAiL5E5B05sEZUj0u5_8-QP_1y_FoYHmcuMeIYklA6o83akAykmhobYtUDbn8-XRtIJJ1ZY3n5YiECWOWF-zRAFncH5NerjKFpdLIhfdj?purpose=fullsize
 
https://images.openai.com/static-rsc-4/fJl2XDxaMJTQnswBUzuhQpEM_f3v4Ie_LaaXnyulksyGA3iSmtP_gTXh3Cql6mnpZ3LaAojPHpgyEfJHAMV2hzPrNBMcn74x9gQse8I2P2tTn25DLjE1vi0Km6Q38_Z2gLXK7Q9i-npz3ymOIa8tBW8HK4shHjAGsLz0vbF_3JnvaDc5arnk1GYIxIEG1xm1?purpose=fullsize
 
9

Closed Circles

A closed circle (●) means the point is included in the graph.

Closed circles are associated with inequalities containing:

≤ or ≥

For example:

x ≥ 2

includes x = 2.

Open Circles

An open circle (○) means the point is not included in the graph.

Open circles are associated with:

< or >

For example:

x > 2

does not include x = 2.

Example

Suppose a graph has:

  • An open circle at (3, 5)
  • A closed circle at (3, 2)

The function's value at x = 3 is:

f(3) = 2

The open circle at (3, 5) is not included.

This distinction becomes particularly important when a function changes rules at a boundary.

Determining Outputs from Piecewise Graphs

A function's output can be determined directly from its graph.

To find f(4):

  1. Locate x = 4 on the horizontal axis.
  2. Move vertically until reaching the graph.
  3. Read the corresponding y-value.
  4. Check whether the point is included.

Suppose the graph contains the point (4, 7).

Then:

f(4) = 7

Remember:

Input = x-coordinate

Output = y-coordinate

https://images.openai.com/static-rsc-4/Iric4arAcgG6aA1PZNZfGK8lGAYx1HXwVLCefRF_XDgS4fLXnBBJ0jY--rsgAlIEqiDT5a8QYN40gdiCR9WGy0VbS5LNYx530XC2Q5lgP6nu6uZEQWnZxIVunUwsWebZY2j8prU3Mnsma4BqcCLK622deW-JUghlDQult5MV9R_jduqZpoeyFFzWiveXSscP?purpose=fullsize
 
https://images.openai.com/static-rsc-4/cyG8x3uyS38t9dgga_nwCv_DgF92zonrtdSfDjxQ9TzR-lGl-wMXdWolRgKoYO1PX5OJtXFlLZZsMg4bZLAEHATj6Ze2VeKV2bUYW6Zdh37eTeYtm2fHYRQxThMRPG2R5KWvQRHhnLuuG9tkH15qLD4FJa9Hd-gRhv30cpoAvI_9KyDZLgiKScCnbmZM0M6i?purpose=fullsize
 
https://images.openai.com/static-rsc-4/sJ7xh-2XKXe-WAPFrAA8U_xbYQIuOGhB23wj4xjxirp7tVKgDyfbSVkebFI_Hrukpo-1xbGJ77X3sbazCDWWf15zpVEbmvnmNjrYXREJTgZoh_bMviUMaTuie8NSwrR6O7lsmssaoAzbhA4YlKP4j0CEyrfYCBgGS6AfhmW2MNKlyoZObY5aIyjqwQAibZwF?purpose=fullsize
 
8

If a graph has an open and closed circle at the same x-value, the closed circle determines the function's output.

If there is no included point at a particular x-value, the function is undefined there.

Worked Example: Evaluating a Piecewise Function

Consider the function:

f(x) = x + 3 when x < 2

f(x) = 6 when 2 ≤ x < 5

f(x) = 2x when x ≥ 5

Example: Find f(−1)

Since −1 < 2, use:

f(x) = x + 3

Substitute:

f(−1) = −1 + 3

f(−1) = 2

Example: Find f(3)

Since 2 ≤ 3 < 5, use:

f(x) = 6

Therefore:

f(3) = 6

Example: Find f(7)

Since 7 ≥ 5, use:

f(x) = 2x

Substitute:

f(7) = 2(7)

f(7) = 14

Notice that evaluating piecewise functions usually involves simple calculations. The challenge is identifying the correct interval.


Step Functions

A step function is a special type of piecewise function.

Its graph consists of horizontal sections that resemble the steps of a staircase.

Within each interval, the output remains constant. At certain boundary values, the output changes suddenly.

https://images.openai.com/static-rsc-4/wNzbq24ARL05Or4qAPlFLvDNDEc2D66fhTa-92pdv9EJXmfmvGlI3_uQ5k6BlIwT8Bil_XYIEFrGKiJ1BhIoUTuPfpkmVbWj6othXhkzxddvFBfJ0xJmrFj_nZt2laHLfoxkvgh04uBkv9Y1htCdcj0ewCcbJjjwtRmZiJiVK14gN8_XN-j9po1iwloOmujC?purpose=fullsize
 
https://images.openai.com/static-rsc-4/XUv3nk4QU9Qz9Xobb6sLG3bUiSSdUxcvdTEA1M-i4AmVGI7GH2i0rl8dZaM2XdQgtdoXh8n4clRB5esmBUBz8rQqx95GmjkoD2kIkshF6mf9z2b7LrJ7SKVbxWcfKWHXLDPGuTPHOwvr3wc1sJAxIfYy1RKCRv3AZN0vdCTfydkpReb3H1YOe0kN4Ekem3C6?purpose=fullsize
 
https://images.openai.com/static-rsc-4/wf_H-XO4Xt5fK88jrx6a7ZbWDTQ6n2hOTVG8fMMeA0fpANWJhnvKFlZ97KdCuCSaEOjMtdSU_jbHEnr3Qr7eK88wubZTTpygkvNqq3fR2oxRoHCchG0xEgxRlW-LVwPgZwlW2so5Qs8GBjmm7vSjzI80vXqcNAR_fJrdfFqSvxCZKUt1oiHoQLbwgl-vDDLh?purpose=fullsize
 
7

Consider:

f(x) = 2 when 0 ≤ x < 1

f(x) = 4 when 1 ≤ x < 2

f(x) = 6 when 2 ≤ x < 3

The outputs are:

Input (x) Output f(x)
0.2 2
0.8 2
1.0 4
1.5 4
2.0 6
2.7 6

Notice that the output stays the same over an interval before jumping to a new value.

This produces the characteristic staircase appearance.

Interpreting Step Graphs

Step graphs are particularly useful when values change according to categories or levels.

Consider a delivery company that charges according to package mass.

Package Mass Delivery Cost
0 < m ≤ 1 kg $5
1 < m ≤ 2 kg $8
2 < m ≤ 3 kg $11
3 < m ≤ 4 kg $14

A package weighing 0.5 kg costs $5.

A package weighing 0.9 kg also costs $5.

However, a package weighing 1.2 kg costs $8.

The price jumps when the package moves into a different weight category.

https://images.openai.com/static-rsc-4/8ojAVU53DsXQtwv8dfavzxe4sNHft7Bosn_AuzXc9U1TQgr7CiDlZUH9Sbm55ySY7PrRxBaqZ_BVkqkBFXbeRfEKOOUujAyvVjZutXjSiTFM3Q1b4hXlm_xU4-u8TJUtfzZzj7GB-HhNmSkl9LzzMdDJDqrXzFf91AH_MSAdb4GiGVDAMU6KCrQcdtmZF50p?purpose=fullsize
 
https://images.openai.com/static-rsc-4/SF4bIVCLtmtUC9zNtZznTHKZSlXjVROA2wIleD18aiiDs4Mgmsd1DRrejvGSBvNSB8tFR14t_3AvImdQqa_YU-wFKtskQUwV55F13O-M5153DyWCLCkZKKzPT7X_hu8x9DmBE-S1Z6v2-TFZt7pHmTGAce0-ATkSgx09a1t5PJcJbEjMSNc2q1_NwsrZOwzH?purpose=fullsize
 
https://images.openai.com/static-rsc-4/YE-URl9ORmDb6o82UbyJDaKtirqG4Hmisop2fVtIHq4yblCUapBO0Tc5vuCG7wbrvgN9eLwy7p64VXp7uvPyf-mldFNW708Cw9-jq0ohFxm7fDrIpf2EzcMtBc-jrblliIsP4ViyoepJYbnpAHDVQ0qvXMe_R9xd0VtSs21eA4yImEmIr_luGoo16Vg4E832?purpose=fullsize
 
6

Important Observation

A step function does not necessarily increase.

Some step functions decrease, while others move both upward and downward.

The defining characteristic is that the output remains constant over intervals.

Why Piecewise Functions Are Useful

Piecewise functions are useful because many real-world situations do not follow one mathematical rule everywhere.

For example, consider a taxi company.

A taxi might charge:

  • A fixed starting fee
  • A particular rate for the first 5 km
  • A different rate for distances beyond 5 km

A single linear equation may not describe the entire journey accurately.

Instead, we can use different equations for different distance intervals.

Piecewise functions allow us to represent these changes while still describing the complete situation as one function.

They are commonly used in:

  • Transportation and delivery pricing
  • Electricity and water billing
  • Income tax calculations
  • Parking fees
  • Mobile phone plans
  • Manufacturing and production costs
  • Temperature control systems
  • Computer programming

Real-Life Example: Parking Fees

Imagine a parking garage with the following charges:

Parking Time Cost
0 < t ≤ 1 hour $3
1 < t ≤ 3 hours $6
3 < t ≤ 6 hours $10
6 < t ≤ 12 hours $15

This situation can be represented by a step function.

https://images.openai.com/static-rsc-4/TSaQF7vb7g4XNhTMfl8MMGHWF-V70RcWhJ2EzYLlVTUJeGsvRRx2GT54ms428dmqtfr0TP7eg8Dbr8JuJPOyKSivatK22WHhSGWt1N4_9Sg-l_nxzo6r_oZSIGvOz5x3n2yZSTtSBk9cLv6qgCkfzNXObU-smUcHpDpLkWMsoJWhHKMI4z5mVqBXX0bY28f5?purpose=fullsize
 
https://images.openai.com/static-rsc-4/9CSaxcgGazseHp_BLfRQyQYqT0oFqz6Tvj2HKuABRI8JywlQeHHVcUCO66onjfDCvcLsJhdYoKP9HRxx025lRH80cnly8LRmiAmq2cv2KyKtqsleKUSWlSpGoNF_PobeUwiWDgvCT7CC9AbQCvTv_wWkz_UOpSvaIhY8zFlKiaWcHTjqRakZhlAdf3R0InkO?purpose=fullsize
 
https://images.openai.com/static-rsc-4/xPMcxL9k7sdN3eKq_XUzirC8TJcGHAdP_CDmsgzRbbiE-fuajdnyZ5JbS0HdYJydAFwr4z_-VmcbbbWbC9uhyMt6R7XKAMhdO3JIN5AX7Ls7_EE-2WcBQvUfoRLGS0lMTPw4lh-Q6P1lCNaXQiuNtxJQw4BkWjEldqFYEhEIYp_VWPskL9UwvOHPd_y5jESy?purpose=fullsize
 
5

Example Questions

How much does parking for 2 hours cost?

Since 1 < 2 ≤ 3:

Cost = $6

How much does parking for 5 hours cost?

Since 3 < 5 ≤ 6:

Cost = $10

What happens when parking time increases from 3 hours to 3.1 hours?

The price increases from $6 to $10.

This sudden increase is represented by a jump in the step graph.

Real-Life Example: Mobile Data Plans

Suppose a mobile phone company offers the following pricing:

Data Usage Monthly Cost
0–5 GB $20
More than 5–10 GB $30
More than 10–20 GB $45

Assume these are fixed charges for each usage category.

A customer using 4 GB pays $20.

A customer using 8 GB pays $30.

A customer using 18 GB pays $45.

The cost remains constant within each category.

This is another example of a step function.

Real-Life Example: Income Tax

Income tax systems often use different tax rates for different income ranges.

For example, a simplified tax system might use:

  • 0% on the first $10,000
  • 10% on the next $20,000
  • 20% on income above $30,000

This is a piecewise relationship because different rates apply to different portions of income.

However, the total tax owed does not normally jump suddenly when someone enters a higher tax bracket.

Instead, the total tax generally increases continuously, with the slope changing at the boundaries.

This illustrates an important distinction:

Not every piecewise function is a step function.

Continuous and Discontinuous Piecewise Functions

Piecewise functions may be continuous or discontinuous.

Continuous Piecewise Functions

A continuous piecewise function has sections that connect without a jump or break.

For example:

f(x) = x + 2 when x < 3

f(x) = 2x − 1 when x ≥ 3

At x = 3:

First rule approaches 5.

Second rule gives 5.

Because the sections meet at the same point, the graph is continuous at x = 3.

Discontinuous Piecewise Functions

A discontinuous function has a break, gap, or jump.

For example:

f(x) = 2 when x < 3

f(x) = 7 when x ≥ 3

The output jumps from 2 to 7 at x = 3.

https://images.openai.com/static-rsc-4/B0rznAGn1nsVunRUYCzBmjvQMUdT6IVbdUEkin5R9-sd__wcX9446gXd8dWLiCQP2CBdt7XFdKvAeRgiQIKEaeM9PEZCufK9N7MbZm_z-BvxIi0R7lhsw5wWGzX2gHqe6lyEJzw7iidcKczhDrKC7Xk5PkO44_J4acVpNkP_sZe4RLn1CvZYOQMe5SCmOlDV?purpose=fullsize
 
https://images.openai.com/static-rsc-4/qjpT-2InR4Jqu5Z_9HrkwWVPgHE7L1NO0hxQgn4wWWEBYwSbMe1hjDOVAifqutEeyjIwPk84MbJBP_IG_QwCjnntsIVwOYPryBB65zZJvZ19ORe_gCZN2FZn2uDtdFoH_oKr-WIATDlyHo_imXSSQpDmDbow9kLzuuPwCbOJ9ibhL8AXblK8JCTfVOGkOAZ5?purpose=fullsize
 
https://images.openai.com/static-rsc-4/4qeoIYikhOMJHtuNQF2xNikflMMi5iYQ7Z8AnriYcxGD5LEDvP1R4GTzxb_OJla5t4daKD1g_ht96Hw4cBsNTTsxFer8P0Aw3D2nsyveZx_7T4umocXweQXXkdRg8oH7lkXGoiJ7bzaM29MPNCmcjbp2hvfyiHIz1mRc8XJh88uNgWpM-6O5FjOnfFJq8ido?purpose=fullsize
 
9

Step functions typically contain jump discontinuities at the boundaries between different levels.

Domain and Range of Step Functions

The domain is the set of possible input values.

The range is the set of possible output values.

Consider:

f(x) = 5 when 0 ≤ x < 2

f(x) = 8 when 2 ≤ x < 4

f(x) = 12 when 4 ≤ x ≤ 6

Domain

The function is defined for every input between 0 and 6, including both endpoints.

Domain:

0 ≤ x ≤ 6

Range

The only possible outputs are:

5, 8, and 12

Range:

{5, 8, 12}

Notice that the range does not include every number between 5 and 12.

This is common for step functions because their outputs are restricted to particular levels.

Comparing Piecewise and Step Functions

Feature Piecewise Function Step Function
Uses different rules Yes Yes
Can contain sloping lines Yes No
Can contain curves Yes No
Contains horizontal sections Sometimes Yes
May have jumps Yes Yes
Output remains constant within each piece Not necessarily Yes
Real-world examples Tax, taxi fares, pricing Parking fees, shipping categories

Every step function is a piecewise function, but not every piecewise function is a step function.


Common Mistakes

Using the wrong rule

Always determine which interval contains the input before calculating the output.

Ignoring open and closed circles

An open circle represents an excluded endpoint. A closed circle represents an included endpoint.

Assuming all piecewise functions are step functions

Step functions contain horizontal sections, but other piecewise functions can contain sloping lines and curves.

Connecting sections that should remain separate

A jump between two pieces is intentional. Do not automatically connect the endpoints.

Confusing domain and range

Domain describes possible inputs. Range describes possible outputs.

Assuming step functions always increase

Step functions can increase, decrease, or change in both directions.


Key Terms

Piecewise Function: A function defined by different mathematical rules over different parts of its domain.

Step Function: A piecewise function consisting of constant horizontal sections, often with jumps between them.

Function: A mathematical relationship in which every input has exactly one output.

Input: The independent variable, usually represented by x.

Output: The dependent value produced by a function, usually represented by f(x) or y.

Interval: A set of input values between specified boundaries.

Boundary: A value where one section of a piecewise function ends or another begins.

Open Circle: A graph symbol indicating that a particular endpoint is excluded.

Closed Circle: A graph symbol indicating that a particular endpoint is included.

Domain: The complete set of allowed input values for a function.

Range: The set of output values produced by a function.

Continuous Function: A function whose graph has no break or jump over the interval being considered.

Discontinuous Function: A function containing a break, gap, or jump.

Constant Function: A function whose output remains unchanged as the input varies.

Jump Discontinuity: A sudden change between two different output levels at a boundary.


Check Your Understanding

1. What is a piecewise function?

2. How does a step function differ from other piecewise functions?

3. Explain the difference between an open circle and a closed circle on a graph.

4. Consider:

f(x) = x + 4 when x < 3

f(x) = 2x when x ≥ 3

Find:

a) f(1)

b) f(3)

c) f(5)

5. A parking garage charges $4 for up to 2 hours, $7 for more than 2 hours up to 5 hours, and $12 for longer stays.

How much would someone pay for:

a) 1 hour?

b) 4 hours?

c) 6 hours?

6. Why is a parking fee schedule often represented by a step function rather than a straight line?

7. Can a piecewise function contain both a horizontal section and a sloping section? Explain.

8. Give two real-world examples of piecewise functions.

9. Explain why every step function is a piecewise function, but not every piecewise function is a step function.

10. Describe what happens to the graph of a step function when the input crosses a boundary between two different levels.


Key Takeaways

  • Piecewise functions use different rules for different intervals of input values.
  • The conditions associated with each rule determine which equation should be used.
  • Piecewise graphs may contain lines, curves, horizontal sections, gaps, or jumps.
  • Open circles indicate excluded endpoints, while closed circles indicate included endpoints.
  • To determine an output from a graph, locate the input on the x-axis and read the corresponding y-value.
  • Step functions are special piecewise functions consisting of horizontal sections.
  • Step functions maintain constant outputs within intervals and may change suddenly at boundaries.
  • Piecewise functions may be continuous or discontinuous.
  • The domain represents possible inputs, while the range represents possible outputs.
  • Piecewise functions are useful for representing real-world situations where mathematical relationships change under different conditions.
  • Common applications include parking fees, shipping costs, utility pricing, income taxes, and mobile data plans.
  • Understanding piecewise functions helps us interpret graphs, calculate outputs, and model situations that cannot be described accurately by a single mathematical rule.