# Nakafa Framework: LLM

URL: /en/subject/high-school/11/mathematics/function-composition-inverse-function/addition-subtraction-function
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/subject/high-school/11/mathematics/function-composition-inverse-function/addition-subtraction-function/en.mdx

Output docs content for large language models.

---

import { LineEquation } from "@repo/design-system/components/contents/line-equation";
import { getColor } from "@repo/design-system/lib/color";

export const metadata = {
  title: "Addition and Subtraction of Functions",
  description: "Learn how to add and subtract functions step-by-step with domain intersection rules. Master function operations through clear examples and practice problems.",
  authors: [{ name: "Nabil Akbarazzima Fatih" }],
  date: "04/27/2025",
  subject: "Function Composition and Inverse Function",
};

## Combining Functions

Imagine you have two function machines, let's call them machine <InlineMath math="f" /> and machine <InlineMath math="g" />. Each machine has its own rules, which are its function (<InlineMath math="f(x)" /> and <InlineMath math="g(x)" />) and the raw materials it can process (its domain, <InlineMath math="D_f" /> and <InlineMath math="D_g" />). We can combine these two machines to create a new machine using addition or subtraction operations.

<LineEquation
  title="Function Addition Visualization"
  description={
    <>
      Observe how the lines <InlineMath math="f(x)=x" /> and{" "}
      <InlineMath math="g(x)=2" /> are added to become{" "}
      <InlineMath math="(f+g)(x)=x+2" />.
    </>
  }
  data={[
    {
      points: Array.from({ length: 11 }, (_, i) => ({
        x: i - 5,
        y: i - 5,
        z: 0,
      })),
      color: getColor("AMBER"),
      labels: [{ text: "f(x)=x", at: 6, offset: [1, -0.5, 0] }],
    },
    {
      points: Array.from({ length: 11 }, (_, i) => ({ x: i - 5, y: 2, z: 0 })),
      color: getColor("SKY"),
      labels: [{ text: "g(x)=2", at: 8, offset: [1, 0.5, 0] }],
    },
    {
      points: Array.from({ length: 11 }, (_, i) => ({
        x: i - 5,
        y: i - 5 + 2,
        z: 0,
      })),
      color: getColor("VIOLET"),
      labels: [{ text: "(f+g)(x)=x+2", at: 9, offset: [1.5, -0.5, 0] }],
    },
  ]}
/>

## Addition of Two Functions

If we want to add function <InlineMath math="f" /> and function <InlineMath math="g" />, we simply add the results from each function for the same value of <InlineMath math="x" />. The result is a new function we call <InlineMath math="(f+g)" />.

<BlockMath math="(f+g)(x) = f(x) + g(x)" />

**Important note:** The combined machine <InlineMath math="(f+g)" /> can only process raw materials (values of <InlineMath math="x" />) that can be processed by _both_ original machines, <InlineMath math="f" /> and <InlineMath math="g" />. So, the domain (domain of origin) of the function <InlineMath math="(f+g)" /> is the intersection of the domain of <InlineMath math="f" /> and the domain of <InlineMath math="g" />.

<BlockMath math="D_{f+g} = D_f \cap D_g" />

This means that <InlineMath math="x" /> must be a member of <InlineMath math="D_f" /> **AND** also a member of <InlineMath math="D_g" />.

### Example of Addition

Suppose we have two functions:

1.  <InlineMath math="f(x) = x^2" />, with domain <InlineMath math="D_f = \{x | x \in \mathbb{R}\}" /> (all
    real numbers).
2.  <InlineMath math="g(x) = \sqrt{x+2}" />, with domain <InlineMath math="D_g = \{x | x \ge -2, x \in \mathbb{R}\}" /> (all
    real numbers greater than or equal to -2, because the square root cannot be
    negative).

**Step 1: Determine the resulting function from addition**

<BlockMath math="(f+g)(x) = f(x) + g(x) = x^2 + \sqrt{x+2}" />

**Step 2: Determine the domain of the resulting function**

We find the intersection of <InlineMath math="D_f" /> and <InlineMath math="D_g" />:

<div className="flex flex-col gap-4">
  <BlockMath math="D_{f+g} = D_f \cap D_g = \{x | x \in \mathbb{R}\} \cap \{x | x \ge -2, x \in \mathbb{R}\}" />
  <BlockMath math="D_{f+g} = \{x | x \ge -2, x \in \mathbb{R}\}" />
</div>

So, the resulting function from addition is <InlineMath math="(f+g)(x) = x^2 + \sqrt{x+2}" /> with domain <InlineMath math="\{x | x \ge -2, x \in \mathbb{R}\}" />.

## Subtraction of Two Functions

The process is similar to addition. To subtract function <InlineMath math="g" /> from function <InlineMath math="f" />, we subtract the result of <InlineMath math="g(x)" /> from <InlineMath math="f(x)" /> for the same value of <InlineMath math="x" />. The result is a new function <InlineMath math="(f-g)" />.

<BlockMath math="(f-g)(x) = f(x) - g(x)" />

Its domain is also the same as for addition, namely the intersection of the domain of <InlineMath math="f" /> and the domain of <InlineMath math="g" />. Why? Because again, the value of <InlineMath math="x" /> must be processable by both initial functions before it can be subtracted.

<BlockMath math="D_{f-g} = D_f \cap D_g" />

### Example of Subtraction

We use the same functions as in the addition example:

1.  <InlineMath math="f(x) = x^2" />, <InlineMath math="D_f = \{x | x \in \mathbb{R}\}" />
2.  <InlineMath math="g(x) = \sqrt{x+2}" />, <InlineMath math="D_g = \{x | x \ge -2, x \in \mathbb{R}\}" />

**Step 1: Determine the resulting function from subtraction**

<BlockMath math="(f-g)(x) = f(x) - g(x) = x^2 - \sqrt{x+2}" />

**Step 2: Determine the domain of the resulting function**
Its domain is the same as the domain of the addition result because the intersection rule is the same:

<BlockMath math="D_{f-g} = D_f \cap D_g = \{x | x \ge -2, x \in \mathbb{R}\}" />

So, the resulting function from subtraction is <InlineMath math="(f-g)(x) = x^2 - \sqrt{x+2}" /> with domain <InlineMath math="\{x | x \ge -2, x \in \mathbb{R}\}" />.

## Practice Problems

Given the functions <InlineMath math="f(x) = 2x - 1" /> with <InlineMath math="D_f = \{x | x \in \mathbb{R}\}" /> and function <InlineMath math="g(x) = x^2 + 3" /> with <InlineMath math="D_g = \{x | x \in \mathbb{R}\}" />.

1.  Determine <InlineMath math="(f+g)(x)" /> and its domain <InlineMath math="D_{f+g}" />.
2.  Determine <InlineMath math="(f-g)(x)" /> and its domain <InlineMath math="D_{f-g}" />.
3.  Calculate the value of <InlineMath math="(f+g)(2)" />.
4.  Calculate the value of <InlineMath math="(f-g)(-1)" />.

### Answer Key

1.  **Finding <InlineMath math="(f+g)(x)" />:**

    <div className="flex flex-col gap-4">
      <BlockMath math="(f+g)(x) = f(x) + g(x)" />
      <BlockMath math="= (2x - 1) + (x^2 + 3)" />
      <BlockMath math="= x^2 + 2x + 2" />
    </div>

    **Finding Domain <InlineMath math="D_{f+g}" />:**

    <div className="flex flex-col gap-4">
      <BlockMath math="D_{f+g} = D_f \cap D_g" />
      <BlockMath math="= \{x | x \in \mathbb{R}\} \cap \{x | x \in \mathbb{R}\}" />
      <BlockMath math="= \{x | x \in \mathbb{R}\}" />
    </div>

    So, <InlineMath math="(f+g)(x) = x^2 + 2x + 2" /> with domain all real numbers.

2.  **Finding <InlineMath math="(f-g)(x)" />:**

    <div className="flex flex-col gap-4">
      <BlockMath math="(f-g)(x) = f(x) - g(x)" />
      <BlockMath math="= (2x - 1) - (x^2 + 3)" />
      <BlockMath math="= 2x - 1 - x^2 - 3" />
      <BlockMath math="= -x^2 + 2x - 4" />
    </div>

    **Finding Domain <InlineMath math="D_{f-g}" />:**

    <div className="flex flex-col gap-4">
      <BlockMath math="D_{f-g} = D_f \cap D_g" />
      <BlockMath math="= \{x | x \in \mathbb{R}\} \cap \{x | x \in \mathbb{R}\}" />
      <BlockMath math="= \{x | x \in \mathbb{R}\}" />
    </div>

    So, <InlineMath math="(f-g)(x) = -x^2 + 2x - 4" /> with domain all real numbers.

3.  **Calculating <InlineMath math="(f+g)(2)" />:**

    We use the result from number 1: <InlineMath math="(f+g)(x) = x^2 + 2x + 2" />

    <div className="flex flex-col gap-4">
      <BlockMath math="(f+g)(2) = (2)^2 + 2(2) + 2" />
      <BlockMath math="= 4 + 4 + 2" />
      <BlockMath math="= 10" />
    </div>

4.  **Calculating <InlineMath math="(f-g)(-1)" />:**

    We use the result from number 2: <InlineMath math="(f-g)(x) = -x^2 + 2x - 4" />

    <div className="flex flex-col gap-4">
      <BlockMath math="(f-g)(-1) = -(-1)^2 + 2(-1) - 4" />
      <BlockMath math="= -(1) - 2 - 4" />
      <BlockMath math="= -7" />
    </div>
