Sharedlove_models.sagewsOpen in CoCalc

A seriously silly model of romantic love!

How do I love thee? Let me model the ways!
- My apologies to Elizabeth Barrett Browning for nerdifying her lovely poem!

(Adapted from various sources. But if you're seriously interested, check out this article!)

The scene

Juliet loves Romeo, and Romeo loves Juliet, at least at time t=0. The question is, how will their feelings evolve with time, and as they meet other, potentially fascinating, new people! Here is our modeling strategy:

  • We will model the rate of change in their feelings, with respect to time.
  • Let J(t) = a function that represents Juliet's love for Romeo at time t.
    The sign and magnitude of J(t) indicate how much Juliet loves (or hates, if it is negative) Romeo.
  • Let R(t) = a similar function of Romeo's feelings about Juliet.
Love is an ever changing function

 
To help you get comfortable with these love functions and their phase plots, let us begin with a warmup exercise.

Each graph below shows the time history of various hypothetical love affairs between Juliet and Romeo. Interpret what is happening in each graph.

Fig. 1 Fig. 2
Fig. 3 Fig. 4
Building a simple love-affair model
 
For simplicity, we will assume that there are only two factors that affect Juliet's future feelings for Romeo: (i) her own current feelings about him, and (ii) his current feelings towards her. And similarly, there are only two factors that affect Romeo's future feelings about Juliet.

As usual, we want to think in terms of the derivatives dJdt\displaystyle \frac{dJ}{dt} and dRdt\displaystyle \frac{dR}{dt}, in order to model J(t)J(t) and R(t)R(t). Here are some question to explore:

  • Suppose we ignore the magnitudes of J(t)J(t) and R(t)R(t), and consider only their signs. Write a couple of sentences discussing how many different combinations of feelings are possible, and what they are (e.g., love-hate, love-love, etc.).
  • We want to express J(t)J^\prime(t) and R(t)R^\prime(t) as functions of the variables they depend upon. To help you think through this, here is an example of a scenario to consider: Suppose Romeo is primarily connected to his own feelings and disconnected from Juliet's. And suppose Juliet has the opposite personality. Then, one simple model for JJ^\prime and RR^\prime would look like:
          J(t)=J+RJ^\prime(t) = - J + R
          R(t)=J+RR^\prime(t) = - J + R

    Here the negative signs on the 1st term suggest both lovers respond negatively when Juliet's love for Romeo increases! The positive signs on the 2nd term suggests both lovers fall deeper in love as Romeo's love for Juliet increases. True, it's weird, but there is plenty of weirdness in the real world!

    Construct a few other simple models of this type. That is:
        J(t)=J^\prime(t) = term(s) that  depend on JJ and RR
                      Explain what sign you want for the term(s) and why?
        R(t)=R^\prime(t) = term(s) that depend on JJ and RR
                      Explain what sign you want for the term(s) and why?

A general formulation of the model that includes all the cases considered above is
                      J(t)=aJ+bRJ^\prime(t) = a J + b R
                      R(t)=cJ+dRR^\prime(t) = c J + d R

where all the coefficients denote constant parameter values that model different personality types and/or behavior traits. For example, here is one classification scheme based on Romeo's personality that has been proposed in the literature:

  1. Eager beaver: c>0 c > 0 and d>0 d > 0 (Romeo is encouraged by his own feelings as well as by Juliet's.)
  2. Narcissistic nerd: c<0 c < 0 and d>0 d > 0 (Romeo wants more of what he feels, but retreats from Juliet's feelings.)
  3. Cautious lover: c>0 c > 0 and d<0 d < 0 (Romeo retreats from his own feelings, but is encouraged by Juliet's.)
  4. Hermit: c<0 c < 0 and d<0 d < 0 (Romeo retreats from his own feelings as well as from Juliet's.)
Explore the model's predictions
 
The four parameters aa, bb, cc, dd, in the general formulation above can be chosen to mimic different personality types. For example, an affair between two Eager beavers would correspond to positive values for all 4 parameters. Pick a few different personality combinations and explore what the model predicts about their love affair. Be sure to try different starting points for each situation; e.g., J(0)J(0) , R(0)R(0) need not always be positive. Use the interactive Sage script below to carry out your explorations.
Interactive simulation of simple love-affair model. Enter/adjust parameter values for system: dJ/dt = a*J + b*R ; dR/dt = c*J + d*R
Interact: please open in CoCalc
A contrived love affair
 
It is not too hard to design a model to mimic any long-term behavior we want. For example, suppose we want both lovers to stay in love permanently, after an initial period of meandering and uncertainty! Consider the following model:


                      J(t)=0.2(J3)(R4)J^\prime(t) = -0.2(J-3) - (R-4)
                      R(t)=(J3)0.2(R4)R^\prime(t) = (J-3) - 0.2(R-4)


Pick any choice of initial values for JJ and RR -- in fact, try various combinations such as hate-hate, love-hate, etc. Use the Sage script below to run these simulations and discuss your results: what are the values of J(t)J(t) and R(t)R(t) in the long-term? arguing from a calculus perspective, can you conjecture why? what are the personality types of Romeo and Juliet in this model (e.g., Eager beaver, Narcissistic nerd, etc.)? Can you think of a simple change to the model that would make them both hate each other in the long-term?

Interactive simulation of model: j' = -0.2*(j-3) - (r-4) , r' = (j-3) - 0.2(r-4) Enter initial values for J and R
Interact: please open in CoCalc
The mathematics behind it
 
First, note the fixed points of the system:


                      J(t)=0.2(J3)(R4)J^\prime(t) = -0.2(J-3) - (R-4)
                      R(t)=(J3)0.2(R4)R^\prime(t) = (J-3) - 0.2(R-4)

Next, let's look at the Jacobian matrix and is eigenvalues. Since the system is linear, the terms in the Jacobian (say, A\bf A) are just the coefficients: A=[0.2110.2] {\bf A} = \left[\begin{array}{cc} -0.2 & -1 \\ 1 & -0.2 \end{array}\right]

Its eigenvalues are found using the Sage segment below.

# Define Jacobian matrix by rows in brackets [] separated by commas
A = matrix( [ [-0.2, -1], [1, -0.2] ] )
# Find eigenvalues of matrix
A.eigenvalues()
[-0.200000000000000 - 1.00000000000000*I, -0.200000000000000 + 1.00000000000000*I]
<string>:1: UserWarning: Using generic algorithm for an inexact ring, which will probably give incorrect results due to numerical precision issues.
Notice the eigenvalues are complex conjugates, with negative real part. These types of eigenvalues always attract the solution to the fixed point in an oscillating pattern. Hence, the phase plot displays converging spiral solutions.


An easy way to change the problem and make the solution diverge would be to change the matrix so its eigenvalues are positive. For example, A=[0.2110.2] {\bf A} = \left[\begin{array}{cc} 0.2 & -1 \\ 1 & 0.2 \end{array}\right] has complex conjugate eigenvalues with positive real part. Thus, the following system will have only diverging spiral solutions

                      J(t)=0.2(J3)(R4)J^\prime(t) = 0.2(J-3) - (R-4)
                      R(t)=(J3)+0.2(R4)R^\prime(t) = (J-3) + 0.2(R-4)

More complex love affairs
The models we have seen so far are all linear, and their solutions exhibit a fairly limited range of behaviors. As you might suspect, things get much more interesting when we try to model non-linear personalities, or other more complicated situations such as 3-way affairs or polyamorous relationships.

  1. Nonlinear personalities
    Here is one simple way to make the Juliet-Romeo model nonlinear
                          J'(t) = a J + b R(1-|R|)
                          R'(t) = c J(1-|J|) + d R

    Can you conjecture what type of real-life behavior the nonlinear terms might capture (assume b and c are positive)? Depending on the choice of parameters, different solution behaviors can be seen. For example, try to run some simulations with a=b=-2 and c=d=1. To really understand what is going on, you will need to try a few different initial values for J(0) and R(0).

  2. A 3-way affair
    Suppose Juliet has an affair with someone (say, Sky). A model will be much easier to develop if she keeps the affair a secret from Romeo! In that case there will be 2 equations for Juliet, plus 1 each for Romeo and Sky. Here is one example of such a model

                          JR'(t) = a JR + b (R-S)
                          JS'(t) = a JS + b (S-R)
                          R'(t) = c JR + d R
                          S'(t) = e JS + f S

    where JR(t) and JS(t) are functions that represent Juliet's love for Romeo and Sky, respectively. As before, R(t) and S(t) represent the respective partners' love for Juliet. If you assume positive parameter values for a-f, can you conjecture meaningful interpretations for all the terms in this model?

    Despite the seeming complexity of this last model, it is still linear, and has a fairly limited range of solution behaviors. To see chaotic solution behaviors it is necessary to include nonlinear terms in the model.