Brief Introduction to Maple

Maple is a symbol manipulator.

Exact arithmetic:

>    1/29+1/31;

60/899

>    arcsin(1/2);

1/6*Pi

>    exp(I*Pi);

-1

Can give numerical answers to arbitrary precision:

>    evalf( arcsin(1/2), 10);

.5235987758

>    evalf( arcsin(1/2), 40);

.5235987755982988730771072305465838140329

>    evalf( Pi, 1000);

3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819...

Note default of evalf is 10 digits:

>    evalf(Pi);

3.141592654

Algebraic expressions:

>    restart;                 Also discuss saving work

>    a:=x^2*exp(x)*cos(x);

a := x^2*exp(x)*cos(x)

>    diff(a,x);

2*x*exp(x)*cos(x)+x^2*exp(x)*cos(x)-x^2*exp(x)*sin(x)

>    int(a,x);

(1/2*x^2-1/2)*exp(x)*cos(x)-(-1/2*x^2+x-1/2)*exp(x)*sin(x)

>    I:=int(a,x=-Pi..Pi);

Error, illegal use of an object as a name

>    I1:=int(a,x=-Pi..Pi);

I1 := -1/2*(exp(Pi)^2*Pi^2-exp(Pi)^2-Pi^2+1)/exp(Pi)

>    simplify(I1);

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

>    factor(I1);

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

>    plot(a,x=0..Pi/2);

[Maple Plot]

Note last thing is NOT a symbolic procedure!

Using Maple to solve equations:

>    restart;

>    a:= x^2-3*x+1=0 ;

a := x^2-3*x+1 = 0

>    solve(a,x);

3/2+1/2*5^(1/2), 3/2-1/2*5^(1/2)

>    solve( {x+s*y=t,2*x-y=s*t} , {x,y} );

{y = -t*(-2+s)/(2*s+1), x = t*(s^2+1)/(2*s+1)}

>    solve( {x+s*y=t,2*x-y=s*t} , {t,y} );

{y = -x*(-2+s)/(s^2+1), t = x*(2*s+1)/(s^2+1)}

>    a:= x=(1+x^2)*cos(x) ;

a := x = (1+x^2)*cos(x)

>    solve(a,x);

RootOf(cos(_Z)*_Z^2+cos(_Z)-_Z)

>    fsolve(a,x);

1.047826930

This is numeric....but matlab does not really have it

>    plot( (1+x^2)*cos(x)-x  , x = -3..3);

[Maple Plot]

>    fsolve(a,x=-3..-1);

-1.984365367

Some linear algebra

>    restart;

>    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...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...

>    M1:=matrix(3,3,[1,3,4,t,1,6,-3,t+4,1] );

M1 := matrix([[1, 3, 4], [t, 1, 6], [-3, t+4, 1]])

>    det(M1);

-65+7*t+4*t^2

>    solve(det(M1)=0,t);

13/4, -5

>    M2:=matrix(3,3,[1,3,4,-5,1,6,-3,-1,1] );

M2 := matrix([[1, 3, 4], [-5, 1, 6], [-3, -1, 1]])

>    det(M2);

0

>    colspace(M2);

{vector([1, 0, -1/2]), vector([0, 1, 1/2])}

>    eigenvals(M2);

0, 3/2+3/2*I*15^(1/2), 3/2-3/2*I*15^(1/2)

>    eigenvects(M2);

[3/2+3/2*I*15^(1/2), 1, {vector([-5/8-3/8*I*15^(1/2), 11/8-3/8*I*15^(1/2), 1])}], [3/2-3/2*I*15^(1/2), 1, {vector([-5/8+3/8*I*15^(1/2), 11/8+3/8*I*15^(1/2), 1])}], [0, 1, {vector([1, -13/7, 8/7])}]

>    eigenvals(M1);    this is going to involve solving a cubic....maple is bad at this.

(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)-(-3*t-4)/(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1, -1/2*(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1/2*...
(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)-(-3*t-4)/(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1, -1/2*(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1/2*...
(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)-(-3*t-4)/(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1, -1/2*(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1/2*...
(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)-(-3*t-4)/(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1, -1/2*(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1/2*...
(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)-(-3*t-4)/(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1, -1/2*(-27+8*t+2*t^2+(5*t^3-152*t^2-576*t+665+4*t^4)^(1/2))^(1/3)+1/2*...

There is now  a package to do strictly numerical  linear algebra on maple....but I use matlab

Programming in maple:

>    x:=1/2;  for i from 1 to 10 do x:=5/2*x*(1-x) end do;

x := 1/2

x := 5/8

x := 75/128

x := 19875/32768

x := 1281241875/2147483648

x := 5549326167209221875/9223372036854775808

x := 101942394419755171106449565951379421875/170141183460469231731687303715884105728

x := 34761739256690745863177298892512763801252997122274649442208474823983937421875/57896044618658097711785492504343953926634992332820282019728792003956564819968

x := 4020943454386858549361934826949305623258243223315993799956664225550331295098177261878061768845487974640793906555804112059355794611314630488443078557421875/67039039649712985497870124991029230637396...
x := 4020943454386858549361934826949305623258243223315993799956664225550331295098177261878061768845487974640793906555804112059355794611314630488443078557421875/67039039649712985497870124991029230637396...
x := 4020943454386858549361934826949305623258243223315993799956664225550331295098177261878061768845487974640793906555804112059355794611314630488443078557421875/67039039649712985497870124991029230637396...

x := 5394016251706463972542512865969925505362316179142251468341315171397946252461340289702379024692215193272357625428877941077887383549791851300619391955571546521433516407564440735247277450436043965227...
x := 5394016251706463972542512865969925505362316179142251468341315171397946252461340289702379024692215193272357625428877941077887383549791851300619391955571546521433516407564440735247277450436043965227...
x := 5394016251706463972542512865969925505362316179142251468341315171397946252461340289702379024692215193272357625428877941077887383549791851300619391955571546521433516407564440735247277450436043965227...
x := 5394016251706463972542512865969925505362316179142251468341315171397946252461340289702379024692215193272357625428877941077887383549791851300619391955571546521433516407564440735247277450436043965227...
x := 5394016251706463972542512865969925505362316179142251468341315171397946252461340289702379024692215193272357625428877941077887383549791851300619391955571546521433516407564440735247277450436043965227...
x := 5394016251706463972542512865969925505362316179142251468341315171397946252461340289702379024692215193272357625428877941077887383549791851300619391955571546521433516407564440735247277450436043965227...

x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...
x := 9694259300734454568747431470522613204055764704668798049300214148561769064189966387561286442439738577038930698803084832348078796439522562169184751042430280248266789365760451904056982882567909686062...

>    x:=1/2;  for i from 1 to 20 do x:=evalf(5/2*x*(1-x)) end do;

x := 1/2

x := .6250000000

x := .5859375000

x := .6065368652

x := .5966247410

x := .6016591485

x := .5991635438

x := .6004164790

x := .5997913268

x := .6001042278

x := .5999478590

x := .6000260638

x := .5999869665

x := .6000065162

x := .5999967418

x := .6000016290

x := .5999991855

x := .6000004072

x := .5999997965

x := .6000001018

x := .5999999490

This of course would better be done in matlab

More generally can write functions known as procedures

Graphics

>    restart;

>    with(plots);

Warning, the name changecoords has been redefined

[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...
[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, displ...

Note: plotting is de facto numeric...better done in matlab but maple has nice procedures (and I know it)

>    animate( sin(x*t), x=-10..10, t=0.5..1);

[Maple Plot]

>    implicitplot3d( x^2-x+2*y+3*z=1, x=-5..5, y=-5..5, z=-10..5, axes=boxed, style=patchnogrid);

[Maple Plot]

>   

>    animate3d(cos(t*x)*sin(t*y),x=-Pi..Pi, y=-Pi..Pi,t=1..2);

[Maple Plot]

>