linalg3apps.mw

Three Applications for Systems of Equations

> restart:with(LinearAlgebra):

Example 1.  Find an equation of the plane containing the 3 points (1,2,3), (0,1,0), (-1,0,1).

Solution. Recall that any plane in the solution set to an equation of the form  Ax+By+Cz-D=0. Plugging in the points gives 3 equations in four unknowns.

> A:=Matrix([
[ 1, 2, 3,-1],

[ 0, 1, 0,-1],

[-1, 0, 1,-1] ]);

A := Matrix([[1, 2, 3, -1], [0, 1, 0, -1], [-1, 0, 1, -1]])

> b:=Vector([0,0,0]);

b := Vector[column]([[0], [0], [0]])

> LinearSolve(A,b);

Vector[column]([[-_t0[4]], [_t0[4]], [0], [_t0[4]]])

If we let t=1 we get A=-1, B=1, C=0 and D=1, or -x+y=1, as an equation for our plane.

Problem 1. Find an equation for the plane going through (1,1,1), (2,0,2), (3,3,1).

Example 2. Find the cubic polynomial that passes through the points (1,0), (3,2), (4,1), and (5,-1); then plot the curve with the data points marked.

Solution. We want an equation of the form, ax^3 + bx^2 + cx + d = y. Substitution of the the four data points into the equation gives us 4 equations and 4 unknowns. For x values determine the matrix A below.

> A:=Matrix([
[  1,  1, 1, 1 ],

[ 27,  9, 3, 1 ],

[ 64, 16, 4, 1 ],

[125, 25, 5, 1 ] ]);

A := Matrix([[1, 1, 1, 1], [27, 9, 3, 1], [64, 16, 4, 1], [125, 25, 5, 1]])

The four y values determine this vector:

> b:=Vector([0,2,1,-1]);

b := Vector[column]([[0], [2], [1], [-1]])

Now we solve Ax=b.

> Coeffients:=LinearSolve(A,b);

Coeffients := Vector[column]([[1/24], [-1], [107/24], [(-7)/2]])

Thus, a=1/24, b=-1, c=107/24 and d=-7/2.

Finally we plot the solution along with the data points. We need an extra plotting package.

> with(plots):

> p1:=plot(Coeffients[1]*x^3+Coeffients[2]*x^2+Coeffients[3]*x+Coeffients[4],x=0..6):

> p2:=plot({[1,0],[3,2],[4,1],[5,-1]},style=point,color=blue,symbol=circle):

> display({p1,p2});

[Plot]

Problem 2. Find and plot the fourth degree polynomial determined by these five points: (-2,0), (-1,-1), (0,3), (1,-1), (2,1).

Example 3. Find the equation in standard form for the circle in the plane that passes through these three points: (0,0), (1,1) and (2,1). Then plot the circle and draw radial lines to the three data points.

Solution. Recall that the standard form of the equation of a circle is (x-h)^2 + (y-k)^2 = r^2.  Substituting in the three points gives three equations in three unknowns.

(0,0) gives h^2 + k^2 = r^2

(1,1) gives (1-h)^2 + (1-k)^2 = r^2

(2,1) gives (2-h)^2 + (1-k)^2 = r^2

But these equations are nonlinear. We expand them and regard h, k, h^2, k^2 and r^2 as unknowns. This gives 3 equations and 5 unknowns that is linear with respect to these unknowns:

0h  + 0k + h^2 + k^2 - r^2 = 0

-2h - 2k + h^2 + k^2 - r^2 = -2

-4h - 2k + h^2 + k^2 - r^2 = -5

We put these coeffients into a matrix and the right hand numbers into a vector.

> A:=Matrix([
[0,0,1,1,-1],

[-2,-2,1,1,-1],

[-4,-2,1,1,-1]]);

A := Matrix([[0, 0, 1, 1, -1], [-2, -2, 1, 1, -1], [-4, -2, 1, 1, -1]])

> b:=Vector([0,-2,-5]);

b := Vector[column]([[0], [-2], [-5]])

Now we solve Ax=b, where x=[h, k, h^2, k^2, r^2](transpose).

> LinearSolve(A,b);

Vector[column]([[3/2], [(-1)/2], [-_t0[4]+_t0[5]], [_t0[4]], [_t0[5]]])

Not surprisingly the solution is not unique, we can choose any values for free parameters, but these will not all solve the original problem. I'll call the parameters a and t. We must have -s+t = h^2 = (3/2)^2 and s = k^2 = (-1/2)^2. But this is just two linear equations in two unknowns. You should get s=1/4 and t=5/2. Now we can compute the radius, r^2 = t = 2/5, so

r = sqrt(5/2).  

Now for the graph! We need some fancier plotting methods.

> with(plottools):

> C:=circle([3/2,-1/2],sqrt(5/2),color=red,thickness=2): # creates the circle

> P1:=plot([[3/2,-1/2],[0,0]],style=line,color=green,thickness=2): # line segment from (3/2,-1/2) to (0,0)

> P2:=plot([[3/2,-1/2],[1,1]],style=line,color=green,thickness=2): # line segment from (3/2,-1/2) to (1,1)

> P3:=plot([[3/2,-1/2],[2,1]],style=line,color=green,thickness=2): # line segment from (3/2,-1/2) to (2,1)

> display(C,P1,P2,P3); # display the four plots together

[Plot]

>

Problem 3. Repeat Example 3 with (-1,0), (2,2) and (3,-2).

Problem 4. What happens to our method of finding the circle going through three points in the plane if the points are colinear (on the same line)?

Problem 5. Find the equation in standard form of the sphere containing these four points, (0,0,0), (2,1,1),

(3,2,0) and (-3,4,-2). (You do not have to plot it!)