Variational Calculus using Minimization. Minimization is implemetned by "Minimization.hpp", which you can get from my other repository. Variational Calculus is to find a function that gives minimal cost functional (function of function). The following is an example of cost functional of function .
In this library, we will express a function by a long vector , which is the value corresponding to each x, i.e. . The above example functional can be calculated by the below approximation:
Now, it is easy to find the solution that gives the minimal of the above left functional, by minimization the above right approximated function, whose variables are .
Variational calculus often has some additional constraints. For example, . This can be implemented by using constrainted minimization.
Actually, in "VariationalCalculusMain.cpp", you can see the implementation of above example.
Eigen::VectorXd x_val(20);
x_val.setZero();
minimization_with_equality_constraints(
[](const std::vector<FuncPtr<double>> x){ return sum_of_sq(x)+5.0*sum_of_sq_diff(x); },
{
[](const std::vector<FuncPtr<double>> x){ return x.front()-10.0; }
}, /// initial x(t) is 10.0
x_val);
std::cout << x_val << std::endl;