Variational calculus, optimization. Algebraic geometry