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.
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
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:
For \((0,3)\), the first coordinate is \(0\). Since \(0\leq 0\), the first branch applies, including at equality:
For \((2,3)\), the first coordinate is \(2\), and \(2>0\). The second branch applies:
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.
Worked Example: A Branch with a Logarithm
Consider the rule
Evaluate \(g(1,1)\), \(g(2,0)\), and determine whether \(g(0,2)\) is defined.
At \((1,1)\), the squared distance expression is
Thus the square-root branch applies. Its radicand is \(4-2=2\), which is nonnegative, so the expression is defined:
At \((2,0)\), the branch test gives
so the first condition \(x^2+y^2\leq4\) applies, including equality. Therefore,
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:
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.
Write down each formula together with the condition that selects it.
Identify restrictions such as nonzero denominators, nonnegative even-root radicands, or positive logarithm arguments.
An input is valid for a branch only if it satisfies its condition and its formula’s restrictions.
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
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:
At \((0,2)\), \(0\leq0\), so the polynomial branch applies:
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.
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
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
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.
- 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?
- For the same function \(p\), which branch gives \(p(0,4)\), and what is its value?
- A branch is defined by \(x>0\) and has formula \(\ln(x-y)\). What additional requirement on the input follows from the logarithm?
- 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?
- Explain what happens to an input for which no branch condition applies.