Pythagorean theorem day

R
Pythagorean theorem
What is a “Pythagorean theorem day”? Calculating “Pythagorean theorem days” in the XXI century.
Author

Yevgen Ryeznik

Published

February 29, 2020

Pythagorean’s theorem

In mathematics, the Pythagorean theorem gives a relation in Euclidean geometry among the three sides of a right triangle. It states that the area of the square which side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares on the other two sides.

It can be written in the form of the following equation:

\[ a^2+b^2 = c^2. \tag{1}\]

Figure 1 shows a geometrical interpretation of the Pythagorean theorem.

Figure 1: Geometry of the Pythagorean theorem

Pythagorean theorem day

I found a funny definition of what is a Pythagorean theorem day. It is the day on which date in the format “yy-mm-dd” satisfies the following equality:

\[ \text{yy}^2 = \text{mm}^2 + \text{dd}^2. \]

For example, August 15, 2017 can be written as 17-08-15, and it is a Pythagorean theorem day since

\[ 17^2 = 8^2 + 15^2. \] I was curious how many days in the 21st century are the Pythagorean theorem days?

R code to find the Pythagorean theorem days

library(lubridate)

pythagorean_days <- tidyr::crossing(
  yy = seq(0, 99),
  mm = seq(1, 12),
  dd = seq(1, 31)
) %>% 
  dplyr::mutate(
    year = as.character(2000+yy),
    month = stringr::str_pad(mm, width = 2, pad = "0"),
    day = stringr::str_pad(dd, width = 2, pad = "0")
  ) %>% 
  dplyr::mutate(
    # making a character representation of a date
    date_txt = stringr::str_glue('{year}{month}{day}'),
    # converting character representation of a date to a Date object.
    # if it is an inappropriate date, the function returns NA.
    date = lubridate::ymd(
      date_txt, 
      quiet = TRUE
    )
  ) %>% 
  # removing row with inappropriate dates
  dplyr::filter(!is.na(date)) %>% 
  dplyr::mutate(
    is_Pythagorean = (yy^2 == mm^2 + dd^2)
  ) %>% 
  # keeping only Pythagorean days
  dplyr::filter(is_Pythagorean) %>% 
  dplyr::select(date)

pythagorean_days
# A tibble: 12 × 1
   date      
   <date>    
 1 2005-03-04
 2 2005-04-03
 3 2010-06-08
 4 2010-08-06
 5 2013-05-12
 6 2013-12-05
 7 2015-09-12
 8 2015-12-09
 9 2017-08-15
10 2020-12-16
11 2025-07-24
12 2026-10-24

As we can see, only 3 such days left in the 21st century, and one will be this year on December 16, 2020.