This paper deals with the two-axis sun tracking system for a photovoltaic system. The trajectories of the sun tracking system are determined in an optimization procedure. The optimization goal is maximization of an electric energy production in the photovoltaic system considering the tracking system consumption. Determination of the tilt angle and azimuth angle trajectories is described as a nonlinear and bounded optimization problem, where the objective function is not available in the explicit form. A stochastic search algorithm called Differential Evolution is used as an optimization tool. In the optimization procedure, the objective function is evaluated by using the models of available solar radiation, tracking system consumption, and the efficiency of solar cells with the appropriate dc/dc converters. The problem bounds are given in the form of lower and upper bounds for both angles and time and angle quantization. The results presented in the paper show, that the optimal trajectories for the tilt and azimuth angle depend on the available solar radiation, solar cell efficiency, tracking system consumption and the optimization bounds.