## 9.11. Contour lines solution for Calculus of Variations using the VBA code

Let us see now how the second approximate numerical approach (see end of Section 9.2) can be implemented easily in Excel using a simple VBA code.

### Example 1

Continuing the Examples 3.a and 3.b of Section 9.2, the original problem was to find the extremal of the functional in the following problem, with exact optimal path
${y}^{\ast}\left(t\right)=\frac{1}{24}{t}^{3}+\frac{23}{24}t+1$
:

$\text{min}J=\underset{0}{\overset{1}{\int}}\left(ty+2{{y}^{\prime}}^{2}\right)dt$

$s.t.y\left(0\right)$

Get *Elements of Numerical Mathematical Economics with Excel* now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.