Metaheuristic optimization algorithms have become popular choice for solving complex and intricate problems which are difficult to solve by traditional methods. Particle swarm optimization has shown an effective performance for solving variant benchmark and real-world optimization problems. However, it suffers from premature convergence because of quick losing of diversity. In order to enhance its performance, this paper proposes an improved particle swarm algorithm with dynamically changing velocity(DCV). Evolution speed and agglomeration degree coefficient are introduced into DCV to achieve a trade-off between exploration and exploitation abilities. The worst particles are recorded to make particles stay away from the best position in the evolution process. The velocity is updated according the position of the global best position, the worst position, particles previous best position, evolution speed and degree of agglomeration coefficient at each iteration. In order to verify the validity of the proposed algorithm in this paper, several typical functions are employed for testing, the results show that the algorithm proposed in this paper obtains a more promising performance than several other algorithms.