Symbolic Operation Ability
In previous chapters, we learned various rules and concepts. In this chapter, we will examine yourproficiency, and see whether you can derive the formulas yourself.
This ability directly determines whether you can follow the derivations in a paper, rather than getting stuck where the author skips steps. Every knowledge point is accompanied by interactive demonstrations, especially the geometric split animation of (a+b)², which makes it clear in one viewing where the "cross term 2ab" comes from.
Why "Symbolic Operation Ability" Matters
When reading papers, you often encounter this situation: the author writes "after simplification, we obtain...", skipping three to five steps in between.
If your symbolic manipulation is not fluent enough, these skipped steps will directly keep you out of the door.
If you are fluent, you can fill in these steps yourself and truly "keep up with" the author's reasoning, rather than passively accepting the conclusion.
For the same rule, "knowing it" and "being able to use it fluently with your eyes closed" are two levels of ability. This chapter trains the latter.
From (a+b)² to Multivariate Expansion
The Most Basic Identity
Geometric Perspective: Why There's an Extra "2ab"
holdThink of it as "the area of a square with side length a+b", and cut this square into 4 pieces:
| Region | Shape | Area |
|---|---|---|
| Top-left corner | Square with side length a | |
| Top-right corner | Rectangle with length b and width a | |
| Bottom-left corner | Rectangle with length a and width b | |
| Bottom-right corner | Square with side length b |
Adding up the four areas。
This "2ab" doesn't appear out of thin air; it comes from the two crossed rectangles. Click the "Expand" button below to see how the four areas separate.
Generalizing to Three Variables
According to the rule that "every pair of variables produces a cross term", you can directly write:
Derivation logic: treatas, and multiply each term with each term pairwise when expanding.
Multiplying identical variables gives the square term (), multiplying different variables occurs twice (e.g.,and), after combining we get。
Generalizing to Vectors
This rule repeatedly appears in vector operations in another form, e.g., computing the squared norm of the difference of two vectors:
The essence is to replace the"numbers" inside with "vectors", and "multiplication" with "dot product".
When you see a similar expansion in a paper, you can directly recall the rule learned here—new formulas are often old rules in a new guise. This is exactly how "symbolic manipulation ability" helps you "see through" new formulas.
Examples
# Idea: plug in a few random numbers and see if both sides of the equation are equal.
for a, b in [(2, 3), (5, 1), (0.5, 2.5), (-1, 4)]:
lhs = (a + b) ** 2 # Left side: (a+b)²
rhs = a ** 2 + 2 * a * b + b ** 2 # Right side: a² + 2ab + b²
print(a, b, abs(lhs - rhs) < 1e-12)
# Also verify the vector version: ‖x - y‖² = ‖x‖² - 2x·y + ‖y‖²
import math
x, y = (3, 4), (1, 2)
lhs = (x[0]-y[0])**2 + (x[1]-y[1])**2
rhs = (x[0]**2 + x[1]**2) - 2*(x[0]*y[0] + x[1]*y[1]) + (y[0]**2 + y[1]**2)
print(abs(lhs - rhs) < 1e-12)
Running the above code outputs:
2 3 True 5 1 True 0.5 2.5 True -1 4 True True
This "random substitution verification" method is very practical: when you forget formula details, plugging in a few numbers can confirm whether the version you remember is correct.
Exercise: expandand。
Click to see the answer
Separately substituteandintoand you're done.
Simplification, Transformation, Completing the Square
Completing the Square: Turning the General Form into "Vertex Form"
The goal of completing the square is to turnthis kind of "missing a piece" expression into a complete square:
Example: complete the square forto get。
Verification: expand, they are indeed equal.
Two typical uses of completing the square:
| Use | Method | Example |
|---|---|---|
| Find the vertex of a quadratic function | See the vertex (-3, -7) directly, no need to graph or differentiate | |
| Complete the square to simplify the derivation | Turn a complex polynomial into a square term by completing the square | Intermediate steps in least squares and maximum likelihood estimation for the normal distribution |
General Approach to Simplification
When encountering a complex expression, usually try in this order:
| Order | Technique | Explanation |
|---|---|---|
| 1 | Combine like terms | Combine terms with the same variable exponents |
| 2 | Factor out common factors | Find the factors common to all terms and pull them out |
| 3 | Use identities | Apply、such as ready-made formulas |
| 4 | Substitution | Replace recurring complex sub-expressions with a new variable |
Example of substitution method: Simplify。
令 t = x² + 1
原式 = t² - 3t + 2 = (t-1)(t-2)
代回 t:
= (x²+1-1)(x²+1-2)
= x² · (x²-1)
= x⁴ - x²
Whether You Can Derive Formulas Yourself Is the Watershed
"Understanding" and "Being Able to Derive" Are Two Different Levels of Ability
| Level | Description |
|---|---|
| Can read and understand | While looking at the derivation steps, you can understand "why this step is valid" |
| Can derive | Close the book and you can walk through those steps yourself |
Many people get stuck on reading papers, not because of "new knowledge", but because of this level: the formulas use only rules from the first three chapters, but you need to organize the correct sequence of steps yourself without hints.
Complete Derivation Exercise: The Minimum of Mean Squared Error
Problem: Given n data points, find a constant c such that the "sum of squared distances" from all points to cis minimized; find the optimal c.
Derivation process:
设 f(c) = Σᵢ (xᵢ - c)²
展开每一项(用到 (a-b)² 公式):
f(c) = Σᵢ (xᵢ² - 2cxᵢ + c²)
= Σᵢ xᵢ² - 2c·Σᵢxᵢ + n·c² (把 Σ 拆到每一项,c 是常数可以提出来)
这是关于 c 的二次函数,开口向上(c² 系数为 n > 0),
顶点(最小值点)在 c = -B/2A,这里 B = -2Σxᵢ,A = n
代入:c = -(-2Σxᵢ) / (2n) = Σxᵢ / n
Conclusion: The optimal c is exactly themean (average) of all data points.。
This derivation uses only knowledge from this chapter and Chapter 1 (expanding squares, Σ summation, and the vertex formula of quadratic functions), yet it yields the important statistical conclusion of "why the mean is the optimal point that minimizes squared error."
Drag the slider and verify by hand: how the sum of squared distances increases when c deviates from the mean.
Examples
data = [1, 3, 4, 8, 9]
mean = sum(data) / len(data)
def sq_error(c):
"""f(c) = Σ(xᵢ - c)²"""
return sum((x - c) ** 2 for x in data)
print(mean) # Mean = 5
print(sq_error(mean)) # Error when c = the mean
# Compare several c values that deviate from the mean: the error is larger in all cases
for c in [0, 3, 5, 7, 10]:
print(c, sq_error(c))
Running the above code produces the following output:
5.0 46.0 0 171 3 66 5 46 7 66 10 171
Note that the errors for c=3 and c=7 are equal (both 66) -- they are the same distance from the mean of 5, which reflects the parabola's "symmetry about the vertex."
Exercise: Try to independently re-derive the process of "the mean minimizing squared error" without looking at the text above, using only three tools: the square expansion formula, the linearity of Σ, and the vertex formula for quadratic functions.
Click to view the answer
Expand, identify it as a quadratic function opening upward, with vertex, which is the mean.
Chapter Summary
| Skills | Core idea in one sentence |
|---|---|
| (a+b)² expansion | Geometrically, it is "cutting a square"; the cross term comes from the product of two directions, and it can be generalized to multiple variables and vectors |
| Completing the square | Turn an expression "missing a piece" into a perfect square, used for finding the vertex and simplifying derivations |
| Simplification approach | Combine like terms → factor out common factors → apply identities → substitution |
| Independent derivation | Being able to walk through a derivation again without looking at the answer is the watershed for understanding formulas in papers |