R and Bigdata and wolfram mathematica

profileoveleberry
wolfram_mathe.zip

M210-S16-class-10.pdf

M 210 Quadratic Equations in Two Variables March 29, 2016

In this class we will study quadratic equations in two variables: equations of the form

ax2 + bxy + cy2 + dx+ ey + f = 0, (*)

where a, b, c, d, e and f are constants. If a = b = c = 0 the equation is not quadratic, but linear and the equation represents a line, a point, or has empty solution. In order for the equation to be quadratic at least one of a, b, or c must be non-zero. Before we discuss examples of quadratic equations, let’s first recall some useful facts about distance, circles and lines.

Contents

1 Distance 96

2 Circles 97

3 Distance to lines 98

4 Parabolas in standard form 100

5 Ellipses in standard form 103

6 Hyperbolas in standard form 107

7 More examples of quadratic equations 109

1 Distance

The distance between points P1 = (x1, y1) and P2 = (x2, y2) is given by the distance formula

P1P2 = √

(x1 − x2)2 + (y1 − y2)2,

an easy consequence of the Pythagorean Theorem.

This distance is implemented in Mathematica as EuclideanDistance.

Example 1. Find the distance between (2,−1) and (−2, 4), and determine all points (x, y) that have the same distance to (2,−1) as to (−1, 2).

Solution. The distance between (2,−1) and (−2, 4) is computed by the following command.

EuclideanDistance[{1, -2}, {-2, 4}]

The points (x, y) with the same distance to the given pair of points satisfy √

(x− 1)2 + (y + 2)2 = √

(x+ 2)2 + (y − 4)2.

Squaring both sides results in the equation (x− 1)2 + (y+ 2)2 = (x+ 2)2 + (y− 4)2, which is easily solved.

Solve[(x - 1)^2 + (y + 2)^2 == (x + 2)^2 + (y - 4)^2, y]

The following displays the given points, the segment connecting them, and the above set of points, which is the perpendicular bisector of the segment connecting the two given points.

M 210 — March 29, 2016 page 97

Show[{

Graphics[{

{Blue, Thickness[0.005], Line[{{1, -2}, {-2, 4}}]},

{Blue, PointSize[0.015], Point[{{1, -2}, {-2, 4}}]},

Text[Style["(1,-2)", 15], {1, -2} + {0, -.35}],

Text[Style["(-2,4)", 15], {-2, 4} + {0, .35}]

}],

Plot[1/4 (5 + 2 x), {x, -4, 4},

PlotStyle -> {Thickness[0.005], Magenta}]

}]

(1,-2)

(-2,4)

2 Circles

The simplest examples of quadratic equations in two variables x and y are circles. It is an immediate consequence of the distance formula that the circle with center (p, q) and radius r has equation

(x− p)2 + (y − q)2 = r2.

Using Mathematica it is easy to find the circle through any three points (the so-called circumcircle of the triangle).

Example 2. Draw the triangle ABC with A = (0, 0), B = (3, 0) and C = (1, 2), and determines this triangle’s circumcircle.

Solution. The following code will draw the triangle.

Graphics[{

{PointSize[0.01], Point[{{0, 0}, {3, 0}, {1, 2}}]},

Line[{{0, 0}, {3, 0}, {1, 2}, {0, 0}}]

}]

To find a circle through the vertices, assume the center has coordinates (p, q) and the radius is r. Then we have three equations (p−0)2+(q−0)2 = r2, (p−3)2+(q−0)2 = r2, and (p−1)2+(q−2)2 = r2, we can pass on to Mathematica to solve:

Solve[{(p - 0)^2 + (q - 0)^2 == r^2, (p - 3)^2 + (q - 0)^2 == r^2,

(p - 1)^2 + (q - 2)^2 == r^2}, {p, q, r}]

M 210 — March 29, 2016 page 98

3 Distance to lines

The distance between a point (x0, y0) and a line y = mx+ b can be seen from the following figure.1

x axis

y axis

b (x0, y0)

|mx0 + b− y0| d

y = mx+ b

1

m √ 1 +

m 2

By similarity of the two right triangles d

1 =

|mx0 + b− y0|√ 1 +m2

, thus

d = |mx0 + b − y0|√

1 +m2 .

The distance between point (x0, y0) and line ax+ by + c = 0 can be seen from the following figure.

1After R.L. Eisenman, An Easy Way from a Point to a Line, Mathematics Magazine, Vol.42, no.1 (1969), pp.40–41.

M 210 — March 29, 2016 page 99

x axis

y axis

b (x0, y0)

| − c

b − a

b x0 − y0|

d

ax+ by + c = 0, that is, y = − c

b − a

b x

normal vector 〈a, b〉

√ a 2 + b 2|b|

By similarity of the two right triangles d

|b| = | − c

b − a

b x0 − y0|√

a2 + b2 , which implies (multiply by |b|) that

d = |ax0 + by0 + c|√

a2 + b2 .

Example 3. Find the points that are equidistant to the lines y = 2x and x+ y = 3.

Solution. The distance of P = (x, y) to line y = 2x is |y − 2x|/ √ 5, while the distance to the line

x+ y = 3 is |x+ y − 3|/ √ 2. We set these distance equal to each other and solve:

|y − 2x|√ 5

= |x+ y − 3|√

2 .

Stripping absolute values, we have the two equations

y − 2x√ 5

= x+ y − 3√

2 and

y − 2x√ 5

= −x+ y − 3√ 2

.

We can use Mathematica to solve each of these equations:

Solve[(y - 2 x)/Sqrt[5] == (x + y - 3)/Sqrt[2], y]

and

Solve[(y - 2 x)/Sqrt[5] == -(x + y - 3)/Sqrt[2], y]

We can convert the answers to TEX code that can be copied in a LATEX document. For example, following the output of

Solve[(y - 2 x)/Sqrt[5] == (x + y - 3)/Sqrt[2], y]

we can enter

y /. % // TeXForm

to see that2

y = −4

√ 5x− 5

√ 2x+ 15

√ 2

5 √ 2− 2

√ 5

.

2Copy the TEX code except the outside braces, then place small spaces between the coefficients and the x’s.

M 210 — March 29, 2016 page 100

Similarly, the other solution is

y = 4 √ 5x− 5

√ 2 x+ 15

√ 2

5 √ 2 + 2

√ 5

.

The following code displays the two given lines and the above two solutions (in magenta and cyan, respectively).

Show[{

Plot[2 x, {x, -1, 4}, AspectRatio -> Automatic, PlotRange -> {{-1.1, 4.1}, {-1.1, 4.1}}],

Plot[3 - x, {x, -1, 4}],

Plot[(15 Sqrt[2] - 5 Sqrt[2] x - 4 Sqrt[5] x)/(5 Sqrt[2] - 2 Sqrt[5]),

{x, -1, 4}, PlotStyle -> Magenta],

Plot[(3 Sqrt[5] + 2 Sqrt[2] x - Sqrt[5] x)/(Sqrt[2] + Sqrt[5]),

{x, -1, 4}, PlotStyle -> Cyan]

}]

-1 1 2 3 4

-1

1

2

3

4

The magenta line is the angle bisector of angle at C in △ABC of the previous example. The other angle bisectors can be computed similarly. The triangle’s incircle is centered at their point of intersection.

4 Parabolas in standard form

Let c be a positive real number. Find all points P in the plane that have equal distance to the line y = −c as to the point F = (0, c).

M 210 — March 29, 2016 page 101

x

y

F = (0, c)

P = (x, y)

−c

c

An equation is readily found: if P = (x, y), the condition is

d(P, F ) = y + c.

This is equivalent to x2 + (y − c)2 = (y + c)2

which is equivalent with x2 = (y + c)2 − (y − c)2 = 4cy,

or

y = 1

4c x2.

The parabola with focus F = (0, c) and directrix y = −c has equation y = 1

4c x2. This is called the

standard equation for the parabola. Note that the vertex of this parabola is the point (0, 0).

Example 4. Determine the directrix and focus of the parabola y = 9− x− x2/6.

Solution. First we find the vertex of this parabola. We can use algebra or calculus.

The Mathematica code

D[9 - x - x^2/6, x]

Solve[% == 0, x]

9 - x - x^2/6 /. %

gives the vertex. We can check the answer:

21/2 - 1/6 (x + 3)^2 // Expand

The parabola is to be shifted over (−3, 21/2) to get it into standard form. We find the value c that determines the focus and directrix by setting the coefficient of x2 equal to 1/(4c):

Solve[1/(4 c) == -(1/6), c]

The parabola’s focus is the point (−3, 21/2 − 3/2) = (−3, 9). The parabola’s directrix is the line y = 9.

The following animation displays the meaning of focus and directrix for this parabola.

M 210 — March 29, 2016 page 102

Manipulate[

Show[{

Plot[21/2 - 1/6 (x + 3)^2, {x, -11, 5}, AspectRatio -> Automatic,

PlotStyle -> Blue, PlotRange -> {{-11, 5}, {0, 12.25}}],

Graphics[{

{Blue, PointSize[0.015], Point[{t, 21/2 - 1/6 (t + 3)^2}]},

Line[{{t, 12}, {t, 21/2 - 1/6 (t + 3)^2}, {-3, 9}}],

{Gray, Circle[{t, 21/2 - 1/6 (t + 3)^2}, 3/2 + 1/6 (t + 3)^2]},

{Red, PointSize[0.015], Point[{-3, 9}]},

{Red, Line[{{-11, 12}, {5, 12}}]}

}]

}], {{t, -3}, -11, 5}]

Example 5. Determine an equation for the parabola with directrix x+ 2y = 4 and focus (3, 2).

Solution. We first plot the directrix and point:

Show[{

Plot[(4 - x)/2, {x, -1, 5}, PlotRange -> {{-1, 5}, {-1, 5}},

AspectRatio -> Automatic, PlotStyle -> Red],

Graphics[{

{Red, PointSize[0.012], Point[{3, 2}]}

}]

}]

-1 1 2 3 4 5

-1

1

2

3

4

5

The distance of point (x, y) to line x+ 2y = 4 is |x+ 2y − 4|√

5 , so the parabola is determined by the

equation √

(x− 3)2 + (y − 2)2 = |x+ 2y − 4|√

5 .

Use Mathematica to square both sides of this equation and simplify the answer:

(x - 3)^2 + (y - 2)^2 - ((x + 2 y - 4)/Sqrt[5])^2 // Expand

%*5 // Expand

M 210 — March 29, 2016 page 103

The parabola’s equation is 4x2 − 4xy − 22x+ y2 − 4y + 49 = 0, and it is plotted together with the directrix and focus by the following code.

Show[{

Plot[(4 - x)/2, {x, -1, 6}, PlotRange -> {{-1.1, 6.1}, {-1.1, 6.1}},

AspectRatio -> Automatic, PlotStyle -> Red],

Graphics[{

{Red, PointSize[0.012], Point[{3, 2}]}

}],

ContourPlot[

4 x^2 - 4 x y - 22 x + y^2 - 4 y + 49 == 0, {x, -1.1, 6.1}, {y, -1.1, 6.1},

ContourStyle -> Blue]

}]

-1 1 2 3 4 5 6

-1

1

2

3

4

5

6

5 Ellipses in standard form

Geometric Description. Given two points F1 and F2 in the plane, and a positive number a larger than half of F1F2, the set of points P such that PF1 + PF2 = 2a is an ellipse with foci F1 and F2. The standard form is obtained if F1 and F2 lie on one of the coordinate axes with their midpoint at the origin.

Case 1: The points F1 and F2 lie on the x-axis with their midpoint at the origin. Then we may assume that F1 = (c, 0) and F2 = (−c, 0) with c > 0. The following figure displays one point P on the ellipse.

M 210 — March 29, 2016 page 104

x

y

F1F2

a b

c

The figure shows that a2 = b2 + c2.

The rectangular equation in standard form is easily derived: simplify the equation

(x− c)2 + y2 + √

(x+ c)2 + y2 = 2a,

by isolating the square roots and repeatedly squaring both sides of the equation: the computations

Sqrt[(x - c)^2 + y^2]^2 - (2 a - Sqrt[(x + c)^2 + y^2])^2 // Expand

(4 a Sqrt[(c + x)^2 + y^2])^2 - (4 a^2 + 4 c x)^2 // Expand

show that the equation is equivalent with

(a2 − c2)x2 + a2y2 = a2(a2 − c2),

that is, b2x2 + a2y2 = a2b2,

or (divide by a2b2): x2

a2 +

y2

b2 = 1.

Note that a is half the horizontal axis of the ellipse. The following figure shows quantities a and b:

M 210 — March 29, 2016 page 105

x

y

F1F2

aa b

cc

a

b

Case 2: The points F1 and F2 lie on the y-axis with their midpoint at the origin. Then we may assume that F1 = (0, c) and F2 = (0,−c) with c > 0. The following figure displays one point P on the ellipse.

x

y

F1

F2

a

b

c

Example 6. Find the foci of the ellipse with equation

4x2 + 6y2 = 24.

Solution. Divide by 24 to get the equation in standard form:

x2

6 +

y2

4 = 1.

The ellipse’s axes have half-lengths a = √ 6 and b = 2. c2 = a2 − b2 = 2, so c =

√ 2. The foci are at

( √ 2, 0) and (−

√ 2, 0).

M 210 — March 29, 2016 page 106

Example 7. Find a quadratic equation for the ellipse with foci at (3,−1) and (−1, 3), going through the point (4,−2).

Solution. The distance c is here equal to

c=EuclideanDistance[{-1, 3}, {3, -1}]/2

The ellipse is centered at the midpoint of segment F1F2:

({-1, 3}+{3, -1})/2

Half the major axis is here

a=EuclideanDistance[{1, 1}, {4, -2}]

The equation is thus

(x− 3)2 + (y + 1)2 + √

(x+ 1)2 + (y − 3)2 = 6 √ 2.

We convert this equation into one of the form (*) using Mathematica:

Sqrt[(x - 3)^2 + (y + 1)^2]^2 - (6 Sqrt[2] - Sqrt[(x + 1)^2 + (y - 3)^2])^2 // Expand

Conclude that the ellipse has quadratic equation 7x2 + 4xy + 7y2 − 18x− 18y = 72. The following code

Show[{

Graphics[{

{Red, PointSize[0.015], Point[{{-1, 3}, {3, -1}}]},

{Blue, PointSize[0.015], Point[{{4, -2}}]}

}],

ContourPlot[

7 x^2 + 4 x y + 7 y^2 - 18 x - 18 y == 72, {x, -5, 5}, {y, -5, 5},

ContourStyle -> {Blue, Thick}]

}]

draws the graph:

M 210 — March 29, 2016 page 107

6 Hyperbolas in standard form

Geometric Description. Given two points F1 and F2 in the plane, and a positive number a, the set of points P such that |PF1 − PF2| = 2a is an hyperbola with foci F1 and F2. The standard form is obtained if F1 and F2 lie on one of the coordinate axes with their midpoint at the origin.

Case 1: Foci F1 = (c, 0) and F2 = (−c, 0). Equation

(x+ c)2 + y2 − √

(x− c)2 + y2 = 2a.

Writing the equation as √

(x+ c)2 + y2 = 2a+ √

(x− c)2 + y2,

squaring both sides yields the equation

(x+ c)2 + y2 = 4a2 + 4a √

(x− c)2 + y2 + (x − c)2 + y2,

so 4a

(x− c)2 + y2 = (x+ c)2 + y2 − ((x − c)2 + y2)− 4a2 = 4cx− 4a2,

thus a √

(x− c)2 + y2 = cx− a2.

Squaring once more results in the equation

a2((x− c)2 + y2) = c2x2 − 2a2cx+ a4,

which is equivalent to

a2x2 − 2a2cx+ a2c2 + a2y2 = a4 − 2a2cx+ c2x2,

and simplifies to (c2 − a2)x2 − a2y2 = a2(c2 − a2).

We have c > a, so c2 − a2 > 0, and we can put b = √ c2 − a2. Using that c2 − a2 = b2 this equation

becomes b2x2 − a2y2 = a2b2.

Finally, dividing by a2b2 results in the equation

x2

a2 − y2

b2 = 1.

This is the standard equation for the hyperbola. The foci of this hyperbola are at (±c, 0), where c2 = a2 + b2.

Case 2: In case the foci are at the points (0,±c), the hyperbola has equation

x2

a2 − y2

b2 = −1.

In either of these standard forms, the curve has asymptotes given by the equations

x2

a2 − y2

b2 = 0.

Example 8. Determine the foci of the hyperbola with equation x2 − y2 = 1.

Solution. The equation is in standard form with a = b = 1. We have c2 = a2 + b2 = 2, so the foci are at the points (

√ 2, 0) and (−

√ 2, 0). The following figure illustrates that the points on the right

branch of this hyperbola all have distance √ 2 more to F2 than to F1.

M 210 — March 29, 2016 page 108

F1F2

The asymptotes are here the lines satisfying x2 − y2 = 0, that is, the lines y = x and y = −x, illustrated in the following graph of the whole hyperbola.

F1F2

Example 9. Find an equation for the hyperbola with foci at (4,−2) and (−2, 4), with vertices at the points (3,−1) and (−1, 3).

Solution. The distance c is here equal to

c=EuclideanDistance[{-2, 4}, {4, -2}]/2

The hyperbola is centered at the midpoint of segment F1F2:

M 210 — March 29, 2016 page 109

({-2, 4}+{4, -2})/2

Half the distance between the vertices is

a=EuclideanDistance[{-3, 1}, {3, -1}]/2

The equation is thus

(x− 4)2 + (y + 2)2 − √

(x+ 2)2 + (y − 4)2 = ±2a.

Use Mathematica to convert this in the form (*).

7 More examples of quadratic equations

Example 10. Find the quadratic equation of the parabola with focus (3, 2) and directrix x+2y = 4.

Solution. First draw the directrix and focus: this can be done using the code

Show[{

Plot[(4 - x)/2, {x, -1, 6}, PlotRange -> {{-1.1, 6.1}, {-1.1, 6.1}},

AspectRatio -> Automatic, PlotStyle -> Red],

Graphics[{

{Red, PointSize[0.012], Point[{3, 2}]}

}]

}]

The distance of P = (x, y) to line x+ 2y = 4 is

|x+ 2y − 4|√ 5

.

The distance between P = (x, y) and F = (3, 2) is

PF = √

(x− 3)2 + (y − 2)2.

So the parabola has equation

|x+ 2y − 4|√ 5

= √

(x− 3)2 + (y − 2)2.

Square both sides to rewrite the equation in the form

(

x+ 2y − 4√ 5

)2

= (x− 3)2 + (y − 2)2.

We find the equation in above form by entering the following into Mathematica:

(x - 3)^2 + (y - 2)^2 - ((x + 2 y - 4)/Sqrt[5])^2 // Expand

We can get rid of fractions by entering:

% * 5 // Expand

The answer is the quadratic 4x2 − 4xy − 22x+ y2 − 4y + 49 = 0. We can plot this into the above figure showing directrix and focus adding the following command inside the Show we already used to draw the above figure:

M 210 — March 29, 2016 page 110

ContourPlot[4 x^2-4 x y-22 x+y^2-4 y+49==0,{x,-1,5},{y,-1,5}, ContourStyle->Blue]

Example 11. Draw the points (0, 2), (0,−1), (1, 1), (1,−2), (−2, 0), determine a quadratic equation that goes through each of these points, and draw it together with the points.

Solution. The following code will draw these points.

pts = {{0, 2}, {0, -1}, {1, 1}, {1, -2}, {-2, 0}};

Graphics[{

{Blue, PointSize[0.015], Point[pts]}

}]

We set up a system of equations as follows. In equation ax2+ bxy+ cy2+dx+ ey+ f = 0 substitute for x and y the values for each of the given points to obtain a system of as many equations. For the first point in our list pts the code

a x^2 + b x y + c y^2 + d x + e y + f /. {x -> pts[[1]][[1]], y -> pts[[1]][[2]]}

will do the substitution. We do this for all points in list pts, then solve the system of equations:

lhs = Table[ a x^2 + b x y + c y^2 + d x + e y + f

/. {x -> pts[[j]][[1]], y -> pts[[j]][[2]]}, {j, 1, 5}]

Solve[Table[lhs[[j]] == 0, {j, 1, 5}], {a, b, c, d, e, f}]

Since Mathematica’s answer is a list of replacement rules, we obtain the quadratic by

a x^2 + b x y + c y^2 + d x + e y + f /. %

Factor[%]

We can make use of ContourPlot to graph the equation. Here’s the code that draws the answer for this example.

Show[{

Graphics[{

{Blue, PointSize[0.015], Point[pts]}

}],

ContourPlot[6 + 13 x + 5 x^2 - 6 y^2 == 0, {x, -5, 3}, {y, -4, 4},

ContourStyle -> Blue]

}, Frame -> True]

Example 12. Draw the triangle with vertices at (1, 0), (1/3, 1), (−1, 0). Find an ellipse that touches the triangle at the midpoints of each of its sides.

Solution. The following code will draw the triangle and the midpoints of its sides.

Graphics[{

Point[{{-1, 0}, {1, 0}, {1/3, 1}}],

Line[{{-1, 0}, {1, 0}, {1/3, 1}, {-1, 0}}],

Point[{{0, 0}, {2/3, 1/2}, {-1/3, 1/2}]

}]

M 210 — March 29, 2016 page 111

The condition of touching at the midpoints needs to be translated in equations. Clearly the three midpoints must lie on the quadratic ax2 + bxy+ cy2 + dx+ ey+ f = 0, resulting in three equations. The following code will generate the coefficients for these three equations:

a x^2 + b x y + c y^2 + d x + e y + f /.

{{x -> 0, y -> 0}, {x -> 2/3, y -> 1/2}, {x -> -1/3, y -> 1/2}}

But we are also given the derivatives dy/dx at each of the midpoints: they need to be equal to the slopes of the sides of the triangle. We can find dy/dx by implicit differentiation of the equation ax2 + bxy + cy2 + dx+ ey + f = 0:

2ax+ by + bx dy

dx + 2cy

dy

dx + d+ e

dy

dx = 0.

Collecting terms containing dy/dx:

(bx+ 2cy + e) dy

dx = −(2ax+ by + d),

so dy

dx = −2ax+ by + d

bx+ 2cy + e .

The slopes of the tangent lines at each of the midpoints can be obtained by

-((2 a x + b y + d)/(b x + 2 c y + e)) /.

{{x -> 0, y -> 0}, {x -> 2/3, y -> 1/2}, {x -> -1/3, y -> 1/2}}

The slopes are easily seen to be 0, -3/2 and 3/4. We need to solve the following system of equations:

Solve[{f == 0, (4 a)/9 + b/3 + c/4 + (2 d)/3 + e/2 + f == 0,

a/9 - b/6 + c/4 - d/3 + e/2 + f == 0, d == 0,

-(((4 a)/3 + b/2 + d)/((2 b)/3 + c + e)) == -3/2,

-((-((2 a)/3) + b/2 + d)/(-(b/3) + c + e)) == 3/4}, {a, b, c, d, e, f}]

We get the quadratic from

a x^2 + b x y + c y^2 + d x + e y + f /. % // Expand // Factor

The ellipse has equation 9x2 − 18y− 6xy + 28y2 = 0. The following code graphs it inside the figure for the triangle.

Show[{

Graphics[{

Point[{{-1, 0}, {1, 0}, {1/3, 1}}],

Line[{{-1, 0}, {1, 0}, {1/3, 1}, {-1, 0}}],

Point[{{0, 0}, {2/3, 1/2}, {-1/3, 1/2}]

}],

ContourPlot[9 x^2 - 18 y - 6 x y + 28 y^2 == 0, {x, -1, 1}, {y, 0, 2/3}]

}]

M 210 — March 29, 2016 page 112

Homework 9 This assignment consists of only Mathematica problems. Solutions of the problems should be given in a single Mathematica notebook displaying the requested formulas and graphics.

1. Show that the polygon through the four points (21, 0), (8, 5), (0, 8), (13, 3) is a parallelogram, and compute its area (see the document “Comments on Homework Assignments 3–5” posted on Moodle).

2. Find the perpendicular bisectors of each of the sides of the triangle of Example 1, and use them to find the circumcircle of the triangle.

3. Find the exact incircle of the triangle of Example 2. This is the circle inside the triangle that touches each of the triangle’s sides drawn in the following figure.

4. Determine the curves that appear in the Moiré pattern of Exercise 6 of class 6 (March 1) on page 61, and draw these curves together with the pattern.

5. Draw concentric families of circles with integer radii centered at the two points (2, 0) and (−2, 0).

M 210 — March 29, 2016 page 113

Determine the curves that appear in the above Moiré pattern, and draw these curves together with the pattern.

6. Show that the tangent line at the point (x0, y0) on the ellipse

x2

a2 +

y2

b2 = 1

has equation x0x

a2 +

y0y

b2 = 1.

7. Show that the tangent line at the point (x0, y0) on the hyperbola

x2

a2 − y2

b2 = 1

has equation x0x

a2 − y0y

b2 = 1.

8. Find the quadratic equation of the parabola with focus (3, 2) and directrix 2x− y = 4.

9. Draw the points (3, 0), (0, 3), (−3, 0), (0,−3), (1, 1). Find a quadratic through the above points, and graph it with the above points.

10. Draw the points (1, 0), (−1, 0), (0, 1), (0,−1), (2, 2). Find a quadratic through the above points, and graph it with the above points.

11. Draw the points (0, 1), (0,−1), (1, 2), (1,−2), (−2, 0). Find a quadratic through the above points, and graph it with the above points.

12. Find the quadratic equation for the ellipse touching the midpoints of the sides of the triangle of Example 2, and graph it with this triangle.

13. Determine the directrix and focus of the parabola y = 1

12 x2 − x− 2.

14. Find the quadratic equation for the ellipse with foci (2, 1) and (−2,−1) going through the points (−1, 2) and (1,−2).

Submit Homework 9 by 3:00pm on Tuesday, April 12, to Moodle.

Please put course, your last name, and homework number in the name of the file you submit (using a file name like M210-HW9-name.nb).

  • Distance
  • Circles
  • Distance to lines
  • Parabolas in standard form
  • Ellipses in standard form
  • Hyperbolas in standard form
  • More examples of quadratic equations

__MACOSX/._M210-S16-class-10.pdf

M210-S16-class-12.pdf

M 210 Tables in LATEX and more Mathematica April 19, 2016

Tables in LATEX Tables can be displayed using the tabular environment delimited with \begin{tabular} and \end{tabular}. Columns are indicated by & signs, and new rows are indicated by \\.

If we want 4 rows and 3 columns, the following LATEX code

\begin{tabular}{|c|c|c|}

∗ & ∗ & ∗ \\

∗ & ∗ & ∗ \\

∗ & ∗ & ∗ \\

∗ & ∗ & ∗ \\

\end{tabular}

will typeset

∗ ∗ ∗

∗ ∗ ∗

∗ ∗ ∗

∗ ∗ ∗

The vertical bars in the argument of \begin{tabular} denote vertical lines; the letters c indicate centered alignment for the corresponding columns. Alternative alignments are l and r for left and right alignment of the column, respectively. Vertical bars can be left out, but there need to be at least as many column alignment symbols (c, l or r) as columns in the tabular environment (and precisely as many if vertical lines are to work correctly). Horizontal lines can be inserted by using \hline.

Example 1:

\begin{tabular}{|r|cc|} \hline

Name & First Bet & Second Bet \\ \hline

Peter & \$10 & \$20 \\

John & \$5 & \$8 \\

David & \$7 & \$10 \\ \hline

\end{tabular}

Modify the above code to obtain1:

Name First Bet Second Bet Peter $10 $20 John $5 $8 David $7 $10

The above was obtained using \phantom{0} to add a digit that LATEX does not display but uses to figure spacing.

Sometime tables need adjustment of vertical spaces.

1The trick is to make use of \phantom.

M 210 — April 19, 2016 page 132

Example 2: Typeset the following:

\begin{center}

\begin{tabular}{|c|c|c|} \hline

\textbf{Country} & \textbf{Area} & \textbf{Population} \\ \hline

Canada & 3,856,721 miles$^2$ & 34 million \\ \hline

China & 3,696,100 miles$^2$ & 1,338 million \\ \hline

Russia & 6,592,800 miles$^2$ & 146 million \\ \hline

USA & 3,794,083 miles$^2$ & 311 million \\ \hline

\end{tabular}

\end{center}

The rows are a bit too crowded. This may be adjusted by adding just before the tabular environment the line \renewcommand{\arraystretch}{1.25}. Try to obtain the above table in the following format.

Country Area Population

Canada 3,856,721 miles2 34 million

China 3,696,100 miles2 1,338 million

Russia 6,592,800 miles2 146 million

USA 3,794,083 miles2 311 million

The LATEX environment array provides a tabular environment in math mode, and tabular output created in Mathematicais exported to this environment by the TeXForm command, so that Mathe-

matica can be used to compute and format tables that can be inserted in a LATEX document.

Example 3. Let’s illustrate by creating a table of with data from Mathematica’s PolyhedronData.

Enter the following into Mathematica.

PolyhedronData["Properties"]

The Platonic polyhedra are listed. We can see what polyhedra are in this family by executing the following.

PolyhedronData["Platonic"]

We can create a table with the vertex, face and edge counts for the Platonic solids as follows. First save the above list:

plato = PolyhedronData["Platonic"]

Then create the following table.

Table[{

PolyhedronData[p, "EdgeCount"],

PolyhedronData[p, "FaceCount"],

PolyhedronData[p, "VertexCount"]},

{p, plato}]

The TableForm and TeXForm can be used to generate an array that can be copied into a LATEX document.

With a little more effort we can insert names of the polyhedra and labels for the columns.

The code

M 210 — April 19, 2016 page 133

Transpose[%]

Prepend[%,plato]

will place the names of the polyhedra before the data. Then entering

Transpose[%]

Prepend[%, {"", "E", "F", "V"}]

TeXForm[%]

will create a table in array environment that typesets the following.

E F V Cube 12 6 8

Dodecahedron 30 12 20 Icosahedron 30 20 12 Octahedron 12 8 6 Tetrahedron 6 4 4

We can then edit this table, possibly changing alignment or even mode (use tabular environment for text mode). The following is the above in text mode.

E F V Cube 12 6 8 Dodecahedron 30 12 20 Icosahedron 30 20 12 Octahedron 12 8 6 Tetrahedron 6 4 4

The above polyhedra in the above table are ordered alphabetically. If we want to order them in an other manner, we will need to sort them. The command Sort can be used with a sorting function to accomplish this. For example, the list plato can be sorted in increasing number of vertices as follows.

Sort[plato,

PolyhedronData[#1, "VertexCount"] < PolyhedronData[#2, "VertexCount"] &]

This and the above procedure can be used to generate the following table.

E F V Tetrahedron 6 4 4 Octahedron 12 8 6 Cube 12 6 8 Icosahedron 30 20 12 Dodecahedron 30 12 20

Example 4. Use Mathematica to create a table for cos(nθ) in terms of powers of cos(θ), for integers n between 2 and 10.

Solution. The Mathematica command TrigExpand can be used to obtain formulas for cos(nθ). For example, entering the following into Mathematica will expand cos(3θ).

TrigExpand[Cos[3 \[Theta]]]

The output provided byMathematica contains terms with sin(θ), which we can convert to expressions involving cos(θ) using the fundamental trig identity cos2(θ) + sin2(θ) = 1. Since there are only even powers we can replace sin(θ) by 1− cos2(θ))1/2, and then expand:

M 210 — April 19, 2016 page 134

% /. {Sin[\[Theta]] -> (1 - Cos[\[Theta]]^2)^(1/2)} // Expand

We try the above code for cos(4θ). The code

TrigExpand[ Cos[4 \[Theta]]] % /. {Sin[\[Theta]] -> (1 - Cos[\[Theta]]^2)^(1/2)} // Expand

will expand the cos(4θ) in terms of powers of cos(θ), as desired. Next we create a table of similar expansions for the desired multiple angles:

ct = Table[

TrigExpand[Cos[n \[Theta]]] /. {Sin[\[Theta]] -> (1 - Cos[\[Theta]]^2)^(1/2)} // Expand,

{n, 2, 10}]

Then the code

TableForm[ct] // TeXForm

will output a table of formulas in array environment that we can use in a LATEX document. The output of the above command is the following:

\begin{array}{c}

2\cos^2(\theta)-1 \\

4\cos^3(\theta)-3\cos(\theta) \\

8\cos^4(\theta)-8\cos^2(\theta)+1 \\

16\cos^5(\theta)-20\cos^3(\theta)+5\cos(\theta) \\

32\cos^6(\theta)-48\cos^4(\theta)+18\cos^2(\theta)-1 \\

64\cos^7(\theta)-112\cos^5(\theta)+56\cos^3(\theta)-7\cos(\theta) \\

128\cos^8(\theta)-256\cos^6(\theta)+160\cos^4(\theta)-32\cos^2(\theta)+1 \\

256\cos^9(\theta)-576\cos^7(\theta)+432\cos^5(\theta)-120\cos^3(\theta)+9\cos(\theta) \\

512\cos^{10}(\theta)-1280\cos^8(\theta)+1120\cos^6(\theta)-400\cos^4(\theta)+50\cos^2(\theta)-1 \\

\end{array}

Adding as first column \cos(n\theta)&= for n = 2, 3, . . . , 10 and changing to an align* environment (which requires the amsmath package), we obtain the following table for cosines of multiple angles:

cos(2θ) = 2 cos2(θ)− 1

cos(3θ) = 4 cos3(θ)− 3 cos(θ)

cos(4θ) = 8 cos4(θ)− 8 cos2(θ) + 1

cos(5θ) = 16 cos5(θ) − 20 cos3(θ) + 5 cos(θ)

cos(6θ) = 32 cos6(θ) − 48 cos4(θ) + 18 cos2(θ) − 1

cos(7θ) = 64 cos7(θ) − 112 cos5(θ) + 56 cos3(θ)− 7 cos(θ)

cos(8θ) = 128 cos8(θ)− 256 cos6(θ) + 160 cos4(θ)− 32 cos2(θ) + 1

cos(9θ) = 256 cos9(θ)− 576 cos7(θ) + 432 cos5(θ)− 120 cos3(θ) + 9 cos(θ)

cos(10θ) = 512 cos10(θ)− 1280 cos8(θ) + 1120 cos6(θ)− 400 cos4(θ) + 50 cos2(θ)− 1

M 210 — April 19, 2016 page 135

More Mathematica Examples

Example 1. UseMathematica to compute the point P of intersection of the lines connecting vertices P1 and P3, and vertices P2 and P4 of the regular pentagon shown in the following figure, and find distance r = OP .

O

P P1

P2

P3

P4 P5

M 210 — April 19, 2016 page 136

Homework 11 Provide the requested information in a LATEX document. Submit also Mathematica notebooks used.

1. Create a table with edge, face and vertex counts for the Archimedean solids.

2. Special values for the sin, cos and tan are given in the following table:

α radians sinα cosα tanα

0◦ 0 0 1 0

15◦ π/12 1 4

√ 2( √ 3− 1) 1

4

√ 2( √ 3 + 1) 2−

√ 3

18◦ π/10 1 4 ( √ 5− 1) 1

4

√ 2 √

5 + √ 5 (3

√ 5−5)

√ 5+

√ 5

10 √ 2

30◦ π/6 1 2

1 2

√ 3 1

3

√ 3

36◦ π/5 1 4

√ 2 √

5− √ 5 1

4 ( √ 5 + 1) (

√ 5−1)

√ 5−

√ 5

2 √ 2

45◦ π/4 1 2

√ 2 1

2

√ 2 1

60◦ π/3 1 2

√ 3 1

2

√ 3

75◦ 5π/12 1 4

√ 2( √ 3 + 1) 1

4

√ 2( √ 3− 1) 2 +

√ 3

90◦ π/2 1 0 ∞

3. Create a table for cos(nθ) in terms of powers of sin(θ), for integers n between 2 and 10.

More Envelopes!

4. Determine the envelope of the family of ellipses

x2

a2 +

y2

(1− a)2 = 1,

where 0 < a < 1.

5. [Extra Credit.] Determine the envelope of the family of lines once reflected off the upper half of the unit circle as indicated in the adjacent figure. (This envelope can be observed on the surface of coffee in a enamel cup positioned away from a light source.)

Suggestion: Use the following diagram

M 210 — April 19, 2016 page 137

b a 1

b

b

P

Q

y

x

to show (part of the problem) that the reflected ray (line through point P and Q) has equation

y = (1 − 2a2)(x − a)

2a √ 1− a2

+ √

1− a2,

and use this to find the coordinates of point Q to draw the envelope.

Submit Homework 11 by 3:00pm on Tuesday, April 26, to Moodle.

Please put course, your last name, and homework number in the name of the file you submit (using a file name like M210-HW11-name).

__MACOSX/._M210-S16-class-12.pdf

M210-S16-class-5.pdf

M 210 More drawing in LATEX February 23, 2016

Arcs

An arc of radius r from point (p, q) with initial angle ϕ (phi) and final angle ψ (psi) is drawn in TikZ by the code

LATEX\draw (p,q) arc (phi:psi:r);

Note that TikZ does not require the center (a, b), which is often easier to determine that the arc’s initial point. Polar coordinates (relative to the arc’s center) can be used to express the initial point in terms of the arc’s center.

(a, b)

(p, q)

ϕ

ψ

r

p = a+ r cosϕ

q = b+ r sinϕ

In tikzpicture environment enter

\draw ({a+r*cos(phi)},{b+r*sin(phi)}) arc (phi:psi:r);

for the specific values of a, b, r, ϕ (phi) and ψ (psi).

LATEX

According to the TikZ’s manual, by default arcs are drawn in positive (counter-clockwise) direction, assuming initial angle ϕ to be smaller than ψ. However, I have been able to draw arcs in negative (clockwise) direction by choosing an initial angle larger than final angle.

Precise Label Positioning

The relative positions above, below, left, right, above left, above right, below left, and below right, provide positioning relative to the node (indicated by the dot) as illustrated in the following figures.

below

above left right

above left

below left

above right

below right

While it is possible to adjust the separation between label and node, it is not that easy to adjust the angle (the above provide label placement only for angles in multiples of 45◦). The following will work to place the label (that is its center) at the the indicated position: precise distance s at relative angle θ from the position of the node.

node

lab el

s

node coordinates (nx, ny) label coordinates (lx, ly)

θ

To place label at the above mentioned position use the code (where θ is theta degrees):

M 210 — February 23, 2016 page 44

LATEX\draw ({nx + s*cos(theta)}, {ny + s*sin(theta)}) node {label};

To rotate the label as in the above illustration, use code:

LATEX\draw ({nx + s*cos(theta)}, {ny + s*sin(theta)}) node {\rotatebox{theta}{label}};

Special Triangles

In trigonometry the triangles with degrees 45-45-90 and 30-60-90 provide exact values for the trigono- metric functions. It is quite easy to obtain the exact values of angles of 15 and 75 degrees from those of 30 degrees by half- and double-angle formulas and other trigonometric identities, however, these values can also be obtained from the following figure containing an equilateral triangle in a square with sides equal to 2.

1

The Regular Pentagon. Use trigonometric functions to draw a regular pentagon with its lower side along the line segment from (−1, 0) to (1, 0). Start by drawing this line segment.

LATEX\begin{center}

\begin{tikzpicture}[scale=2]

\draw[line width=1.2pt] (-1,0) -- (1,0);

\end{tikzpicture}

\end{center}

Extend the line segment on both sides by adding the following code.

LATEX\draw[line width=1.2pt] (1,0) -- ({1+2*cos(72)},{2*sin(72)});

\draw[line width=1.2pt] (-1,0) -- ({-1-2*cos(72)},{2*sin(72)});

Close the top of the pentagon, using angles denoted in the desired figure on the following page, by adding the following code.

LATEX\draw[line width=1.2pt]

({1+2*cos(72)},{2*sin(72)})--(0,{2*sin(72)+2*sin(36)})--({-1-2*cos(72)},{2*sin(72)});

Of course we can shorten the code by placing it all in one string using --cycle to close the pentagon’s path.

M 210 — February 23, 2016 page 45

Now add the following lines to provide a coordinate system.

LATEX\draw[gray] (-2,0)--(2,0);

\draw[gray] (0,-.25)--(0,3.35);

Add the second gray horizontal line.

Color and label the indicated angles. The yellow angle with the x-axis was obtained by the following code.

LATEX\draw[fill=yellow!50] (1,0)--(1.55,0) arc (0:72:0.55) -- cycle;

Use this as an example to draw the other angles.

108◦ 72◦

72◦

36◦

1

1/2 cos(72◦)

cos(36◦)

From the figure we see

cos(36◦) = 1

2 + cos(72◦).

Using the double angle formula for the cosine we have

cos(36◦) = 1

2 + 2 cos2(36◦)− 1,

which can be rewritten as 4 cos2(36◦)− 2 cos(36◦)− 1 = 0.

Because cos(36◦) > 0, with the help of the quadratic formula we conclude

cos(36◦) = 2 +

4− 4(4)(−1)

8 =

2 + √ 20

8 =

√ 5 + 1

4 .

It follows that

cos(72◦) =

√ 5− 1

4 .

See TikZercise 3 for an alternative derivation.

Construction Regular Pentagon.

Draw a unit circle, and let A and B be the points (0, 1) and (−1, 0), respectively.

M 210 — February 23, 2016 page 46

B O

A

Let C be the midpoint of OB. Then by the Pythagorean Theorem we have

AC2 = (1/2)2 + 12 = 5/4 =⇒ AC = 1

2

√ 5.

B O

A

C

Use AC as length for a pentagon, constructed as indicated in the following figure.

M 210 — February 23, 2016 page 47

B O

A

C

D

EF

Homework 4

TikZercises. Draw the following in a LATEX document using TikZ:

1. Draw the following proof of the Pythagorean Theorem.

a b

c

c

c

c

b a

b

a

a

b

a

a

a

b

b

b

M 210 — February 23, 2016 page 48

2. Draw the figure from page 44 with all angles labelled, and use the figure to find the exact values of cos, sin and tan at angles 15◦ and 75◦.

3. Draw a right-angled triangle with angles 72◦ and 18◦ whose side adjacent angle 72◦ has length 1 as shown in the adjacent figure.

To determine the exact value of hypotenuse x, first put two such triangles together as indicated in the following figure. Next, extend the above tri- angles’ base, mark a point E length x to the left of A along the base and complete a larger triangle BDE as shown in the following figure.

72◦

18◦

x

1A

B

C

72◦ 72◦

18◦ 18◦

x

1 1x A

B

C DE

Answer the following questions in your LATEX document:

(a) Find the missing angles ∠AEB and ∠ABE.

(b) Show that triangles DBE and ADB are similar.

(c) Using the similarity of triangles DBE and ADB, set up an equation for x and solve this equation.

(d) Find the missing sides and angles in the following two special right triangles, then draw them showing all sides and angles.

M 210 — February 23, 2016 page 49

72◦

18◦

1A C

B

E C

B

4. Draw the following figure with missing angles (indicated by arcs) and line segments filled in, and use this information to find identities for cos(α+ β) and sin(α+ β).

[Use optional argument rotate=ang in \draw for appropriate angle ang (in degrees) to rotate the line segments to denote a right angle.]

α

β

1

M 210 — February 23, 2016 page 50

5. On the legs of angle ∠ABC points P , Q, R and S are so that all five blue segments are equal (BP = PS = SR = RQ = BQ). Draw this figure and show that ∠ABC = 36◦.

C

AB R

S

P

Q

6. The following figure

1/2

1/4

1/8

1/16

1/32

1/64 1/128

1

256

shows that 1

2 +

1

4 +

1

8 +

1

16 +

1

32 +

1

64 +

1

128 +

1

256 + · · · = 1.

Using summation notation, the above states that

∞ ∑

k=1

1

2k = 1.

M 210 — February 23, 2016 page 51

7. Draw the following figure and typeset the derivation of the Law of Cosines following the figure.

θ

a c

b a cos θ b− a cos θ

a si n θ

The Pythagorean Theorem applied to the right-angled triangle results in

c2 = (a sin θ)2 + (b− a cos θ)2

= a2 sin2 θ + b2 + a2 cos2 θ − 2ab cos θ

= a2(cos2 θ + sin2 θ) + b2 − 2ab cos θ

= a2 + b2 − 2ab cosθ.

8. Draw the following figure.

θ θ

1

cos θ

sin θ

cos2 θ

sin2 θ

θ

co s θ sin

θ co s θ sin

θ

Behold:

cos 2θ = cos2 θ − sin2 θ,

sin 2θ = 2 cos θ sin θ.

9. Draw the following figure, and typeset the conclusions.

M 210 — February 23, 2016 page 52

A BC

P

θ

θ

1

Q

cos 2θ

sin 2θ

cos θ

cos θ

Considering right △APQ, it follows from the figure that

sin θ = sin 2θ

2 cos θ ,

cos θ = 1 + cos 2θ

2 cos θ ,

from which the identities

sin 2θ = 2 cos θ sin θ,

cos 2θ = 2 cos2 θ − 1.

follow easily.

Submit Homework 4 by 3:00pm on Tuesday, March 1, to Moodle.

Please put course, your last name, and homework number in the name of the file you submit (using a file name like M210-HW4-name).

__MACOSX/._M210-S16-class-5.pdf

The rest HW.pdf

Part1(H4): Solutions of TikZercises 7 and 9 (with 8 as optional extra problem) should be given in a single LaTeX document (see pages 51-52 of the Moodle version of the handouts posted under Class 5); please put your name, the assignment number and date on the top of your homework submission, and also upload a PDF of the typeset document.

Part2(H9): Solutions of the problems (1, 2, 3, 8, 9,10,13, and 14) should be given in a single Mathematica notebook displaying the requested formulas and graphics (please put your name, the assignment number and date on the top of your Mathematica notebook). See pages 112-113 of the handouts (problems 13 and 14 were not on the handout given in class; see page 113 of the Moodle version for these problems).

Part3(H11) Problems 1 and 2 of the handout of April 19(12), and problem 5 for extra credit.

Part4(H12) Problems 1, 2, 3, 6 and 7 from the revised handout of April 26, with problems 8 and/or 9 for extra credit (note that problem 6 of the original handout has changed).

PS:Revised handout of April 26 (examples worked in class on Polyhedra and Ruled surfaces discussed in more detail, more examples of Polyhedra added, problem 6 changed, and problem 7 added.

__MACOSX/._The rest HW.pdf