The science
Point lens. A lens of mass M bends light by an angle 4GM/(c²b). A source almost behind it is magnified; the natural angular scale is the Einstein radius
θE = √(4GM/c² · Drel), with Drel = 1/DL − 1/DS. With u the lens-source separation in units of θE the total magnification is
A(u) = (u²+2) / (u√(u²+4)), and for a straight relative path u(t) = √(u0² + ((t−t0)/tE)²). The Einstein time tE = θE/μrel is typically 20-30 days for bulge events. For small u0, Apeak ≈ 1/u0 (Paczynski 1986).
Adding a planet. A planet of mass ratio q = mp/mstar at projected separation s (in units of θE) turns the lens into a binary. For a source position ζ the thin-lens equation is
ζ = z − Σi mi / conj(z − zi) (complex plane, masses in units of the total). The magnification map is the area ratio image/source. It diverges on caustics, the images of the critical curve. A planet makes a planetary caustic near s − 1/s (wide, s>1, or two off-axis triangles for s<1) and a central caustic near the star. A source crossing one produces a short bump or dip on top of the smooth curve (Mao & Paczynski 1991, Gould & Loeb 1992).
How the maps here are computed. By inverse ray shooting (Kayser, Refsdal & Stabell 1986; Wambsganss 1997): rays are shot from the image plane through the lens equation onto a source-plane grid and counted per bin, each ray weighted by the image-plane area it represents, so A = (sum of weights)/(bin area) and A = 1 far from the lens. The image plane is refined adaptively (a quadtree discards cells that cannot land in the window) and a log-polar patch resolves each lens. There is one window per caustic cluster; outside the windows the lens is treated as a point lens of the total mass. The finite source is a uniform disc of radius ρ = θ*/θE (no limb darkening), averaged over the map.
Timescales. The anomaly lasts about tplanet ≈ tE√q (the planet's own Einstein-ring crossing time): about 1.5 days for a Jupiter, about 2 hours for an Earth around a 0.3 solar-mass star. A survey must sample faster than that: Roman's planned microlensing survey observes each field about every 15 minutes, whereas a one-per-night ground survey misses Earth-mass anomalies. Finite source size smooths a caustic crossing when ρ exceeds the caustic size, which is why Earths need small sources or a high-magnification event.
Detection. Photometric noise grows as √(flux): here σ = σ0√(15 min / cadence)·√A in units of the unlensed source flux. The page fits a point-lens model (t0, u0, tE, source and blend flux) to the noisy data and reports Δχ² = χ²(point lens) − χ²(true binary model). A planet is counted as detected above the threshold (Roman survey forecasts use Δχ² of about 160). Penny et al. (2019) forecast of the order of 1400 bound cold planets from the Galactic Bulge Time-Domain Survey; early reports say Roman is performing better than predicted, but those are preliminary statements, not a result this lab reproduces.
Experiments. (1) The raw ray-shot point-lens peak is compared with the exact formula averaged over the same box of map bins, and with 1/u0. (2) For each mass ratio a Monte-Carlo draws random separations 0.55-1.9, impact parameters 0-1 and track angles; the noise-free signal against the refitted point lens gives an expected Δχ², and one Gaussian noise draw (Δχ² = E + 2√E z) decides detection.
Simplifications: point sources are not limb-darkened; no blending, parallax, orbital motion, second planets or a binary source; photon-limited noise only (no sky, no crowding systematics, no gaps or slews); planet mass in Earth masses assumes a 0.3 solar-mass lens by default; Roman is drawn as a generic stylised telescope. Bound-planet detection probability depends on the full survey design, which this lab only caricatures.