Tutorials › Calculus III › Piecewise Formulas and Branch Domains

Domains and Function Representations · Tutorial 215 of 999

Piecewise Formulas and Branch Domains

Match each input to its branch, check the branch formula’s restrictions, and assemble the full domain from the inputs the branches actually cover.

Beginner 9 min read

What You'll Learn

  • Identify the branch condition that applies to a given input.
  • Evaluate a branch formula only after checking its condition.
  • Distinguish branch conditions from restrictions imposed by the formulas.
  • Determine the domain covered by several branches.
  • Recognize gaps, overlaps, and undefined values in a piecewise definition.

Why Piecewise Formulas Need Careful Reading

A scalar function can use different formulas for different parts of its input space. This is useful when one rule describes one region and another rule describes a different region. To evaluate such a function correctly, you must first find the branch whose condition matches the input, then use that branch’s formula.

The branch conditions also determine which inputs are covered. They may cover the entire intended input space, leave some inputs out, or overlap. In addition, an expression in a branch can have restrictions of its own. A complete domain check must account for both the conditions and the formulas.

Definition: A piecewise-defined scalar function is specified by giving one or more conditions on the input and an associated formula for each condition. At an input, use a formula only when its associated condition is satisfied. The domain consists of the inputs for which the piecewise definition assigns a valid value.

How to Evaluate a Piecewise Function

For a function of two variables, an input is an ordered pair \((x,y)\). Each branch condition describes which pairs may use its formula. To evaluate the function at a particular pair, substitute both coordinates into each condition and determine which condition is true. Then substitute into the corresponding formula.

For example, a condition such as \(x\leq 0\) depends only on the first coordinate. A condition such as \(x^2+y^2\leq 4\) depends on both coordinates. In either case, the condition is tested at the input pair itself; it is not a condition to be checked after choosing a formula.

Worked Example: Selecting a Branch at the Boundary

Let \(f:\mathbb{R}^2\to\mathbb{R}\) be given by

$$ f(x,y)= \begin{cases} x^2+y, & x\leq 0,\\ 2x-y, & x>0. \end{cases} $$

Evaluate \(f(-2,3)\), \(f(0,3)\), and \(f(2,3)\).

For \((-2,3)\), the first coordinate is \(-2\), and \(-2\leq 0\). The first branch applies:

$$ f(-2,3)=(-2)^2+3=4+3=7. $$

For \((0,3)\), the first coordinate is \(0\). Since \(0\leq 0\), the first branch applies, including at equality:

$$ f(0,3)=0^2+3=0+3=3. $$

For \((2,3)\), the first coordinate is \(2\), and \(2>0\). The second branch applies:

$$ f(2,3)=2(2)-3=4-3=1. $$

Check each result against its condition: \(-2\leq0\), \(0\leq0\), and \(2>0\), respectively. The values \(7\), \(3\), and \(1\) therefore come from the correct branches.

Branch Conditions and Formula Restrictions

A branch condition tells you where a formula is intended to apply. It does not automatically guarantee that the formula is defined at every input in that region. For example, if a branch contains a fraction, its denominator must be nonzero. If it contains an even root, the radicand must be nonnegative. If it contains a logarithm, its argument must be positive.

These restrictions are imposed by the formula itself. To find the valid inputs for a branch, combine its stated condition with all restrictions required by its expression. The complete domain is the collection of valid inputs from every branch. A condition in one branch cannot be used to justify a formula belonging to another branch.

Domain rule: For each branch, take the inputs satisfying both its branch condition and the formula’s own domain restrictions. The function’s domain is the union of the valid inputs from all branches. Any input not covered by a valid branch is outside the domain.

Worked Example: A Branch with a Logarithm

Consider the rule

$$ g(x,y)= \begin{cases} \sqrt{4-x^2-y^2}, & x^2+y^2\leq 4,\\ \ln(x-y), & x^2+y^2>4 \text{ and } x>y. \end{cases} $$

Evaluate \(g(1,1)\), \(g(2,0)\), and determine whether \(g(0,2)\) is defined.

At \((1,1)\), the squared distance expression is

$$ 1^2+1^2=2\leq4. $$

Thus the square-root branch applies. Its radicand is \(4-2=2\), which is nonnegative, so the expression is defined:

$$ g(1,1)=\sqrt{4-1^2-1^2}=\sqrt{2}. $$

At \((2,0)\), the branch test gives

$$ 2^2+0^2=4, $$

so the first condition \(x^2+y^2\leq4\) applies, including equality. Therefore,

$$ g(2,0)=\sqrt{4-2^2-0^2}=\sqrt{0}=0. $$

At \((0,2)\), \(0^2+2^2=4\), so the first branch condition is satisfied. The second branch condition is not satisfied, because it requires \(x^2+y^2>4\), and \(4\) is not greater than \(4\). Therefore the value is assigned by the first branch:

$$ g(0,2)=\sqrt{4-0^2-2^2}=\sqrt{0}=0. $$

In particular, it would be incorrect to try the logarithm at this point: its branch condition does not apply. To see the logarithm branch’s separate restrictions, its condition requires both \(x^2+y^2>4\) and \(x>y\). The latter ensures \(x-y>0\), so the logarithm has a positive argument. The first branch already ensures its radicand is nonnegative. Together, the two branches cover the disk \(x^2+y^2\leq4\) and the part outside it where \(x>y\); other points outside the disk are not covered.

Determining the Full Domain

A reliable domain analysis can be done branch by branch. First record the condition attached to each formula. Next, find the restrictions required by that formula. Combine the condition and restrictions for that branch. Finally, collect the valid regions from all branches and look for any gaps.

1
List the branches.
Write down each formula together with the condition that selects it.
2
Check each formula.
Identify restrictions such as nonzero denominators, nonnegative even-root radicands, or positive logarithm arguments.
3
Combine within each branch.
An input is valid for a branch only if it satisfies its condition and its formula’s restrictions.
4
Collect the valid regions.
The domain consists of all inputs valid for at least one branch. Check whether any inputs are left uncovered.

Worked Example: A Denominator Restricts One Branch

Let

$$ h(x,y)= \begin{cases} \dfrac{x+y}{x-y}, & x>0,\\ x^2+y^2, & x\leq0. \end{cases} $$

Find the domain and evaluate \(h(2,1)\), \(h(0,2)\), and \(h(2,2)\).

In the first branch, the condition is \(x>0\). The denominator must also be nonzero, so \(x-y\ne0\), or equivalently \(y\ne x\). Thus this branch is valid when \(x>0\) and \(y\ne x\). In the second branch, \(x\leq0\), and the polynomial \(x^2+y^2\) is defined for every real \(y\). Hence the domain includes all points with \(x\leq0\), and points with \(x>0\) except those on the line \(y=x\).

At \((2,1)\), \(2>0\), so use the fraction. Its denominator is \(2-1=1\), which is nonzero:

$$ h(2,1)=\frac{2+1}{2-1}=\frac{3}{1}=3. $$

At \((0,2)\), \(0\leq0\), so the polynomial branch applies:

$$ h(0,2)=0^2+2^2=0+4=4. $$

At \((2,2)\), the first branch condition \(2>0\) is satisfied, but its denominator is \(2-2=0\). The branch formula is therefore undefined at this input, and the second branch does not apply because \(2\leq0\) is false. Thus \(h(2,2)\) is undefined. This verifies why the branch condition alone is not enough to establish that an input belongs to the domain.

Coverage, Gaps, and Overlaps

Branches need not cover every possible input. If no condition applies to an input, the piecewise rule assigns no value there, so that input is not in the domain. A branch expression may also fail to be defined at an input even when its condition applies, as the fraction example showed.

Conditions can also overlap. If two conditions apply to the same input, a piecewise definition must make the value unambiguous. This is guaranteed if the instructions specify which branch takes priority, or if the applicable formulas give the same value throughout the overlap. If neither is established, the rule does not specify a unique function value there. Conditions such as \(x\leq0\) and \(x>0\) avoid overlap and cover all real first coordinates.

Pay special attention to equality symbols. In the first example, \(x\leq0\) includes the boundary \(x=0\), while \(x>0\) does not. The boundary input therefore uses exactly one branch. Replacing \(x\leq0\) by \(x<0\) would leave \(x=0\) uncovered unless another branch included it. The branch conditions, not an informal guess about which formula “looks right,” determine boundary membership.

A Short Justification of the Domain Rule

Why is the domain obtained by collecting the valid inputs from each branch? Consider any input. If the piecewise rule assigns it a value, the input must satisfy the condition of a branch used to assign that value. The corresponding formula must also be defined there. So every input in the domain belongs to the valid inputs for at least one branch.

Conversely, if an input satisfies a branch condition and that branch’s formula is defined there, the rule supplies a value at that input, provided the definition is unambiguous if another branch also applies. Thus that input is in the domain. The two directions establish that the domain consists precisely of the valid inputs from the branches, collected together.

Key takeaway: Do not evaluate a piecewise formula before matching its condition. Do not declare an input in the domain until you have checked both that a branch applies and that its formula is defined.

Common Mistake: Using a Formula from the Wrong Branch

For the function \(f\) in the first worked example, suppose someone evaluates \(f(-2,3)\) using the second formula \(2x-y\). The resulting calculation is

$$ 2(-2)-3=-4-3=-7. $$

The arithmetic is correct, but the result is not \(f(-2,3)\): the input has \(x=-2\), and \(-2\leq0\), so the first branch applies. The correction is

$$ f(-2,3)=(-2)^2+3=4+3=7. $$

The error came from choosing a formula without first checking its condition. A good habit is to write down the true branch condition before substituting into the formula.

Check Your Understanding

For each question, identify the relevant branch condition before evaluating or describing the domain.

  1. Let \(p(x,y)=x+y\) when \(x<1\), and \(p(x,y)=x-y\) when \(x\geq1\). Which branch gives \(p(1,4)\), and what is its value?
  2. For the same function \(p\), which branch gives \(p(0,4)\), and what is its value?
  3. A branch is defined by \(x>0\) and has formula \(\ln(x-y)\). What additional requirement on the input follows from the logarithm?
  4. A branch has condition \(x\leq0\) and formula \(\dfrac{1}{x-y}\). What restriction must be added to the condition for the formula to be defined?
  5. Explain what happens to an input for which no branch condition applies.