Phys 2301-20 January 23

Systems of linear equations

Suppose you have a system of two linear equations for two unknowns, e.g.

eqn1= 2 x + 3y == 7
eqn2 = x + 4y == 6

YOUR JOB (TopHat):  Remember how to Solve this system, and answer two TopHat questions (LinearSys01 and LinearSys02).

BTW here is one way to have Mathematica draw the two equations as lines.
When we solve we find the point where the lines intersect.

ContourPlot[{2x+3y==7,x+4y==6},{x,0,3},{y,0,3}]

BTW note in passing that while *generically* two lines intersect, sometimes they may not.
Parallel lines are a symptom of inconsistent equations, e.g.

ContourPlot[{2x+3y==7,2x+3y==6},{x,0,3},{y,0,3}]

Or we may *seem* to have two equations, which really say the same thing twice.

ContourPlot[{2x+8y==12,x+4y==6},{x,0,3},{y,0,3}]

Mathematica Challenge:  
Use ParametricPlot3D to produce a figure like the following, which shows how two generic planes intersect to form a line,
while three generic planes intersect at a point.
These planes are of course the three equations from the TopHat question above, where I’ve also added the solution point.

Matrices

The following line, when evaluated, asks for all output to be filtered through the formatting command MatrixForm.

$Post=MatrixForm

E.g., here is the matrix form of the 2x2 system above, together with its solution.

mat={{2,3},{1,4}} 
vecA = {x,y}
vecB = {7,6}
mat.vecA==vecB
Solve[mat.vecA==vecB,vecA]

Alternatively, we can express the solution using the concept of the inverse matrix:

Inverse[mat]
Inverse[mat].vecB

Here is the general expression for the inverse of a 2x2 matrix:

genmat={{a,b},{c,d}}
Inverse[genmat]

Observe how each term is divided by a common factor, the Determinant, defined as:

Det[MatrixForm[genmat]]==Det[genmat] (* these two lines are purely exercises in typesetting *) 
Inverse[MatrixForm[genmat]]==MatrixForm[Det[genmat]*Inverse[genmat]//Simplify]/Det[genmat]

TopHat Questions: What are Det[m] and Inverse[m] for m=(({{1, 2}, {3, 4}}))?

As you know,  the matrix (({{a, b}, {c, d}}))maps the input  (({{1}, {0}})) to (({{a}, {c}})) and the input (({{0}, {1}})) to (({{b}, {d}})).
The determinant is the length of the cross-product of (({{a}, {c}})) and(({{b}, {d}})), which in turn is the area of the parallelogram they span.
For the case (({{2, 3}, {1, 4}}))we can visualize this by drawing the input and output vectors:

mat={{2,3},{1,4}} 
With[{x={1,0},y={0,1},z={0,0}}, (* Create temporary symbols for xhat, yhat, and zero *)
Graphics[{
{Red,  {Dashed,Arrow[{z,x}]},Arrow[{z,mat.x}]},
{Blue,{Dashed,Arrow[{z,y}]},Arrow[{z,mat.y}]},
{Orange,Opacity[.4],Parallelogram[z,{mat.x,mat.y}]}
}]]

The matrix mat maps the unit square into a parallelogram of area Det[mat], and likewise maps
any given polygon into a new polygon of area scaled by a factor of Det[mat].
Here is how to draw a polygon: just make a list of the vertices.

points = {{1,0},{1,3},{2,3},{2,2},{1,0}}
Graphics[{Opacity[.4],Orange,Polygon[points]}]

Here is how to hook up a slider to rotate by a given angle.
Observe how the area stays the same as we rotate (since Det=1).

Manipulate[Show[Graphics[{
{Black,Disk[{0,0},.02]}, (* this marks the origin *)
{Opacity[.4],Orange,Polygon[points]}, (*this is the original polygon*)
{Opacity[.4],Blue,Polygon[points.RotationMatrix[-θ]]} (*and the rotated polygon*)
}],PlotRange->{{-2,4},{-2,4}}],{{θ,0},π,-π}]

This one does the same thing, now with a choice of linear transformations.

(xform[1,θ_] = RotationMatrix[θ];
xform[2,θ_]= {{1,Sin[θ]},{Cos[θ]-1,1}};
xform[3,θ_]={{Cosh[θ],Sinh[θ]},{Sinh[θ],Cosh[θ]}};
xform[4,θ_]= {{Cosh[θ],Sin[θ]},{Sinh[θ],Cos[θ]}};
Manipulate[Graphics[{
{Black,Disk[{0,0},.02]}, (* this marks the origin *)
Text[MatrixForm[xform[i,Θ]],{-1,3.5}], (* this displays the matrix *)
{Opacity[.4],Orange,Polygon[points]}, (*this is the original polygon*)
{Opacity[.4],Blue,Polygon[points.Transpose[xform[i,θ]]]} (*and the transformed polygon*)
},PlotRange->{{-2,4},{-2,4}}],{i,{1,2,3,4}},{{θ,0},π,-π}])

TopHat Questions: 
-For each choice of transformation, is there a value of θ which makes the determinant vanish?
-And for one of them, precisely what value of θ?