Matrices (linalg)
| > | with(linalg); |
Warning, the protected names norm and trace have been redefined and unprotected
| > | m:=matrix([[1,2,3],[2,3,1],[3,2,1]]); |
| > | det(m); |
| > | im:=inverse(m); |
| > | id3:=evalm(m&*im); |
| > | eigenvalues(m); |
| > | map(evalf,[%]); |
| > | charpoly(m,lambda); |
| > | eig:=[eigenvectors(m)]; |
| > | eiv:=eig[2][1]; |
| > | eigm2:=op(eig[2][3]); |
| > | evalm((m-eiv*id3)&*eigm2); |
| > | nullspace(m); |
Gaussian Elimination
| > | 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:=addrow(m,2,3,-4); |
| > | submatrix(m,1..2,1..3); |
| > | minor(m,1,2); |
Matrices (LinearAlgebra)
| > | with(LinearAlgebra); |
Warning, the assigned name GramSchmidt now has a global binding
| > | M:=Matrix(3,[[1,2,3],[-1,-3,-5],[-5,7,9]]); |
| > | sort(CharacteristicPolynomial(M,lambda)); |
| > | Eigenvalues(M); |
| > | f:= (i,j) -> x^i+y^j; |
| > | Matrix(3,f); |
Differentiation, Integration (diff, int)
| > | restart; |
| > | diff(x^n,x); |
| > | diff(1/sqrt(x+1),x); |
| > | diff(x^x,x); |
| > | diff(exp(x*ln(x)),x); |
| > | int(x^n,x); |
| > | int(sin(x)^5,x); |
| > | int(exp(-x^2),x); |
| > | int(sqrt(1-x^2),x=-1..1); |
| > | int(1/(1+x^3),x=0..infinity); |
| > | int(1/(1+x^6),x=0..infinity); |
| > | int(1/(1+x^7),x=0..infinity); |
| > | 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.
| > | int(cos(x)/(1+x^2),x=0..infinity); |
| > | convert(%,exp); |
| > | simplify(%); |
| > | int(log(x)/(1+x)^3,x=0..infinity); |
Number Theory (numtheory)
| > | with(numtheory); |
Warning, the protected name order has been redefined and unprotected
| > | ifactor(2^(2^6)+1); |
| > | divisors(111111); |
| > | n:=2352356; |
| > | phi(n); |
| > | pr:=convert(factorset(n),list); |
| > | n*product('(1-1/pr[i])','i'=1..nops(pr)); |
| > | cyclotomic(3,x); |
| > | cyclotomic(6,x); |
| > | cyclotomic(7,x); |
| > | cyclotomic(8,x); |
| > | cyclotomic(100,x); |
| > | 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; |
Count the number of primes less than a given limit
| > | pi(100); |
resultants
| > | p:=x^6+y^2-1; |
| > | q:=x^3+y^3-5; |
| > | factor(resultant(p,q,x)); |
| > | solve({p,q},{x,y}); |
| > | with(plots): |
Warning, the name changecoords has been redefined
| > | 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}); |
other packages
| > | with(orthopoly); |
| > | seq(T(n,x),n=1..6); |
| > | map(factor,[%]); |
| > | with(stats);with(stats[statplots]): |
| > | mark:=rand(1..100); |
| > | marks:=[seq(mark(),i=1..30)]; |
| > | histogram(marks); |