Sub topic 5
Negative and Fractional Inputs
Prerequisites and the substitution rule
This chapter assumes you can use PEMDAS, work with fractions and exponents, and solve simple algebraic equations. You should also know that a function is a rule that maps an input to an output.
Consider the defined operation
a★b=2a+b^2.The symbol ★ has no standard meaning here. Use only the rule given in the question. To evaluate \(a★b\), substitute the first input for \(a\), substitute the second input for \(b\), and then follow the order of operations.
For example:
3★4=2(3)+4^2=6+16=22.The same process works for negative and fractional inputs. The main challenge is keeping the substituted values grouped correctly.
Negative inputs: keep the parentheses
When a negative number replaces a variable, put it in parentheses. This is especially important when the variable is squared.
For example:
(-2)★(-3)=2(-2)+(-3)^2.Now calculate each part:
2(-2)+(-3)^2=-4+9=5.The expression \((-3)^2\) equals \(9\). Without parentheses, \(-3^2\) is usually interpreted as \(-(3^2)=-9\). The parentheses show that the whole negative number is being squared.
A negative first input affects the linear term \(2a\). A negative second input does not make \(b^2\) negative, because squaring a real number produces a nonnegative result.
| Expression | Correct interpretation | Value |
|---|---|---|
| \((-3)^2\) | Square the whole negative number | 9 |
| \(-3^2\) | Negate \(3^2\) | -9 |
| \(2(-3)\) | Multiply 2 by -3 | -6 |
Use a similar rule for other powers. For example, \((-2)^3=-8\), while \(-2^3=-8\) happens to have the same value because the exponent is odd. Do not rely on that coincidence. Parentheses make the intended operation clear.
def star(a, b):
return 2 * a + b ** 2
print(star(-2, -3)) # 2*(-2) + (-3)**2 = 5Fractional inputs: calculate exactly
Fractions are substituted just like integers. Keep the fraction grouped when it is raised to a power.
Evaluate:
\frac12★\left(-\frac34\right).Substitute into the definition:
2\left(\frac12\right)+\left(-\frac34\right)^2.Then simplify:
1+\frac9{16}=\frac{16}{16}+\frac9{16}=\frac{25}{16}.The negative sign disappears from the squared fraction, but the first term remains positive because the first input is positive.
For GRE work, exact fractions are usually safer than decimals. Exact values prevent rounding errors and make comparisons easier.
from fractions import Fraction
def star(a, b):
return 2 * a + b ** 2
a = Fraction(1, 2)
b = Fraction(-3, 4)
print(star(a, b)) # 25/16A reliable checking routine
When an input is negative or fractional, use this sequence:
- Copy the definition.
- Replace every variable with its value in parentheses.
- Apply exponents before addition or subtraction.
- Simplify multiplication and division.
- Combine terms and check the sign.
The diagram shows the order.
Common errors
Do not change the definition because the inputs are negative. In \(a★b=2a+b^2\), the coefficient 2 and exponent 2 remain unchanged.
Do not swap the inputs. In general,
(-2)★3=2(-2)+3^2=5,but
3★(-2)=2(3)+(-2)^2=10.Do not square the entire expression unless the definition tells you to. The rule is \(2a+b^2\), not \((2a+b)^2\).
Exercise
Given a★b = 3a - b², evaluate (-1/2)★(-4).
Show answer
3(-1/2) - (-4)² = -3/2 - 16 = -35/2.