function r = p2(s)

% Parametrized functions in t for x and y
f_x = @(t) 0.5 + 0.3*t + 3.9*t^2 - 4.7*t^3;
f_y = @(t) 1.5 + 0.3*t + 0.9*t^2 - 2.7*t^3;

% Derivatives for x and y
f_xprime = @(t) 0.3 + 7.8*t - 14.1*t^2;
f_yprime = @(t) 0.3 + 1.8*t - 8.1*t^2;

f_arc = @(t) sqrt(f_xprime(t)^2 + f_yprime(t)^2);

% Set portion of arc length divided by
% total arc length minus s to 0 and solve
f_b = @(t) adapquad(f_arc, 0, t, 0.5e-6)/adapquad(f_arc, 0, 1, 0.5e-6) - s;

% Solve for solution using bisection
% This produces the t necessary to be
% s of the way along the curve
r = bisect(f_b, -0.5e-3, 1+0.5e-3, 0.5e-3);