Quiz #2 Arc Length --- Fall 2007

Contents

Exercise #1 --- Close all open figure windows.

The following command will close all open figure windows. This is something we do so that running the file will popup a fresh new figure window and we won't have to use the mouse or the command shg to bring the figure window to the front of the desktop.

close all

The domain.

We use the linspace command to produce 200 equally spaced points on the domain [1,4].

t=linspace(1,4,200);

Compute x and y.

We next compute x and y. Note the use of the array operators (dot-notation).

x=exp(t).*(cos(t)+sin(t));
y=exp(t).*(cos(t)-sin(t));

The plot.

We plot the result in the xy-plane

plot(x,y)

Annotate the axes

We use the xlabel and ylabel commands to annotate the axes.

xlabel('x-axis')
ylabel('y-axis')

Title

The parametric equations are too long to fit in a one-line title. Hence, we will create a cell array that holds each equation as a row. The title command then takes the cell array and typesets it as a multi-line title.

Note the use of braces in titleStr(1) = { }.

There's a bit of TeX code here. The caret is used for superscripts in TeX. If you wish more than one character to be in the superscript, use braces to surround the intended superscript.

titleStr(1) = {'x = e^t ( cos(t) + sin(t) )'};
titleStr(2) = {'y = e^t ( cos(t) - sin(t) )'};
title(titleStr)

Smybolic Computation

In this segment, we will use the Symbolic Toolbox, Matlab's interface to Maple to make some symbolic calculations to check our hand-written evaluation of the integral.

First define t as a symbolic variable, then define x and y in terms of t.

syms t
x=exp(t)*(cos(t)+sin(t));
y=exp(t)*(cos(t)-sin(t));

Define ds

Define the fundamental piece of arc length and simplify the result.

ds=sqrt(diff(x,t)^2+diff(y,t)^2);
ds=simple(ds)
ds =
2*exp(2*t)^(1/2)

Integrate

We now use the int command to integate

int(ds, 1, 4)
ans =
2*exp(4)-2*exp(1)

Click on the link that follows to obtain hand-calculations for the arc length.

Quiz #2 Solutions

Exercise #2 --- Close all open figure windows.

The following command will close all open figure windows. This is something we do so that running the file will popup a fresh new figure window and we won't have to use the mouse or the command shg to bring the figure window to the front of the desktop.

close all

The domain.

We use the linspace command to produce 200 equally spaced points on the domain [1,2].

t=linspace(1,2,200);

Compute x and y.

We next compute x and y. Note the use of the array operators (dot-notation).

x=t-t.^2;
y=4/3*t.^(3/2);

The plot.

We plot the result in the xy-plane

plot(x,y)

Annotate the axes

We use the xlabel and ylabel commands to annotate the axes.

xlabel('x-axis')
ylabel('y-axis')

Title

The parametric equations are too long to fit in a one-line title. Hence, we will create a cell array that holds each equation as a row. The title command then takes the cell array and typesets it as a multi-line title.

Note the use of braces in titleStr(1) = { }.

There's a bit of TeX code here. The caret is used for superscripts in TeX. If you wish more than one character to be in the superscript, use braces to surround the intended superscript.

titleStr(1) = {'x = t - t^2'};
titleStr(2) = {'y = (4/3) t^{3/2}'};
title(titleStr)

Numerical Integration

We will use an anonymous function to define the integrand

f = @(t) sqrt(1+4*t.^2);

Click on the link that follows to obtain hand-calculations for the integrand..

Quiz #2 Solutions

Quad

We now use the quad command to integrate

quad(f,1,2)
ans =
    3.1678