Sponsored links: Algebra eBooks
 

Related

charpoly-eigenvalues-eigenvectors-factor-lambda-matrix

A:matrix([-0.09,0.038...

charpoly(A,%lambda);

factor(%);

Calculate

charpoly-eigenvectors-matrix-nullspace-rank

a: matrix([0,1],[0,0]);

rank(a);

nullspace(a);

Calculate

charpoly-determinant-eigenvalues-ident-invert-load-matrix

m: matrix ([a, b], [c...

u: matrix ([0, 2, -1]...

eigenvalues (u);

Calculate

charpoly-matrix

m:matrix([1,1],[0,1]);

charpoly(m,x);

Calculate

charpoly-determinant-eigenvalues-ident-invert-load-matrix

m: matrix ([a, b], [c...

u: matrix ([0, 2, -1]...

eigenvalues (u);

Calculate

charpoly-eigenvalues-expand-invert-matrix-solve

M: matrix([1/2, -1/4]...

I: matrix([1, 0],[0,1]);

eigenvalues(M);

Calculate

charpoly-determinant-eigenvalues-eigenvectors-ident-invert-load-matrix

/* MATRICE U */u: mat...

eigenvalues (u);

eigenvectors (u);

Calculate

charpoly-eigenvalues-eigenvectors-matrix

m: matrix([1,3],[3,1]);

eigenvalues(m);

eigenvectors(m);

Calculate

charpoly-coeff-determinant-diagmatrix-ev-matrix-ratexpand-solve-transpose

A:matrix([2,1+t,0],[1...

expr:charpoly(A,x);

expr2:ratexpand(expr);

Calculate

charpoly-diagmatrix-ev-expand-invert-matrix-transpose

m:matrix([3,2,0,0],[0...

a:matrix([0,0,1,0],[0...

b:invert(a);

Calculate

charpoly

Run Example
(%i1)m:matrix([1,1,-1],[1,5,1],[1,-1,-2]);
                                [ 1   1   - 1 ]
                                [             ]
(%o1)                           [ 1   5    1  ]
                                [             ]
                                [ 1  - 1  - 2 ]
(%i2) eq1:x+y-z=0;
(%o2)                           - z + y + x = 0
(%i3) eq2:x+5*y+z=0;
(%o3)                           z + 5 y + x = 0
(%i4) eq3:x-y-2*z=0;
(%o4)                          - 2 z - y + x = 0
(%i5) linsolve([eq1,eq2,eq3],[x,y,z]);

solve: dependent equations eliminated: (3)
                             3 %r1        %r1
(%o5)                   [x = -----, y = - ---, z = %r1]
                               2           2
(%i6) n:matrix([3/2],[-(1/2)],[1]);
                                    [  3  ]
                                    [  -  ]
                                    [  2  ]
                                    [     ]
(%o6)                               [   1 ]
                                    [ - - ]
                                    [   2 ]
                                    [     ]
                                    [  1  ]
(%i7) m.n;
                                     [ 0 ]
                                     [   ]
(%o7)                                [ 0 ]
                                     [   ]
                                     [ 0 ]
(%i8) charpoly(m,x);
(%o8)                 ((- x - 2) (5 - x) + 1) (1 - x) + 9
(%i9) 
Run Example
mat: matrix([F1*gamma,F2*gamma,F3*gamma,0,0],[0,0,0,S*e1,0],[0,0,0,0,S*e2],[F1*(1-gamma),F2*(1-gamma),F3*(1-gamma),0,0],[0,0,0,S*(1-e1),S*(1-e2)]);
(%o1) 
     [    F1 gamma        F2 gamma        F3 gamma         0           0      ]
     [                                                                        ]
     [       0               0               0            e1 S         0      ]
     [                                                                        ]
     [       0               0               0             0          e2 S    ]
     [                                                                        ]
     [ F1 (1 - gamma)  F2 (1 - gamma)  F3 (1 - gamma)      0           0      ]
     [                                                                        ]
     [       0               0               0         (1 - e1) S  (1 - e2) S ]
(%i2) cp: charpoly(mat,%lambda);
(%o2) (%lambda e1 F2 S ((1 - e2) S - %lambda) (1 - gamma)
                            2                      2
 - %lambda ((1 - e1) e2 F3 S  (1 - gamma) + %lambda  ((1 - e2) S - %lambda)))
                                                   2
 (F1 gamma - %lambda) + %lambda (1 - e1) e2 F1 F3 S  (1 - gamma) gamma
 - %lambda e1 F1 F2 S ((1 - e2) S - %lambda) (1 - gamma) gamma
(%i3) sol: substitute([F1=8,F2=12,F3=18,S=0.4,e1=0.1,e2=0.02,gamma=0.0725],cp);
(%o3) (0.58 - %lambda) (0.4452 (0.392 - %lambda) %lambda
                                     2
 - %lambda ((0.392 - %lambda) %lambda  + 0.0480816))
 - 0.258216 (0.392 - %lambda) %lambda + 0.027887328 %lambda
(%i4) allroots(sol);
(%o4) [%lambda = 0.0, %lambda = - 1.0976066942388965E-16, 
%lambda = - 0.39421038450343, %lambda = 0.30113872422923, 
%lambda = 1.065071660274204]
(%i5) sol2: substitute([F1=8,F2=12,F3=18,S=0.4,e1=0.1,e2=0.02,%lambda=1],cp);
(%o5) (0.608 - 0.34368 (1 - gamma)) (8 gamma - 1) + 2.74944 (1 - gamma) gamma
(%i6) solve(sol2);

rat: replaced 2.74944 by 8592/3125 = 2.74944

rat: replaced 0.608 by 76/125 = 0.608

rat: replaced -0.34368 by -1074/3125 = -0.34368
                                          59
(%o6)                           [gamma = ----]
                                         1009
(%i7) float(sol2);
(%o7) (0.608 - 0.34368 (1.0 - 1.0 gamma)) (8.0 gamma - 1.0)
                                              + 2.74944 (1.0 - 1.0 gamma) gamma
(%i8) float(59/1009);
(%o8)                          0.058473736372646
(%i9) 
Run Example
/* MATRICE U */u: matrix ([0, 2, -1], [3,-2,0], [-2,2,1]);
                               [  0    2   - 1 ]
                               [               ]
(%o1)                          [  3   - 2   0  ]
                               [               ]
                               [ - 2   2    1  ]
(%i2) eigenvalues (u);
(%o2)                      [[2, - 4, 1], [1, 1, 1]]
(%i3) eigenvectors (u);
                                       3    1           3
(%o3) [[[2, - 4, 1], [1, 1, 1]], [[[1, -, - -]], [[1, - -, 1]], [[1, 1, 1]]]]
                                       4    2           2
(%i4) u-x*ident (3);
                            [ - x     2      - 1  ]
                            [                     ]
(%o4)                       [  3   - x - 2    0   ]
                            [                     ]
                            [ - 2     2     1 - x ]
(%i5) determinant (u-x*ident (3));
(%o5)         - (- x - 2) (1 - x) x - 6 (1 - x) - 2 (- x - 2) - 6
(%i6) /* MATRICE P */p: matrix ([1,4,2], [1,3,-3], [1,-2,2]);
                                [ 1   4    2  ]
                                [             ]
(%o6)                           [ 1   3   - 3 ]
                                [             ]
                                [ 1  - 2   2  ]
(%i7) invert (p);
                                [     2    3  ]
                                [ 0   -    -  ]
                                [     5    5  ]
                                [             ]
                                [ 1         1 ]
(%o7)                           [ -   0   - - ]
                                [ 6         6 ]
                                [             ]
                                [ 1    1  1   ]
                                [ -  - -  --  ]
                                [ 6    5  30  ]
(%i8) /* MATRICE M */m: matrix ([a, b], [c, d]);
                                   [ a  b ]
(%o8)                              [      ]
                                   [ c  d ]
(%i9) determinant (m);
(%o9)                              a d - b c
(%i10) invert (m);
                         [      d             b     ]
                         [  ---------   - --------- ]
                         [  a d - b c     a d - b c ]
(%o10)                   [                          ]
                         [       c           a      ]
                         [ - ---------   ---------  ]
                         [   a d - b c   a d - b c  ]
(%i11) determinant (m);
(%o11)                             a d - b c
(%i12) charpoly(m,x);
(%o12)                       (a - x) (d - x) - b c
(%i13) load ("nchrpl");
(%o13)         /usr/share/maxima/5.21.1/share/matrix/nchrpl.mac
(%i14) ncharpoly(m,x);
                          2
(%o14)                   x  + (- d - a) x + a d - b c
(%i15) eigenvalues (m);
                 2                    2
           sqrt(d  - 2 a d + 4 b c + a ) - d - a
(%o15) [[- -------------------------------------, 
                             2
                                      2                    2
                                sqrt(d  - 2 a d + 4 b c + a ) + d + a
                                -------------------------------------], [1, 1]]
                                                  2
(%i16) /* Demo */batch ("eigen");

read and interpret file: #p/usr/share/maxima/5.21.1/share/matrix/eigen.mac
(%i17) eval_when([translate, batch, demo, load, loadfile], 
mi(var) ::= buildq([var], mode_identity(fixnum, var)), 
dv(var) ::= buildq([var], define_variable(var, false, boolean)))
(%i18)                        dv(hermitianmatrix)
(%i19)                       dv(nondiagonalizable)
(%i20)                         dv(knowneigvals)
(%i21)                         dv(knowneigvects)
(%i22)              define_variable(listeigvects, [], list)
(%i23)              define_variable(listeigvals, [], list)
(%i24)               define_variable(rightmatrix, [], any)
(%i25)               define_variable(leftmatrix, [], any)
(%i26) innerproduct(x, y) := block([listarith], listarith : true, 
                                                     ratsimp(conjugate(x) . y))
(%i27) unitvector(x) := block([listarith], listarith : true, 
                                                                 x
                                                      ------------------------)
                                                      sqrt(innerproduct(x, x))
(%i28)              columnvector(x) := transpose(matrix(x))
(%i29) gramschmidt(x, [myinnerproduct]) := 
block([listarith, dimnsn, listall, intern, count, denom, unit, index1, 
index2], if myinnerproduct = [] then myinnerproduct : innerproduct
 else myinnerproduct : first(myinnerproduct), 
mode_declare([dimnsn, count, index1, index2], fixnum, [listall], list, 
[intern, denom, unit], any), listarith : true, dimnsn : mi(length(x)), 
listall : [part(x, 1)], count : 1, if dimnsn = 1 then return(x)
 else (for index1 from 2 thru dimnsn do (unit : part(x, index1), 
for index2 thru count do (intern : part(listall, index2), 
denom : apply(myinnerproduct, [intern, intern]), 
                             apply(myinnerproduct, [intern, unit]) intern
unit : factor(ratsimp(unit - --------------------------------------------))), 
                                                denom
count : 1 + count, listall : endcons(unit, listall)), return(listall)))
(%i30) eigenvalues(mat) := block([dimnsn, listall, solution, multiplicities, 
solveexplicit, dummy : gensym(), index2], 
mode_declare([dimnsn, index2], fixnum, [listall, solution], list, [dummy], 
any), listall : [], solveexplicit : true, dimnsn : mi(length(mat)), 
solution : block([programmode : true], solve(charpoly(mat, dummy), dummy)), 
if solution = [] then (print(" "), 
print("solve is unable to find the roots of"), 
print("the characteristic polynomial."), return(listall))
 else (for index2 thru dimnsn do (dimnsn : 
mi(1 - part(multiplicities, index2) + dimnsn), 
listall : endcons(rhs(part(solution, index2)), listall)), 
listall : endcons(multiplicities, [listall]), return(listall)))
(%i31) eigenvectors(mat) := block([equations, unknowns, solution, listall, 
eigvals, dimnsn, count, vectr, index3, index4, index2, index1, matrx, mmatrx, 
notknwn, unit, multiplicities, %rnum, realonly, algebraic, interm, intern], 
mode_declare([equations, unknowns, solution, listall, eigvals, unit, interm], 
list, [dimnsn, count, index3, index4, index2, index1], fixnum, 
[vectr, matrx, mmatrx, intern, notknwn], any), unknowns : [], 
dimnsn : mi(length(mat)), count : mi(dimnsn), notknwn : gensym(), 
if knowneigvals then eigvals : listeigvals else eigvals : eigenvalues(mat), 
if eigvals = [] then (nondiagonalizable : true, return(eigvals))
 else (multiplicities : part(eigvals, 2), 
for index1 thru dimnsn do unknowns : endcons(concat(notknwn, index1), 
unknowns), vectr : columnvector(unknowns), matrx : mat . vectr, 
nondiagonalizable : false, eigvecs : [], realonly : false, algebraic : true, 
for index1 thru count do (count : mi(1 - part(multiplicities, index1)
 + count), mmatrx : matrx - part(eigvals, 1, index1) vectr, equations : [], 
for index2 thru dimnsn do equations : cons(mmatrx         , equations), 
                                                 index2, 1
%rnum : 0, solution : algsys(equations, unknowns), 
interm : map('rhs, solution ), unit : [], 
                           1
if %rnum # part(multiplicities, index1) then nondiagonalizable : true, 
for index3 thru %rnum do (intern : substvectk(%rnum_list, index3, interm), 
unit : append(unit, [intern])), if unit = []
 then (print(" "), print("algsys failure: the eigenvector(s) for the", index1, 
"th eigenvalue will be missing.")), if hermitianmatrix and (%rnum > 1)
 then unit : gramschmidt(unit), eigvecs : append(eigvecs, [unit])), 
return([eigvals, eigvecs])))
(%i32) substvectk(l, n, exp) := (mode_declare(l, list, n, fixnum, exp, any), 
block([sub_list : [], j : 0], mode_declare(sub_list, list, j, fixnum), 
for var in l do (mode_declare(var, any), j : 1 + j, 
sub_list : cons(var = (if j = n then 1 else 0), sub_list)), 
sublis(sub_list, exp)))
(%i33) uniteigenvectors(M) := block([uv], 
mode_declare(uv, list, [i, j], fixnum), 
if knowneigvects then uv : copy(listeigvects) else uv : copy(eigenvectors(M)), 
if uv = [] then [] else (for i thru length(uv ) 
                                             2
do (for j thru length((uv ) ) do ((uv ) )  : ratsimp(unitvector(((uv ) ) ))), 
                         2           2                              2
                           i           i                              i
                                         j                              j
uv))
(%o33) uniteigenvectors(M) := block([uv], 
mode_declare(uv, list, [i, j], fixnum), 
if knowneigvects then uv : copy(listeigvects) else uv : copy(eigenvectors(M)), 
if uv = [] then [] else (for i thru length(uv ) 
                                             2
do (for j thru length((uv ) ) do ((uv ) )  : ratsimp(unitvector(((uv ) ) ))), 
                         2           2                              2
                           i           i                              i
                                         j                              j
uv))
(%i34) similaritytransform(mat) := block([listvec, listuevec], 
mode_declare([listvec, listuevec], list), listuevec : uniteigenvectors(mat), 
if nondiagonalizable then return(listuevec)
 else (listvec : apply(append, listuevec ), 
                                        2
rightmatrix : transpose(apply('matrix, listvec)), 
if hermitianmatrix then leftmatrix : conjugate(transpose(rightmatrix))
                              <- 1>
 else leftmatrix : rightmatrix     , return(listuevec)))
(%i35)                      conj(x) := conjugate(x)
(%i36)                inprod(x, y) := innerproduct(x, y)
(%i37)                     uvect(x) := unitvector(x)
(%i38)                   covect(x) := columnvector(x)
(%i39) gschmit(x, [f]) := if f = [] then gramschmidt(x) else gramschmidt(x, f )
                                                                             1
(%i40)                  eivals(mat) := eigenvalues(mat)
(%i41)                 eivects(mat) := eigenvectors(mat)
(%i42)              ueivects(mat) := uniteigenvectors(mat)
(%i43)             simtran(mat) := similaritytransform(mat)
(%o43)          /usr/share/maxima/5.21.1/share/matrix/eigen.mac
(%i44) 
[allroots,at,charpoly,float,lambda,matrix,solve] [allroots,at,charpoly,lambda,matrix,solve] [allroots,at,charpoly,lambda,matrix] [at,charpoly,lambda,matrix] [batch,charpoly,determinant,eigenvalues,eigenvectors,ident,invert,load,matrix] [charpoly,coeff,determinant,diagmatrix,ev,matrix,ratexpand,solve,transpose] [charpoly,coeff,determinant,diagmatrix,matrix,ratexpand,solve,transpose] [charpoly,coeff,eliminate,expand,matrix,plot2d,sublis] [charpoly,coeff,eliminate,expand,matrix,sublis] [charpoly,coeff,expand,matrix,solve,sublis] [charpoly,coeff,expand,matrix] [charpoly,coeff,matrix,ratexpand,solve] [charpoly,coeff,matrix,ratexpand] [charpoly,coeff,matrix] [charpoly,determinant,eigenvalues,eigenvectors,ident,invert,load,matrix] [charpoly,determinant,eigenvalues,ident,invert,load,matrix] [charpoly,determinant,eigenvalues,invert,load,matrix] [charpoly,determinant,expand,load,matrix] [charpoly,determinant,factor,ident,lu_factor,matrix,minor,nullspace,rank] [charpoly,determinant,invert,matrix] [charpoly,diagmatrix,ev,expand,invert,matrix,transpose] [charpoly,echelon,eigenvalues,eigenvectors,factor,matrix] [charpoly,echelon,eigenvectors,factor,matrix] [charpoly,eigenvalues,eigenvectors,expand,factor,matrix,solve] [charpoly,eigenvalues,eigenvectors,factor,matrix,solve] [charpoly,eigenvalues,eigenvectors,matrix,solve] [charpoly,eigenvalues,eigenvectors,matrix] [charpoly,eigenvalues,expand,invert,matrix,solve] [charpoly,eigenvalues,expand,invert,matrix] [charpoly,eigenvalues,matrix] [charpoly,eigenvectors,matrix,nullspace,rank] [charpoly,eigenvectors,matrix] [charpoly,ev,expand,invert,matrix,transpose] [charpoly,expand,factor,matrix] [charpoly,expand,invert,matrix] [charpoly,expand,linsolve,matrix] [charpoly,expand,matrix] [charpoly,matrix,ratexpand] [charpoly,matrix,ratsimp] [charpoly,matrix]

Related Help

Help for Charpoly