# basis of subspace of complex field

Hi -

Given a set of elements of CC, or perhaps QQbar, I want to compute a basis for a subspace over QQ that contains those elements.

For example, given $3$, $1+\sqrt{5}$, $i$, and $i-1$, I'd expect my output to be $\{1, \sqrt{5}, i\}$, since my original four elements can be written as $(3,0,0)$, $(1,1,0)$, $(0,0,1)$, and $(-1,0,1)$ with respect to that basis.

Obviously, the basis won't be unique.

Can anybody suggest what tools in Sage might be useful for this calculation?

edit retag close merge delete

Sort by » oldest newest most voted

Here is one way:

sage: K, elts, hom = number_field_elements_from_algebraics([3, 1+sqrt(5), I, I-1], minimal=True)
sage: K.defining_polynomial()
y^4 + 3*y^2 + 1
sage: K.power_basis()
[1, a, a^2, a^3]
sage: map(vector, elts)
[(3, 0, 0, 0), (4, 0, 2, 0), (0, -2, 0, -1), (-1, -2, 0, -1)]
sage: A = matrix(QQ, map(vector, elts))
sage: A.image().basis()
[
(1, 0, 0, 0),
(0, 1, 0, 1/2),
(0, 0, 1, 0)
]
sage: mybasis = map(K, A.image().basis()); mybasis
[1, 1/2*a^3 + a, a^2]
[1, -1/2*I, 1/2*sqrt(5) - 3/2]

more