% This is used by hw4_p2:  it defines y(x), its derivatives, and other functions needed
%  to solve the ODE  for  dx^2/dt^2.

function [y, yp, ypp, Q]=hw4_p2_track(x)   % y, y', y'', Q 

global  a b track_type

if track_type == 1
	y = b*(-(a-x).^3 + a^2*(a-x));
	yp = b*(3*(a-x).^2 - a^2);
	ypp = b*(-6*(a-x));
elseif track_type == 2
    y = b*(-x.^3 + a^2*x);
	yp = b*(-3*x.^2 + a^2);
	ypp = b*(-6*x);
end
Q = sqrt(1+yp.^2);


