The science
Forward kinematics. Each joint is a Denavit–Hartenberg frame with joint angle θᵢ, offset dᵢ = 0, link length aᵢ and twist αᵢ = 0 (planar). The transform is Aᵢ = Rz(θᵢ)·Tx(aᵢ) and the end-effector pose is T = A₁A₂…Aₙ. For 2R: x = L₁cosθ₁ + L₂cos(θ₁+θ₂), y = L₁sinθ₁ + L₂sin(θ₁+θ₂).
Analytic IK (2R). cosθ₂ = (x²+y²−L₁²−L₂²)/(2L₁L₂), θ₁ = atan2(y,x) − atan2(L₂sinθ₂, L₁+L₂cosθ₂). The sign of sinθ₂ chooses elbow up or down; a target with |cosθ₂|>1 is outside the workspace.
Jacobian. Position velocity ṗ = J(θ)θ̇, column i is ẑ × (pₑ − pᵢ), i.e. (−(yₑ−yᵢ), xₑ−xᵢ). Iterative IK uses Δθ = Jᵀ(JJᵀ + λ²I)⁻¹e (damped least squares, Wampler / Nakamura–Hanafusa); λ → 0 gives the pseudo-inverse (the page uses λ = 0.002 only to avoid a division by zero) J⁺ = Jᵀ(JJᵀ)⁻¹, whose step explodes when JJᵀ becomes singular. CCD rotates one joint at a time to point the tip at the target.
Singularities. Manipulability w = √det(JJᵀ) = σ₁σ₂ (Yoshikawa), the product of the semi-axes of the velocity ellipse; condition number κ = σ₁/σ₂. For a 2R arm w = L₁L₂|sinθ₂|: it vanishes when the arm is fully stretched (θ₂ = 0) or folded (θ₂ = π). The reachable workspace is the annulus |L₁−L₂| ≤ r ≤ L₁+L₂ (cloud: 12 000 random joint samples, coloured by w).
Honest simplifications. Planar kinematics only — no dynamics, torques, inertia, collisions or actuator limits; joint limits are symmetric and simply clamp the angles; the damping λ is constant (adaptive damping would be better near singularities); CCD can stall in local minima. Self-checks: DH chain vs closed form, analytic IK round trip, analytic vs finite-difference Jacobian, and DLS convergence on random reachable targets.