Getting started
Define a Vector Space¶
To define a subspace of R^n or C^n, use fn
V (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Dimension 3
Vector [c0, c1, c2]
You can provide a list of constraints
U (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[0, 1, 2]]
Dimension 1
Vector [0, c0, 2*c0]
Or specify a basis
W (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0]]
Dimension 2
Vector [c0, c1, 0]
Operations with Vectors¶
Check whether a vector is an element of a vector space
True
False
Generate a random vector from a vector space
[0, 2, 4]
[0, c0, 2*c0]
Find the coordinate vector representation of a vector
[1, 2]
[1, 2, 0]
[3/2, -1/2]
Check whether a list of vectors is linearly independent
True
False
Operations on Vector Spaces¶
Check for equality of two vector spaces
False
Check whether a vector space is a subspace of another
True
False
Take the sum of two vector spaces
U + W (Subspace of R^3)
-----------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Dimension 3
Vector [c0, c1, c2]
Take the intersection of two vector spaces
U ∩ W (Subspace of R^3)
-----------------------
Field R
Identity [0, 0, 0]
Basis []
Dimension 0
Vector [0, 0, 0]
Take the span of a list of vectors
S (Subspace of R^3)
-------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, -1], [0, 1, 2]]
Dimension 2
Vector [c0, c1, -c0 + 2*c1]
Define a Linear Map¶
>>> def mapping(vec):
>>> return [vec[0], vec[1], 0]
>>>
>>> T = LinearMap("T", domain=V, codomain=W, mapping=mapping)
>>> print(T.info())
T : V → W
---------
Field R
Rank 2
Nullity 1
Injective? False
Surjective? True
Bijective? False
Matrix [[1, 0, 0], [0, 1, 0]]
[0, 0, 0]
[1, 2, 0]
Operations with Linear Maps¶
Find the image of a linear map
im(T) (Subspace of R^3)
-----------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, 0]]
Dimension 2
Vector [c0, c1, 0]
Find the kernel of a linear map
ker(T) (Subspace of R^3)
------------------------
Field R
Identity [0, 0, 0]
Basis [[0, 0, 1]]
Dimension 1
Vector [0, 0, c0]
Define an Inner Product¶
Here we define the standard dot product
>>> def mapping(vec1, vec2):
>>> return sum(i * j for i, j in zip(vec1, vec2))
>>>
>>> dot = InnerProduct("dot", vectorspace=V, mapping=mapping)
>>> print(dot.info())
dot : V × V → R
---------------
Orthonormal Basis [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Matrix [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
14
Operations with Inner Products¶
Compute the norm of a vector
sqrt(14)
Check whether a list of vectors is pairwise orthogonal
False
True
Check whether a list of vectors is orthonormal
True
Take the orthogonal complement of a vector space
perp(U) (Subspace of R^3)
-------------------------
Field R
Identity [0, 0, 0]
Basis [[1, 0, 0], [0, 1, -1/2]]
Dimension 2
Vector [c0, c1, -c1/2]
Define a Linear Operator¶
>>> def mapping(vec):
>>> return [vec[0], 2*vec[1], 3*vec[2]]
>>>
>>> T = LinearOperator("T", vectorspace=V, mapping=mapping)
>>> print(T.info())
T : V → V
---------
Field R
Rank 3
Nullity 0
Injective? True
Surjective? True
Bijective? True
Matrix [[1, 0, 0], [0, 2, 0], [0, 0, 3]]
[1, 2, 3]
Operations with Linear Operators¶
Given an inner product, check whether a linear operator
True
True
False
False
True