function err = shoot(v0)

%  err = shoot(v0) returns  err = u(T) - b, which is then called by 
%  Matlab's root-finder fsolve from pendulum_shoot2.m  to  apply 
%  the shooting method to u" + sin(u) = 0, % u(0) = a, u(T) = b.

  a = 0.7;
  b = 0.7;
  T = 2*pi;
  tspan = [0 T];
  y0 = [a v0];
  [t, y] = ode45('pendulum_dydt',tspan,y0);

  uT = y(length(t),1);
  err = uT - b
