Maple is a symbol manipulator.
Exact arithmetic:
> | 1/29+1/31; |
> | arcsin(1/2); |
> | exp(I*Pi); |
Can give numerical answers to arbitrary precision:
> | evalf( arcsin(1/2), 10); |
> | evalf( arcsin(1/2), 40); |
> | evalf( Pi, 1000); |
Note default of evalf is 10 digits:
> | evalf(Pi); |
Algebraic expressions:
> | restart; Also discuss saving work |
> | a:=x^2*exp(x)*cos(x); |
> | diff(a,x); |
> | int(a,x); |
> | I:=int(a,x=-Pi..Pi); |
Error, illegal use of an object as a name
> | I1:=int(a,x=-Pi..Pi); |
> | simplify(I1); |
> | factor(I1); |
> | plot(a,x=0..Pi/2); |
Note last thing is NOT a symbolic procedure!
Using Maple to solve equations:
> | restart; |
> | a:= x^2-3*x+1=0 ; |
> | solve(a,x); |
> | solve( {x+s*y=t,2*x-y=s*t} , {x,y} ); |
> | solve( {x+s*y=t,2*x-y=s*t} , {t,y} ); |
> | a:= x=(1+x^2)*cos(x) ; |
> | solve(a,x); |
> | fsolve(a,x); |
This is numeric....but matlab does not really have it
> | plot( (1+x^2)*cos(x)-x , x = -3..3); |
> | fsolve(a,x=-3..-1); |
Some linear algebra
> | restart; |
> | with(linalg); |
Warning, the protected names norm and trace have been redefined and unprotected
> | M1:=matrix(3,3,[1,3,4,t,1,6,-3,t+4,1] ); |
> | det(M1); |
> | solve(det(M1)=0,t); |
> | M2:=matrix(3,3,[1,3,4,-5,1,6,-3,-1,1] ); |
> | det(M2); |
> | colspace(M2); |
> | eigenvals(M2); |
> | eigenvects(M2); |
> | eigenvals(M1); this is going to involve solving a cubic....maple is bad at this. |
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; for i from 1 to 20 do x:=evalf(5/2*x*(1-x)) end do; |
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
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); |
> | implicitplot3d( x^2-x+2*y+3*z=1, x=-5..5, y=-5..5, z=-10..5, axes=boxed, style=patchnogrid); |
> |
> | animate3d(cos(t*x)*sin(t*y),x=-Pi..Pi, y=-Pi..Pi,t=1..2); |
> |