The Euler line of a triangle

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[2]-B[2])/(A[1]-B[1]),
      n: A[2]-k*A[1],

Next, compute the line through a point A which is perpendicular to a line l:

line_A_l(A,l) :=
      k: -1/coeff(l, x),
      n: A[2]-k*A[1],

The intersection of two lines:

line_intersection(l1, l2) :=
      [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) :=
            polygon([P1, P2, P3]),
            explicit(ev(m1), x, 0, 11),
            explicit(ev(m2), x, 0, 11),
            explicit(ev(m3), x, 0, 11),
            explicit(ev(pb1), x, 0, 11),
            explicit(ev(pb2), x, 0, 11),
            explicit(ev(pb3), x, 0, 11),
            explicit(ev(a1), x, 0, 11),
            explicit(ev(a2), x, 0, 11),
            explicit(ev(a3), x, 0, 11),
            explicit(ev(e), x, 0, 11),
         axis_top = false,
         axis_bottom = false,
         axis_left = false,
         axis_right = false,
         ytics = false,
         xtics = false))$

3 thoughts on “The Euler line of a triangle

  1. Nicolás Guarín says:

    Hi Andrejv,

    I like your post about Euler’s line and I’m thinking about doing a wxm file to upload it on the wxMaxima webpage.

    First I write your comments and code to a file and then I try to run some examples but I found that for some values of P1,P2 and P3 it output

    Division by 0
    #0: draw_triangle(p1=[0,0],p2=[0,8],p3=[8,0])
    — an error. To debug this try: debugmode(true);

    Good Luck and Thanks for your post.

    Nicolás Guarín Z.

  2. As I say in a comment at the beginning I assume that no line is vertical or horizontal for the code to work. You get an error because you have a horizontal and a vertical side of the triangle.

  3. Nicolas says:

    Ok, excuse me.

    I didn’t see that line.

    Maybe later I will improve the code to be able to include horizontal an vertical lines.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s