# Introduction to Mathematical Modeling ## What is Modeling? A **mathematical model** is a mathematical representation of a real-world system. Its purpose is to make predictions and provide insight into how that system behaves. **Mathematical modeling** is the process of building, simulating, and evaluating these models. We construct mathematical models because it's often too costly or even impossible to conduct real-world experiments. A model is a way to describe the behavior of a system and *predict outcomes* using *mathematical equations* and *computer simulations*. ## Types of Models There are many different types of mathematical models. In this course, we will focus on the following: * **Deterministic models** predict the future based on current information and do not include randomness. These models often use *systems of differential equations* to describe how a system changes over time. * **Stochastic models** include randomness and are based on *probability distributions* and *stochastic processes*. * **Data-driven models** look for patterns in observed data to predict the output of a system. These models often take the form of *functions with parameters* that are computed to fit the observed data. ## The Modeling Process The modeling process provides a systematic approach to solving complex, real-world problems. It's a cyclical process, and you may need to revisit earlier steps as you go. 1. **State the Problem:** Modeling problems are often open-ended, which means there are many possible solutions, different levels of complexity, and various tools you can use. To begin, you must first clearly state the problem so you know exactly what you are trying to solve. 2. **Identify Variables and Parameters:** You should be able to identify the key quantities from a clear problem statement. - **Independent variables** are the inputs to the system. - **Dependent variables** are the outputs you are trying to predict. - **Parameters** are quantities that remain constant within the relationships between variables. - **Best Practice:** List all variables and parameters, giving each a name, a symbol, and identifying their dimensions (such as length, mass, and time). 3. **Make Assumptions and Identify Constraints:** * **Assumptions** simplify the model and help define the relationships between variables and parameters. For example, when modeling the motion of a falling object near Earth, you often assume the force of gravity is constant. * **Constraints** describe the allowed values for your variables and parameters. For instance, the mass of an object must always be positive. 4. **Build a Solution:** With a clear problem statement, along with your variables, parameters, assumptions, and constraints, you can decide which mathematical tools to use. The context of the problem will often make it clear whether your model should be **deterministic**, **stochastic**, **data-driven**, or a combination. Once you've chosen the type of model, you can begin to apply the appropriate mathematical tools. 5. **Analyze and Assess:** Just because you find a solution, it doesn't mean the result is meaningful. You must *interpret the solution* to see if it makes sense in the context of the problem. Ask yourself: * Does the solution answer the problem statement? * Are the results reasonable and practical? * Does the solution make sense given the real-world context? If the answer is no, you must critically analyze your process. Perhaps there was an algebraic error, an incorrect input, or a flawed assumption. Analyzing and assessing can be a tedious but crucial part of the process. 6. **Report the Results:** The final step is to share your findings. You need to create a clear and concise report of the model and its implementation. This report allows you to share your findings with the research community and contribute to the field. ## Examples :::success **Example 1: The SIAM Gas Price Problem** The problem is adapted from the Society for Industrial and Applied Mathematics (SIAM). **Step 1: Identify the Problem** The goal is to determine which option is more cost-effective: buying gas at a convenient station on your route (Station A) or driving out of your way to a cheaper station (Station B). **Step 2: Define Variables and Parameters** * *Variables:* * $P_A$: Price of gas at Station A ($/liter). * $P_B$: Price of gas at Station B ($/liter). * $k$: Distance between Station A and B (km). * $S$: Cost difference between buying gas at Station B vs. Station A ($). * $T$: Cost of the round trip to Station B ($). * *Fixed Variables:* * $n$: The volume of gas purchased (liters). * $f_e$: The fuel economy of the vehicle (km/liter). * *Inputs:* $k,P_A,P_B,n,f_e$ * *Outputs:* $S,T$ **Step 3: Identify Assumptions and Constraints** * There is a station out of the way (Station B) that has cheaper gas than Station A. * The driver will buy a fixed amount of gas, $n$. * The car's fuel economy is constant. * The round-trip distance to Station B is $2k$. **Step 4: Build a Solution** We develop two equations: one for the monetary savings from the price difference ($S$), and one for the cost of the trip to the cheaper station ($T$). * *Savings $S$:* The price difference per liter multiplied by the amount of gas purchased. $$S=(P_A−P_B)n$$ * *Travel Cost $T$:* The round-trip distance ($2k$) multiplied by the cost of fuel per kilometer ($P_B/f_e$). $$T = \frac{2kP_B}{f_e}$$ * To decide if the trip is worth it, we compare $S$ and $T$. If * $S>T$, it's a good deal to drive to Station B. * If $S \le T$, it's not worth it. * We can also find the *break-even distance*, $k$, where savings equal travel costs ($S=T$). $$k= \frac{f_e(P_A−P_B)n}{2P_B}$$ ```python= P_B = 1.92 P_A = 2.01 n = 40 f_e = 100/5 k = f_e * ((P_A-P_B)*n)/(2*P_B) print("Break even distance between Station A and B is", k, "km") ``` ``` Break even distance between Station A and B is 18.74999999999997 km ``` **Step 5: Analyze and Assess the Solution** The result of $18.75$ km seems reasonable. The model's behavior is correct: as the price difference between stations increases, the break-even distance also increases, and vice versa. However, the model can be improved by considering additional factors like the time spent traveling, a non-constant fuel economy, or a "convenience factor". **Step 6: Report Results** The final report should detail the problem, assumptions, variables, calculation values, and conclusions. This Jupyter Notebook itself serves as an example of a report. ::: :::success **Example 2: The Ski Trip Problem** **Step 1: Identify the Problem** We need to model the snow depth outside a cabin to determine how long it will take for the depth to reach 0.5 meters or less, allowing a group to leave after a snowstorm. **Step 2: Define Variables and Parameters** * $s$: The rate of falling snow (m/day). * $m$: The rate at which the melting rate is linearly increasing (m/day$^2$). * $t$: Time in days. * $D$: The depth of the snow (m). * $R$: The amount of refreezing water (m). * $S$: The total snowfall rate (m/day). * $M$: The total melting rate (m/day). **Step 3: Identify Assumptions and Constraints** * The initial snow depth is 2 meters. * The group can leave when the snow depth is 0.5 meters or less. * Snow compaction and other environmental processes are ignored. * Refreezing occurs at the same time as melting. * The snow depth is homogeneous. **Step 4: Build a Solution** We model the rate of change of snow depth as the "inflow" minus the "outflow." * *Snowfall:* The rate is constant, so $S=s$. * *Melting:* The rate increases linearly with time, so $M=mt$. * *Refreezing:* 50% of the melted snow refreezes, so $R=0.5M=0.5mt$. * The rate of change of snow depth, $dD/dt$, is the sum of the rates that add to the depth (snowfall and refreezing) minus the rate that subtracts from it (melting). \begin{align}\frac{dD}{dt} &=(S+R)−M \\&=(s+0.5mt)−mt \\&=s−0.5mt\end{align} * Solving the differential equation with the initial condition $D(0)=2$, we get a quadratic function for snow depth over time: $$D(t)=st− \frac14 mt^2+2$$ * Using the given values, $s=0.1 m/day$ and $m=0.02 m/day^2$, we can plot the snow depth over time. ```python= t = np.linspace(0,35,1000) s = 0.1 m = 0.02 D = s*t-1/4*m*t**2+2 plt.plot(t,D) plt.axhline(y=0.5, color='r', linestyle='--') #horizontal line for depth of 0.5m plt.xlabel('Days') plt.ylabel('Snow Depth') plt.grid() plt.show() ``` ![image](https://hackmd.io/_uploads/rk1s_peolx.png) * We want to find when the depth reaches $0.5$ meters. We set $D(t)=0.5$ and solve for $t$: $$0.5=0.1t−\frac14(0.02)t^2+2$$ This is a quadratic equation that can be solved using the quadratic formula, which yields two solutions: $t=−10$ days and $t=30$ days. Since time cannot be negative, the group will be stuck for **30 days**. **Step 5: Analyze and Assess the Solution** The solution makes sense because the snowfall and refreezing rates are much higher than the melting rate, so it would take a significant amount of time for the snow to melt. The model's sensitivity to changes in the snowfall, melting, and refreezing rates also seems to be physically realistic. One potential improvement is to include human intervention, such as clearing snow from the doorway. Another is to avoid the assumption that melting and refreezing occur at the same time, as they often happen at different times of day. **Step 6: Report Results** The final report should contain the problem description, assumptions, variables, calculation values, and a summary of the analysis and conclusions. It should also include a schematic diagram and any shortcomings of the model, such as the fact that the solution becomes unphysical (negative depth) for certain inputs. :::