function P = P_inner(a,b,n)
%P_INNER computes perimeter of inscribed polygon

theta=2*pi/n;
sum=0;

for k=1:n
    xk=a*cos(k*theta);
    yk=b*sin(k*theta);

    xkp1=a*cos((k+1)*theta);
    ykp1=b*sin((k+1)*theta);

    dk=sqrt((xk-xkp1)^2 + (yk-ykp1)^2);
    sum=sum+dk;
end

P=sum;

end

