HDP Algorithms for Trajectory Tracking and Formation Control of Multi-Agent Systems