%Problem 4 - Replace the Bisection Method in Step 2 with Newton's Method
%and repeat steps 2 and 3.
%Step 2
val = newtarclen(.5,.001);
sprintf('Time Position at 50 percent of the curve length with a tolerance of .001 is %4.4f',val)
%Step 3
%n = 4
%Initialize graph
s=0:.01:1;
X=0.5+0.3*s+3.9*s.^2-4.7*s.^3;
Y=1.5+0.3*s+0.9*s.^2-2.7*s.^3;
plot(X,Y)
hold all
t=zeros(5,1);
%Getvalues for t
for i=0:4
t(i+1)=newtarclen(i*.25,.001);
end
x=0.5+0.3*t+3.9*t.^2-4.7*t.^3;
y=1.5+0.3*t+0.9*t.^2-2.7*t.^3;
%Plot!
plot(x,y,'+')
clear

%n = 20
f = @(x)((0.3+7.8*x-14.1*x^2)^2+(0.3+1.8*x-8.1*x^2)^2)^(1/2);

%Initialize graph
s=0:.01:1;
X=0.5+0.3*s+3.9*s.^2-4.7*s.^3;
Y=1.5+0.3*s+0.9*s.^2-2.7*s.^3;
plot(X,Y)
hold all
t=zeros(20,1);
%Get values for T
for i=0:19
t(i+1)=newtarclen(i*.05,.001);
end
%Graph them
x=0.5+0.3*t+3.9*t.^2-4.7*t.^3;
y=1.5+0.3*t+0.9*t.^2-2.7*t.^3;
plot(x,y,'+')
clear;