Kapitel 3
Elementare Operationen
> restart:
> 2+3;
> 2 3; # * is missing
Error, unexpected number
> 2*3;
> 2^3;
> 1/2;
> 1/2+1/3;
> sqrt(2);
> evalf( sqrt(2) );
> evalf( sqrt(2), 60);
symbolic calculcation, exact resulat
> sqrt(2) * sqrt(8) - 4;
numeric calculation
> evalf(sqrt(2))*evalf(sqrt(8))-4;
Präzision
> Digits; # default is 10
> Digits:=50;
> evalf(sqrt(2))*evalf(sqrt(8))-4;
> Digits:=10: # back to default
> 100!;
> evalf(100!,5);
>
> evalf(100!,20);
> lg2:=log[2](256);
> evalf(lg2); # numeric
> simplify(lg2); # symbolic
> sq2:=evalf(sqrt(2));
> evalf(1/sq2^2,50); # 40 digits are rubbish !
Zeichenketten (Strings)
> str1:="Maple hat Strings.";
> convert(str1,symbol);
> convert("abc",list);
> cat(%[]);
> convert("abc",'bytes');
> convert(%,'bytes');
> str1[7..9];str1[-8..-2];
>
> searchtext("stri",str1);
> SearchText("stri",str1);
> sort(["Eva","Adam","Abel","Kain","Noah","Lot","Moses"],(x,y)->is(x>y));
>
>
Komplexe Zahlen, Matrizen, elementare Statistik
Komplexe Zahlen
> -20 * I + 200 * I / (20 + 10 * I);
> abs(4-12*I); evalf(%);
Lineare Algebra
> mat1:=<< 1| 2| 3>,< 7|11|-3>>;
> mat2:=<<0,-3,5>|<7,17,-1>>;
> mat3:=mat1 . mat2;
> 3*mat1;
> mat4:= mat2 . mat1 + <<1,0,0>|<0,1,0>|<0,0,1>>;
> mat4^3;
> mat4^(-1);
> with(LinearAlgebra):
> Determinant(mat4);
Statistik
> with(stats): with(describe):
> data:=[ 10.2, 9.9, 10, 9.95, 10, 10.1, 10.4, 9.3, 9.85, 10.05, 10.1 ];
> mean(data);
> variance(data);
> sqrt(%);