Software to approximate area of curve

158 Views Asked by At

Does any know of a math program where I can measure the area of a closed parametric curve ?

I know that I can measure the area between 2 curves with the TI-Nspire, but not for one curve in parametric form.

I'm looking to verify my answer for the following curve (area of left and right side separately).

enter image description here

If you're curious the parametric equation of the curve is :

$$x(t) = e^{\sin(\pi t)}$$ $$y(t) = e^{\sin(2\pi t)}$$ $$ 0 \leq t \leq 2 $$

Using Greens Theorem, I get $0.8445 \text{ units}^2$ for the left side and $2.7726 \text{ units}^2$ for the right side.

I'm just looking for a software where I can check my answers my self.

Thanks,

Liam

2

There are 2 best solutions below

2
On BEST ANSWER

The parametric equation of the boundary is $$0\leq t \leq 2,\ \begin{cases} x(t) = e^{\sin(\pi t)}\\ y(t) = e^{\sin(2\pi t)} \end{cases}$$ First, change it to the non-parametric form. Let $p=\ln x$ and $q=\ln y$. Thus $$q^2=4p^2(1-p^2)\Rightarrow q=\pm 2p\sqrt{1-p^2}$$ or $$y=e^{\pm 2\ln x \ \sqrt{1-(\ln x)^2}}$$

We are interested in the region $R=R_1\cap R_2$ between the two curves. We consider it in two cases:

  • $\frac{1}{e}<x \le 1 \Rightarrow R_1=\{(x,y):e^{2\ln x \ \sqrt{1-(\ln x)^2}} \le y\le e^{- 2\ln x \ \sqrt{1-(\ln x)^2}}\}$

  • $1<x \le e \Rightarrow R_2=\{(x,y):e^{-2\ln x \ \sqrt{1-(\ln x)^2}} \le y\le e^{ 2\ln x \ \sqrt{1-(\ln x)^2}}\}$

Now we calculate the probability that a random point in a box $B$ defined as

$$B=\{(x,y): 0\le x\le 3, 0\le y\le3\}$$

is inside the regions $R_1$ and $R_2$, respectively.

To do that, we randomly select $N$ points $(x,y)$ in the given box and count those that are inside the desired region. If $M_i$ points are inside the desired region $R_i$, then the desired probability is $M_i/N$ (for $i=1,2$). But this probability is related to the area of the box and the area of the desired region as

$$\frac{\mathsf{Area}(R_i)}{\mathsf{Area}(B)}\approx\frac{M_i}{N}$$ Thus

$$\boxed{\mathsf{Area}(R_i)\approx\frac{9M_i}{N}}$$

Based on the above explanation, one can use the following Matlab code:

t = 0:.01:2; % first draw the boundary
x = exp(sin(pi*t));
y = exp(sin(2*pi*t));
plot(x,y)
hold on

N = 50000;
M1 = 0; %initialize the counters
M2 = 0;
for n = 1:N
    x = 3*rand; % uniformly random x between 0 and 3
    y = 3*rand; % uniformly random y between 0 and 3
    if x>=exp(-1) && x <= 1
        if y<=exp(-2*log(x).*sqrt(1-log(x).^2)) && ...
              y>=exp(2*log(x).*sqrt(1-log(x).^2))
          M1 = M1+1; % the point is in R1
          plot(x,y,'r')
        end
    elseif x>=1 && x <= exp(1)
        if y<=exp(2*log(x).*sqrt(1-log(x).^2)) && ...
              y>=exp(-2*log(x).*sqrt(1-log(x).^2))
          M2 = M2+1; % the point is in R2
          plot(x,y,'g')
        end        
    end
end
A1=9*M1/N
A2=9*M2/N

which gives A1 = 0.8474 and A2 = 2.7940.

enter image description here

The accuracy can be improved by increasing $N$.

1
On

If you can parametrise the region, not just the boundary, then Mathematica can do it. Here it is for the unit disk:

Area[ParametricRegion[{Cos[t] a, Sin[t] a}, {{t, -Pi, Pi}, {a, 0, 1}}]]

Output is Pi. Hopefully the syntax is clear from context: the parametrisation of the disk is as $(\cos(t) a, \sin(t) a)$ for $-\pi \leq t < \pi$ and $0 \leq a \leq 1$.

You can use http://lab.open.wolframcloud.com/objects/wpl/GetStarted.nb (replacing the example code 2+2 with whatever you want) to run Mathematica expressions.