Four particles moving in a plane have masses and velocity components ,
PHYSICS · Subjective · Fermi University Physics · Computational Physics · Scientific programming for physicists · Scientific programming for physicists
Computational Physics, Ch Arrays: a field is a rectangle of numbers
Problem
Four particles moving in a plane have masses m=(1.0,2.0,0.5,3.0)kg and velocity components vx=(2.0,−1.0,4.0,0.0)ms−1, vy=(0.0,3.0,−2.0,5.0)ms−1, each stored as an array of shape (4,). The total kinetic energy is currently found by total = 0.0for i in range(4): total += 0.5*m[i]*(vx[i]**2 + vy[i]**2)
(a) Write a single array expression, using no loop, that gives the same total kinetic energy.
(b) Evaluate the loop and your array expression for the data above, and state their difference.