PHYSICS · Multi-part · Fermi University Physics · Computational Physics · Scientific programming for physicists · Scientific programming for physicists
Scientific Computing for Physicists, Ch Letting the computer do advanced algebra: operators, series and differentiated programs
Problem
In reduced units (ϵ=σ=1), one Lennard-Jones pair with separation components Δx, Δy, Δz contributes three gradient components gα=−48Δα(rij2)−7+24Δα(rij2)−4,α=x,y,z, where rij2=Δx2+Δy2+Δz2. Count operations with one rule: every addition, multiplication, squaring and integer power counts as one, and Δx, Δy, Δz are given.
((a)) How many operations do the three components take when rij2 is written out in full everywhere it appears?
((b)) Common-subexpression elimination computes rij2, u=(rij2)−7 and v=(rij2)−4 once and writes gα=−48Δαu+24Δαv. How many operations now?
((c)) Factor first, gα=Δα(−48u+24v), then eliminate again. How many operations now, and why could elimination alone not find this saving?