In this paper a search for the trajectory that minimizes the cost function is studied. In robotic studies the cost function can be defined as a function of time, tracking error or applied torque. In this study the cost function is selected as a function of applied torque, so the main aim is minimizing the energy consumption. For this purpose a simple robot manipulator is chosen, and its kinematic and dynamic models are derived by Denavit-Hartenberg convention and Euler-Lagrange method. Then two different trajectory polynomials are described, one is solved from boundary conditions without optimization and one is solved by optimization and the same boundary conditions. These two different trajectory polynomials and their cost functions values are compared. The effect and efficiency of optimization are examined.