User:Egm6341.s10.team3.Min/HW4

6(a) Install Chebfun and practice sum commond
Ref: Lecture Notes [[media:Egm6341.s10.mtg25.djvu|p.25-1]]

Problem Statement
Install chebfun and practice sum command to do integration$$\displaystyle I = \int_{0}^{1}\frac{e^{x}-1}{x}dx$$, and record the computational time

Solution
i) Chebfun installation The chebfun can be downloaded from http://www2.maths.ox.ac.uk/chebfun/files.html

We installed the "chebfun" successful based on the instruction which is also availabe in the above webpage. In chebfun, 'sum' command will returns the definite integral of a chebfun over its range of defination.

The integral is normally calculated by an FFT-based variant of Clenshaw-Curtis quadrature.

This formula is applied on each fun and then the results are added up.

The chebfun will be used in the following problem to show comparision of speed among different numerical methods for integration.

For detailed information, one can refer the paper: Battles and Trefethen, An extension of Matlab to continuous functions and operators (SIAM J. Sci. Comp., 2004)

ii) Chebfun, Sum command

We use the command 'sum' in chebfun to compute I with error to $$ 10^{-10}$$  Result:

I_c=1.317902151454404 E_c=4.403588604873221e-012

Elapsed time is 0.139211 seconds.

-- By Min Zhong 12:00, 02 March 2010 (UTC)

6 (d) compare trapz, quad, clencurt
Ref: Lecture Notes [[media:Egm6341.s10.mtg25.djvu|p.25-2]]

Problem Statement
For $$\displaystyle I = \int_{0}^{1}\frac{e^{x}-1}{x}dx$$, compare $$\displaystyle I_{n}$$ to $$\displaystyle O(10^{-10})$$ and computational time by - Matlab : trapz, quad and clencurt

Solution
i) Trapz

We use the command 'trapz' in matlab to compute I with error to $$ 10^{-10}$$   Result

I_t = 1.317902151493208

n_t = 32768

E_t = 3.880429311209355e-011

Elapsed time is 0.753827 seconds

ii) Quad

We use the command 'quad' in matlab to compute I with error to $$ 10^{-10}$$   Result:

I_q=1.317902151454412

Elapsed time is 0.043016 seconds.

iii) Clencurt

We use the command 'clencurt' in matlab to compute I with error to $$ 10^{-10}$$   Result:

I_cl = 1.317902151447634

Elapsed time is 0.001750 seconds.

iv) Compare computational time

As above table shown, clencurt has the shortest computational time and trapz takes longest time.

Therefore,clencurt is the more efficient way to get a numerical integration value for the given function.

 -- By Min Zhong 12:00, 02 March 2010 (UTC)

7 (a) Use chebfun to do integration
Ref: Lecture Notes [[media:Egm6341.s10.mtg25.djvu|p.25-2]]

Problem Statement
For $$\displaystyle I = \int_{-5}^{5}\frac{1}{1+x^2}dx$$, compare $$\displaystyle I_{n}$$ to $$\displaystyle O(10^{-10})$$ and computational time by - chebfun: sum command,

Solution
 Chebfun

We use the command 'sum' in chebfun to compute I with error to $$ 10^{-10}$$

Result:

I_c=2.746801533890032

Elapsed time is 0.141973 seconds.

E=4.440892098500626e-016

7 (d) compare trapz, quad, clencurt
Ref: Lecture Notes [[media:Egm6341.s10.mtg25.djvu|p.25-2]]

Problem Statement
For $$\displaystyle I = \int_{-5}^{5}\frac{1}{1+x^2}dx$$, compare $$\displaystyle I_{n}$$ to $$\displaystyle O(10^{-10})$$ and computational time for - chebfun: sum command, - Matlab : trapz, quad and clencurt

Solution
i) Trapz

We use the command 'trapz' in matlab to compute I with error to $$ 10^{-10}$$

Result:

I_t = 2.746801533832626

n_t = 65536

E_t = 5.740607988968804e-011

Elapsed time is 0.061356 seconds.

ii) Quad

We use the command 'quad' in matlab to compute I with error to $$ 10^{-10}$$

Result:

I_q= 2.746801533869947

Elapsed time is 0.029688 seconds.

iii) Clencurt

We use the command 'clencurt' in matlab to compute I with error to $$ 10^{-10}$$ Result:

Elapsed time is 0.011186 seconds.

I_cl = 2.746801533874087

n = 62

iv) Compare computational time

As above table shown, Quad has the shortest computational time among these commonds.

Therefore, Quad is a more efficient way to get a numerical integration value for the given function.   -- By Min Zhong 2:00, 03 March 2010 (UTC)

8 (a) Apply chebfun to integration
Ref: Lecture Notes [[media:Egm6341.s10.mtg25.djvu|p.25-2]]

Problem Statement
Compute $$\displaystyle I = \int_{0}^{2\pi}\frac{1-sin^{2}(\frac{\pi}{12})}{1-sin(\frac{\pi}{12})cos\theta}d\theta$$, and computational time - chebfun: sum command,

Solution
 Chebfun

We use the command 'sum' in chebfun to compute I with error to $$ 10^{-10}$$

Result:

I_c= 6.069090959564774

E_c=3.552713678800501e-015

Elapsed time is 0.140592 seconds.

8 (d) compare trapz, quad, clencurt
Ref: Lecture Notes [[media:Egm6341.s10.mtg25.djvu|p.25-2]]

Problem Statement
For $$\displaystyle I = \int_{0}^{2\pi}\frac{1-sin^{2}(\frac{\pi}{12})}{1-sin(\frac{\pi}{12})cos\theta}d\theta$$,

- Matlab : trapz, quad and clencurt

Solution
i) Trapz

We use the command 'trapz' in matlab to compute I with error to $$ 10^{-10}$$

Result:

I_t =6.069090959564874

n_t =16

E_t =1.039168751049147e-013

Elapsed time is 0.023226 seconds.

ii) Quad

We use the command 'quad' in matlab to compute I with error to $$ 10^{-10}$$

Result:

I_q=6.069090959562212

Elapsed time is 0.023456 seconds.

iii) Clencurt

We use the command 'clencurt' in matlab to compute I with error to $$ 10^{-10}$$ Result:

I_cl = 6.069090959664361

n = 20

Elapsed time is 0.006226 seconds.

iv) Compare computational time

As above table shown, clencurt has the shortest computational time among these commonds .

Therefore, cleancurt is a more efficient way to get a numerical integration value for the given function.

-- By Min Zhong 12:00, 02 March 2010 (UTC)