[[TOC]]
Algebra Trigonometry Geometry
Number Sets
Exercises
Number
Rational
Integer
Complex
Implement a Vector
class to handle [vector] object based on the following public class interface.
using Number = double;
using Radians = double;
class Vector
{
public:
Vector(const size_t& n); // zero initializes values
Number& at(const size_t& index);
size_t getSize() const;
};
Given the implementation of a Vector
object, compute the [scalar product] of of a [number] and a [vector].
Vector scalar_product(const Number& c, const Vector& v);
Given the implementation of a Vector
object, compute the [dot product] of two [vectors].
Number dot_product(const Vector& u, const Vector& v);
Given the implementation of a Vector
object, compute the [magnitude] (often called length) of a [vector].
Number magnitude(const Vector& v);
Given the implementation of a Vector
object, compute the [magnitude] of a [vector].
Radians direction(const Vector& v);
Scalar Product Dot Product
Inverse Transpose Determinant Trace
Matrix
Implement a class Matrix
to handle [matrix] objects based on the following public class interface.
using Number = double;
struct Order { size_t m, n };
class Matrix
{
public:
Matrix(const size_t& m, const size_t& n); // zero initializes values
Number& at(const size_t& i, const size_t& j);
Order getOrder() const;
};
Hint: You might choose to store your matrix's data as an array of [mathematical vector] objects, or by computing the row/column offset if storing the data in a single array.
Given the implementation of a Matrix
, compute the [scalar product] of a [number] and a [matrix].
Matrix scalar_product(const Number& c, const Matrix& A);
Given the implementation of a Matrix
, compute the [dot product] of two [matrices].
Matrix dot_product(const Matrix& A, const Matrix& B);
Given the implementation of a Matrix
, compute its [trace].
Number trace(const Matrix& A);
Given the implementation of a Matrix
, compute its [determinant], where the matrix, A, is restricted to an [order] of 2x2.
Number determinant_2x2(const Matrix& A);
Given the implementation of a Matrix
, compute its [determinant].
Number determinant(const Matrix& A);
Guass-Jordan
What happens when elimination fails?
To be a vector space:
The word "space" means all linear combinations (of vectors, matrices or functions) stay inside the space.
A basis is a set of vectors that perfectly describe a space.
Every linear combination of vectors in a basis give different results.
Dimension is the number elements within a basis -- the number of independent columns of a space.
Full rank matrices have rank $r = m = n$
A subspace of a vector space is a set of vectors that satisfy:
Every subspace includes the zero vector. Because $cv = 0$ when $c = 0$.
Any space is a subspace of itself: eg. all of $\R^3$ is a subspace in $\R^3$.
Examples of spaces in $\R^3$:
A plane in 3 dimensional space is not $\R^2$. It is a plane inside $\R^3$
Examples of subspaces:
When we move into function space, linear differential equations replace linear algebraic equations.
The column space, $C(A)$, is all linear combinations of the columns of $A$ -- all possible vectors $AX$.
$Ax = b$ is solvable if and only if $b$ is in the column space of $A$.
The $r$ independent columns of $A$ are a basis for $C(A)$.
The rows of $A$ are the columns of $A^T$.
Therefore, the Row Space of $A$, $R(A)$ is the column space of $A^T$, $C(A^T)$.
The Null Space of $A$, $N(A)$, is found by the solutions to $Ax = 0$.
There are non-zero solution to $Ax = 0$ if $n > m$
The $n - r$ special solutions to $Ax = 0$ are a basis for $N(A)$.
The Left-Null Space is the null space of $A^T$.
The Null Space of $A^T$ is found by the solutions to $yA^T = 0$.
CR QR LU LDU
Given a [matrix], compute its [eigenvalues].
std::vector<Number> eigenvalues(const Matrix& A);
Given a [matrix] and an [eigenvalue], compute its corresponding [eigenvector].
Vector eigenvector(const Matrix& A, const Number& lambda);
std::vector<Number> eigenvalues(const Matrix& A)
{
Matrix I = identity_matrix(A.getOrder());
Variable lambda = 'l';
Expression expression = determinant(A - lambda*I);
return roots(expression, lambda);
}
Vector eigenvector(const Matrix& A, const Number& lambda)
{
Matrix I = identity_matrix(A.getOrder());
Matrix eigen_matrix = determinant(A - lambda*I);
return nullspace(eigen_matrix);
}