introMaple.mws

 Matrices (linalg)

>    with(linalg);

Warning, the protected names norm and trace have been redefined and unprotected

[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...

>    m:=matrix([[1,2,3],[2,3,1],[3,2,1]]);

m := matrix([[1, 2, 3], [2, 3, 1], [3, 2, 1]])

>    det(m);

-12

>    im:=inverse(m);

im := matrix([[-1/12, -1/3, 7/12], [-1/12, 2/3, -5/12], [5/12, -1/3, 1/12]])

>    id3:=evalm(m&*im);

id3 := matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

>    eigenvalues(m);

1, -2, 6

>    map(evalf,[%]);

[1., -2., 6.]

>    charpoly(m,lambda);

lambda^3-5*lambda^2-8*lambda+12

>    eig:=[eigenvectors(m)];

eig := [[1, 1, {vector([1, -3/2, 1])}], [6, 1, {vector([1, 1, 1])}], [-2, 1, {vector([-13/11, 3/11, 1])}]]

>    eiv:=eig[2][1];

eiv := 6

>    eigm2:=op(eig[2][3]);

eigm2 := vector([1, 1, 1])

>    evalm((m-eiv*id3)&*eigm2);

vector([0, 0, 0])

>    nullspace(m);

{}

  Gaussian Elimination

>    m:=matrix([[1,2,3,-2],[2,3,1,4],[3,2,1,7]]);

m := matrix([[1, 2, 3, -2], [2, 3, 1, 4], [3, 2, 1, 7]])

>    m:=addrow(addrow(m,1,2,-2),1,3,-3);

m := matrix([[1, 2, 3, -2], [0, -1, -5, 8], [0, -4, -8, 13]])

>    m:=addrow(m,2,3,-4);

m := matrix([[1, 2, 3, -2], [0, -1, -5, 8], [0, 0, 12, -19]])

>    submatrix(m,1..2,1..3);

matrix([[1, 2, 3], [0, -1, -5]])

>    minor(m,1,2);

matrix([[0, -5, 8], [0, 12, -19]])

 Matrices (LinearAlgebra)

>    with(LinearAlgebra);

Warning, the assigned name GramSchmidt now has a global binding

[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, ...

>    M:=Matrix(3,[[1,2,3],[-1,-3,-5],[-5,7,9]]);

M := Matrix(%id = 154901776)

>    sort(CharacteristicPolynomial(M,lambda));

lambda^3-7*lambda^2+31*lambda-10

>    Eigenvalues(M);

Vector(%id = 135892440)

>    f:= (i,j) -> x^i+y^j;

f := proc (i, j) options operator, arrow; x^i+y^j end proc

>    Matrix(3,f);

Matrix(%id = 136188444)

  Differentiation, Integration (diff, int)

>    restart;

>    diff(x^n,x);

x^n*n/x

>    diff(1/sqrt(x+1),x);

-1/(2*(x+1)^(3/2))

>    diff(x^x,x);

x^x*(ln(x)+1)

>    diff(exp(x*ln(x)),x);

(ln(x)+1)*exp(x*ln(x))

>    int(x^n,x);

x^(n+1)/(n+1)

>    int(sin(x)^5,x);

-1/5*sin(x)^4*cos(x)-4/15*sin(x)^2*cos(x)-8/15*cos(x)

>    int(exp(-x^2),x);

1/2*Pi^(1/2)*erf(x)

>    int(sqrt(1-x^2),x=-1..1);

1/2*Pi

>    int(1/(1+x^3),x=0..infinity);

2/9*Pi*3^(1/2)

>    int(1/(1+x^6),x=0..infinity);

1/3*Pi

>    int(1/(1+x^7),x=0..infinity);

1/7*Beta(1/7,6/7)

>    int(1/(1+x^n),x=0..infinity);

Definite integration: Can't determine if the integral is convergent.

Need to know the sign of --> n

Will now try indefinite integration and then take limits.

1/n*Pi*csc(Pi/n)

>    int(cos(x)/(1+x^2),x=0..infinity);

-1/2*Pi*sinh(1)+1/2*cosh(1)*Pi

>    convert(%,exp);

-1/2*Pi*(1/2*exp(1)-1/2*1/exp(1))+1/2*(1/2*exp(1)+1/2*1/exp(1))*Pi

>    simplify(%);

1/2*Pi*exp(-1)

>    int(log(x)/(1+x)^3,x=0..infinity);

-1/2

 Number Theory (numtheory)

>    with(numtheory);

Warning, the protected name order has been redefined and unprotected

[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divisors, factorEQ, factorset, fermat, imagunit, index, integral_basis, invcfrac, invphi, issqrfree, jacobi, kronecker, lambda, legendre, mcombine, mersen...
[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divisors, factorEQ, factorset, fermat, imagunit, index, integral_basis, invcfrac, invphi, issqrfree, jacobi, kronecker, lambda, legendre, mcombine, mersen...
[GIgcd, bigomega, cfrac, cfracpol, cyclotomic, divisors, factorEQ, factorset, fermat, imagunit, index, integral_basis, invcfrac, invphi, issqrfree, jacobi, kronecker, lambda, legendre, mcombine, mersen...

>    ifactor(2^(2^6)+1);

``(67280421310721)*``(274177)

>    divisors(111111);

{1, 3, 7, 11, 13, 21, 33, 37, 39, 77, 91, 111, 143, 231, 259, 273, 407, 429, 481, 777, 1001, 1221, 1443, 2849, 3003, 3367, 5291, 8547, 10101, 15873, 37037, 111111}

>    n:=2352356;

n := 2352356

>    phi(n);

1169640

>    pr:=convert(factorset(n),list);

pr := [2, 191, 3079]

>    n*product('(1-1/pr[i])','i'=1..nops(pr));

1169640

>    cyclotomic(3,x);

x^2+x+1

>    cyclotomic(6,x);

x^2-x+1

>    cyclotomic(7,x);

x^6+x^5+x^4+x^3+x^2+x+1

>    cyclotomic(8,x);

x^4+1

>    cyclotomic(100,x);

x^40-x^30+x^20-x^10+1

>    for n from 1 to 500 do
   if {coeffs(cyclotomic(n,x))} minus {1,-1} <> {}
      then lprint(n); fi;
od;

105

165

195

210

255

273

285

315

330

345

357

385

390

420

429

455

495

>    s:={};
st:=time():
for n from 1 to 2000 do
   s:=s union {coeffs(cyclotomic(n,x))}: od:
time()-st;
s;

s := {}

40.161

{-4, -3, -2, -1, 1, 2, 3, 4, 5}

  Count the number of primes less than a given limit

>    pi(100);

25

 resultants

>    p:=x^6+y^2-1;

p := x^6+y^2-1

>    q:=x^3+y^3-5;

q := x^3+y^3-5

>    factor(resultant(p,q,x));

(24+y^2-10*y^3+y^6)^3

>    solve({p,q},{x,y});

{y = RootOf(24+_Z^2-10*_Z^3+_Z^6), x = RootOf(_Z^3-5+RootOf(24+_Z^2-10*_Z^3+_Z^6)^3)}

>    with(plots):

Warning, the name changecoords has been redefined

>    p:=x^2+y^2-1;q:=x-y-1;

p := x^2+y^2-1

q := x-y-1

>    a:=implicitplot(p,x=-1..1,y=-1..1):

>    b:=implicitplot(q,x=-2..2,y=-2..1,color=green):

>    display({a,b});

[Maple Plot]

 other packages

>    with(orthopoly);

[G, H, L, P, T, U]

>    seq(T(n,x),n=1..6);

x, -1+2*x^2, 4*x^3-3*x, 1+8*x^4-8*x^2, 16*x^5-20*x^3+5*x, -1+32*x^6-48*x^4+18*x^2

>    map(factor,[%]);

[x, -1+2*x^2, x*(4*x^2-3), 1+8*x^4-8*x^2, x*(16*x^4-20*x^2+5), (-1+2*x^2)*(16*x^4-16*x^2+1)]

>    with(stats);with(stats[statplots]):

[anova, describe, fit, importdata, random, statevalf, statplots, transform]

>    mark:=rand(1..100);

mark := proc () local t; global _seed; _seed := irem(a*_seed,p); t := _seed;  to concats do _seed := irem(a*_seed,p); t := s*t+_seed end do; irem(t,divisor)+offset end proc
mark := proc () local t; global _seed; _seed := irem(a*_seed,p); t := _seed;  to concats do _seed := irem(a*_seed,p); t := s*t+_seed end do; irem(t,divisor)+offset end proc
mark := proc () local t; global _seed; _seed := irem(a*_seed,p); t := _seed;  to concats do _seed := irem(a*_seed,p); t := s*t+_seed end do; irem(t,divisor)+offset end proc
mark := proc () local t; global _seed; _seed := irem(a*_seed,p); t := _seed;  to concats do _seed := irem(a*_seed,p); t := s*t+_seed end do; irem(t,divisor)+offset end proc
mark := proc () local t; global _seed; _seed := irem(a*_seed,p); t := _seed;  to concats do _seed := irem(a*_seed,p); t := s*t+_seed end do; irem(t,divisor)+offset end proc

>    marks:=[seq(mark(),i=1..30)];

marks := [77, 39, 86, 69, 22, 10, 56, 64, 58, 61, 75, 86, 17, 62, 8, 50, 87, 99, 67, 10, 74, 82, 75, 67, 74, 43, 92, 94, 1, 12]

>    histogram(marks);

[Maple Plot]