Zurück zum Inhaltsverzeichnis

Kapitel 14

geometry-Package

> restart:
with(geometry):

> point(A,1,1), point(B,3,5), point(C,6,3);

A, B, C

> line(g, [A,B]);

g

> _EnvHorizontalName:='x':_EnvVerticalName:='y':

> detail(g);

`name of the object:  g\nform of the object:  line2...
`name of the object:  g\nform of the object:  line2...
`name of the object:  g\nform of the object:  line2...

> line(h, [C, point(``,0,0)]);

h

> intersection(IP,g,h);

IP

> coordinates(IP);

[2/3, 1/3]

> circle(c, [A,B,C]):

> intersection(IP,h,c);

[h_intersect1_c, h_intersect2_c]

> map(coordinates, IP);

[[6, 3], [5/4, 5/8]]

> point(P, [7,py]):

> AreCollinear(A,B,P);

AreCollinear: "hint: could not determine if -26+2*py is zero"

FAIL

> draw([A,B,C,g,h,c], color=black, scaling=constrained);

[Maple Plot]

Das Package geom3d

> restart:with(geom3d):

Warning, the name polar has been redefined

Über die Umgebungsvariablen _EnvXName, _EnvYName, _EnvZName kann man die Namen der Achsen festlegen:

> _EnvXName:='x1':_EnvYName:='x2':_EnvZName:='x3':_EnvTName:='t':

> point(A,4,-1,1):point(B,7,1,0):point(C,4,7,-3):

> plane(e1,[A,B,C]):line(l1,[A,B]):sphere(k,[point(M,4,0,3),3]):

> detail(l1);

`name of the object:  l1\nform of the object:  line...
`name of the object:  l1\nform of the object:  line...
`name of the object:  l1\nform of the object:  line...

> detail(e1);

`name of the object:  e1\nform of the object:  plan...
`name of the object:  e1\nform of the object:  plan...
`name of the object:  e1\nform of the object:  plan...

> NormalVector(e1);

v1 := [0, 12, 24]

> detail(k);

`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...
`name of the object:  k\nform of the object:  spher...

> intersection(p,l1,k);

geom3d/areinterls: "two points of intersection"

p

> detail(p[1]);

`name of the object:  l1_intersect1_k\nform of the ...
`name of the object:  l1_intersect1_k\nform of the ...
`name of the object:  l1_intersect1_k\nform of the ...

> coordinates(p[2]);

[4-3/7*sqrt(14), -1-2/7*sqrt(14), 1+1/7*sqrt(14)]

>

LinearAlgebra

> restart:

> with(LinearAlgebra);

[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...
[Add, Adjoint, BackwardSubstitute, BandMatrix, Basi...

Vektoren

> v1z:= <a|b|c>; v1s:=<a,b,c>;

v1z := _rtable[841864]

v1s := _rtable[842264]

> v2:= Vector[row](3, n->x^n);Transpose(v2);

v2 := _rtable[842344]

_rtable[976952]

> v1z + v2 ;v1s+v2;

_rtable[977712]

Error, (in rtable/Sum) invalid arguments

> v1z * 2;

_rtable[978792]

> map(x->x+3,v1z);

_rtable[1071700]

> DotProduct(v1z, v2,conjugate=false);

x*a+x^2*b+x^3*c

> v1z . Transpose(v2);

x*a+x^2*b+x^3*c

> v2 . v1s;

x*a+x^2*b+x^3*c

> Transpose(v2).v1z;

_rtable[1502192]

> DotProduct(v1z, v2);

conjugate(x)*a+conjugate(x)^2*b+conjugate(x)^3*c

> DotProduct(v1s, v2);

conjugate(a)*x+conjugate(b)*x^2+conjugate(c)*x^3

> DotProduct(<1, I>, <1,I> );

2

> DotProduct( <1, I>, <1,I>, conjugate=false );

0

> CrossProduct(v1s,v2);

_rtable[1547076]

> CrossProduct(<1|3|4>,<a|b|c>);

_rtable[1629256]

>

> Norm( <a,b,c> );

max(abs(c),abs(b),abs(a))

> Norm( <a,b,c>, 1);

abs(a)+abs(b)+abs(c)

> Norm( <a,b,c>, 2);

sqrt(abs(a)^2+abs(b)^2+abs(c)^2)

> Normalize( <1|2|3>,2 );

_rtable[1475552]

> VectorAngle( <1,0,0>,<1,1,1> );

arccos(1/3*sqrt(3))

> evalf(%*180/Pi);

54.73561030

Matrizen

> restart:with(LinearAlgebra):

> Matrix(2,2,[[a,b],[c,d]]);<<a|b>,<c|d>>;<<a,c>|<b,d>>;

_rtable[1200872]

_rtable[1153072]

_rtable[1240520]

> Matrix( [[a,b,c], [d,e,f], [g,h,i]]);

_rtable[1334420]

> Matrix( 3,3, (n,m)->n*x^m);

_rtable[1325300]

> Matrix( 3,5,storage=sparse);

_rtable[1331956]

> IdentityMatrix(3,4);

_rtable[1096900]

>

> DiagonalMatrix([1,<<1,-1>|<-1,1>>,2,3]);

_rtable[28864644]

> BandMatrix( [1,x,-1], 1,4);

_rtable[1160512]

> ToeplitzMatrix( <a,b,c,d>,4,symmetric);

_rtable[1593780]

> RandomMatrix(15,15);

_rtable[1578268]

> RandomMatrix(2,2,generator=rand(0..10)/10);

_rtable[1550232]

Zugriff auf Matrizenelemente

> restart:with(LinearAlgebra):

> m1:=<<1|2|3|4>,<a|b|c|d>,<e|f|g|h>,<w|x|y|z>>;

m1 := _rtable[1026512]

> m1[2..3,2..4];

_rtable[24536224]

> SubMatrix(m1,1..2,3..4);

_rtable[871964]

> SubMatrix(m1,[3,1],[2..4,1]);

_rtable[920052]

> Row(m1, 2);

_rtable[817724]

> Column(m1,2);

_rtable[817964]

> v1:=Matrix(1,4,(m,n)->x^n);

v1 := _rtable[989200]

> m1[1,3]:=5;

m1[1,3] := 5

> m1[3..3,1..4]:=v1;m1;

m1[3 .. 3,1 .. 4] := _rtable[989200]

_rtable[1026512]

> m2:=Matrix(4,4):

> m2[2..4,2..4]:=m1[1..3,1..3];

m2[2 .. 4,2 .. 4] := _rtable[1052620]

> m2;

_rtable[936852]

> m2[1,1]:=5;m2;

m2[1,1] := 5

_rtable[936852]

Elementare Matrizenoperationen

> restart:with(LinearAlgebra):

> m1:=<<a,c,e>|<b,d,f>>;

m1 := _rtable[22725480]

> m2:=<<r|s|t>,<u|v|w>>;

m2 := _rtable[22730656]

> Transpose(m2);

_rtable[22732704]

> m2 * 3;

_rtable[22734752]

> m2 + 3;

_rtable[22736944]

> map(sqrt, m2);

_rtable[1365200]

> m1 + Transpose(m2);

_rtable[23972308]

> m1 . m2;

_rtable[22890736]

> m2 . m1;

_rtable[23976772]

> m3:=Matrix([[1,2],[3,4]]);

m3 := _rtable[23980844]

> 1/m3;

_rtable[23983292]

> m3^3, m3 . m3 . m3;

_rtable[23985428], _rtable[24327764]

Produkte

> restart:with(LinearAlgebra):

> m1:=<<a|b|c>,<d|e|f>,<g|h|i>>:

> v1:=<u|v|w>;

v1 := _rtable[23987916]

> v2:=<u,v,w>;

v2 := _rtable[23987956]

> m1 . v2;

_rtable[23987996]

> v1 . m1 ;

_rtable[23988036]

> v1 . v2;

u^2+v^2+w^2

> v2 . v1;

_rtable[24049524]

Determinanten, Inverse, ...

> restart:with(LinearAlgebra):

> m1:=<<1| 2| 3>,<4|-5| 6>,<9| 8| 7>>;

m1 := _rtable[964220]

> Determinant(m1);

200

> m2:=MatrixInverse(m1);

m2 := _rtable[1026612]

> Rank(m1);

3

> v:=<14,12,46>;

v := _rtable[1443016]

> m2 . v;

_rtable[1527756]

> m1 . %;

_rtable[23428152]

> Trace(m1);

3

> Norm(<<a|b|c>,<d|e|f>,<g|h|i>>);

max(abs(a)+abs(b)+abs(c),abs(d)+abs(e)+abs(f),abs(g...

> Norm(<<a|b|c>,<d|e|f>,<g|h|i>>,Frobenius);

sqrt(abs(a)^2+abs(d)^2+abs(g)^2+abs(b)^2+abs(e)^2+a...

> Norm(<<a|b|c>,<d|e|f>,<g|h|i>>,1);

max(abs(a)+abs(d)+abs(g),abs(b)+abs(e)+abs(h),abs(c...

> Norm(<<1|2>,<3|7>>,2);

sqrt(RootOf(1-63*_Z+_Z^2,index = 2))

> allvalues(%);

sqrt(63/2+1/2*sqrt(3965))

> Rank( <<1|2>,<3|4>> );

2

> Rank( <<1|2>,<3|6>> );

1

Lineare Gleichungssysteme

> restart:with(LinearAlgebra):

> A:=<<1|2|3>,<4|-5|6>,<9|8|7>>:

> b:=<14,12,46>:

> LinearSolve(A,b);

_rtable[23485648]

> A:=<<1|2|3>,<4|8|12>,<1|-1|0>>:

> LinearSolve(A,b);

Error, (in LinearAlgebra:-LA_Main:-LinearSolve) inconsistent system

> NullSpace(A);

{_rtable[999108]}

> A . %[1];

_rtable[1115056]

> A:=<<1|2|3>,<4|5|6>,<0|0|0>>:

> b:=<1,2,0>:

> lsg:=LinearSolve( A,b,free='t');

lsg := _rtable[1114336]

> A . lsg ;

_rtable[1114456]

> A := <<3,0,4.0>|<-2,3,4>>:

> b := <1,2,4>:

> LinearSolve(A,b);

Error, (in LinearAlgebra:-LA_Main:-LinearSolve) inconsistent system

> X:=LeastSquares(A,b);

X := _rtable[1457412]

> A . X;

_rtable[1457692]

> Norm(A.X-b,2);

.639999999999999902

> glsys:=[2*y+x+3*z-16=-2,4*x-5*y+6*z=12,9*x+8*y+7*z=46]:

> glmat1:=GenerateMatrix(glsys, [x,y,z]);

glmat1 := _rtable[1359700], _rtable[1351444]

> glmat2:=GenerateMatrix(glsys, [x,y,z], augmented=true);

glmat2 := _rtable[1454732]

> LinearSolve(glmat2);

_rtable[1352044]

> glmat1[1] . %;

>

_rtable[862088]

>

Umformungen

> restart:with(LinearAlgebra):

> m:=RandomMatrix(4,5);

m := _rtable[22849148]

> (P,L,U):=LUDecomposition(m);

P, L, U := _rtable[22852396], _rtable[22854712], _r...

> P.L.U;

_rtable[22861096]

> U1,R:=LUDecomposition(m,output=['U1','R']);

U1, R := _rtable[22863224], _rtable[22867696]

> U1.R;

_rtable[22870056]

> mat:=RandomMatrix(4,4);Pivot(mat,2,3);

mat := _rtable[47880880]

_rtable[47884260]

Eigenwerte, Eigenvektoren

> restart:with(LinearAlgebra):

> m1:=<<41, 5, -10>|<3, 39, -6>|<-14,-14, 64>>;

m1 := _rtable[47947600]

> ew:=Eigenvalues(m1);

ew := _rtable[47915296]

> ev:=Eigenvectors(m1,output='list');

ev := [[36, 2, {_rtable[47915336], _rtable[47915376...

> Eigenvectors(m1);

_rtable[47915456], _rtable[47961944]

> CharacteristicPolynomial(m1, lambda);

-93312+6480*lambda-144*lambda^2+lambda^3

> m1 - DiagonalMatrix(<lambda,lambda,lambda>);Determinant(%);

_rtable[47966140]

93312-6480*lambda+144*lambda^2-lambda^3

> solve(%);

72, 36, 36

>

>

Orthonormalbasen

> restart:with(LinearAlgebra):

> v1:=<3|4|0>: v2:=<2|-1|3>: v3:=<-1|0|2>: v4:=<1|-2|1>:

> GramSchmidt([v1,v2,v3,v4]);

[_rtable[48505960], _rtable[48506600], _rtable[4850...

> onb:=GramSchmidt([v1,v2,v3,v4],normalized=true);

onb := [_rtable[48976972], _rtable[877108], _rtable...

> DotProduct(onb[1], onb[2]), DotProduct(onb[2], onb[2]);

0, 1

> with(tensor);

[Christoffel1, Christoffel2, Einstein, Jacobian, Ki...
[Christoffel1, Christoffel2, Einstein, Jacobian, Ki...
[Christoffel1, Christoffel2, Einstein, Jacobian, Ki...
[Christoffel1, Christoffel2, Einstein, Jacobian, Ki...
[Christoffel1, Christoffel2, Einstein, Jacobian, Ki...

>

Zurück zum Inhaltsverzeichnis