Matrices and Vectors
This chapter covers the following topics:
- Matrices and their operations
- Vectors
- Gradient, divergence, and curl
- Identities
- Newton’s method for root extraction
- Trapezoidal rule for numerical integration
- Simpson’s rule for numerical integration
Matrices and their operations
A matrix is a rectangular array of numbers arranged in rows and columns. We usually write an matrix (with rows and columns) as:
Addition and subtraction
You can add or subtract two matrices only if they have the same dimensions. The operation is done element by element:
Matrix multiplication
Matrix multiplication is not done element by element. Instead, each entry of the product comes from a row-by-column dot product.
If is an matrix and is a matrix, then is an matrix, and each entry is
Matrix multiplication is defined only when the number of columns of matches the number of rows of .
Example: multiplying two matrices
Find for and .
Each entry of comes from a row-by-column dot product:
Answer:
Determinant of a matrix
The determinant is defined for square matrices. It produces a single number that is used in several places, including checking whether a matrix is invertible.
For a matrix:
For a matrix:
Inverse of a matrix
A square matrix has an inverse only if its determinant is nonzero (that is, ). For a matrix , the inverse is found by swapping the diagonal entries, negating the off-diagonal entries, and dividing by the determinant:
Example: inverting a matrix
Find for .
First, compute the determinant: .
Since , the inverse exists:
Answer:
Identity matrix
An identity matrix is a square matrix with ones on the diagonal and zeros everywhere else:
It acts like the number 1 in matrix multiplication:
Properties of matrices
- Associative property:
- Distributive property:
- Commutative property (addition):
- Transpose of a product:
- Inverse property:
This section has outlined the main matrix operations and the key definitions used with square matrices.
Vectors
A vector is a quantity that has both magnitude and direction. In three dimensions, a vector is often written in component form as:
Where:
- are the components of the vector in the x, y, and z directions.
- are unit vectors in the x, y, and z directions, respectively.
Vector addition and subtraction
Addition
Vector addition combines components in the same direction:
Subtraction
Vector subtraction subtracts components in the same direction:
Example: magnitude of a resultant vector
Two vectors are given by and . Find the magnitude of the resultant vector .
The magnitude of a vector is , so:
Answer:
Dot product (scalar product)
The dot product of two vectors produces a scalar. It can be defined using magnitudes and the angle between the vectors:
Or computed directly from components:
- Result: Scalar
- Measures projection of one vector onto another.
Cross product (vector product)
The cross product of two vectors produces a vector perpendicular to both. Its magnitude depends on the angle between the vectors:
Where is the unit vector perpendicular to both and .
Using a determinant form:
- Result: Vector
- Direction follows the right-hand rule.
Angle between two vectors
You can find the angle between two nonzero vectors using the dot product:
Gradient, divergence, and curl
Gradient (∇f)
The gradient takes a scalar field and produces a vector field. The gradient points in the direction where increases most rapidly.
Divergence (∇· F)
The divergence takes a vector field and produces a scalar field:
- Measures the “outflowing-ness” of a vector field at a point.
Curl (∇× F)
The curl takes a vector field and produces another vector field:
- Measures the rotation or swirling strength of the field.
Identities
Vector algebra identities
Vector dot product properties
-
Unit vector dot products:
-
Perpendicular unit vectors:
Vector cross product properties
-
Unit vector cross products:
-
Cyclic permutation:
Vector calculus identities
-
Laplacian operator:
-
Curl of a gradient:
-
Divergence of a curl:
Newton’s method for root extraction
Newton’s method (also called the Newton-Raphson method) is an iterative numerical technique for finding roots of a real-valued function (that is, values of where ).
The iteration formula is:
- Choose an initial guess
- Compute successive approximations using the formula
- Stop when the difference is below a chosen tolerance
Example: approximating with Newton’s method
Find the positive root of (whose root is ), starting from .
Since , the iteration formula is:
Iteration 1:
Iteration 2:
Answer: After two iterations, , within of
Trapezoidal rule for numerical integration
The trapezoidal rule estimates a definite integral by approximating the graph of with straight-line segments, forming trapezoids.
Single application
For over :
This is just the composite trapezoidal rule with - a single trapezoid spanning the whole interval.
Composite trapezoidal rule
Divide the interval into equal subintervals of width , then:
Example: composite trapezoidal rule
Estimate using the composite trapezoidal rule with subintervals ().
The function values at are , , , , .
Answer: (the exact value is ; the trapezoidal estimate overshoots slightly here because is concave up).
Simpson’s rule for numerical integration
Simpson’s rule estimates a definite integral by fitting parabolas through points on the curve.
Single application
For over , with midpoint :
This is just the composite Simpson’s rule with - a single parabola fit across the whole interval, using the midpoint as the second node.
Composite Simpson’s rule
Let be even and :
Example: composite Simpson’s rule
Estimate using composite Simpson’s rule with subintervals ().
The function values at are , , , , . The odd-indexed nodes () get weight , and the even interior node () gets weight :
Answer: (this matches the exact value of - Simpson’s rule is exact for polynomials up to degree 3, which is why it outperforms the trapezoidal estimate of from the earlier example).