User:Egm6322.s12.TEAM1.HW/HW6

Problem 1: Find the Continued Fraction for the Square Root of Five
 Solved without assistance 

Find
Find the continued fraction for the $$ \sqrt{5} \ $$

Solution
Re-arrange to get To rid the denominator of the square root term, multiply numberator and denominator by $$ \sqrt{5}+2 \ $$ to get: Substituting the value for x in Eq 1.4 back into Eq 1.2: Values begin to repeat, because from Eq 1.2, the value of $$ \sqrt{5} \ $$ is already known: This may also be written in the following forms: $$ \sqrt{5} = 2+\frac{1}{4+}\frac{1}{4+}\frac{1}{4+}\frac{1}{4+}\frac{1}{4+}\frac{1}{\cdots} \ $$ $$ \sqrt{5} = \left \{ 2,4,4,4,\cdots \right \} \ $$ $$ \sqrt{5} = \left [ 2,\bar 4 \ \right ] \ $$

Problem 2: Approximate Pi using Euclid's Algorthm
 Solved without assistance 

Given
$$ \pi\ \ $$ can be approximated successively by

Find
A) Use the method of successive subtractions or Euclid's Algorithm to show the given statement. B) Generate a sequence of rational numbers that approximates $$ \pi\ \ $$ from Wallis' Theorem: $$ \frac{ \pi\ }{2} = \frac{2*2*4*4*6*6*8*8 \cdots}{1*3*3*5*5*7*7*9\cdots} \ $$ C) Compare the rate of convergence of the continued fraction versus the Wallis Sequence.

Solution
A) Consider the shorthand values given in Eq2.1 and defining vectors as: Thus by the method of successive subtractions one must find the quotients given by above vectors $$ \overline{AB} \ $$, $$ \overline{CD} \ $$, $$ \overline{EF} \ $$, $$ \overline{GH} \ \ $$, beginning with the simplest, For Eq2.2 we have: For Eq2.3 we have: For Eq2.4 we have: For Eq2.5 we have: B) In order to generate a sequence of rational numbers similar to the Wallis sequence of: $$ \frac{ \pi\ }{2} = \frac{2*2*4*4*6*6*8*8 \cdots}{1*3*3*5*5*7*7*9\cdots} \ $$, I utilized an Excel Spreadsheet. I was able to use a sequence of 170 terms, at which point Excel stops computing terms any longer due to large numbers being generated in the sequence. See screen capture below (with several rows hidden to save space). One can see that Wallis' sequence slowly begins to approximate $$ \pi\ \ $$. C) The comparison of the speed of convergence between Wallis sequence versus the continued fraction is quite large. Using the terms found in this problem, one can see that it only required 2 terms to closely approximate $$ \pi\ \ $$ to the hundredths place using continued fractions, whereas I used 170 terms of Wallis' sequence and still only had an accuracy to the tenth place of a whole number.

Problem 3: Compare the convergence of power series and continued fraction method
 Solved without assistance 

Given
Power series of tan x: $$\displaystyle x \in ]-\pi /2,\pi/2 [$$ $$\displaystyle tan x = x + \frac{1}{3}x^3 + \frac{2}{15}x^5 + ... + \frac{(-1)^{n-1}2^{2n}(2^{2n}-1)B_{2n}}{(2n)!}x^{2n-1} + ...$$ Continued fraction of tan x: $$\displaystyle tan x = \frac{x}{\displaystyle 1 -\frac{x^2}{\displaystyle 3 -\frac{x^2}{\displaystyle 5 -\frac{x^2}{\displaystyle 7 -\frac{x^2}{\ddots}}}}}$$

Find
Take $$x = \pi / 4$$ and compare the term -by-term convergence of the power series (2) p.48-25b and the continued fraction (1). Provide a plot to visualize the convergence.

Solution
the exact solution of $$\displaystyle tan\left(\frac{\pi}{4}\right )$$ is 1.0 x = $$\frac{\pi}{4}$$ For power series, when n = 1 $$\displaystyle tanx = x = \frac{\pi}{4}=0.7853$$ When n = 2, $$\displaystyle tanx = x + \frac{1}{3}x^3= 0.9467$$ When n = 3, $$\displaystyle tanx = x + \frac{1}{3}x^3 + \frac{2}{15}x^5 = 0.9865$$ When n = 4, $$\displaystyle tanx = x + \frac{1}{3}x^3 + \frac{2}{15}x^5 + \frac{17}{315}x^7 = 0.99649$$ When n =5, $$\displaystyle tanx = x + \frac{1}{3}x^3 + \frac{2}{15}x^5 + \frac{17}{315}x^7 + \frac{62}{2835}x^9 = 0.9989$$ For continued fraction method, n = 1 $$\displaystyle tan x = \frac{x}{\displaystyle 1} = \frac{\pi}{4} = 0.7853 $$ When n = 2, $$\displaystyle tan x = \frac{x}{\displaystyle 1 -{x^2}}= 2.0498$$ When n =3, $$\displaystyle tan x = \frac{x}{\displaystyle 1 -\frac{x^2}{\displaystyle 3 -{x^2}}} = 1.059685$$ When n =4, $$\displaystyle tan x = \frac{x}{\displaystyle 1 -\frac{x^2}{\displaystyle 3 -\frac{x^2}{\displaystyle 5 -{x^2}}}} = 1.00144$$ When n = 5, $$\displaystyle tan x = \frac{x}{\displaystyle 1 -\frac{x^2}{\displaystyle 3 -\frac{x^2}{\displaystyle 5 -\frac{x^2}{\displaystyle 7 -{x^2}}}}}= 1.000018$$ These results show that as n increases, the convergence speed of continued fraction method will be faster than power series.

Problem 4: proof of the conversion between cdf and pdf forms of normal distribution
 Solved without assistance 

Given:
The definition of error function erf.

Find:
show that cdf of normal distribution can be obtained from pdf of normal distribution, and vice versa.

Solution:
From the defition of cdf (cumulative distribution function) we have: $$\displaystyle \Phi (x)=\int\limits_{-\infty }^{x}{f(t)dt}=\int\limits_{-\infty }^{x}{\frac{1}{\sqrt{2\pi }}{{e}^{-{{t}^{2}}/2}}dt}$$ Continued derivation based on the substitution of $$t=\sqrt{2}s$$,

$$\begin{align} & \Phi (x)=\frac{1}{\sqrt{2\pi }}\int\limits_{-\infty }^{x/\sqrt{2}}{{{e}^{-{{(\sqrt{2}s)}^{2}}/2}}d(\sqrt{2}s)} \\ & =\frac{1}{\sqrt{\pi }}\int\limits_{-\infty }^{x/\sqrt{2}}{{{e}^{-{{s}^{2}}}}ds} \\ & =\frac{1}{\sqrt{\pi }}\int\limits_{0}^{x/\sqrt{2}}{{{e}^{-{{s}^{2}}}}ds}+\frac{1}{\sqrt{\pi }}\int\limits_{-\infty }^{0}{{{e}^{-{{s}^{2}}}}ds} \\ & =\frac{1}{2}(\frac{2}{\sqrt{\pi }}\int\limits_{0}^{x/\sqrt{2}}{{{e}^{-{{s}^{2}}}}ds})+\frac{1}{2\sqrt{\pi }}\int\limits_{-\infty }^{\infty }{{{e}^{-{{s}^{2}}}}ds} \end{align}$$ Because $$\int\limits_{-\infty }^{\infty }{{{e}^{-{{s}^{2}}}}ds}=\sqrt{\pi }$$, which is proved in problem R13.5 and the definition of error function $$erf(x)=\frac{2}{\sqrt{\pi }}\int\limits_{0}^{x}{{{e}^{-{{s}^{2}}}}ds}$$ , we have: $$\begin{align} & \Phi (x)=\frac{1}{2}(\frac{2}{\sqrt{\pi }}\int\limits_{0}^{x/\sqrt{2}}{{{e}^{-{{s}^{2}}}}ds})+\frac{1}{2\sqrt{\pi }}\int\limits_{-\infty }^{\infty }{{{e}^{-{{s}^{2}}}}ds} \\ & =\frac{1}{2}(erf(x/\sqrt{2})+1) \end{align}$$ If we substitute the equation

$${x}'=\left( x-\mu \right)/\sigma $$ , into the above derivation, we obtain: $$\Phi (x)=\frac{1}{2}(erf(\left( x-\mu \right)/\sqrt{2}\sigma )+1)$$ The derivation from the cdf to pdf of normal distribution is the same procedure, just use the differential operator instead of integral operator.

Problem 5: integrate constant function with specific weight analytically and numerically
 Solved without assistance 

Find:
Integrate the constant function 1 with the weight $${{e}^{-{{x}^{2}}}}$$ $$\displaystyle I(1)=\int\limits_{-\infty }^{\infty }{1\centerdot {{e}^{-{{x}^{2}}}}dx}$$ 1. Analytically 2. Verify with WolframAlpha 3. Numerically using Gauss-Hermite quadrature and plot the convergence of numerical value as a function of n.

Solution:
1.Analytically: First,square up the integral to convert the line integral into an integral over the plane $$\displaystyle {{I}^{2}}=\int\limits_{-\infty }^{\infty }{\int\limits_{-\infty }^{\infty }{{{e}^{-({{x}^{2}}+{{y}^{2}})}}dx}dy}$$ Then,convert the area integral to polar coordinates to integrate: $$\begin{align} & {{I}^{2}}=\int\limits_{-\infty }^{\infty }{\int\limits_{-\infty }^{\infty }{{{e}^{-({{x}^{2}}+{{y}^{2}})}}dx}dy} \\ & =\int\limits_{-\pi }^{\pi }{\int\limits_{0}^{\infty }{{{e}^{-({{(r\sin \theta )}^{2}}+{{(r\cos \theta )}^{2}})}}rdr}d\theta } \\ & =\int\limits_{-\pi }^{\pi }{\int\limits_{0}^{\infty }{{{e}^{-{{r}^{2}}}}\frac{1}{2}d\left( {{r}^{2}} \right)}d\theta } \\ & =\int\limits_{-\pi }^{\pi }{\frac{1}{2}\left( \int\limits_{0}^{\infty }{{{e}^{-t}}dt} \right)d\theta } \\ & =\int\limits_{-\pi }^{\pi }{\frac{1}{2}\left( -{{e}^{-\infty }}-(-{{e}^{-0}}) \right)d\theta } \\ & =\int\limits_{-\pi }^{\pi }{\frac{1}{2}d\theta } \\ & =\pi \end{align}$$ in which the substitution of $$t={{r}^{2}}$$ is used during derivation. So, we obtain: $$\displaystyle I=\int\limits_{-\infty }^{\infty }{{{e}^{-{{x}^{2}}}}dx}=\sqrt{\pi }$$ 2.Verify with WolframAlpha: $$\displaystyle \int\limits_{-\infty }^{\infty }{{{e}^{-{{x}^{2}}}}dx}=\sqrt{\pi }\approx 1.77245$$ So, the same result with analytical one is obtained. 3. Numerically: Use the Gauss-Hermite quadrature with the table for {x_i} and {H_i} at DLMF:Gauss-Hermite formula. $$\displaystyle {{I}_{n}}(1)=\sum\limits_{i=1}^{n}{{{H}_{i}}f({{x}_{i}})}=\sum\limits_{i=1}^{n}$$ n=2: $$0.\text{886227}*2=1.772454$$ n=3: $$\text{0}\text{.295409*2+1}\text{.18164}=1.772458$$ n=4: $$\text{0}\text{.804914*2+0}\text{.0813128*2}=1.7724536$$ n=5:

$$\text{0}\text{.94530872048294+0}\text{.393619323152241*2+0}\text{.0199532420590459*2=}1.7724538509055138$$ n=10:

$$\text{0}\text{.610862633735325799*2+0}\text{.240138611082314686*2+0}\text{.0338743944554810631*2+0}\text{.00134364574678123269*2+0}\text{.00000764043285523262063*2=}1.7724538509551602$$ And the plot is shown in the following figure:

Problem 6: Prove that a Polynomial belongs to a Real Set of Numbers
 Solved without assistance 

Find:
Show that:

Solution:
For $$ p_n \in \mathcal P_n \  $$ and $$ p_n(x)= \sum_{i=0}^n k_i^nx^i \  $$ Consider the polynomial: $$ s(x):= p_{n+1}(x)-A_nxp_n(x)\in \mathcal P_{n+1} \ $$

$$ = \sum_{i=0}^{n+1}k_i^{n+1}x^i-A_n \sum_{i=0}^n k_i^nx^{i+1} \ $$

$$ = \sum_{j=-1}^n k_{j+1}^{n+1}x^{j+1}-A_n \sum_{i=0}^n k_i^nx^{i+1} \ $$

$$ = \sum_{j=-1}^{n-1}k_{j+1}^{n+1}x^{j+1}+k_{n+1}^{n+1}-A_n \sum_{i=0}^{n-1}k_i^nx^{i+1}-A_nk_n^nx^{n+1} \ $$

$$ = \sum_{j=-1}^{n-1}k_{j+1}^{n+1}x^{j+1}-A_n \sum_{i=0}^{n-1}k_i^nx^{i+1}+(k_{n+1}^{n+1}x^{n+1}-A_nk_n^nx^{n+1}) \ $$

If $$ A_n=\frac{k_{n+1}^{n+1}}{k_n^n}=:\frac{k_{n+1}}{k_n} \ $$

Then

$$ k_{n+1}^{n+1} x^{n+1} - A_n k_n^n x^{n+1} =(k_{n+1}^{n+1}- A_n k_n^n) x^{n+1} = 0 \ $$

$$ s(x) = \sum_{j=-1}^{n-1}k_{j+1}^{n+1}x^{j+1}-A_n \sum_{i=1}^{n-1}k_i^nx^{i+1}+0 = \sum_{i=0}^n k_i^{n+1}x^i-A_n \sum_{j=2}^nk_{j-1}^nx^j \in \mathcal P_n \ $$

Thus:

$$ s(x)=p_{n+1}(x)-A_nxp_n(x)=\sum_{i=0}^n d_ip_i(x) \ $$

Problem 7: Show Orthogonality using Scalar Products
 Solved without assistance 

Find
Show that: for $$ j \ne n-1 \ $$ and for $$ j = n-1 \ $$ Also using Eqs 7.1 and 7.3, show that: for $$ j < \ n-1 \ $$

Solution:

 * {| style="width:100%" border="0" align="left"

\displaystyle \langle p_j,p_{n+1}-A_nxp_n(x)\rangle= \sum_{i=0}^n d_i \underbrace{\langle p_j,p_i \rangle}_{\displaystyle h_j\delta_{ij} } =h_jd_j $$
 * 
 * }
 * }

For the equation above to be satisfied
 * {| style="width:100%" border="0" align="left"

\displaystyle j\leq n $$
 * 
 * }
 * }


 * {| style="width:100%" border="0" align="left"

\displaystyle q_{j+1}:=xp_j \in \mathcal P_{j+1} $$
 * 
 * }
 * }

When$$j=n$$
 * {| style="width:100%" border="0" align="left"

\displaystyle q_{j+1}=q_{n+1}=xp_n=\sum _{i=0}^{n+1}d_ip_i(x) $$
 * 
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \langle q_{n+1},p_n \rangle =d_n\langle p_n,p_n \rangle =d_nh_n \neq 0 $$
 * 
 * }
 * }

When$$j=n-1$$
 * {| style="width:100%" border="0" align="left"

\displaystyle q_{j+1}=q_n=xp_{n-1}=\sum_{i=0}^nd_ip_i(x) $$
 * 
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \langle q_n,p_n \rangle =d_n \langle p_n,p_n \rangle =d_nh_n \neq 0 $$
 * 
 * }
 * }

When$$j
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle q_{j+1}\in \mathcal P_{j+1} $$ For $$p_n$$ is perpendicular to $$\mathcal P_{j+1}$$ So
 * 
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \langle q_{j+1},p_n\rangle =0 $$
 * 
 * }
 * }
 * {| style="width:100%" border="0" align="left"

\displaystyle \begin{align} & \ \langle p_j, p_{n+1}-A_nxp_n(x) \rangle \\ &= \langle p_j, p_{n+1} \rangle - \langle p_j, A_nxp_n \rangle\\ &= 0-\langle A_n x p_j ,p_n \rangle \\ &= \langle q_{j+1}, p_n \rangle\\ &= 0 \end{align} $$
 * 
 * }
 * }

=Contributing Members & Referenced Lecture=

=Table of Contributions=