Solutions to a Viral Calculus Problem on a Couple’s Breakup (using Python)

Jan Barrera
3 min readFeb 22, 2022

--

I recently came upon this calculus problem that has somehow gone viral in the internet because it is about a lover’s breakup. I wrote some solutions in Google Colab using python’s symbolic and numerical library.

Problem

On a rainy day, a girl broke up with her boyfriend after together for 8 long years. They decided to separate at the place where everything about them began, at the same time. The boy is due north crying and running at the rate of 5ft/sec and the girl is walking due east at the rate of 1ft/sec thinking if she made the right decision. How fast are they separating from each other 5 seconds after they started moving to a new life without each other?​

The problem can be visually represented as the diagram below:

The following solutions were written in python using sympy and numpy.

Solution 1

Let:
x be the distance travelled by the girl.
y be the distance travelled by the boy.

We define the speed of the girl and the boy as:
speed of girl: dx/dt = 1 ft/sec
speed of boy: dy/dt= 5 ft/sec

Then we define the distances travelled as a function of time:
distance travelled by girl: x(t) = 1 * t
distance travelled by boy: y(t) = 5 * t

Lastly, since they are moving perpendicular to each, we can use the pythagorean equation for the distance between boy and girl:

Then we let sympy solve the problem for us.

from sympy import *                                           init_printing()    

t = symbols('t', positive=True)
x = 1*t
y = 5*t
distance = sqrt(x**2 + y**2) rate_of_separation = diff(distance, t) Eq(symbols('rate-of-separation'), rate_of_separation)

This is as concise as it can get. We can however further evaluate to get the numerical value.

Eq(symbols('rate-of-separation'), N(rate_of_separation))

Notice that the solution is time invariant. The velocity at which they are separating from each other is constant and does not change with time.

A variation of this solution is to get the derivative first, then substituting for known values.

x = Function('x')(t)                                          
y = Function('y')(t)
distance = sqrt(x**2 + y**2)
rate_of_separation = diff(distance, t) Eq(symbols('rate-of-separation'), rate_of_separation)

We evaluate the equation for t = 5.

𝑥(5)=1∗5=5
𝑦(5)=5∗5=25
𝑑𝑥𝑑𝑡|𝑡=5=1
𝑑𝑥𝑑𝑡|𝑡=5=5

Then substitute the values.

rate_of_separation = 
rate_of_separation
.subs(Derivative(Function('x')(t), t), 1)
.subs(Derivative(Function('y')(t), t), 5).subs(Function('x')(t), 5)
.subs(Function('y')(t), 25)
Eq(symbols('rate-of-separation'), rate_of_separation)

The problem can also be considered a physics problem involving velocities (as vectors). The velocities of the boy and the girl are orthogonal (i.e. perpendicular), and the resultant velocity is the rate at which they move away from each other.

from numpy import *velocity_boy = array([0, 5])
velocity_girl = array([1, 0])
resultant = linalg.norm(add(velocity_boy, velocity_girl))
Eq(symbols(‘rate-of-separation’), resultant)

Same result.

They will drift away from each other at a speed of 5.1 ft/sec… forever.

--

--