Compute the gravitational accelerations in the system
    q in row vector of 6 elements: sun (x, y, z), earth (x, y, z)

def accel(q: np.ndarray):
    """
    Compute the gravitational accelerations in the system
    q in row vector of 6 elements: sun (x, y, z), earth (x, y, z)
    """

    # Infer number of dimensions from q
    dims: int = len(q)

    # Initialize acceleration as dimsx1 array
    a: np.ndarray = np.zeros(dims)
    
    # Iterate over each distinct pair of bodies
    for i in range(B):
        for j in range(i+1, B):
    
            # Masses of body i and j
            m0 = mass[i]
            m1 = mass[j]
        
            # Extract position of body i and j as 3-vectors
            pos_0 = q[slices[i]]
            pos_1 = q[slices[j]]
        
            # Displacement vector from body i to body j
            dv_01: np.ndarray = pos_1 - pos_0
        
            # Distance from body i to j
            r_01: float = np.linalg.norm(dv_01)
            
            # Unit vector pointing from body i to body j
            udv_01 = dv_01 / r_01
        
            # The force between these has magnitude G*m0*m1 / r^2
            f_01: float = (G * m0 * m1) / (r_01 ** 2)
            
            # The force vectors are attractive
            a[slices[i]] += f_01 * udv_01 / m0
            a[slices[j]] -= f_01 * udv_01 / m1
        
    # Return the acceleration vector
    return a