Jump to content

User:Egm6322.s14.team2/report2: Difference between revisions

From Wikiversity
Content deleted Content added
Line 629: Line 629:
({{EquationRef|Eq 7-3}}) then becomes <ref>http://ice.uchicago.edu/2012_presentations/Faculty/Judd/Quadrature_ICE11.pdf</ref>:
({{EquationRef|Eq 7-3}}) then becomes <ref>http://ice.uchicago.edu/2012_presentations/Faculty/Judd/Quadrature_ICE11.pdf</ref>:


{{NumBlk|::|<math>\int_{a}^{+\infty} e^{-y} g(y)\,dx \approx e^{-a} \sum_{i=1}^n w_i \, g(x_i+a) </math> |{{EquationRef|Eq 7-7}}|}}
{{NumBlk|::|<math>\int_{a}^{+\infty} e^{-y} g(y)\,dy \approx e^{-a} \sum_{i=1}^n w_i \, g(x_i+a) </math> |{{EquationRef|Eq 7-7}}|}}

A numerical python (NumPy) script was written to test the quadrature for this integral. The source code is given below:


A numerical python (NumPy) script was written to test the quadrature for the integral in ({{EquationRef|Eq 7-1}}). The source code is given below:
(Note: NumPy is an opensource
<source lang="python">
<source lang="python">
#################################################################################
#################################################################################
Line 714: Line 714:
plt.show()
plt.show()
</source>
</source>


Script terminal output:
<pre>
n=4
0.145107525093
n=16
0.162236347114
n=100
0.172558662198
exact
0.195247541983
</pre>

Plot generated by script:
[[image:LogarithmicConvergence.png|frame|center|Figure 7.1: Convergence of ({{EquationRef| 7-1}}) with increasing integration points]]


The above script uses NumPy's Laguerre module quadrature routine: numpy.polynomial.laguerre.laggauss(deg). This routine solves the roots of the Laguerre polynomials by first finding the eigenvalues of the [https://en.wikipedia.org/wiki/Companion_matrix Companion Matrix], and then applying an iteration of [https://en.wikipedia.org/wiki/Newton%27s_method Newton's Method] to improve accuracy.

[http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.polynomial.laguerre.laggauss.html#numpy.polynomial.laguerre.laggauss Documentation]

[https://github.com/numpy/numpy/blob/master/numpy/polynomial/laguerre.py#L1647 source]

The above script uses ({{EquationRef| 7-5}}) to calculate ({{EquationRef| 7-1}}).

{{NumBlk|::|<math>\int_{2}^{+\infty} e^{-y} \left ( e^{-y} \frac{1}{y \log^2(y)} \right ) \,dy \approx e^{-2} \sum_{i=1}^n w_i \, g(x_i+2) </math> |{{EquationRef|Eq 7-8}}|}}

The script above compares favourably with values calculated by Dr. Burkardt <ref>http://people.sc.fsu.edu/~%20jburkardt/c_src/test_int_laguerre/test_int_laguerre_prb_output.txt</ref>.

<center><table class="wikitable">
<tr>
<td width="20%" align="center">''n''</td>
<td width="40%" align="center">''Python Script''</td>
<td align="center">''Dr. Burkardt''</td>
</tr>

<tr>
<td width="20%" align="center">4</td>
<td width="40%" align="center">0.145107525093</td>
<td align="center">0.145108</td>
</tr>

<tr>
<td width="20%" align="center">16</td>
<td width="40%" align="center">0.162236347114</td>
<td align="center">0.162236</td>
</tr>

<caption>Table 7.1 Comparison of quadrature calculations</caption>

</table>
</center>


As can be seen in Figure 1, even at 100 integration points there is still significant error or around 12 percent.

====Part b====


=Contributing Team Members=
=Contributing Team Members=

Revision as of 23:38, 6 February 2014

Report 2 PEA 2 Spring 2014 Team 2

Problems are given in lecture notes Sec66a


Problem 1

Given Information

Here is a sample equation and a sample in-text reference to the equation.

 

 

 

 

(Eq 1-1)

Here is a link to (Eq 1-1)


Problem Statement

The atomic-resolution TEM figure on p.66-16 is not obvious (not easy to see and to understand); search the literature (web, pdf papers, pdf reports, etc.) for better (good quality) figure(s) that show the dislocation at atomic level with a burger vector. for example, here is an image web search for “dislocation atomic TEM burger vector”.

Solution

R2.2 Roots of Associated Laguerre Polynomials

Problem Statement

Plot the associated Laguerre polynomials for and . Use MATLAB to find the roots of for , and verify the numbers in the table on p.66a-7

Note: If you already have the plots made in report R1, you simply copy and paste these plots in report R2; the task then is only to find the roots of these polynomials.

Find

(a): Associated Laguerre polynomial plots

(b): Roots of Laguerre polynomials

(c): Verify numbers in the table on p.66-7

Solution


Part (a): Associated Laguerre Polynomial Plots

The plot was created using the Python scripting language.

Figure 1: Associated Laguerre Polynomial ([1])


Part (b): Roots of Associated Laguerre Polynomials

The roots of the associated Laguerre polynomial were computed using Wolfram Alpha. The syntax for creating associated Laguerre polynomials in Wolfram Alpha: LaguerreL[n,k,x] where n is the degree, k is the family of Laguerre polynomials, and x is the independent variable.


The Laguerre polynomial given by,

 

 

 

 

(Eq 2-1)

Has three roots. The approximate roots of the polynomial are:




The Laguerre polynomial given by,

 

 

 

 

(Eq 2-2)

Has three roots. The roots of the polynomial are:




The Laguerre polynomial given by,

 

 

 

 

(Eq 2-3)

Has three roots. The roots of the polynomial are:




The Laguerre polynomial given by,

 

 

 

 

(Eq 2-4)

Has three roots. The roots of the polynomial are:




The Laguerre polynomial given by,

 

 

 

 

(Eq 2-5)

Has three roots. The roots of the polynomial are:




Part (c): Two Sets of Roots of Associated Laguerre Polynomials For

In this section we are asked to compute the roots of the associated Laguerre polynomials with . We are then asked to compare these results to previously tabulated results.

The Laguerre polynomial given by,

 

 

 

 

(Eq 2-6)

The following roots:

Associated Laguerre Polynomial Roots of
Root # Root
0
0.5277
1.796
3.877
6.919
11.235
17.65



The Laguerre polynomial given by,

 

 

 

 

(Eq 2-7)

The following roots:

Associated Laguerre Polynomial Roots of
Root # Root
0
0.4610
1.564
3.352
5.916
9.421
14.19
21.09

Problem 3

Given Information

(Eq 3-1) was given for the value of PN(u) and (Eq 3-2) through (Eq 3-4) were given for the Laguerre polynomials written with the same variables as (Eq 3-1) for comparisons.

 

 

 

 

(Eq 3-1)

 

 

 

 

(Eq 3-2)

 

 

 

 

(Eq 3-3)

 

 

 

 

(Eq 3-4)

Problem Statement

Compare (Eq 3-1) to the various finite power series expressions for the associated Laguerre polynomials in (Eq 3-2) through (Eq 3-4) as specified in R2.3: sec.66a, Pb-66-6.

Solution

On our honor, we did this assignment on our own, without looking at the solutions in previous semesters or other online solutions.


The falling factorial term in (Eq 3-1) can be rewritten with a Pochhammer symbol.

 

 

 

 

(Eq 3-5)

Where,

 

 

 

 

(Eq 3-6)

The Pochhammer symbol can be related to a binomial coefficient by the equation:

 

 

 

 

(Eq 3-7)


Plugging (Eq 3-7) into (Eq 3-5) results in:

 

 

 

 

(Eq 3-8)

The binomial coefficient has the following closed form for integer arguments:[1]

 

 

 

 

(Eq 3-9)

Substituting the closed form in (Eq 3-9) into (Eq 3-8) gives:

 

 

 

 

(Eq 3-10)

For the the case where , (Eq 3-3) has the form:

 

 

 

 

(Eq 3-11)

Using the expression (Eq 3-7) for the binomial term in (Eq 3-11) yields:

 

 

 

 

(Eq 3-12)

Plugging (Eq 3-12) into (Eq 3-11) gives:

 

 

 

 

(Eq 3-13)

It should be noted that the summation index in (Eq 1-13) changes from to . This is because when the binomial coefficient is zero and cannot be represented by the factorial expression. This term must be brought outside of the sum, but since the term is zero, all that results is an index change.

The first term of (Eq 3-13) is brought outside the summation. To reproduce (Eq 3-8)

 

 

 

 

(Eq 3-14)

Problem 4

Given Information

The following equation is given for ds2<\sup>:

 

 

 

 

(Eq 4-1)

xi is written in spherical coordinates in (Eq 4-2) through (Eq 4-4).

 

 

 

 

(Eq 4-2)

 

 

 

 

(Eq 4-3)

 

 

 

 

(Eq 4-4)

Problem Statement

Show that the infinitesimal length ds2 in (Eq 4-1) can be written in spherical coordinates, (Eq 4-5), as given in Pb.R*7.3 on pp.39-[1,3] of sec.39 of the notes.

 

 

 

 

(Eq 4-5)

Solution

On our honor, we did this assignment on our own, without looking at the solutions in previous semesters or other online solutions.

The derivatives of xi are given in (Eq 4-6) through (Eq 4-8).

 

 

 

 

(Eq 4-6)

 

 

 

 

(Eq 4-7)

 

 

 

 

(Eq 4-8)

(Eq 4-9) was developed by substituting the squared derivatives in the summation of (Eq 4-1) and combining like terms.

 

 

 

 

(Eq 4-9)

Using the Pythagorean Trigonometric Identity, (Eq 4-9) reduces to (Eq 4-10).

 

 

 

 

(Eq 4-10)

Problem 5

Given Information

The following equation is given for P2(x), the Legendre Polynomial of degree n=2:

 

 

 

 

(Eq 5-1)

Problem Statement

Using variation of parameters, show that Equation 5-2 is a second solution to the Legendre differential equation in Equation 5-3 as given in Pb.R*6.11 on pp.37-4 in sec.37 of the notes.

 

 

 

 

(Eq 5-2)

Solution

The Legendre differential equation of degree n=2 is given in equation 5-3.

 

 

 

 

(Eq 5-3)

Using reduction of order, some function, v, times P2(x) and the first two derivatives of the product are substituted into the Legendre differential equation in equation 5-7. Furthermore, since P2(x) is a solution to the Legendre equation the coefficient of the first order term, v, reduces to zero. Since the lowest order term cancels out, the second order differential equation is reduced to a first order differential equation where w=v' and w'=v in Equation 5-8 which can be solved through separation of variables.

 

 

 

 

(Eq 5-4)

 

 

 

 

(Eq 5-5)

 

 

 

 

(Eq 5-6)

 

 

 

 

(Eq 5-7)

 

 

 

 

(Eq 5-7)

Through partial fraction decomposition, the integral is

 

 

 

 

(Eq 5-8)

Through integration

 

 

 

 

(Eq 5-9)

Using properties of the natural logarithm and then inverting it using the exponential function, equation 5-9 becomes

 

 

 

 

(Eq 5-10)

Substituting v' back into Equation 5-10 and again using partial fraction decomposition

 

 

 

 

(Eq 5-11)

Completing the integration

 

 

 

 

(Eq 5-12)

Substituting v multiplied by the arbitrary constant 8 back into Equation 5-4 then identifying the new solution as Q2

 

 

 

 

(Eq 5-12)

Problem 6

Given Information

The following equations are given for heat conduction on a cylinder

 

 

 

 

(Eq 6-1)

 

 

 

 

(Eq 6-2)

 

 

 

 

(Eq 6-3)

Problem Statement

(a) Find

 

 

 

 

(Eq 6-4)

in terms of

 

 

 

 

(Eq 6-5)

and

 

 

 

 

(Eq 6-6)


(b) Find

 

 

 

 

(Eq 6-7)

Identify in terms of

(c) Find in terms of cylindrical coordinates

(d) Use separation of variable to find the separated equations of Laplace's equation in cylindrical coordinates and compare to the Bessel equation:

 

 

 

 

(Eq 6-8)

Solution

Part a

The total differential of can be written as:

 

 

 

 

(Eq 6-9)

Similar expressions can be written for and .

 

 

 

 

(Eq 6-10)

 

 

 

 

(Eq 6-11)

Plugging in the expressions from (Eq 6-1), (Eq 6-2) and (Eq 6-3):

 

 

 

 

(Eq 6-12)

 

 

 

 

(Eq 6-13)

 

 

 

 

(Eq 6-14)

Part b

Plugging in (Eq 6-12), (Eq 6-13), and (Eq 6-14) into (Eq 6-7).

 

 

 

 

(Eq 6-15)

Expanding (Eq 6-14) out, and applying the following trig identity:

 

 

 

 

(Eq 6-16)

Results in the following expression:

 

 

 

 

(Eq 6-17)

Comparing (Eq 6-17) to the left hand side of (Eq 6-7):

 

 

 

 

(Eq 6-18)

 

 

 

 

(Eq 6-19)

 

 

 

 

(Eq 6-20)

Part c

The Laplacian operator for a scalar function in general curvilinear coordinates is defined as[2]:

 

 

 

 

(Eq 6-21)

Plugging in (Eq 6-18), (Eq 6-19) and (Eq 6-20).

 

 

 

 

(Eq 6-22)

 

 

 

 

(Eq 6-23)

 

 

 

 

(Eq 6-24)

Part d

Laplace's equation in cylindrical coordinates is:

 

 

 

 

(Eq 6-25)

 

 

 

 

(Eq 6-26)

Assume a solution to (Eq 6-26) has the following form:

 

 

 

 

(Eq 6-27)

Plugging (Eq 6-27) into (Eq 6-26):

 

 

 

 

(Eq 6-28)

Dividing by

 

 

 

 

(Eq 6-29)

The terms in z are then "seperated" and set equal to a constant: .

 

 

 

 

(Eq 6-30)

Multiplying by :

 

 

 

 

(Eq 6-31)

Now the term can be separated and set to .

 

 

 

 

(Eq 6-32)

Making a change of variable:

 

 

 

 

(Eq 6-33)

 

 

 

 

(Eq 6-34)

 

 

 

 

(Eq 6-35)

Plugging the above change of variable into (Eq 6-32) and multiplying by gives:

 

 

 

 

(Eq 6-36)

Which is Bessel's equation given in (Eq 6-8).

Problem 7

Given Information

The following equations is given

 

 

 

 

(Eq 7-1)


and

(Eq 7-1) is motivated by quadrature tests written by Dr. John Burkardt found here:

http://people.sc.fsu.edu/~%20jburkardt/c_src/test_int_laguerre/test_int_laguerre.html

Problem Statement

(a) Find the values of the integral of the function (7-1) by other means (exact or approximate), then evaluate these integrals with the Gauss-Laguerre quadrature for comparison.


(b) Find and appropriate transformation to show the equality of (7-2) and (7-3). Find the value of in some table and use the Gauss-Laguerre quadrature to find an approximate value of the integral to compare.

Solution

Part a

Gauss-Laguerre quadrature is a Gaussian quadrature that integrates a function over the interval with the weighting factor .

 

 

 

 

(Eq 7-3)

Since the integral in (Eq 7-3) has the weighting term in it, a transformation can be applied to integrate an arbitrary function of interest.

 

 

 

 

(Eq 7-4)


The integration points are found to be the roots of the Laguerre polynomial , and the weights are found by the following expression [3]:

 

 

 

 

(Eq 7-5)

Since the integral in (Eq 7-1) has a lower limit of 2 instead of zero, a change of variable is needed.

 

 

 

 

(Eq 7-6)

(Eq 7-3) then becomes [4]:

 

 

 

 

(Eq 7-7)

A numerical python (NumPy) script was written to test the quadrature for the integral in (Eq 7-1). The source code is given below: (Note: NumPy is an opensource

#################################################################################
# Name: gausslagtest.py
# Author: Cameron Stewart
# Date: 2/5/2014
# Purpose: This script uses Gauss-Laguerre quad  to integrate the integral:
#     exp(-2) Integral (2 to infinity) (1/(x*log(x)^2)
#################################################################################
import numpy as np
import matplotlib.pyplot as plt
#################################################################################
# Function name: TestFunction
# Input: a value, or array of values of x
# Output: g(x) at given points
# f(x)=exp(-2)/(x*log(x)*log(x); g(x)=f(x)*(e^x)
# Function f(x) that is desired to be integrated this function is multiplied by
# e^x to account for the weighting function e^-x in G-L Quad
#################################################################################
def TestFunction(x):
    y=np.exp(x)*1/(x*np.log(x)*np.log(x))*np.exp(-2)
    return y

#################################################################################
# Uses the numpy Laguerre Gauss quadrature routine:
# numpy.polynomial.laguerre.laggauss(deg)  to find roots and weight points.
# Output is tuple of 1d arrays for the weights and integration points.  
# Note: Not tested for deg>100
#################################################################################

weight=(np.polynomial.laguerre.laggauss(4))
# weight[0] contains the roots/integration points
# weight[1] contains the weights at said points

# COV: y=x+a to account for lower limit of 
# integration
a=2

func=TestFunction(weight[0]+a)
integ=weight[1]*func
integ=np.exp(-a)*np.sum(integ)
print('n=4')
print(integ)

weight=(np.polynomial.laguerre.laggauss(16))
func=TestFunction(weight[0]+a)
integ=weight[1]*func
integ=np.exp(-a)*np.sum(integ)
print('n=16')
print(integ)

weight=(np.polynomial.laguerre.laggauss(100))

func=TestFunction(weight[0]+a)
integ=weight[1]*func
integ=np.exp(-a)*np.sum(integ)
print('n=100')
print(integ)

# Exact value computed from analytic solution
exact=np.exp(-2)*1./(np.log(2))
print('exact')
print(exact)

#################################################################################
# Plot to show the convergence with increasing integration points
#################################################################################
t=np.linspace(2,100,99)
error=[]
for i in range(2, 101):
    weight=(np.polynomial.laguerre.laggauss(i))
    func=TestFunction(weight[0]+a)
    integ=weight[1]*func
    integ=np.exp(-a)*np.sum(integ)
    error.append((np.abs(integ-exact))\
                     /exact*100.)
plt.plot(t,error)
plt.title('Convergence test for Gauss-Laguerre quadrature: logarithmic integral')
plt.xlabel(r'Integration points: $n$')
plt.ylabel(r'Error %')
plt.show()


Script terminal output:

n=4
0.145107525093
n=16
0.162236347114
n=100
0.172558662198
exact
0.195247541983

Plot generated by script:

Figure 7.1: Convergence of ( 7-1) with increasing integration points


The above script uses NumPy's Laguerre module quadrature routine: numpy.polynomial.laguerre.laggauss(deg). This routine solves the roots of the Laguerre polynomials by first finding the eigenvalues of the Companion Matrix, and then applying an iteration of Newton's Method to improve accuracy.

Documentation

source

The above script uses ( 7-5) to calculate ( 7-1).

 

 

 

 

(Eq 7-8)

The script above compares favourably with values calculated by Dr. Burkardt [5].

n Python Script Dr. Burkardt
4 0.145107525093 0.145108
16 0.162236347114 0.162236
Table 7.1 Comparison of quadrature calculations


As can be seen in Figure 1, even at 100 integration points there is still significant error or around 12 percent.

Part b

Contributing Team Members




Problem Assignments
Problem # Solved by Reviewed by
1 Neal, Christopher all
2 Neal, Christopher all
3 Bartlett, Elizabeth all
4 Stewart, Cameron all
5 Bartlett, Elizabeth all
6 Bartlett, Elizabeth all
7 Bartlett, Elizabeth all

References