Lab Project 1

advertisement

Lab Project 1

> with(LinearAlgebra):

> with(plots):

Warning, the name changecoords has been redefined

Exercise 1a: we start by looking at the plane defined by the first equation:

> plot3d(-x-2*y,x=-5..5,y=-5..5,axes=normal);

–4

–2

4 y

2

5

0

15

10

–5

2

–10 x

–15

–2

4

–4

Then we add the second equation:

> plot3d({-x-2*y,2*y-2*x+3},x=-5..5,y=-5..5,axes=normal);

–4

–2

4 y

20

10

0

–2

–4

–10 x

4 and we see that, so far, the intersection is a line. We finally add the last plane:

> plot3d({-x-2*y,2*y-2*x+3,1/2-x/2},x=-5..5,y=-5..5,axes=normal);

–4

–2

4 y

20

10

0

–2

–4

–10 x

4

It seems to be that the triple intersection is a point. We can get a better view by graphing the line obtained from the intersection of the first two planes and the third plane:

> LinearSolve(<<1,2>|<2,-2>|<1,1>>,<0,3>);





 4 _t0

2

_t0

6 _t0

2

2

+

3

3







> line:=spacecurve([4*t+3,t,-6*t-3],t=-2..2,axes=normal,labels=["x",

"y","z"],thickness=2,color=brown):

> plane:=plot3d(1/2-x/2,x=-5..5,y=-5..5):

> display(plane,line);

–4

10

8

6 x

4

2

–2 5

–4 y

0

–5

–10

–15

2

4

And we see that the intersection is, in fact, a point.

We find the intersection algebraically:

> LinearSolve(<<1,2,1>|<2,-2,0>|<1,1,2>>,<0,3,1>);







1

-1

2







0

Again, we obtain a point as the solution. We could now go back to the previous graphs and check that the coordinates of the solution are those of the intersection.

Exercise 1b: We graph the first two planes:

> plot3d({1/2-x/2-y/2,-x},x=-2..2,y=-2..2,axes=normal);

–2

2

–1

1 y

2

1

0

–1

1 x

–2

–1

2

–2 and the intersection is a line. We add the third plane:

> plot3d({1/2-x/2-y/2,-x,-y},x=-2..2,y=-2..2,axes=normal);

2

1

2

–2

1 y x

–1

2

–2

–2

This frontal view may clarify the intersections

> plot3d({1/2-x/2-y/2,-x,-y},x=-2..2,y=-2..2,axes=normal);

2

–2

1

–1 x

2

1

0

–1 y

1

–2

–2

2 and we see that the intersection is empty because the planes intersect pairwise, but not all of them at the same time.

We find the solution algebraically:

> LinearSolve(<<1,1,0>|<1,0,1>|<2,1,1>>,<1,0,0>);

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

That is, algebraically the system is incompatible (so that there are no solutions).

Exercise 2a: We write the matrix version of the relations, where we consider the T-nodes as data and the P-nodes as unknowns:

> AP:=<<-4,1,0,0,1,1>|<1,-4,1,0,0,1>|<0,1,-3,1,0,1>|<0,0,1,-4,1,1>|<

1,0,0,1,-4,1>|<1,1,1,1,1,-5>>;

> bP:=<-T1,-T2,0,-T3,-T4,0>;

AP :=















-4

1

0

0

1

1

-4

1

0

0

0

1

-3

1

0

0

0

1

-4

1

1

0

0

1

-4

1

1

1

1

1

1 1 1 1 1 -5

















bP :=















T1

T2

0

T3

T4

0















Exercise 2b: We find the solution for the P-nodes in terms of the T-nodes by solving the linear system:

> sol:=LinearSolve(AP,bP); sol :=















 90 T3

551





197 T3

1102

17

58

487 T3

1102

+

+

T3

113 T4

551

90

+

T4

551

6 T4

29

119

551

T4

+

+











119 T3

551

15

+

+

T3

229

+

551

T4

+

+

+

+

229 T1

551

119 T1

6

551

T1

29

90 T1

551

113

551

+

T1

+

+

+

+

119

551

487

1102

17 T2

+

58

197

90

T2

T2

T2

1102

T2

551

58

7 T4

29

7 T1

29

15 T2

58





























 equivalently:

> evalf(sol);















0.1633393829

T3

+

0.2050816697

T4

+

0.4156079855

T1

+

0.2159709619

T2

0.1787658802

0.2931034483

0.4419237750

0.2159709619

0.2586206897

T3

T3

T3

T3

T3

+

+

+

+

+

0.1633393829

0.2068965517

0.2159709619

0.4156079855

0.2413793103

T4

T4

T4

T4

T4

+

+

+

+

+

0.2159709619

0.2068965517

0.1633393829

0.2050816697

0.2413793103

T1

T1

T1

T1

T1

+

+

+

+

+

0.4419237750

0.2931034483

0.1787658802

0.1633393829

0.2586206897

T2

T2

T2

T2

T2

















Exercise 2c: we simply substitute the given temperature values at the T nodes into the expression for the solution of the P-nodes

> subs({T1=0,T2=100,T3=0,T4=200},sol);





























 34500

551

42350

551

2050

29

33650

551

54800

551

2150































29 or,

> evalf(%);









62.61343013

76.86025408

70.68965517





61.07078040



99.45553539

74.13793103

















Exercise 2d: Same as above, but we don’t specify the temperature T4:

> subs({T1=0,T2=100,T3=0},sol);





























 11900

551

24350

551

850

29

9850

551

9000

551

750

+

+

+

+

+

+

113

6

551

90

551

T4

551

T4

29

119 T4

551

229

T4

T4

29

7 T4

29





























 or,

> evalf(%);







 21.59709619

+

0.2050816697

T4

44.19237750

+

0.1633393829

T4

29.31034483

+

0.2068965517

T4









17.87658802

+

0.2159709619

T4

16.33393829

+

0.4156079855

T4

25.86206897

+

0.2413793103

T4

















Each line of the solution gives the dependence of the corresponding P-node on the value of T4. The coefficient of T4 in each formula represents how "sensitive" the node is to the value T4. Thus, the node that is the most sensitive to T4 is P5 (it has the largest coefficient). We notice that according to the diagram P5 is the node closest to T4 (it is the only one that is directly connected to T4) so that we expected it to be the most senistive to T4.

Exercise 2e: We again express the relations as a linear system of equations. This time there are no fixed temperatures (all nodes are subjected to the averaging law):

> AN:=<<-1,1/2,0,0,1/2>|<1/2,-1,1/2,0,0>|<0,1/2,-1,1/2,0>|<0,0,1/2,-

1,1/2>|<1/2,0,0,1/2,-1>>;

AN :=

























-1

1

2

0

0

1

2

-1

1

2

0

0

1

2

-1

1

2

0

0

1

2

-1

1

2

0

0

1

2

























1

2

0 0

1

2

-1

> bN:=<0,0,0,0,0>; bN :=















0

0







0





0

0





Exercise 2f: we solve the system:

> LinearSolve(AN,bN);















_t0

3

_t0

3

_t0

3

_t0

3

_t0

3















We see that there are infinitely many solutions (so, no unique solution).

Exercise 3a: we have to create the lists of points corresponding to the lines and circle:

> listCircle:=seq([cos(2*Pi*t/100),sin(2*Pi*t/100)],t=0..100):

> listShortLine:=seq([t/50,t/50],t=0..100):

> listLongLine:=seq([t/50,-t/50],t=0..150):

> listTestGraph:=listCircle,listShortLine,listLongLine:

> listplot([listTestGraph],style=POINT,symbol=POINT,scaling=constrai ned);

2

1

–1 1 2 3

–1

–2

–3

Exercise 3b: We use the form of the matrix of a rotation by 30 degrees in the clockwise direction (this type of matrix was discussed in class and is also in the textbook). We start by converting the angle to radians and we put a minus sign because it is a rotation in the clockwise direction:

> alpha:=-30*Pi/180;

π

6

Then, the coefficient matrix is

> M:=<<cos(alpha),sin(alpha)>|<-sin(alpha),cos(alpha)>>;

M := 





2

3 1

2 





-1 3

2 2

Exercise 3c: As discussed in the second tutorial we apply M to each point of the test graph (which reaquires some conversions)

> Rot:=x->convert((M.convert(x,Vector)),list);

> transformedTestGraph:=map(Rot,[listTestGraph]):

> listplot(transformedTestGraph,style=POINT,symbol=POINT,scaling=con strained);

Rot := x

→ convert ( M . ( ( x Vector ) ) , list )

1

–1 –0.5

0.5

1 1.5

2 2.5

–1

–2

–3

–4

The previous graph shows the rotated figure.

Exercise 3d:

> A:=<<0,1>|<1,0>>;

> T:=x->convert((A.convert(x,Vector)),list);

> transformedTestGraph:=map(T,[listTestGraph]): listplot(transformedTestGraph,style=POINT,symbol=POINT,scaling=con strained);

A :=

T := x

→ convert ( A . (

0 1

1 0



( x Vector ) ) , list )

–3 –2 –1

3

2

1

0

–1

1 2

We see that the resulting graph corresponds to a reflection across the line y=x.

Exercise 4: We have

> A:=<<2,0,-2,7,0>|<3,1,2,2,0>|<0,7,1,3,1>|<-1,-2,0,1,-1>|<K,1,1,1,-

1>>;

A :=















2

0

-2

7

3

1

2

2

0

7

1

3

-1

-2

0

1

K

1

1

1

0 0 1 -1 -1















We find the inverse matrix:

> MatrixInverse(A);

























24

25 ( 8

+

3 K

5 ( 8

25 (

25 (

8

8

2

+

3

3

47

+

122

+

3

3

8

+

3 K

K )

K

K

)

)

)

2 (

5 (

25 (

− +

25 (

2 (

1

3 (

+

8

8

8

2

3

+

+

+

18

− +

+

3

3

9

3

3

8

+

3 K

K

K

K

K

K

)

K

25 ( 8

+

3 K

K

)

)

)

)

)

)

6 (

25 (

16

5 (

25 (

8

8

+

8

+

3 K

− +

8

+

3 K

144

25 (

4

+

7

+

+

7

K

3

K

7

8

+

3 K

)

K

)

K

K

8

+

3 K )

)

)

8

25 ( 8

+

3 K

2 (

5 (

2 (

25 (

2 (

25 (

8

+

2

+

13

8

38

8

9

+

2

3

+

+

K

K

K

3

3

8

+

3 K

)

)

K

K

K

K

)

)

)

)

)

− +

25 (

2 (

5 (

7

8

− +

25 (

25 (

8

8

8

8

+

+

11

+

+

21

4

3

+

+

3

3

38

3

3

K

K

K

K

K

)

)

K

K

K

)

)

)

146

+

113 K

























We see that the formula for the inverse matrix is fine, as long as the denominators don’t vanish, that is, unless K=-8/3. In this case, the matrix A reduces to

> B:=subs(K=-8/3,A);

B :=















2

0

-2

7

3

1

2

2

0

7

1

3

-1

-2

0

1

-8

3

1

1

1















0 0 1 -1 -1 and we can understand this matrix, for instance, by viewing its reduced form

> ReducedRowEchelonForm(B);























1

0

0

0

0

1

0

0

0

0

1

0

0

0

0

1

-8

25

-2

15

47

75

122

75























0 0 0 0 0

Since the last row of the reduced form is null we see that the matrix is not invertible in this case. That is, if K is not -8/3, A is invertible.

Exercise 5: we have to see if there are real numbers a1, a2 and a3 such that v = a1 w1+ a2 w2 + a3

Exercise 5: w3. We can set this up as a linear system with augmented matrix

> v:=<12,-3,-8,8,40>; w1:=<2,1,-1,1,7>; w2:=<0,2,3,-1,1>;w3:=<1,-1,3,0,4>;

> A:=<w1|w2|w3|v>; v :=













12

-3





-8





8 



40

 w1 w2

:=

:=

























 w3 :=















0

4







1

-1





3





A :=













2 0 1 12

1 2 -1 -3





-1 3 3 -8





1 -1 0 8 



7 1 4 40



-1 



1



3





0

2





1

7







-1





2

1





We solve as usual

> LinearSolve(A);





Thus, v is a linear combination of w1, w2 and w3 as

> 5*w1-3*w2+2*w3;

5

-3

2







12

-3





-8





8

40





















Download