(Programming) Estimate the length of the curve (hypotrochoid) to six significant decimal digits

Register or Login to View the Solution or Ask a Question

Question : Estimate the length of the curve (hypotrochoid) to six significant decimal digits applying a numerical method of your choice.
\[x(t) =\frac{3}{2} cos(t) +cos(3t) , y(t) =\frac{3}{2} sin(t) −sin(3t) \]defined on the interval 0 ≤ t ≤ 2π.
Identify the method and plot the {x, y} points involved in the computation.

Solution :

The length of a parametric curve {x(t), y(t)} is given by the integral

\[\int_{a}^{b} \sqrt{x'(t)^2+y'(t)^2}dt\]

where a ≤ t ≤ b

Trapezoidal Rule to Estimate the length of the curve (hypotrochoid)

Trapezoidal rule to calculate the numerical approximation of the definite integral is given as

\[\int_{a}^{b} f(x) dx =\frac{\delta x}{2} \left(f(x_{0})+2f(x_{1})+f(x_{0})+2f(x_{2})+…..2f(x_{n-1})+f(x_{n})\right)\]

Matlab Code

clear all
x=@(t) (3/2)*cos(t)+cos(3*t)
y=@(t) (3/2)*sin(t)-sin(3*t)
a=0
b=2*pi
n=5 % number of partitions of the interval
h=(b-a)/n % stepsize
S = 0;
for i = 1:n
    t(i) = a +h* (i-1); 
end
 
 
for i = 1:n
    f(i) = sqrt((x(t(i)))^2+(y(t(i)))^2);
end
 
% Trapezoidal Rule
for i = 1:n
    if ( i == 1 || i == n)
        S = S+ f(i)/2;
    else
        S = S + f(i);  
    end
end
I = S * h; 
 
I  % length of the curve
plot(x(t(:)),y(t(:)))
xlabel('x')
ylabel('y')

Output :

x =

@(t) (3 / 2) * cos (t) + cos (3 * t)

y =

@(t) (3 / 2) * sin (t) - sin (3 * t)

a = 0
b = 6.2832
n = 5
h = 1.2566
I = 7.7032

Register or Login to View the Solution or Ask a Question

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply