#include #include "common-fadbad++.cpp" #define CONTROLS 1 #define DIMS 2 #define CHARGES 2 F > charges[CHARGES][DIMS]; template D p(D (&x)[DIMS]) { D r = 0.0; for (int l = 0; l D naive_euler(D (&w)[CONTROLS]) { D x[DIMS], xdot[DIMS], delta_t = 1e-1, g[DIMS], xddot[DIMS], t[DIMS], x_new[DIMS], delta_t_f, x_t_f[DIMS]; charges[0][0] = 10.0; charges[0][1] = 10.0-w[0]; charges[1][0] = 10.0; charges[1][1] = 0.0; x[0] = 0.0; x[1] = 8.0; xdot[0] = 0.75; xdot[1] = 0.0; loop: gradient(p, x, g); ktimesv(-1.0, g, xddot); ktimesv(delta_t, xdot, t); vplus(x, t, x_new); if (x_new[1]>0.0) { for (int j = 0; j