Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168749
Image: ubuntu2004
m1=matrix(ZZ,[[1,2,3],[4,5,6]])
m1.parent()
Full MatrixSpace of 2 by 3 dense matrices over Integer Ring
m1
[1 2 3] [4 5 6]
m1/2
[1/2 1 3/2] [ 2 5/2 3]
m2=matrix(QQ,[[1,2,3],[4,5,6]])
m2.parent()
Full MatrixSpace of 2 by 3 dense matrices over Rational Field
m2
[1 2 3] [4 5 6]
m2/2
[1/2 1 3/2] [ 2 5/2 3]
m3=matrix(RR,[[1,2,3],[4,5,6]])
m3.parent()
Full MatrixSpace of 2 by 3 dense matrices over Real Field with 53 bits of precision
m3
[1.00000000000000 2.00000000000000 3.00000000000000] [4.00000000000000 5.00000000000000 6.00000000000000]
m3/2
[0.500000000000000 1.00000000000000 1.50000000000000] [ 2.00000000000000 2.50000000000000 3.00000000000000]
a=matrix(ZZ,[[3,1,1],[2,1,2]])
b=matrix(ZZ,[[1,-2,3],[4,5,-6]])
a+b
[ 4 -1 4] [ 6 6 -4]
a-b
[ 2 3 -2] [-2 -4 8]
a.transpose()
[3 2] [1 1] [1 2]
transpose(a.transpose())
[3 1 1] [2 1 2]
a*b.transpose()
[ 4 11] [ 6 1]
transpose(b)*a
[11 5 9] [ 4 3 8] [-3 -3 -9]
A=matrix(QQ,3,range(9));A
[0 1 2] [3 4 5] [6 7 8]
b=matrix(QQ,3,1,[1,2,3]);b
[1] [2] [3]
x=A\b;x
[-2/3] [ 1] [ 0]
A*x
[1] [2] [3]
A=matrix(QQ,3,range(9));A[0,0]=2;A
[2 1 2] [3 4 5] [6 7 8]
b=matrix(QQ,1,3,[1,2,3]);b
[1 2 3]
x=b*A^(-1);x
[ 0 5/3 -2/3]
x*A
[1 2 3]
(8*a)*b.transpose()
[64] [80]
8*(a*transpose(b))
[64] [80]
Q=matrix ([[2,1,0,0,0,],[0,2,1,0,0],[0,0,2,1,0],[0,0,0,2,1],[0,0,0,0,2]])
Q^3
[ 8 12 6 1 0] [ 0 8 12 6 1] [ 0 0 8 12 6] [ 0 0 0 8 12] [ 0 0 0 0 8]
rank(Q)
5
Q.inverse()
[ 1/2 -1/4 1/8 -1/16 1/32] [ 0 1/2 -1/4 1/8 -1/16] [ 0 0 1/2 -1/4 1/8] [ 0 0 0 1/2 -1/4] [ 0 0 0 0 1/2]
Q^(-1)*Q
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_4.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("UV4oLTEpKlE="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmpknSzK5/___code___.py", line 3, in <module> exec compile(u'Q**(-_sage_const_1 )*Q' + '\n', '', 'single') File "", line 1, in <module> NameError: name 'Q' is not defined
A=matrix(RR,[[1,2,5],[1,3,-2],[3,7,8],[1,4,-9]])
b=matrix(RR,[[1],[1],[3],[1]])
rank(A)
2
AA=matrix(RR,4,4)
AA.set_block(0,0,A)
AA.set_block(0,3,b)
rank(AA)
2
A.rref()
[ 1.00000000000000 0.000000000000000 19.0000000000000] [0.000000000000000 1.00000000000000 -7.00000000000000] [0.000000000000000 0.000000000000000 0.000000000000000] [0.000000000000000 0.000000000000000 0.000000000000000]
s=A.right_kernel()
ss=s.basis_matrix();ss
[ 1.00000000000000 -0.368421052631579 -0.0526315789473684]
x=A.solve_right(b);x
[ 1.00000000000000] [0.000000000000000] [0.000000000000000]