Path following method to minimize f(x)=xc (box constrained optimization)

Remember that the minimizer is zero when the integer c is even otherwise the miminizer is on the boundary

 

Insert an integer value c (years-1) (1 < c < 6)
Insert the Euler step dt (0 < dt < 1)
Insert the initial value (-4 < x0 < 4)
Insert the number of steps N (1 ≤ N ≤ 10000)
Largest value of t computed tmax=h*N:
Corresponding value of the obective function x(tmax):