In my first post I will use Maxima to prove a nice theorem about three special points of the triangle. The nice thing is that no special knowledge about Euclidean geometry is needed, only basic properties of lines and points in the plane.
I will investigate points and lines in the plane. A point is represented as a pair [x,y] and for lines I use the explicit form k*x+n.
I need four little Maxima functions for computing with lines and points. The first computes the line through given points A and B:
line_A_B(A, B) := block([k, n], k: (A-B)/(A-B), n: A-k*A, k*x+n)$
Next, compute the line through a point A which is perpendicular to a line l:
line_A_l(A,l) := block([k,n], k: -1/coeff(l, x), n: A-k*A, k*x+n)$
The intersection of two lines:
line_intersection(l1, l2) := block( [sol:solve(l1=l2, x)], ratsimp(subst(sol, [x, l1])))$
Finally, a function which checks if a point A is on the line l:
point_on_line(A, l) := is(equal(subst(map("=", [x,y], A), y-l),0))$
Now we have everything we need to start investigating the points of the triangle. The triangle is given by its vertices P1 = [x1, y1], P2 = [x2, y2] and P3 = [x3, y3]. I assume that the vertices are positioned so that no line I compute is vertical or horizontal (otherwise we can rotate the triangle in the plane).
First I define the vertices of the triangle in Maxima:
P1: [x1, y1]$ P2: [x2, y2]$ P3: [x3, y3]$
The line through a vertex and the midpoint of the opposite side of the triangle is called a median. All three medians in a triangle intersect in a common point which is called the centroid of the triangle. Let’s prove this using Maxima.
Compute the midpoints of the sides:
M1: (P2+P3)/2$ M2: (P1+P3)/2$ M3: (P1+P2)/2$
Now compute the medians:
m1: line_A_B(P1, M1)$ m2: line_A_B(P2, M2)$ m3: line_A_B(P3, M3)$
And the intersections (lines which begin with -> show the output):
Ce: line_intersection(m1, m2); -> [(x3+x2+x1)/3,(y3+y2+y1)/3] line_intersection(m1, m3); -> [(x3+x2+x1)/3,(y3+y2+y1)/3] line_intersection(m2, m3); -> [(x3+x2+x1)/3,(y3+y2+y1)/3]
Clearly all intersections are the same, we also get a nice formula for the centroid. We can also check that Ce (intersection of m1 and m2) is on the line m3:
point_on_line(Ce, m3); -> true
A perpendicular bisector is a line through the midpoint of a side of the triangle, which is perpendicular to the side. All three perpendicular bisectors intersect in a common point called circumcenter. Let’s prove this using Maxima.
Define the perpendicular bisectors:
pb1: line_A_l(M1, line_A_B(P2, P3))$ pb2: line_A_l(M2, line_A_B(P1, P3))$ pb3: line_A_l(M3, line_A_B(P1, P2))$
Check that the intersection of pb1 and pb2 is on pb3:
Ci: line_intersection(pb1, pb2)$ point_on_line(Ci, pb2); -> true
An altitude of a triangle is a line through a vertex which is perpendicular to the opposite side. Again, all three altitudes intersect in a common point called the orthocenter of the triangle. Again we can check this using Maxima.
Compute the altitudes:
a3: line_A_l(P3, line_A_B(P1, P2))$ a2: line_A_l(P2, line_A_B(P1, P3))$ a1: line_A_l(P1, line_A_B(P2, P3))$
Check that the intersection of a1 and a2 is on the line a3:
O: line_intersection(a1, a2)$ point_on_line(O, a3); -> true
The Euler line
There is a nice fact about the centroid, circumcenter and the orthocenter of a triangle. They are co-linear, that is they all are on a common line. Again, we can check this using Maxima:
e: line_A_B(Ce, Ci)$ point_on_line(O, e); -> true
Finally here is an image of a triangle with the centroid (in blue), circumcenter (in red) and orthocenter (in green). The black line is the Euler line.
This is the code in Maxima I used to create the image:
set_draw_defaults(proportional_axes = xy)$ wxplot_size:[400, 400]$
draw_triangle(P1, P2, P3) := block([x1,x2,x3,y1,y2,y3], [x1,y1]:P1, [x2,y2]:P2, [x3,y3]:P3, wxdraw2d( fill_color="white", line_width=2, polygon([P1, P2, P3]), line_width=1, color="blue", point_type=filled_circle, points_joined=true, point_size=0, explicit(ev(m1), x, 0, 11), explicit(ev(m2), x, 0, 11), explicit(ev(m3), x, 0, 11), point_size=1.2, points(ev([Ce])), color="red", points(ev([Ci])), explicit(ev(pb1), x, 0, 11), explicit(ev(pb2), x, 0, 11), explicit(ev(pb3), x, 0, 11), color="dark-green", points(ev([O])), explicit(ev(a1), x, 0, 11), explicit(ev(a2), x, 0, 11), explicit(ev(a3), x, 0, 11), color="black", explicit(ev(e), x, 0, 11), xrange=[0,11], yrange=[0,11], axis_top = false, axis_bottom = false, axis_left = false, axis_right = false, ytics = false, xtics = false))$