# Simulation and Monte Carlo Methods

Mathematics I · Scientific Programming · https://tryals.app/learn/mathematics-i/simulation-and-monte-carlo-methods

## Computing with Randomness

Some problems resist exact solutions but can be **estimated by random sampling**. **Monte Carlo methods** use deliberate randomness: generate many random scenarios and use their statistics to approximate answers for integrals, areas, and probabilities.

| Application | Approach | Formula |
| --- | --- | --- |
| Estimating $\pi$ | Scatter points in a unit square containing a quarter-circle | $\pi \approx 4 \cdot \frac{\text{points inside}}{\text{total points}}$ |
| High-dimensional integrals | Bypass exponential grid growth using random samples | Cost is independent of dimension count |

Monte Carlo shines for **high-dimensional integrals** where grid-based methods fail entirely due to exponentially growing point requirements.

## Convergence and Simulation

A Monte Carlo estimate's error shrinks as $\frac{1}{\sqrt{N}}$ with sample count $N$. This means convergence is **slow**: gaining one more decimal digit of accuracy requires **one hundred times** more samples.

| Feature | Monte Carlo Property |
| --- | --- |
| **Convergence rate** | Error proportional to $\frac{1}{\sqrt{N}}$ |
| **Best used for** | Quick estimates and high-dimensional problems |
| **Poor used for** | High-accuracy computations needing many digits |

> **Common pitfall:** Expecting estimates to improve quickly. Doubling samples only cuts error by $\sqrt{2}$, not in half.

Monte Carlo methods also **simulate** stochastic systems directly—such as particle diffusion or financial markets—by averaging many random trials.

## Practice questions

5 of this lesson's 11 practice questions, with answers. The full set is in the app.

### 1. Euler's method for a differential equation takes a step along the current tangent. Why does the error accumulate over many steps rather than staying at the per-step level?

A. Because each step starts from a point already slightly wrong.
B. Because each step introduces an independent error, and independent errors add in quadrature.
C. Because the tangent line becomes less accurate as the solution grows larger.
D. Because floating-point round-off dominates over the method's own error after enough steps.

**Answer:** A. Because each step starts from a point already slightly wrong.

**Why:** The first step lands slightly off, and the second follows the tangent to whichever curve passes through *that* point, building on the error rather than correcting it. Local O(h²) over 1/h steps gives global O(h), so halving the step only halves the error. RK4 evaluates four times per step for O(h⁴), a far better return, which is why it is the workhorse.

Page: https://tryals.app/practice/mathematics-i/simulation-and-monte-carlo-methods/eulers-method-for-a-differential-equation-takes-a-step-along-the

### 2. Select every statement about Monte Carlo methods that is TRUE.

A. Grid-based methods beat Monte Carlo as the number of dimensions grows
B. Monte Carlo is a poor choice when many accurate digits are required
C. A hundred times as many samples buys roughly one more accurate decimal digit
D. The error shrinks in proportion to 1 over N
E. Randomness can attack problems that are not themselves random

**Answer:** B. Monte Carlo is a poor choice when many accurate digits are required; C. A hundred times as many samples buys roughly one more accurate decimal digit; E. Randomness can attack problems that are not themselves random

**Why:** The error goes like 1 over the SQUARE ROOT of N, and grids fail in high dimensions while Monte Carlo does not. Estimating pi from random points is the classic case of randomness solving a completely deterministic problem.

Page: https://tryals.app/practice/mathematics-i/simulation-and-monte-carlo-methods/select-every-statement-about-monte-carlo-methods-that-is-true

### 3. Order the steps of estimating the area of an irregular shape by Monte Carlo.

**Answer:**

1. Enclose the shape in a rectangle whose area is known
2. Generate many random points uniformly inside the rectangle
3. Count how many of them fall inside the shape
4. Multiply the rectangle's area by the fraction that fell inside
5. Report the estimate together with its uncertainty

**Why:** The known enclosing area is what converts a counted fraction into an area. Reporting the uncertainty is part of the method, not an optional courtesy, without it the number claims a precision it does not have.

Page: https://tryals.app/practice/mathematics-i/simulation-and-monte-carlo-methods/order-the-steps-of-estimating-the-area-of-an-irregular-shape-by-monte

### 4. Complete the statement about convergence.

**Answer:** Doubling the number of Monte Carlo samples reduces the error by a factor of about **the square root of 2**.

**Why:** Doubling N divides the error by the square root of 2, roughly 1.4, not by 2. Expecting the error to halve is the standard misreading of the convergence rate, and it makes Monte Carlo look far cheaper than it is.

Page: https://tryals.app/practice/mathematics-i/simulation-and-monte-carlo-methods/complete-the-statement-about-convergence

### 5. A simulation of the solar system using Euler's method shows the Earth spiralling into the Sun over a few thousand orbits. Is that a bug?

A. Not a coding bug but a method one: Euler does not conserve energy
B. No, the orbit really does decay, and the simulation is accurate
C. Yes, a correct Euler implementation conserves orbital radius
D. Yes, the timestep was too large, and any smaller value removes the drift

**Answer:** A. Not a coding bug but a method one: Euler does not conserve energy

**Why:** Euler leaks energy systematically, so the error is a drift rather than noise and a smaller timestep only postpones the spiral. Symplectic integrators are built to conserve the relevant quantity exactly, which is why orbital mechanics uses them and why 'reduce h' is the wrong instinct here.

Page: https://tryals.app/practice/mathematics-i/simulation-and-monte-carlo-methods/a-simulation-of-the-solar-system-using-eulers-method-shows-the-earth
