# Nakafa Framework: LLM
URL: https://nakafa.com/en/subject/high-school/11/mathematics/function-modeling/piecewise-function-modeling
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/subject/high-school/11/mathematics/function-modeling/piecewise-function-modeling/en.mdx
Output docs content for large language models.
---
import { getColor } from "@repo/design-system/lib/color";
import { LineEquation } from "@repo/design-system/components/contents/line-equation";
export const metadata = {
  title: "Piecewise Function Modeling",
  description: "Model real-world scenarios using piecewise functions. Learn tiered pricing, tax brackets, and multi-stage processes with step-by-step examples.",
  authors: [{ name: "Nabil Akbarazzima Fatih" }],
  date: "05/18/2025",
  subject: "Functions and Their Modeling",
};
## Understanding Piecewise Functions
A piecewise function is a function that is defined by several different equations on certain intervals of its domain. Each "piece" of the function applies to a specific part of the domain.
### Mathematical Definition
A piecewise function can be written in the form:
where  are intervals that form a partition of the function's domain.
**Characteristics of piecewise functions:**
- Consists of several different equations
- Each equation applies to a specific interval
- Can be continuous or discontinuous
- Intervals do not overlap
## Types of Piecewise Functions
### Linear Piecewise Functions
A linear piecewise function is a function where each piece is a linear function.
 {
        const x = -2 + i * 0.1;
        return { x, y: 2 * x + 3, z: 0 };
      }),
      color: getColor("PURPLE"),
      showPoints: false,
      labels: [{ text: "y = 2x + 3", at: 10, offset: [-1.5, 1, 0] }],
    },
    {
      points: Array.from({ length: 21 }, (_, i) => {
        const x = 0 + i * 0.1;
        return { x, y: -x + 3, z: 0 };
      }),
      color: getColor("ORANGE"),
      showPoints: false,
      labels: [{ text: "y = -x + 3", at: 10, offset: [1, 1, 0] }],
    },
    {
      points: Array.from({ length: 21 }, (_, i) => {
        const x = 2 + i * 0.1;
        return { x, y: 0.5 * x, z: 0 };
      }),
      color: getColor("CYAN"),
      showPoints: false,
      labels: [{ text: "y = 0.5x", at: 10, offset: [1, -0.5, 0] }],
    },
  ]}
  cameraPosition={[0, 0, 12]}
  showZAxis={false}
/>
The function above can be written as:
### Quadratic Piecewise Functions
Piecewise functions can also contain quadratic pieces or combinations of linear and quadratic functions.
 {
        const x = -3 + i * 0.1;
        return { x, y: x * x, z: 0 };
      }),
      color: getColor("VIOLET"),
      showPoints: false,
      labels: [{ text: "y = x²", at: 15, offset: [-1, -1, 0] }],
    },
    {
      points: Array.from({ length: 31 }, (_, i) => {
        const x = 0 + i * 0.1;
        return { x, y: 2 * x, z: 0 };
      }),
      color: getColor("TEAL"),
      showPoints: false,
      labels: [{ text: "y = 2x", at: 15, offset: [1, -1, 0] }],
    },
  ]}
  cameraPosition={[0, 0, 12]}
  showZAxis={false}
/>
## Continuity of Piecewise Functions
### Continuous Piecewise Functions
A piecewise function is said to be continuous if there are no "jumps" at the connection points between pieces.
Condition for continuity at point :
**Example of a continuous piecewise function:**
For continuity at :
- 
- 
- 
### Discontinuous Piecewise Functions
Discontinuous piecewise functions have "jumps" or "holes" at certain points.
      Example of a function with jump discontinuity at{" "}
      .
    >
  }
  data={[
    {
      points: Array.from({ length: 21 }, (_, i) => {
        const x = -2 + i * 0.1;
        return { x, y: x + 2, z: 0 };
      }),
      color: getColor("ROSE"),
      showPoints: false,
      labels: [{ text: "y = x + 2", at: 10, offset: [-1, 1, 0] }],
    },
    {
      points: Array.from({ length: 21 }, (_, i) => {
        const x = 1 + i * 0.1;
        return { x, y: 2 * x - 3, z: 0 };
      }),
      color: getColor("AMBER"),
      showPoints: false,
      labels: [{ text: "y = 2x - 3", at: 10, offset: [1, 1, 0] }],
    },
  ]}
  cameraPosition={[0, 0, 12]}
  showZAxis={false}
/>
## Modeling with Piecewise Functions
### Progressive Rates
Many real-world situations can be modeled with piecewise functions, such as progressive tax rates or tiered parking fees.
**Example: Electricity Rates**
An electricity company applies tiered rates:
- 0-50 kWh: Rp 1,000/kWh
- 51-100 kWh: Rp 1,500/kWh
- > 100 kWh: Rp 2,000/kWh
The mathematical model:
**Electricity cost table:**
| Usage (kWh) | 30     | 50     | 75     | 100     | 150     |
| ----------- | ------ | ------ | ------ | ------- | ------- |
| Cost (Rp)   | 30,000 | 50,000 | 87,500 | 125,000 | 225,000 |
### Staged Speed
**Example: Multi-Modal Journey**
Someone takes a journey with:
- Walking: 5 km/h for 0.5 hours
- Cycling: 15 km/h for 1 hour
- Driving: 60 km/h for 0.5 hours
Distance function with respect to time:
## Determining Piecewise Function Equations
To determine piecewise function equations from graphs or situations:
1. **Identify the intervals** of the domain
2. **Determine the equation** for each interval
3. **Check continuity** at connection points
4. **Write in piecewise notation**
**Example:**
From a graph showing:
- Line with slope 2 from x = -2 to x = 0
- Horizontal line y = 4 from x = 0 to x = 2
- Line with slope -1 from x = 2 to x = 4
Solution steps:
1. Interval 1: 
   - Passes through (-2, 0) with slope 2
   - Equation: 
2. Interval 2: 
   - Horizontal line
   - Equation: 
3. Interval 3: 
   - Passes through (2, 4) with slope -1
   - Equation: 
Piecewise function:
## Practice Problems
1. Determine the values of , , and  for the function:
   
2. An online taxi company applies the following rates:
   - Base fare: Rp 10,000 (for the first 2 km)
   - Km 3-10: Rp 4,000/km
   - Above 10 km: Rp 3,000/km
   Create a piecewise function model for the total cost!
3. Determine whether the following function is continuous at :
   
4. Sketch the graph of the function:
   
5. A worker is paid with the following system:
   - First 8 hours: Rp 50,000/hour
   - Overtime (9th hour onwards): Rp 75,000/hour
   If the maximum work is 12 hours/day, create a daily wage function!
### Answer Key
1. **Calculating function values:**
   For : since , use 
   
   For : since , use 
   
   For : since , use 
   
2. **Taxi fare model:**
   Let  be the distance in km, then:
   
     
   
   Or simplified:
   
     
   
3. **Checking continuity:**
   At :
   
     
     
     
   
   Since , the function is **continuous** at .
4. **Sketch of graph :**
   
         Graph of Function 
       >
     }
     description={
       <>
         Piecewise function with three parts: decreasing linear, quadratic, and
         constant
       >
     }
     data={[
       {
         points: Array.from({ length: 21 }, (_, i) => {
           const x = -2 + i * 0.1;
           return { x, y: -x + 2, z: 0 };
         }),
         color: getColor("PURPLE"),
         showPoints: false,
         labels: [{ text: "y = -x + 2", at: 10, offset: [0, 0.5, 0] }],
       },
       {
         points: Array.from({ length: 21 }, (_, i) => {
           const x = 0 + i * 0.1;
           return { x, y: x * x, z: 0 };
         }),
         color: getColor("ORANGE"),
         showPoints: false,
         labels: [{ text: "y = x²", at: 10, offset: [0, 0.5, 0] }],
       },
       {
         points: Array.from({ length: 21 }, (_, i) => {
           const x = 2 + i * 0.1;
           return { x, y: 4, z: 0 };
         }),
         color: getColor("CYAN"),
         showPoints: false,
         labels: [{ text: "y = 4", at: 10, offset: [0, 0.5, 0] }],
       },
     ]}
     cameraPosition={[0, 0, 12]}
     showZAxis={false}
   />
5. **Daily wage function:**
   Let  be the working hours, then:
   
     
   
   Or simplified: