Love dynamics system​
​By Chuqi Ren​
University of Minnesota
Goal:​
The main idea of this project is to help students learn how to transfer their daily problems into math language by providing the example of a dynamic system. In this courseware, we try to simulate players (students) personalities (two person per group) and then, using dynamic system to generate their result (if they will fall in love together or not). Playing this course ware, students can see how their inputs in human language affect the coefficients and graph of their final personality model in math language. Also, after constructing a differential equation system of the two personalities, student can visually see how their initial condition and personality models affect their final result.
​Main Results:​
The way to approach this goal is, firstly, to get two characters’ reaction function, like how their love for their lovers changed corresponding to their lovers’ affection, by asking them to finish questionnaire. The questionnaire will classify them into various personality models automatically; the values they entered for each form will be used to calculate the coefficients of their model. Secondly, it will generate some random noise and add to their model. Thirdly, using the NonLinearModelFit Function to find the best fit model. Finally, we can obtain the function of their rate of change in affection by combining their reaction function and their love function.
​Future Work:​
The next step of this project is to introduce another character, Romeo, and generate his unique personality model following the same steps. After that, we can generate Romeo and Juliet’s dynamic system, which shows us lots of information about their love story. Also, the recent model of rate of change in affection only contains their reaction function and themselves. We might want to introduce some other variables, like career and health, and see how these variables also affect the love dynamic system.

Section 1. Reaction Function

Personality Models

The following are the initial personality models, or say reaction functions. Each model presents a different personality (You might find that some models are similar to others, like adding a minus sign. The reason I do that is to make the questionnaire clearer and more organized). My original idea is to generate models based on their input data, but it is hard to solve the “exceed” issue (the fitted model cannot provide a credible value when the independent variable exceeds the range of original inputs). PCA might works, but it requires a huge database and only provides linear models. Therefore, the best approach recently is to have our models first and then assign players (students) to our models.
alpha, gamma, and beta are coefficients; Juliet is the independent variable.
In[]:=
model1[alpha_,Juliet_]:=0.5alphaJuliet​​model2[alpha_,Juliet_]:=alphaJuliet​​model3[alpha_,Juliet_]:=-alphaJuliet​​model4[alpha_,Juliet_,gamma_]:=alphaJuliet(1-(Juliet/gamma)^2)​​model5[beta_,Juliet_]:=Which[Juliet>0,-betaJuliet,Juliet<=0,0]​​model6[alpha_,Juliet_,gamma_]:=-alphaJuliet(1-(Juliet/gamma)^2)
Model1 represents a person whose affection is highly independent of others' reactions (their lovers' love for them generally won' t change their love for their lovers) . To increase the playability, I multiply the whole model by 0.5 so that it can be clearly distinguished from the model2, which represents a person who is love to be loved and hate to be hated . Model3 is similar to model2 . It is love to be hated and hate to be loved . Model4, in comparison with model2, is more like an avoidant personality . It is love to be loved at first, but after their love reach a peak, they will calm down soon and rethink their relationship with their lovers . Model6 represents the similar personalities oppositely . Model5 represents the so - called "lithromantic" personality, which means once others show their love, the player will immediately dislike them . I also scale the value of beta by 2, similar as what I did for the model1 . You will see it in detail later .

Coefficients

In[]:=
(*Weassumeallthegreekletterarepositiveconstantparameters*)
◼
  • alpha: alpha represents the degree of dependence. Higher alpha means players’ affections for their lovers are higher depend on the love them noticed from their lovers. (Obtained from each form[])
  • ◼
  • gamma: One meaningful variable related to gamma is peak. After having the value of peak, people can have the value of gamma by multiplying peak by square root of three. (More detailed steps are represent below.)
  • ◼
  • peak: peak is the local maximum of model4 (model6). In words, it means when Juliet’s love approach to this value, Romeo will calm down soon. (Obtained from finalform)
  • ◼
  • beta: beta is a relatively big value. It represents how quickly people decrease their affection once they notice other loves them. (Obtained from A15 or inside form[])
  • In[]:=
    (*stepsforgettinggammausingpeaks*)
    Using model4 as an example, we can first take derivative of the reaction function. Then, since peak represents the value of Juliet (x) when Romeo (y) reach to the local maximum point, we can plug peak into the function and solve for gamma. As we can see here, gamma and peak has a positive linear relationship (gamma= Sqrt[3] since peak is always positive).
    In[]:=
    f[x_]:=testAlpha*x*(1-(x/testGamma)^2)​​f'[x]
    Out[]=
    -
    2testAlpha
    2
    x
    2
    testGamma
    +testAlpha1-
    2
    x
    2
    testGamma
    In[]:=
    SolveValues-(2*testAlpha*
    2
    testPeak
    )
    2
    testGamma
    +testAlpha1-
    2
    testPeak
    2
    testGamma
    ==0&&testGamma>0,testGamma,Reals
    Out[]=
    
    3
    2
    testPeak
    
    In[]:=
    (*gamma*)
    gamma is directly generated by peak
    gammaDisplay is used to show only three digits of gamma
    finalGamma is gamma+0.5, used to decrease the variation of models with different value of gamma.
    In[]:=
    gamma:=Sqrt[3]peak​​gammaDisplay:=DecimalForm[​​Sqrt[3]peak,3​​]​​finalGamma:=Sqrt[3]peak+0.5
    In[]:=
    (*finalalpha(toavoidalpha=0)*)
    In[]:=
    finalAlpha/;SameQ[alpha,0]:=alpha+1/3;​​finalAlpha/;!SameQ[alpha,0]:=alpha;
    The coefficients we used in our final models is finalAlpha, finalGamma, and beta .

    Section2. Questionnaire

    This section is the collection of all forms used in the questionnaire. To make it clear, the numbers inside forms represent the previous answer players entered (1 means players’ affection increase or keep the same, 2 means players’ affection decrease). For example, form[121] means the player has a positive impression of Juliet at the beginning (the first 1), but Juliet shows low interest in him (the second 2). Based on this situation, the player does not change his mind and still loves Juliet (the third 1). The questionnaire will provide players with a new form based on their previous answers and previous form. In another word, if you finished form[11], based on your answer (affection increase or decrease), you will only get form[111] or form[112]. You won’t get form[121] since it should follow the form[11...] pattern. Sometimes players can get their final model by finishing forms in form list. However, sometimes, we need another forms to distinguish model 2, 4 , model1, 5, and model3, 6. Those forms are inside <Determine model2,4, model1,5, and model3,6> subsection. formGamma is only used to obtain the value of peak.

    form1 list
    

    form2 list
    

    Determine model2,4, model1,5, and model3,6
    

    final form
    

    formGamma for peak
    

    Section3. Model Fit

    Final Model

    This subsection is to assign players into personality models. After they finish questionnaire, we should have finalmodelword, which is dynamic string based on the forms they answered. Then, we will use it to match our original six model.
    In[]:=
    (*Maindefinitions:*)​​finalModel[alpha_,Juliet_,gamma_,beta_]/;SameQ[finalmodelword,model1]:=model1[alpha,Juliet];​​finalModel[alpha_,Juliet_,gamma_,beta_]/;SameQ[finalmodelword,model2]:=model2[alpha,Juliet];​​finalModel[alpha_,Juliet_,gamma_,beta_]/;SameQ[finalmodelword,model3]:=model3[alpha,Juliet];​​finalModel[alpha_,Juliet_,gamma_,beta_]/;SameQ[finalmodelword,model4]:=model4[alpha,Juliet,gamma];​​finalModel[alpha_,Juliet_,gamma_,beta_]/;SameQ[finalmodelword,model5]:=model5[beta,Juliet];​​finalModel[alpha_,Juliet_,gamma_,beta_]/;SameQ[finalmodelword,model6]:=model6[alpha,Juliet,gamma];
    In[]:=
    (*Definitionfor"bad"input:*)​​finalModel[___]:=0;
    In[]:=
    (*Definitionfornoinputatall:*)​​finalModel[]:=0;

    Fitted Model (add some noises)

    Next, we will add some noises to the final reaction function so that it is more realistic. The approach is to add some random real numbers between -1 and 1 to our original data. Then, we can use EstimateBackground to make data smoother since people’s affection won’t be too rapid. These data will be collected inside baseJuliet.
    In[]:=
    rangeMin=-5;​​rangeMax=5;
    In[]:=
    (*dataJuliet*)
    In[]:=
    dataJulietY:=Table[finalModel[finalAlpha,Juliet,finalGamma,beta]+RandomReal[{-1,1}],{Juliet,rangeMin,rangeMax}]​​​​dataJuliet:=Transpose[{​​(rangeMin-1)+Accumulate[Table[1,Abs[rangeMax-rangeMin]+1]],​​dataJulietY​​}]​​peaksData:=FindPeaks[dataJulietY,2]
    In[]:=
    ​​(*baseJuliet*)
    Using EstimateBackground to make data smoother
    In[]:=
    baseJulietY:=EstimatedBackground[​​dataJulietY]​​​​baseJuliet:=Transpose[{​​(rangeMin-1)+Accumulate[Table[1,Abs[rangeMax-rangeMin]+1]],​​baseJulietY​​}]​​peaksBase:=FindPeaks[baseJulietY,2]
    In[]:=
    (*GraphDisplay*)
    In[]:=
    Dynamic[​​ListPlot[​​Tooltip[​​{dataJuliet,baseJuliet}],​​Joined->{True},​​PlotStyle->{Automatic,PointSize[.026]}​​]]
    Find the best fitted model after adding noises

    Section4. Output (Visualization)

    Romeo’s Viewpoint:

    After you run the following code, it will generate questionnaire for you steps by steps. What you should do is just enter a value and then, hit the “submit” button. All the coefficients will be record. Once you hit the “finally” button, your own reaction function will be generated automatically. All the values and graphs could be check inside <Some Dynamic Values> subsection.

    Dynamic Values:

    All the elements below will changed based on the input of the above questionnaire. You can visualize how everything changed corresponding to questionnaire.

    model

    Concluding remarks

    I am still working on this project. Recently, it only contains one differential equation. The next steps are:
    ◼
  • Introduce second character, Juliet. Then, we can build differential equation systems based on that.
  • ◼
  • Introduce more variables into the function of rate of change in affection, such as career and health.
  • ◼
  • Make it like a real courseware.
  • ◼
  • Make a Manipulate version so that it is easier to change each values.
  • ◼
  • Find a way that can display questionnaire and dynamic model in one page.
  • ◼
  • Once the love dynamic system done, generate an animation beginning with the initial impressions.
  • ◼
  • Improve the code of generate forms. Collect all the forms and make a “super” form function.
  • Keywords

    ◼
  • Dynamic System
  • ◼
  • Ordinary Differential Equation
  • ◼
  • Derivative Function
  • ◼
  • Differential Equation System
  • Acknowledgment

    Thanks to my mentor, Daniel Robinson, and my co-mentor, Craig Carter. They help me a lot with my coding stuff and expand my horizon in this project. Also, thanks to a YouTuber, 3Blue1Brown, who did a great job in visualizing the dynamic system. It is his video that inspires me to do this project.

    References

    ◼
  • Rinaldi, S. (1998). Laura and Petrarch: An intriguing case of cyclical love dynamics. SIAM Journal on Applied Mathematics, 58(4), 1205–1221. https://doi.org/10.1137/s003613999630592x
  • ◼
  • Steven H. Strogatz (1988) Love Affairs and Differential Equations, Mathematics Magazine, 61:1, 35-35, DOI: 10.1080/0025570X.1988.11977342
  • ◼
  • YouTube. (2019). Differential equations, a tourist’s guide | DE1. YouTube. Retrieved July 19, 2022, from https://www.youtube.com/watch?v=p_di4Zn4wz4.