# HP Forums

Full Version: Find a basis from cartesian equations
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello
I want to find an easier way to find vectors which are a basis of a vector space defined by cartesian equations. For eixample:
x1+2x2+x3+2x4+x5=0
-x1-2x2-x4+2x5=0
x1+2x2+3x3+4x4+7x5=0

So, first I reduce the system (applying Gauss reduction):
I use RREF(matrix of coefficients of the system)
rref([[1,2,1,2,1],[-1,-2,0,-1,2],[1,2,3,4,7]])
to obtain
[[1,2,0,1,-2],[0,0,1,1,3],[0,0,0,0,0]]

So we have two equations which means the subspace represented have 5-2 dimensions. So for a basis of this space we need three independent vectors.

Next I use solve() giving values to find three possible vectors:
solve([[x1+2*x2+x4-2*x5,x3+x4+3*x5,x2 = 1,x4 = 0,x5 = 0]],[x1,x2,x3,x4,x5])
which gives {[-2,1,0,0,0]}

So I will change values for x2=0, x4=1 and X5=0 which gives {[-1,0,-1,1,0]}

And third and last I change x2=0, X4=0 and X5=1 which gives {[2,0,-3,0,1]}

This is a very complicated way, to obtain the three vectors of the basis.
Is there a function to solve this directly?

Toni
I suppose you could combine the last 3 steps by setting x2=a, x4=b, x5=c, with a, b and c unassigned.
Good point!

You could also use gbasis instead of RREF (that way, you wouldn't have to type the coefficients into a matrix).
Both works:
First give {[-2*a-b+2*c,a,-b-3*c,b,c]}which giving values to a,b,c give same answer in one step (before three).

Second just jumps one step, so both together make it easier.

Anyway, if someone finds a direct way tell me
thanks again

Toni
Hello again

I have seen a different possibility. May not be very mathematically appropiate but the result seems OK:
The kernel of a linear map is a set of the vectors whose image is (0...0). So up to a point vectros who solve the equations.

If you aply Ker(matrix of coefficients of the former equations), this gives directly the the vectors of the basis in just one operation.

With so many functions it is not easy to find one that fits what you are looking for. HP manual is not very extensive.

Thanks again

Toni
Inside Giac/Xcas, syst2mat does the conversion from linear equations to matrix form, unfortunately it is not available on the Prime.
m:=syst2mat([x1+2x2+x3+2x4+x5=0,-x1-2x2-x4+2x5=0,x1+2x2+3x3+4x4+7x5=0],[x1,x2,x3,x4,x5]);
ker(m[0..2,0..4]);
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :