Official Information 
Course Number:  MATH 2121.001 
Course Title:  Mathematical Modeling and Simulation 
Times:  TR 11:0012:20 
Room:  010 Wachman Hall 
 
Instructor: 
Benjamin Seibold 
Instructor Email: 
seibold(at)temple.edu 
Instructor Office:  518 Wachman Hall 
Instructor Office Hours:  T 12:2013:30, W 11:0012:00 
 
Official:  Course Syllabus 
 
Course Materials: 
There is no required textbook for this course. All materials will be provided by the instructor (including lecture notes, short videos, software) or acquired via assigned reading.
For students who wish to read more on the topic of modeling and simulation in general (not directly related to the present course), the following textbooks provide suitable sources:

Prerequisites:  Programming: MATH1034/CIS1051/CIS1057/CIS1068 or equivalent. Mathematics: MATH1042 or equivalent. See Course Catalog for uptodate prerequisites. 
Course Goals: 
By the end of the semester, students will be able to build models and simulations for complex emergent phenomena, and to systematically analyze and interpret the simulation results. 
Topics Covered: 
This course introduces the concept of (a) building a mathematical model of a realworld process, (b) using computational resources to simulate the model, and (c) properly interpreting the results. The main focus lies on processes with many interacting agents, such as: traffic flow, spread of diseases, animal swarming, economic markets, social networks, robotics. The course provides an overview of model building concepts, training on the implementation of models in a computing environment, as well as theoretical background on how to analyze and understand largescale emergent structures (such as traffic waves, stock market crashes, swarm intelligence, etc.). General interest in mathematical model building and in programming is required. 
Course Grading: 
Homework and inclass activities: 30%; course project: 40%; examination: 30%. 
Final Exam Date:  05/07/2024. 
Attendance Policy: 
Students are expected to attend every class. If a student cannot attend a class for some justifiable reason, they are expected to contact the instructor before class. Students are expected to actively participate in the inclass activities and to be properly prepared to do so, including having completed any preclass assignments and providing suitable hardware and software, as explained during the first class. 
Homework: 
Homework problem sets will be assigned every 1.5 to 2 weeks, and must be submitted by the submission date to the course instructor (any extension must be requested and granted before the submission deadline), involving both a programming part and a written/typed part as instructed on the problem set. All submitted work must be the student's own work, though discussion with classmates is allowed and even encouraged. All submitted software must adhere to best practices, including a description of purpose, clear comments, and properly citing code segments from other sources. 
Programming: 
Computational problems will be conducted using MATLAB. Temple University has a site license for MATLAB, and it can be installed freeofcharge on personal computers by the steps given on the ITS website. For the course project, other languages may also be used, but for specific assignments the usage of MATLAB is required. 
Course Project: 
Over the course of the semester, each student will work on an individual course project related to the course material, on a topic found in discussion with the course instructor. Each course projects should demonstrate the major themes of model building, computer simulation, presentation, interpretation, and analysis of results. Project topics suggested by the student are very welcome, and the instructor will make an effort to admit topics of specific interest to students. Each project involves a project proposal, a midterm report, a final report, and a project presentation (dates see below). 
Course Schedule 
01/16/2024 Class 1 
Principles of agentbased models, Mexican wave example, Matlab basics

01/18/2024 Class 2 
Deterministic vs. stochastic models, contagion model, Matlab data structures and randomness

01/23/2024 Class 3 
MonteCarlo method, nested functions in Matlab

01/25/2024 Class 4 
Random walks, randomness in Matlab

01/30/2024 Class 5 
Random walks in 2d, histograms

02/01/2024 Class 6 
Random walks with bias, simulated annealing

02/06/2024 Class 7 
Butterfly movement model

02/08/2024 Class 8 
Runandtumble, E. coli model, chemotaxis

02/13/2024 Class 9 
Agents affecting field quantities

02/15/2024 Class 10 
Diffusion (macroscopic and microscopic)

02/20/2024 Class 11 
Interactions between agents, population dynamics models

02/22/2024 Class 12 
Theory of population dynamics

02/27/2024 Class 13 
Dynamical systems, equilibria, stability

02/29/2024 Class 14 
Numerical time stepping

03/12/2024 Class 15 
RungeKutta methods, SIR model

03/14/2024 Class 16 
Traffic flow: car following models, traffic waves, instabilities

03/19/2024 Class 17 
Traffic flow: cellular automaton models

03/21/2024 Class 18 
Conway's game of life

03/26/2024 Class 19 
General cellular automaton models

03/28/2024 Class 20 
Models for crowd dynamics

04/02/2024 Class 21 
Swarming and flocking

04/04/2024 Class 22 
Ant colony simulation

04/09/2024 Class 23 
Economic models: fundamentals and trading

04/11/2024 Class 24 
Economic models: stock market

04/16/2024 Class 25 
Opinion dynamics

04/18/2024 Class 26 
Calibration, verification, validation

04/23/2024 Class 27 
Project presentations

04/25/2024 Class 28 
Project presentations

05/07/2024 
Final Examination 
Course Reading and Presentation Materials 

Instructional Videos 

Matlab Programs 
 Simple model for a mexican wave in a sports stadium, generated by spectators who stand up and sit down to create the wave as an emergent structure:
temple_abm_mexican_wave.m
 Same model as above, but implemented in an alternative fashion: plotting is done graphically, and the update rule is implemented in a nonvectorized fashion:
temple_abm_mexican_wave_alternative.m
 Simple model for a contagion process of agents in a onedimensional arrangement. Infected agents infect neighbors with a certain probability, and the disease spreads:
temple_abm_contagion1d.m
 Multiple random walkers in one space dimension, whose paths cannot cross (any random step that would cause crossing is rejected). This is a simple example of multiple random walking agents whose paths are not independent:
temple_abm_random_walkers.m
 Random walkers in two space dimensions, exhibiting an animation of their paths. For one walker, each step is drawn uniformly from {1,0,1}^2; for the other walker, each step is drawn uniformly from [1,1]^2:
temple_abm_random_walk_2d.m
 Example of a Levy flight (a random walk with heavytailed step lengths) in two space dimensions, with lognormally distributed step length (and uniformly distributed angle). The 2d histogram of the final positions is plotted:
temple_abm_random_walk_levy_histogram.m
 Random walk on a given function with a certain probability that an upward step is rejected. The rejection probability increases in time. This is an example of the simulated annealing technique:
temple_abm_random_walk_annealing.m
 Random walk in 2d over a background map, modeling the motion of a butterfly. Each step is either a deterministic uphill motion or a random step:
temple_abm_butterfly_animation.m
 Motion of butterflies via random walk in 2d over a background map. Now, multiple agents are simulated and statistical properties of their paths are extracted (here: the width of corridors):
temple_abm_butterfly_corridor_width.m
 Model for bacteria (such as E. coli) moving in a 2d concentration field. Their motion is runandtumble, where the probability to terminate their straight motion depends on whether they "their" concentration value is improving or not:
temple_abm_bacteria_run_and_tumble.m
 Model for bacteria (such as E. coli) moving in a 2d concentration field. In addition to executing a concentrationbased runandtumble motion, the bacteria consume the concentration in their vicinity:
temple_abm_bacteria_run_and_tumble_and_eat.m
 Constructing density field from point positions in 2d, via histogram and kernel density estimation, using Gaussian kernels:
temple_abm_kde.m
 Diffusion of a 2d concentration field (with noflux boundary conditions), computed via a macroscopic finite volume method:
temple_abm_diffusion_macroscopic.m
 Comparison of microscopic diffusion (the histogram of many random walkers) with macroscopic diffusion (approximating the diffusion equation via finite volumes):
temple_abm_diffusion_micro_vs_macro.m
 Agents moving in a 2d rectangle, aging (and dying), and producing offspring if exactly two agents are in the same square of the domain:
temple_abm_population_migrate_mate_and_age.m
 Two populations of agents moving in a 2d rectangle, and reproducing and dying. The prey reproduction rate decreases with prey density, and the death rate increases with predator density. The predator reproduction rate increases with prey density, and the death rate increases with predator density:
temple_abm_population_predator_prey.m
 Classical population dynamics without agents. The dynamics of two species are demonstrated in various cases: predatorprey, logistic growth, competition, and mutalism:
temple_abm_population_local.m
 Comparison of three methods for time stepping for ordinary differential equations:
temple_abm_ode_time_stepping.m
 Followtheleader traffic model in which drivers equilibrate their car's velocity to that of the vehicle immediately ahead:
temple_abm_traffic_follow_the_leader.m
 A more complex car following model in which drivers have two objective: a) equilibrate their velocity to that of the vehicle immediately ahead, and b) go towards an optimal velocity that depends on the headway:
temple_abm_traffic_car_following.m
 Cellular automaton model for vehicular traffic flow (the NagelSchreckenberg model). Vehicles move from cell to cell while constantly adjusting their velocity:
temple_abm_traffic_cellular.m
 Implementation of the popular cellular automaton model game of life by John Conway:
temple_abm_cellular_game_of_life.m
 Same game of life, but now initial configurations are read from data files.
temple_abm_cellular_game_of_life_file_ic.m.
This program needs the two data files
temple_abm_cellular_game_of_life_file_ic_blinker_ship.txt and temple_abm_cellular_game_of_life_file_ic_glider_gun.txt
to be in the same directory.
 Binary cellular model in 1d with immediate neighbor interaction only. This particular example implements rule 184:
temple_abm_cellular_rule184.m
 Cellular model in 2d for the dynamics of crowds. This example has agents that wish to walk to the right, and agents that wish to walk to the left. Each cell can be occupied only by a single agent:
temple_abm_cellular_crowd.m
 Model for swarming birds. Each agent (bird) is moving with a fixed speed, and it adjusts its direction of flight according to other agents nearby. There is a zone of repulsion (radius 1/3) and a zone of alignment (radius between 1/3 and 1):
temple_abm_swarming_birds.m
 Model for foraging ants. Each agent (ant) is moving with a fixed speed, and it adjusts its direction of motion to trace high concentrations of a pheromone field. In turn, every agent leaves a trail of pheromones when walking:
temple_abm_swarming_ants.m
 Model for a market. Producing agents sell goods to consuming agents at a market price. Each agent has a desired price, and a trade occurs when the market price meets or is even better than the agent's desired price. In turn, the market price adjusts according to the balance of willing buyers vs. sellers:
temple_abm_economy_supply_and_demand.m
 Model for a stock market. Agents possess shares of stock, cash, and individual buying and selling prices. The stock price adjusts to balance supply and demand. Whenever possible, trades take place. The agents' prices adjust randomly, plus a momentum component:
temple_abm_economy_stock_market.m
 Opinion dynamics model. In a onedimensional opinion space, each agent is drawn towards the average opinion of other agents who are nearby in opinion space:
temple_abm_opinion_dynamics.m
 Opinion dynamics model with spatial component. In a twodimensional space (location, opinion), each agent is drawn towards the average opinion of other agents who are nearby in location as well as in opinion:
temple_abm_opinion_dynamics_2d.m

Matlab Introductions and References 

Homework Problem Sets 

Course Projects 
Every student has to conduct an individual course project over the course of the semester. Proposals (written, via email) for projects are due Wed 01/31/2024. Midterm project reports are due Tue 03/12/2024. Final project reports are due Fri 05/03/2024.
 Justin Uwe Cannan: Sociality modeling and simulation
 Theron Halsey: Simulation of airplane boarding approaches
 Anubhav Kundu: Simulation and dynamics of bird flu (H5N1)
 Jihye Lee: COVID19 2D grid spread simulation
 Chloe Simmons: Unraveling book popularity: The magic formula?
 Emily Spencer: Exploring the ecology of biofilms through simulation
 Nathalia Valli: Spread of thoughts
 Renxuan Yao: Bidding dynamics: Simulation of online auction strategies and market behavior
 Nisa Zaman: Evacuation drill simulations
