Sponsored links: Algebra eBooks
 

Related

batch-tanh

batch(solve_rec);

tt1: t[n] = tanh( t[n...

solve_rec(tt1, t[n-1]);

Calculate

batch

batch(solve_rec);

solve_rec(1+1, 2*3, 8...

Calculate

batch-eliminate-first

batch(solve_rec);

eq1: WINEamt[t] = WIN...

eq2: WATERamt[t] = WA...

Calculate

batch-load-tanh

batch(solve_rec);

load(solve_rec);

tt1: t[n] = tanh( t[n...

Calculate

batch

batch(solve_rec);

eq1: a[n] = a[n-1] + ...

solve_rec(eq1,a[n], a...

Calculate

batch-load-tanh

batch(solve_rec);

load(solve_rec);

tt1: t[n] = tanh( t[n...

Calculate

batch-eliminate

batch(solve_rec);

eq1: WINEamt[t] = WIN...

eq2: WATERamt[t] = WA...

Calculate

batch

batch(solve_rec);

eq1: a[n] = a[n-1] + ...

solve_rec(eq1,a[n]);

Calculate

batch-eliminate

batch(solve_rec);

eq1: WINEamt[t] = WIN...

eq2: WATERamt[t] = WA...

Calculate

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

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

eigenvalues (u);

eigenvectors (u);

Calculate

batch

Run Example
(%i1)/* 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) 
Run Example
batch(solve_rec);

read and interpret file: #p/usr/share/maxima/5.21.1/share/contrib/solve_rec/solve_rec.mac
(%i2)          eval_when(batch, ttyoff : true, nolabels : true)
(%o68)  /usr/share/maxima/5.21.1/share/contrib/solve_rec/solve_rec.mac
(%i69) tt1: t[n] = tanh( t[n] + fb * t[n-1] );
(%o69)                     t  = tanh(t  + fb t     )
                            n         n       n - 1
(%i70) solve_rec(tt1, t[n-1]);
(%o70)                               false
(%i71) 
Run Example
batch(solve_rec);

read and interpret file: #p/usr/share/maxima/5.21.1/share/contrib/solve_rec/solve_rec.mac
(%i2)          eval_when(batch, ttyoff : true, nolabels : true)
(%o68)  /usr/share/maxima/5.21.1/share/contrib/solve_rec/solve_rec.mac
(%i69) eq1: WINEamt[t] = WINEamt[t-1] - WINEpct[t-1]*3;
(%o69)             WINEamt  = WINEamt      - 3 WINEpct
                          t          t - 1            t - 1
(%i70) solve_rec(eq1, WINEamt[t]);

WINEpct
       %j + 1
------------- non-rational term ratio to nusum
  WINEpct
         %j
                                         t - 1
                                         ====
                                         \
(%o70)                WINEamt  = %k  - 3  >     WINEpct
                             t     1     /             %j
                                         ====
                                         %j = 1
(%i71) 

Related Help

Help for Batch