User:Eml5526.s11.team01/Hwk2
Problem 1 [edit]
Given [edit]
An elastic bar with a cross section A(x)
Find [edit]
Derive heat problem equation from Lecture Slide Mtg.6
Solution [edit]
Fig. 1 Shows a bar of cross section A(x), with conductivity k(x), density ρ, specific heat c, with an internal heat source (or sink) f(x,t). In the bar the heat is transferred only by conduction in x direction. The temperature has been called u(x,t)
The partial differential equation for this problem can be obtained doing an energy balance in an infinitesimal element of the bar. Fig. 2 shows an infinitesimal element of length dx; heat entering the body on the left hand side is
and heat going out the body on the right hand side is 
Doing the energy balance we obtain:
Where
is the change of energy with respect to time which can be calculated in terms of the temperature as:
The heat flow and the cross area at the right hand side of the element can be approximated by:
Replacing on Eq.1.2 we obtain:
Doing the product we get:
Neglecting the second order term we have:
The first two terms in the latter equation are the derivative of a product; therefore:
Using the Fourier’s law, the heat flow can be expressed as function of temperature. For an unidirectional case we have:
Where k(x) is the conductivity of the material. Replacing equation Eq.1.9 in Eq.1.10 we have:
Problem 2 [edit]
Given [edit]
![\left [B _{jk} \right ]=\begin{bmatrix}
1 &1 &1 \\
2 &-1 &3 \\
3 &2 &6
\end{bmatrix}](http://upload.wikimedia.org/math/d/2/5/d2579eb6dca9656a88b9bdc68d798d6a.png)
Find [edit]
2.1
.
2.2 Find
.
2.3 Find
.
2.4 Solve
on 7-2 for 
2.5 Use equation 1 on 7-4 to find
What is
&
?
2.6 Solve for
compare to
in 4).
2.7 Observe the symmetric properties of
&
. Further Discuss the Pros & Cons of Bubnov-Galerkin & Petrov-Galerkin Methods.
Solution [edit]
2.1 [edit]
=
-
.
2.2 [edit]
Find
.
According to the
on 7-1,
given before we have,

Successively performing multiplication by
we get,
Substituting the given values we get,

This equation can also be written in the following format,

on 7-2 is obtained by multiplying
by each
, so we can write,



These 3 equations can be further presented as below in the matrix form,

Which also can be written as

Substituting the numerical values we get,

Performing the product, we get:
is equivalent to
where
Furthermore,
2.3 [edit]
=
From 
2.4 [edit]
Solve
on 7-2 for 
Rearranging
We get

2.5 [edit]
Use equation 1 on 7-4 to find
. Further, What is
&
?
In this case,
, where
is the orthonormal basis.
Starting with Equation 1 on 7-2, we get:

If we multiply successively by
, we get the following equations,


Which can be further written as,

As
is orthonormal basis, we can write the following,

Substituting the respective values we have,

Simplifying we obtain that,

Replacing the numerical values we get,
This equation is nothing but the system

From where we can conclude that
is a matrix whose columns are the vectors
and
.
2.6 [edit]
Solve for
compare to
in problem 2.4
We can see that this result is identical to the result we obtained in problem 2.4
2.7 [edit]
Observe the symmetric properties of
&
. Further Discuss the Pros & Cons of Bubnov-Galerkin & Petrov-Galerkin Methods.
We can explicitely see that
is always symmetric because it is obtained from the product of
; where as
is not always symmetric. It will be symmetric only when the vector b is a Orthonormal basis.
The pros of Bubnov-Galerkin method is the symmetry of the stiffness matrix which is generally easy to solve, however more calculations are necessary to get the stiffness matrix. Whereas, in the Petrov-Galerking method, obtaining the stiffness matrix is easier but solving the system on other hand can be more difficult owing to its non-symmetry.
Problem 3 [edit]
Given [edit]
Given Equation 1 on 8-1 which states 
and
where 
Find [edit]
Show that

is equivalent to

Solution [edit]
For avoiding confusion we are designating the weight function as
in
and the weight function as
in
.
Considering
and Substituting for 

As
is an orthonormal basis, performing a successive product by
in the
, we get

In the similar way

.
.
.
;
Furthermore all the equations can be combined and written as
We can cleraly observe that the Matrix on the left hand side is the identity matrix
; Moreover we have also written
as a vector which further can be called as
. and
becomes
Which is identical to
.
Problem 4 [edit]
Show that
Given [edit]
Find [edit]
From Lecture 9
4.1
4.2![\int xlnxdx = \frac{1}{2} x^2 \left[lnx - \frac{1}{2} \right]](http://upload.wikimedia.org/math/4/7/d/47d19f4fd191d9607b77f1c853cce3b6.png)
4.3
4.4
From Lecture 10
4.5 Find the exact solution
for the problem (3) on 9-2
4.6 Plot 
Solution [edit]
4.1 [edit]
Prove that
In order to integrate by parts we choose
and 
Now we apply the formulae for integration by parts which is:
Where 
Substituting these values into Eq.4.3 we get:
4.2 [edit]
Prove that
In order to integrate by parts we choose:
and 
Where 
Substituting these values into Eq.4.3 we get:
Factoring out
we get:
4.3 [edit]
Find
The integral can also be written as follows:
To solve this integral, we made the next change of variables:
Substituting these values into Eq.4.8 we get:
Which can be expanded to:
Finally, replacing y as a function of x we have:
Choosing 
4.4 [edit]
Find
We start by changing the variables with:
Replacing these values into Eq.4.14 we get:
Changing the variables we get:
Choosing
we have:
The result is the same as Eq.4.13
4.5 [edit]
The problem is solving the differential equation:
With the boundary conditions:
The differential equation can be written:
Now integrate:
Now the solution of
is:
The first integral can be solved using Eq.4.17 with
and the second integral can be solved
Therefore the total solution is:
After simplifying everything we obtain:
Where
and
are constants and can be solved using the boundary conditions (Eq.4.20)
The derivative of u is:
Therefore:
Solving for
then gives:
Replacing
into Eq.4.28 gives:
The complete solution is:
4.6 [edit]
Plot 
Problem 5 [edit]
Given [edit]
Find [edit]
Show that
where
,
with 
Solution [edit]
We have 
which means
,
,...,
.
So there exist arbitrary numbers
that

which is equivalent to the following:
Problem 6 [edit]
Given [edit]
Consider
, where
on interval
,
i.e. 
Find [edit]
6.1 Construct
(F); Observe the properties of 
6.2 Find det
(F)
6.3 Conclude that F is orthogonal
Solution [edit]
6.1 [edit]
Construct 
So
First we solve the integral:
- with

Then we can write:
where we add and subtract the quantity
So
And the identity:
, can be used to have the following result:
Performing the integration we have:
The parameters 2(m-n) and 2(m+n) are integers because n and m are integers; therefore, when the sine is evaluated at T it becomes
where k is integer and therefore
. When the function is evaluated at 0, clearly the sine is 0 too. However when m=n, the parameter 2(m-n) becomes 0 and the first term of the last equation is indeterminate. But when m=n the integral can be calculated as:


![=\frac{1}{2} [x+ \frac{T}{4m\pi} sin(\frac{4m\pi}{T}x )]\mid_0^T](http://upload.wikimedia.org/math/d/1/3/d13fae158626f18bda784087568b87ce.png)

We conclude that the integral is
when
and 0 otherwise.
Following identical procedure, the other integrals can be calculated to obtain:
and it can be seen that
is diagonal.
6.2 [edit]
Because
is diagonal, the determinant can be easily calculated as the following:
6.3 [edit]
Conclude that
is orthogonal.
Although
is diagonal, and orthogonal, it is not equal to the identity matrix, therefore it is not equal to
.
Problem 7 [edit]
Consider the family 
Is
an othogonal family evaluated at
?
From Lecture 10
Given [edit]
Find [edit]
Is
an othogonal family evaluated at
?
Solution [edit]
Let's start by calculating 

Performing the integration we obtain:
When equation 7.2 is evaluated at (0,1) we obtain:
Where it can clearly be observed that
is not orthogonal
Problem 8 [edit]
Show that equation 1 and equation 2 on 10-4 are equivalent.
From Lecture 11
Given [edit]
Let's define our equations:
Equation 1 on 10-4
and Equation 2 on 10-4
With
Find [edit]
Show that
and
are equivalent.
Solution [edit]
If we chose
to be orthogonal, we have:



When we multiply
times
we observe that multiply by
is equivalent to multiplying by the identity matrix, therefore replacing
in
we have:
Problem 9 [edit]
Given [edit]
Solving a differential equation using Weight Residual Form. From lecture 12
The partial differential equation is:
The boundary conditions are:


As weighting funtion should be used:
We will use 
Find [edit]
- 9.1 Find an approximate solution of the form
for n=2 - 9.2 Find two equations that enforce the boundary conditions
- 9.3 Project the weight residues
- 9.4 Display the equations in matrix form
- 9.5 Solve for

- 9.6 Construct
and plot
and 
- 9.7 Repeat 9.1 to 9.6 for n = 4 and n = 6
Solution [edit]
9.1 Find an approximate solution with n=2 [edit]
When n = 2 we have:
and
Therefore:
9.2 Find two equations that enforce the boundary conditions [edit]
The boundary conditions are:
And
9.3 Project the weight residues [edit]
In this case changing the function u(x) by the approximated function
in the PDE (Eq.9.1), we found that P(u) is:
The equation 9.8 can be written as:
Projecting the residue we have:
After substitution of (Eq.9.4) and (Eq.9.9) in (Eq.9.10) the following equation is obtained
9.4 Display the equations in matrix form [edit]
Performing the product and then the integration indicated in (Eq.9.11) we have:
The latter equation is clearly of the form
. We can observe that K is not symmetric.
9.5 Solve for
[edit]
In (Eq.9.12) we have three equations; but, as we need to enforce the boundary conditions we take the only one of them and solve it together with (Eq.9.6) and (Eq.9.7). From these equations we now have the system:
After solving the system in (Eq.9.13) we obtain d:
9.6 Construct
and plot
and
[edit]
Replacing d in (Eq.9.5) we obtain the approximated solution:
On the other hand, the exact solution of the PDE (Eq.9.1) with the given boundary condition is:
In Fig.9.1 we show the exact and the approximated solution.
9.7 Repeat 9.1 to 9.6) for i = 4 and i = 6 [edit]
Now we repeat the procedure using i = 4 and i=6 in Eq.9.4
As the procedure is the same shown before, we develop a routine using Matlab to perform the products, the integration and to solve the system of equations. The routine is show in the appendix.
Fig.9.2 and Fig.9.3 shown the numerical solution for i = 4 and i = 6 respectively. It can be clearly seen that as the number of terms used in (Eq.9.4) the agreement between the analytical and numerical solution is better.
Fig.9.4 Show the error at x = 0.5 as funtion of the number of terms used in Eq.9.4. Clearly the error tends to be 0 as the number of terms increases. The error shown in Fig.9.4 was calculated as the absolute value of the difference between the analytical and the numerical solution at x = 0.5
Plots:
Appendix [edit]
Matlab Code:
clear all; syms x b = [cos(pi/4); cos(x+pi/4); cos(2*x+pi/4)]; %this is the bi funtion d2b = [0 cos(x+pi/4) 4*cos(2*x+pi/4)]; %This is the second derivative of b. The negative k = b*d2b; %perfoms the product between b and the second derivative K = 2*int(k,0,1) %performs the integration F = 3*int(b,0,1) z = [0:0.1:1]; K3 = [cos(pi/4) cos(1+pi/4) cos(2+pi/4); 0 sin(pi/4) 2*sin(pi/4); 0 -1+cos(1)+sin(1) -2+2*cos(2)+2*sin(2)]; F3 = [0; 4; 3/2*2^(1/2)]; d3 = inv(K3)*F3; %Calculates di for i = 1:11 f3(i) = d3(1)*cos(pi/4)+d3(2)*cos(z(i)+pi/4)+ d3(3)*cos(2*z(i)+pi/4); %calculates Uh fnal(i) = -(3/4)*z(i)*z(i)-4*z(i)+19/4; %This is the analytic solution end figure, plot(z,f3,'ko') %plots both solution hold on plot(z,fnal,'k') xlabel('x') ylabel('U(x)') legend('Numerical solution','Analytical solution') title('Numerical and analytical solution with i = 2') err(1) = abs(fnal(6)-f3(6)); %NOW WITH n = 4 syms x b = [cos(pi/4); cos(x+pi/4); cos(2*x+pi/4); cos(3*x+pi/4); cos(4*x+pi/4) ]; %this is the bi funtion d2b = [0 cos(x+pi/4) 4*cos(2*x+pi/4) 9*cos(3*x+pi/4) 16*cos(4*x+pi/4)]; %This is the second derivative of b. The negative k = b*d2b; %perfoms the product between b and the second derivative K = 2*int(k,0,1) %performs the integration F = 3*int(b,0,1) z = [0:0.1:1]; K3 = [cos(pi/4) cos(1+pi/4) cos(2+pi/4) cos(3+pi/4) cos(4+pi/4); 0 sin(pi/4) 2*sin(pi/4) 3*sin(pi/4) 4*sin(pi/4); 0 -1+cos(1)+sin(1) -2+2*cos(2)+2*sin(2) -3+3*cos(3)+3*sin(3) ... -4+4*cos(4)+4*sin(4); 0 1/2-1/2*sin(1)^2+1/2*cos(1)^2 -4/3+4*sin(1)+4/3*cos(3) ... -9/4+9/2*sin(2)+9/4*cos(4) -16/5+16/3*sin(3)+16/5*cos(5); 0 -1/3+sin(1)+1/3*cos(3) 3-sin(2)^2+cos(2)^2 -9/5+9*sin(1)+9/5*cos(5) ... -8/3+8*sin(2)+8/3*cos(6)]; F3 = [0; 4; 3/2*2^(1/2); -3/2*2^(1/2)+3/2*cos(1)*2^(1/2)+3/2*sin(1)*2^(1/2); -3/4*2^(1/2)+3/4*cos(2)*2^(1/2)+3/4*sin(2)*2^(1/2)]; d3 = inv(K3)*F3; %Calculates di for i = 1:11 f3(i) = d3(1)*cos(pi/4)+d3(2)*cos(z(i)+pi/4)+ d3(3)*cos(2*z(i)+pi/4) ... +d3(4)*cos(3*z(i)+pi/4)+ d3(5)*cos(4*z(i)+pi/4); %calculates Uh fnal(i) = -(3/4)*z(i)*z(i)-4*z(i)+19/4; %This is the analytic solution end figure, plot(z,f3,'ko') %plots both solution hold on plot(z,fnal,'k') xlabel('x') ylabel('U(x)') legend('Numerical solution','Analytical solution') title('Numerical and analytical solution with i = 4') err(2) = abs(fnal(6)-f3(6)); %NOW WITH n = 6 syms x b = [cos(pi/4); cos(x+pi/4); cos(2*x+pi/4); cos(3*x+pi/4); cos(4*x+pi/4); ... cos(5*x+pi/4); cos(6*x+pi/4)]; %this is the bi funtion d2b = [0 cos(x+pi/4) 4*cos(2*x+pi/4) 9*cos(3*x+pi/4) 16*cos(4*x+pi/4) ... 25*cos(5*x+pi/4) 36*cos(6*x+pi/4)]; %This is the second derivative of b. k = b*d2b; %perfoms the product between b and the second derivative K = 2*int(k,0,1) %performs the integration F = 3*int(b,0,1) z = [0:0.1:1]; K3 = [cos(pi/4) cos(1+pi/4) cos(2+pi/4) cos(3+pi/4) cos(4+pi/4) cos(5+pi/4) ... cos(6+pi/4); 0 sin(pi/4) 2*sin(pi/4) 3*sin(pi/4) 4*sin(pi/4) 5*sin(pi/4) 6*sin(pi/4); 0 -1+cos(1)+sin(1) -2+2*cos(2)+2*sin(2) -3+3*cos(3)+3*sin(3) ... -4+4*cos(4)+4*sin(4) -5+5*cos(5)+5*sin(5) -6+6*cos(6)+6*sin(6); 0 1/2-1/2*sin(1)^2+1/2*cos(1)^2 -4/3+4*sin(1)+4/3*cos(3) ... -9/4+9/2*sin(2)+9/4*cos(4) -16/5+16/3*sin(3)+16/5*cos(5) ... -25/6+25/4*sin(4)+25/6*cos(6) -36/7+36/5*sin(5)+36/7*cos(7); 0 -1/3+sin(1)+1/3*cos(3) 3-sin(2)^2+cos(2)^2 -9/5+9*sin(1)+9/5*cos(5) ... -8/3+8*sin(2)+8/3*cos(6) -25/7+25/3*sin(3)+25/7*cos(7) -9/2+9*sin(4)+9/2*cos(8); 0 -1/4+1/2*sin(2)+1/4*cos(4) -4/5+4*sin(1)+4/5*cos(5) ... 15/2-3/2*sin(3)^2+3/2*cos(3)^2 -16/7+16*sin(1)+16/7*cos(7) ... -25/8+25/2*sin(2)+25/8*cos(8) -4+12*sin(3)+4*cos(9); 0 -1/5+1/3*sin(3)+1/5*cos(5) -2/3+2*sin(2)+2/3*cos(6) ... -9/7+9*sin(1)+9/7*cos(7) 14-2*sin(4)^2+2*cos(4)^2 ... -25/9+25*sin(1)+25/9*cos(9) -18/5+18*sin(2)+18/5*cos(10)]; F3 = [0; 4; 3/2*2^(1/2); -3/2*2^(1/2)+3/2*cos(1)*2^(1/2)+3/2*sin(1)*2^(1/2); -3/4*2^(1/2)+3/4*cos(2)*2^(1/2)+3/4*sin(2)*2^(1/2); -1/2*2^(1/2)+1/2*cos(3)*2^(1/2)+1/2*sin(3)*2^(1/2); -3/8*2^(1/2)+3/8*cos(4)*2^(1/2)+3/8*sin(4)*2^(1/2)]; d3 = inv(K3)*F3; %Calculates di for i = 1:11 f3(i) = d3(1)*cos(pi/4)+d3(2)*cos(z(i)+pi/4)+ d3(3)*cos(2*z(i)+pi/4) ... +d3(4)*cos(3*z(i)+pi/4)+ d3(5)*cos(4*z(i)+pi/4)+d3(6)*cos(5*z(i)+pi/4)+ ... d3(7)*cos(6*z(i)+pi/4); %calculates Uh fnal(i) = -(3/4)*z(i)*z(i)-4*z(i)+19/4; %This is the analytic solution end figure, plot(z,f3,'ko') %plots both solution hold on plot(z,fnal,'k') xlabel('x') ylabel('U(x)') legend('Numerical solution','Analytical solution') title('Numerical and analytical solution with i = 2') err(3) = abs(fnal(6)-f3(6)); n = [3 5 7] figure, plot(n,err) xlabel('n=number of functions') ylabel('Error') title('Difference between nalytical and numerical solution as function of i, at x = 0.5')
























.



![Det[K]=\begin{vmatrix}
3 &4 &11\\
4 &14 &22 \\
11 &22 &49
\end{vmatrix}= 64](http://upload.wikimedia.org/math/3/0/1/3019dfbb423a711689928917d120e42b.png)























![\int \frac{x^2}{1+cx} dx = \frac{1}{c} \int \left[x - \frac{x}{1+cx} \right]dx = \frac{1}{c} \left[\int xdx - \int \frac{x}{1+cx} dx \right]](http://upload.wikimedia.org/math/c/0/5/c0507d01c6708e630fc36476efd5eb3e.png)







![\frac{1}{c^3} \left[ \frac{ \left(1+cx \right)^2}{2} - 2 \left(1+cx \right) + ln \left(1+cx \right) \right]](http://upload.wikimedia.org/math/2/6/b/26b5a35a393aca978d16383f2bbea28c.png)












![\frac{d}{dx} \left[ \left( 2+3x \right) \frac{du}{dx} \right] +5x = 0 ~~~ \forall x \in \left]0,1 \right[](http://upload.wikimedia.org/math/1/6/6/166c2eeb97dda51dedff0277acc54e23.png)



![\frac{d}{dx} \left[ \left( 2+3x \right) \frac{du}{dx} \right] = -5x](http://upload.wikimedia.org/math/3/8/f/38f119af5838e6b33422571d82d3c030.png)

![\left[ \left( 2+3x \right) \frac{du}{dx} \right] = -5 \frac{x^2}{2} + k](http://upload.wikimedia.org/math/c/2/c/c2cca8f7972488ead89f49f4b6a0368f.png)







![u \left(x \right) = -2.5 \frac{1}{3^3} \left[ \frac{ \left(2+ 3x \right)^2}{2} - 2 \times 2 \left(2+3x \right) + 2^2 ln \left( 2+3x \right) \right] + \frac{k}{3} ln \left(2+3x \right) +q](http://upload.wikimedia.org/math/0/6/b/06bc574e3bae787217d3dfa708826b13.png)
































![I=\frac{1}{2} [ \frac{T}{2(m-n)\pi} sin(\frac{2(m-n)\pi}{T} x) + \frac{T}{2(m+n)\pi} sin(\frac{2(m+n)\pi}{T} x) ] \mid_0^T](http://upload.wikimedia.org/math/4/f/a/4fab1d5b44d9412344ff2bc545460ba8.png)






















for n=2




























