Computational Methods for Biological Modeling & Simulation · Fall 2026
Assignment 1: Allometric Scaling
How does a biological quantity change as an organism gets larger?
Before you begin
An allometric model relates a measured biological quantity B — such as metabolic rate, heart rate, or limb length — to body mass M. These models are important because they reveal how biological form and function scale across organisms of vastly different sizes, from a shrew to a whale, and help us predict unmeasured quantities, understand energy budgets, and connect structure to function. In this assignment you will fit, compare, and differentiate such models using the tools from class.
Mathematically, an allometric law can be expressed as:
B(M) = aMb, M > 0.
Here a sets the scale and b is the allometric exponent.
Dataset: metabolic rate and body mass
Use the following toy data throughout Problems 1–3. These measurements are illustrative, not measurements from a particular species. Body mass is in kg and metabolic rate is in watts (W).
Observation
Body mass M (kg)
Metabolic rate B (W)
1
0.10
2.0
2
0.20
3.5
3
0.40
5.5
4
0.80
9.4
5
1.60
15.2
6
3.20
26.3
7
6.40
41.8
8
12.80
71.4
Problem 1
Implement the Lagrange interpolating polynomial in Python that passes through all eight data points.
Plot the raw data as points and the interpolant as a smooth curve over the range 0.05 to 14 kg. Use enough points (say, 500) so the curve looks smooth.
Use the interpolant to estimate B at M = 0.30, 1.20, and 5.00 kg. Report each value.
Also evaluate the interpolant at some large values of M, for example M = 20, 50, and 100 kg. Report those values. Do we trust those results? Explain why or why not.
Problem 2
Take the natural logarithm of both M and B. Plot log B against log M. Does the relationship look linear?
Fit log Bi = c + b log Mi by least squares using all eight observations. Write your 8 × 2 design matrix X. Report the fitted values of c and b, and then compute a = exp(c). Give the fitted power law with units.
Plot two figures: (i) the log-log data with the least-squares line, and (ii) the original-scale data with the fitted power law B(M) = aMb as a smooth curve.
Use your fitted model to estimate B at M = 0.30, 1.20, and 5.00 kg — the same masses you used in Problem 1. Compare these values with the interpolant values from Problem 1. Which results do you trust more for estimating B at an unmeasured mass: the interpolant or the least-squares fit? Explain your reasoning in terms of noise, overfitting, and the biological trend.
Problem 3
Using the Lagrange interpolant from Problem 1, compute the numerical derivative at 500 equally spaced points between M = 0 and M = 15 kg using a central difference with a small step h (e.g., h = 0.01). Plot dB/dM versus M for the interpolant. Describe the shape of the derivative curve. Does it look smooth? Does it show oscillations?
Repeat part (a) using the least-squares power law B(M) = aMb with your fitted values of a and b. Plot the numerical derivative on the same axes or a separate figure.
Compute the analytical derivative of the least-squares fit: B′(M) = abMb−1. Plot this analytical derivative over the same range. Compare it with the numerical derivative from part (b). Plot the difference between the two derivatives.
Interpret what dB/dM means in this biological context. What are its units? What does a positive, increasing derivative say about how metabolic rate changes as body mass increases?
Graduate students only
Problem 4
A published study of California horn sharks reports allometric exponents of approximately 0.966 for resting metabolic rate and 1.073 for maximum metabolic rate. Gill area has exponent approximately 0.564 below 0.203 kg and approximately 1.012 above 0.203 kg. Treat these reported exponents as fixed values for this exercise; the measured relationships also have uncertainty.
Let resting demand be R = rM0.966, maximum demand be Q = qM1.073, and gill area be G = gMp, with positive constants. Derive the mass exponents of G/R and G/Q for each reported gill-area regime. That is, for each regime, find the exponent e such that G/R ∝ Me and G/Q ∝ Me.
For each regime, state whether each ratio rises or falls as mass increases. For a tenfold increase in mass within each regime, calculate the multiplicative change in G/Q.
Using Python, plot G/R and G/Q versus M on a log-log plot from M = 0.01 kg to M = 10 kg, using the appropriate gill-area exponent for each mass. Assume r = q = g = 1 for the plot (since the constants cancel in the ratio). Describe what happens at the 0.203 kg breakpoint.
Explain one reason that comparing fitted exponents alone cannot establish that gill area physically limits metabolic rate. In particular, consider uncertainty and what a surface-area argument assumes about biological structure.
Problem 5
Suppose metabolic power Y provides maintenance and growth:
Y = YcN + Ec dN/dt.
Here N is cell number, Yc is maintenance power per cell, Ec is the energy needed to make one cell, and each cell has mass Mc. Assume positive constants and Y = aM3/4 with M = McN.
Eliminate N to show that dM/dt = (aMc/Ec)M3/4 − (Yc/Ec)M. Check units of both terms.
Set dM/dt = 0 to derive the positive equilibrium mass Mmax. Explain the direction of growth just below and just above this mass.
For initial mass 0 < M(0) = M0 < Mmax, substitute u = M1/4. Derive a linear differential equation for u, solve it, and transform back to an explicit formula for M(t). Verify the initial value and limiting mass.
Choose numerical values for the constants so that Mmax = 10 kg and Yc/Ec = 0.5 per unit time. (For example, let Yc/Ec = 0.5 and solve for the remaining combination.) Solve the differential equation numerically using scipy.integrate.solve_ivp or a simple Euler method for three initial masses: M0 = 0.1, 1.0, and 5.0 kg. Plot M(t)/Mmax against dimensionless time τ = Yct/(4Ec) for each initial condition on the same axes. Compare their shapes. Does the model predict finite-time arrival at Mmax?
Compare your numerical solutions with the analytical formula from part (c). Do they agree? Plot both for one initial condition to check.
Submission Instructions
Add your name at the top of your solution file. Accept Assignment 1 through Classroom50, then upload your completed solution to your own assignment repository.
Submit a single Jupyter notebook (.ipynb, preferred) or PDF (.pdf) containing your solution code, plots, numerical results, and written answers to every required question. All students should complete Problems 1–3; graduate students should also complete Problems 4–5. Organize your work by problem and part, and label plot axes with units.
For notebook submissions, run all cells in order and save the notebook with its outputs visible. You may export a Jupyter notebook as a PDF instead; check that all code, plots, and answers are included and readable.