The problem of the synthesis of proportional-integrating (PI) and proportional-integraldifferentiating (PID) controllers in a nonstandard formulation is considered. For a linear one-dimensional control object with nonzero initial conditions, it is required to find a controller that is optimal in the sense of a quadratic functional of the state of the object with a regularization additive in control. The synthesis procedure is a solution of the corresponding quadratic optimization problem using a method similar to the conjugate gradient method (the direction at each step is calculated by the conjugate gradient method, and the step length is calculated by the Armijo rule). Numerical examples illustrate the effectiveness of the proposed algorithm in the synthesis of controllers for models of control objects that are common in practice.