Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

 

## -*- encoding: utf-8 -*- 

""" 

This file (./linalg_doctest.sage) was *autogenerated* from ./linalg.tex, 

with sagetex.sty version 2011/05/27 v2.3.1. 

It contains the contents of all the sageexample environments from this file. 

You should be able to doctest this file with: 

sage -t ./linalg_doctest.sage 

It is always safe to delete this file; it is not used in typesetting your 

document. 

 

Sage example in ./linalg.tex, line 136:: 

 

sage: MS = MatrixSpace(ZZ,2,3); MS 

Full MatrixSpace of 2 by 3 dense matrices over Integer Ring 

sage: VS = VectorSpace(GF(3^2,'x'),3); VS 

Vector space of dimension 3 over Finite Field in x of size 3^2 

 

Sage example in ./linalg.tex, line 148:: 

 

sage: list(MatrixSpace(ZZ,2,3).basis()) 

[ 

[1 0 0] [0 1 0] [0 0 1] [0 0 0] [0 0 0] [0 0 0] 

[0 0 0], [0 0 0], [0 0 0], [1 0 0], [0 1 0], [0 0 1] 

] 

 

Sage example in ./linalg.tex, line 190:: 

 

sage: A = matrix(GF(11), 2, 2, [1,0,0,2]) 

sage: B = matrix(GF(11), 2, 2, [0,1,1,0]) 

sage: MG = MatrixGroup([A,B]) 

sage: MG.cardinality() 

200 

sage: identity_matrix(GF(11),2) in MG 

True 

 

Sage example in ./linalg.tex, line 226:: 

 

sage: MS = MatrixSpace(ZZ,2,3); A = MS([1,2,3,4,5,6]); A 

[1 2 3] 

[4 5 6] 

 

Sage example in ./linalg.tex, line 247:: 

 

sage: a = matrix(); a.parent() 

Full MatrixSpace of 0 by 0 dense matrices over Integer Ring 

 

Sage example in ./linalg.tex, line 263:: 

 

sage: a = matrix(GF(8,'x'),3,4); a.parent() 

Full MatrixSpace of 3 by 4 dense matrices over Finite Field 

in x of size 2^3 

 

Sage example in ./linalg.tex, line 274:: 

 

sage: g = graphs.PetersenGraph() 

sage: m = matrix(g); m; m.parent() 

[0 1 0 0 1 1 0 0 0 0] 

[1 0 1 0 0 0 1 0 0 0] 

[0 1 0 1 0 0 0 1 0 0] 

[0 0 1 0 1 0 0 0 1 0] 

[1 0 0 1 0 0 0 0 0 1] 

[1 0 0 0 0 0 0 1 1 0] 

[0 1 0 0 0 0 0 0 1 1] 

[0 0 1 0 0 1 0 0 0 1] 

[0 0 0 1 0 1 1 0 0 0] 

[0 0 0 0 1 0 1 1 0 0] 

Full MatrixSpace of 10 by 10 dense matrices over Integer Ring 

 

Sage example in ./linalg.tex, line 295:: 

 

sage: A = matrix([[1,2],[3,4]]) 

sage: block_matrix([[A,-A],[2*A, A^2]]) 

[ 1 2|-1 -2] 

[ 3 4|-3 -4] 

[-----+-----] 

[ 2 4| 7 10] 

[ 6 8|15 22] 

 

Sage example in ./linalg.tex, line 320:: 

 

sage: A = matrix([[1,2,3],[4,5,6]]) 

sage: block_matrix([1,A,0,0,-A,2], ncols=3) 

[ 1 0| 1 2 3| 0 0] 

[ 0 1| 4 5 6| 0 0] 

[-----+--------+-----] 

[ 0 0|-1 -2 -3| 2 0] 

[ 0 0|-4 -5 -6| 0 2] 

 

Sage example in ./linalg.tex, line 346:: 

 

sage: A = matrix([[1,2,3],[0,1,0]]) 

sage: block_diagonal_matrix(A, A.transpose()) 

[1 2 3|0 0] 

[0 1 0|0 0] 

[-----+---] 

[0 0 0|1 0] 

[0 0 0|2 1] 

[0 0 0|3 0] 

 

Sage example in ./linalg.tex, line 397:: 

 

sage: A = matrix(3,3,range(9)) 

sage: A[:,1] = vector([1,1,1]); A 

[0 1 2] 

[3 1 5] 

[6 1 8] 

 

Sage example in ./linalg.tex, line 414:: 

 

sage: A[::-1], A[:,::-1], A[::2,-1] 

( 

[6 1 8] [2 1 0] 

[3 1 5] [5 1 3] [2] 

[0 1 2], [8 1 6], [8] 

) 

 

Sage example in ./linalg.tex, line 446:: 

 

sage: A = matrix(ZZ,4,4,range(16)); A 

[ 0 1 2 3] 

[ 4 5 6 7] 

[ 8 9 10 11] 

[12 13 14 15] 

 

 

Sage example in ./linalg.tex, line 462:: 

 

sage: A.matrix_from_rows_and_columns([0,2,3],[1,2]) 

[ 1 2] 

[ 9 10] 

[13 14] 

 

Sage example in ./linalg.tex, line 505:: 

 

sage: MS = MatrixSpace(GF(3),2,3) 

sage: MS.base_extend(GF(9,'x')) 

Full MatrixSpace of 2 by 3 dense matrices over Finite Field 

in x of size 3^2 

sage: MS = MatrixSpace(ZZ,2,3) 

sage: MS.change_ring(GF(3)) 

Full MatrixSpace of 2 by 3 dense matrices over Finite Field of size 3 

 

Sage example in ./linalg.tex, line 896:: 

 

sage: a = matrix(GF(7),4,3,[6,2,2,5,4,4,6,4,5,5,1,3]); a 

[6 2 2] 

[5 4 4] 

[6 4 5] 

[5 1 3] 

 

Sage example in ./linalg.tex, line 910:: 

 

sage: u = copy(identity_matrix(GF(7),4)); u[1:,0] = -a[1:,0]/a[0,0] 

sage: u, u*a 

( 

[1 0 0 0] [6 2 2] 

[5 1 0 0] [0 0 0] 

[6 0 1 0] [0 2 3] 

[5 0 0 1], [0 4 6] 

) 

 

Sage example in ./linalg.tex, line 932:: 

 

sage: v = copy(identity_matrix(GF(7),4)); v.swap_rows(1,2) 

sage: b = v*u*a; v, b 

( 

[1 0 0 0] [6 2 2] 

[0 0 1 0] [0 2 3] 

[0 1 0 0] [0 0 0] 

[0 0 0 1], [0 4 6] 

) 

 

Sage example in ./linalg.tex, line 954:: 

 

sage: w = copy(identity_matrix(GF(7),4)) 

sage: w[2:,1] = -b[2:,1]/b[1,1]; w, w*b 

( 

[1 0 0 0] [6 2 2] 

[0 1 0 0] [0 2 3] 

[0 0 1 0] [0 0 0] 

[0 5 0 1], [0 0 0] 

) 

 

Sage example in ./linalg.tex, line 1024:: 

 

sage: A = matrix(GF(7),4,5,[4,4,0,2,4,5,1,6,5,4,1,1,0,1,0,5,1,6,6,2]) 

sage: A, A.echelon_form() 

( 

[4 4 0 2 4] [1 0 5 0 3] 

[5 1 6 5 4] [0 1 2 0 6] 

[1 1 0 1 0] [0 0 0 1 5] 

[5 1 6 6 2], [0 0 0 0 0] 

) 

 

Sage example in ./linalg.tex, line 1147:: 

 

sage: a = matrix(ZZ, 4, 6, [2,1,2,2,2,-1,1,2,-1,2,1,-1,2,1,-1,\ 

....: -1,2,2,2,1,1,-1,-1,-1]); a.echelon_form() 

[ 1 2 0 5 4 -1] 

[ 0 3 0 2 -6 -7] 

[ 0 0 1 3 3 0] 

[ 0 0 0 6 9 3] 

 

Sage example in ./linalg.tex, line 1163:: 

 

sage: a.base_extend(QQ).echelon_form() 

[ 1 0 0 0 5/2 11/6] 

[ 0 1 0 0 -3 -8/3] 

[ 0 0 1 0 -3/2 -3/2] 

[ 0 0 0 1 3/2 1/2] 

 

Sage example in ./linalg.tex, line 1189:: 

 

sage: A = matrix(ZZ,4,5,[4,4,0,2,4,5,1,6,5,4,1,1,0,1,0,5,1,6,6,2]) 

sage: H, U = A.echelon_form(transformation=True); H, U 

( 

[ 1 1 0 0 2] [ 0 1 1 -1] 

[ 0 4 -6 0 -4] [ 0 -1 5 0] 

[ 0 0 0 1 -2] [ 0 -1 0 1] 

[ 0 0 0 0 0], [ 1 -2 -4 2] 

) 

 

Sage example in ./linalg.tex, line 1250:: 

 

sage: A = matrix(ZZ, 4, 5,\ 

....: [-1,-1,-1,-2,-2,-2,1,1,-1,2,2,2,2,2,-1,2,2,2,2,2]) 

sage: S,U,V = A.smith_form(); S,U,V 

( 

[ 0 -2 -1 -5 0] 

[1 0 0 0 0] [ 1 0 0 0] [ 1 0 1 -1 -1] 

[0 1 0 0 0] [ 0 0 1 0] [ 0 0 0 0 1] 

[0 0 3 0 0] [-2 1 0 0] [-1 2 0 5 0] 

[0 0 0 6 0], [ 0 0 -2 -1], [ 0 -1 0 -2 0] 

) 

 

Sage example in ./linalg.tex, line 1284:: 

 

sage: A.elementary_divisors() 

[1, 1, 3, 6] 

sage: S == U*A*V 

True 

 

Sage example in ./linalg.tex, line 1329:: 

 

sage: B = matrix(GF(7),5,4,[4,5,1,5,4,1,1,1,0,6,0,6,2,5,1,6,4,4,0,2]) 

sage: B.transpose().echelon_form() 

[1 0 5 0 3] 

[0 1 2 0 6] 

[0 0 0 1 5] 

[0 0 0 0 0] 

 

Sage example in ./linalg.tex, line 1344:: 

 

sage: B.pivot_rows() 

(0, 1, 3) 

sage: B.transpose().pivots() == B.pivot_rows() 

True 

 

Sage example in ./linalg.tex, line 1381:: 

 

sage: R.<x> = PolynomialRing(GF(5),'x') 

sage: A = random_matrix(R,2,3); A # random 

[ 3*x^2 + x x^2 + 2*x 2*x^2 + 2] 

[ x^2 + x + 2 2*x^2 + 4*x + 3 x^2 + 4*x + 3] 

 

Sage example in ./linalg.tex, line 1393:: 

 

sage: b = random_matrix(R,2,1); b # random 

[ 4*x^2 + 1] 

[3*x^2 + 2*x] 

 

Sage example in ./linalg.tex, line 1404:: 

 

sage: A.solve_right(b) # random 

[(4*x^3 + 2*x + 4)/(3*x^3 + 2*x^2 + 2*x)] 

[ (3*x^2 + 4*x + 3)/(x^3 + 4*x^2 + 4*x)] 

[ 0] 

 

Sage example in ./linalg.tex, line 1418:: 

 

sage: A.solve_right(b) == A\b 

True 

 

Sage example in ./linalg.tex, line 1449:: 

 

sage: a = matrix(QQ,3,5,[2,2,-1,-2,-1,2,-1,1,2,-1/2,2,-2,-1,2,-1/2]) 

sage: a.image() 

Vector space of degree 5 and dimension 3 over Rational Field 

Basis matrix: 

[ 1 0 0 1/4 -11/32] 

[ 0 1 0 -1 -1/8] 

[ 0 0 1 1/2 1/16] 

sage: a.right_kernel() 

Vector space of degree 5 and dimension 2 over Rational Field 

Basis matrix: 

[ 1 0 0 -1/3 8/3] 

[ 0 1 -1/2 11/12 2/3] 

 

Sage example in ./linalg.tex, line 1472:: 

 

sage: a = matrix(ZZ,5,3,[1,1,122,-1,-2,1,-188,2,1,1,-10,1,-1,-1,-1]) 

sage: a.kernel() 

Free module of degree 5 and rank 2 over Integer Ring 

Echelon basis matrix: 

[ 1 979 -11 -279 811] 

[ 0 2079 -22 -569 1488] 

sage: b = a.base_extend(QQ) 

sage: b.kernel() 

Vector space of degree 5 and dimension 2 over Rational Field 

Basis matrix: 

[ 1 0 -121/189 -2090/189 6949/63] 

[ 0 1 -2/189 -569/2079 496/693] 

sage: b.integer_kernel() 

Free module of degree 5 and rank 2 over Integer Ring 

Echelon basis matrix: 

[ 1 979 -11 -279 811] 

[ 0 2079 -22 -569 1488] 

 

Sage example in ./linalg.tex, line 1684:: 

 

sage: A = matrix(GF(97), 4, 4,\ 

....: [86,1,6,68,34,24,8,35,15,36,68,42,27,1,78,26]) 

sage: e1 = identity_matrix(GF(97),4)[0] 

sage: U = matrix(A.transpose().maxspin(e1)).transpose() 

sage: F = U^-1*A*U; F 

[ 0 0 0 83] 

[ 1 0 0 77] 

[ 0 1 0 20] 

[ 0 0 1 10] 

 

Sage example in ./linalg.tex, line 1703:: 

 

sage: K.<x> = GF(97)[] 

sage: P = x^4-sum(F[i,3]*x^i for i in range(4)); P 

x^4 + 87*x^3 + 77*x^2 + 20*x + 14 

 

Sage example in ./linalg.tex, line 1709:: 

 

sage: P == A.charpoly() 

True 

 

Sage example in ./linalg.tex, line 1813:: 

 

sage: A = matrix(ZZ,8,[[6,0,-2,4,0,0,0,-2],[14,-1,0,6,0,-1,-1,1],\ 

....: [2,2,0,1,0,0,1,0],[-12,0,5,-8,0,0,0,4],\ 

....: [0,4,0,0,0,0,4,0],[0,0,0,0,1,0,0,0],\ 

....: [-14,2,0,-6,0,2,2,-1],[-4,0,2,-4,0,0,0,4]]) 

sage: A.frobenius() 

[0 0 0 4 0 0 0 0] 

[1 0 0 4 0 0 0 0] 

[0 1 0 1 0 0 0 0] 

[0 0 1 0 0 0 0 0] 

[0 0 0 0 0 0 4 0] 

[0 0 0 0 1 0 0 0] 

[0 0 0 0 0 1 1 0] 

[0 0 0 0 0 0 0 2] 

 

Sage example in ./linalg.tex, line 1845:: 

 

sage: A.frobenius(1) 

[x^4 - x^2 - 4*x - 4, x^3 - x^2 - 4, x - 2] 

 

Sage example in ./linalg.tex, line 1851:: 

 

sage: F,K = A.frobenius(2) 

sage: K 

[ 1 -15/56 17/224 15/56 -17/896 0 -15/112 17/64] 

[ 0 29/224 -13/224 -23/448 -17/896 -17/896 29/448 13/128] 

[ 0 -75/896 75/896 -47/896 0 -17/896 -23/448 11/128] 

[ 0 17/896 -29/896 15/896 0 0 0 0] 

[ 0 0 0 0 1 0 0 0] 

[ 0 0 0 0 0 1 0 0] 

[ 0 1 0 0 0 0 1 0] 

[ 0 -4/21 -4/21 -10/21 0 0 -2/21 1] 

 

Sage example in ./linalg.tex, line 1877:: 

 

sage: K^-1*F*K == A 

True 

 

Sage example in ./linalg.tex, line 1905:: 

 

sage: S.<x> = QQ[] 

sage: B = x*identity_matrix(8) - A 

sage: B.elementary_divisors() 

[1, 1, 1, 1, 1, x - 2, x^3 - x^2 - 4, x^4 - x^2 - 4*x - 4] 

 

Sage example in ./linalg.tex, line 1913:: 

 

sage: A.frobenius(1) 

[x^4 - x^2 - 4*x - 4, x^3 - x^2 - 4, x - 2] 

 

Sage example in ./linalg.tex, line 1981:: 

 

sage: A = matrix(GF(7),4,[5,5,4,3,0,3,3,4,0,1,5,4,6,0,6,3]) 

sage: A.eigenvalues() 

[4, 1, 2, 2] 

sage: A.eigenvectors_right() 

[(4, [ 

(1, 5, 5, 1) 

], 1), (1, [ 

(0, 1, 1, 4) 

], 1), (2, [ 

(1, 3, 0, 1), 

(0, 0, 1, 1) 

], 2)] 

sage: A.eigenspaces_right() 

[ 

(4, Vector space of degree 4 and dimension 1 over Finite Field 

of size 7 

User basis matrix: 

[1 5 5 1]), 

(1, Vector space of degree 4 and dimension 1 over Finite Field 

of size 7 

User basis matrix: 

[0 1 1 4]), 

(2, Vector space of degree 4 and dimension 2 over Finite Field 

of size 7 

User basis matrix: 

[1 3 0 1] 

[0 0 1 1]) 

] 

 

Sage example in ./linalg.tex, line 2019:: 

 

sage: A.eigenmatrix_right() 

( 

[4 0 0 0] [1 0 1 0] 

[0 1 0 0] [5 1 3 0] 

[0 0 2 0] [5 1 0 1] 

[0 0 0 2], [1 4 1 1] 

) 

 

Sage example in ./linalg.tex, line 2144:: 

 

sage: A = matrix(ZZ,4,[3,-1,0,-1,0,2,0,-1,1,-1,2,0,1,-1,-1,3]) 

sage: A.jordan_form() 

[3|0|0 0] 

[-+-+---] 

[0|3|0 0] 

[-+-+---] 

[0|0|2 1] 

[0|0|0 2] 

 

Sage example in ./linalg.tex, line 2163:: 

 

sage: J,U = A.jordan_form(transformation=True) 

sage: U^-1*A*U == J 

True 

""" 

# This file was *autogenerated* from the file linalg_doctest.sage. 

from sage.all_cmdline import * # import sage library