# 2 suns project

Just an idea: you could plot the planet's trajectory in the rotating frame in which the suns are fixed:

# Pseudo-random numbers

## Utility of random numbers

Test plausibility of a proposition before investing effort in trying to prove it: det(AB) = ?

Sample without fear of seeing only special cases: contrast regular grid

### Hazards of regular sampling

Download and save this file but don't look at the contents: mystery.py. It defines a function f. Approximate the average of f by sampling it at linspace(0,1,17).

Moiré patterns

## How to generate sequences of pseudo-random numbers

In digital computer, must be a deterministic scheme.

Mayfly model at b=4 generates "irregular", "chaotic", trajectories. Why no good for this purpose?

Random points on a dart board

How can the graph of a function densely cover a square?

### Linear congruential generator

What does the graph of y = 2x mod 1 over [0,1] look like? How about y = r0 + 2x mod 1? How about y = 3x mod 1?

LCG: Choose a multiplier a and a modulus m, both huge; and a starting integer (seed) i0. Let ik + 1 = aik mod m, and rk = ik ⁄ m.

# Linear congruential pseudo-random number generator

rng_i = 17                              # seed
rng_a = 427419669081    # multiplier
rng_m = 999999999989    # mod


infamous randu

# Linear congruential pseudo-random number generator "RANDU"
# FAMOUSLY BAD. DO NOT USE!
rng_i = 17                      # seed
rng_a = 2**16+3         # multiplier
rng_m = 2**31           # mod


# Monte Carlo integration

Exercise: Estimate the area of the flower whose boundary has the equation r = (2 + cos7θ) in polar coordinates.

(Pick points at random in an enclosing rectangle and count the fraction of points that are inside the flower.)