Professional Documents
Culture Documents
Solution:
We will to integrate Z 2 p
1 + x3 dx
0
using Gaussian quadrature with n = 4 ,
2 Problem 2
Solution:
Where
X0 1
= (3)
Y0 1
In orden to find the first, second, third, fourth, and fifth approximation to a solution of f (x, y) = 0 and
the relative error, we make the following script:
3 Problem 3
Solution:
The Hermite interpolating polynomial of degree ≤ 3 for f at the values -1,-1,1,1 is:
P (x) f [x0 ] + f [x0 , x1 ](x − x0 ) + f [x0 , x1 , x2 ](x − x0 )(x − x1 ) + f [x0 , x1 , x2 , x3 ](x − x0 )(x − x1 )(x − x2 )
=
1
P (x) = 0 + 0(x + 1) + (x + 1)2 + 0(x + 1)2 (x − 1)
4
1
P (x) = (x + 1)2
4
4 Problem 4
Solution:
We will to find the first three iterates of the Jacobi method of the following system:
1.0 0.5 0 x 1
0 1.0 0.5 · y = 0 (4)
0.5 0.0 1.0 z 0
We will to find the first three iterates of the Gauss Seidel method of the following system:
1.0 0.5 0 x 1
0 1.0 0.5 · y = 0 (5)
0.5 0.0 1.0 z 0
6 Problem 6
Solution:
We will to find the first four iterates to approximates the largest eigenvalue of
1.0 0.5 0
0.5 1.0 0.5 (6)
0 0.5 1.0
7 Problem 7
Solution:
We have to use the Taylor method of order 2, which iteration formula is given by:
h 0
yn+1 = yn + h f (tn , yn ) + f (tn , yn )
2
To solve
and the following plot show us the comparative between Exact Solution and the solution performed by
Taylor method of order 2
8 Problem 8
Solution:
x1 = y (7)
x2 = y0 (8)
00
x3 = y (9)
x01 = x2 (10)
x02 = x3 (11)
x03 = et − sin(t)x3 − 4x2 − cos(t)x1 (12)
9 Problem 9
Solution:
We have to use the shooting method (with Runge Kutta method of order 4) to solve
y 00 = y + x2 0 ≤ x ≤ 2
with boundary values y(0) = −2.0; y(2) = −6.0
In order to find the solution we will rewrite the equation as follows:
Let be
u = y (16)
0
v = y (17)
u0 = v (18)
0 2
v = u+x (19)
(20)
Note that this system is a initial value problems, so it is not necessary satisfy the value of y(2) = −6 (
Unless we are incredibly lucky), but will help in the following way:
To solve this system we will use the Runge Kutta method of order 4:
and with the following script we obtain two solution of the above system:
• First Solution:
u0 = v (23)
0 2
v = u+x (24)
(25)
where
u(0) = −2 (26)
v(0) = −2 (27)
• Second Solution
u0 = v (28)
0 2
v = u+x (29)
(30)
with
u(0) = −2 (31)
v(2) = 2 (32)
In the following plot we can see the two solution explain above and the solution given by the Shooting
method
10 Problem 10
Solution:
y 00 = y + x2 0 ≤ x ≤ 2
with boundary values y(0) = −2.0; y(2) = −6.0
note that:
y(x−∆x)−2y(x)+y(x+∆x)
• y 00 (x) ≈ ∆x2
so for xj = j × h, with 0 ≤ j ≤ 10
y 00 (xj ) − y(xj ) = x2j (33)
y(xj − ∆x) − 2y(xj ) + y(xj + ∆x)
− y(xj ) = x2j (34)
∆x2
y(xj − ∆x) − (2 + ∆x2 )y(xj ) + y(xj + ∆x)
= x2j (35)
∆x2
(36)
So we have the following scheme
1
yj−1 − (2 + ∆x2 )yj + yj+1 = x2j
∆x 2
where,
• j = 2, · · · , N − 1
• y1 = −2 and yN = −6
• x = 0 : ∆x : 2
We can rewrite equation in a matrix form as follows:
1
−(2 + ∆x2 ) x22 − ∆x
1 y2 2 y1
1 −(2 + ∆x2 ) 1 y3 x3 2
1 1 −(2 + ∆x2 ) 1
y4 x24
=
2
∆x
.. ..
..
. . .
2 1
1 −(2 + ∆x ) yN −1 x2N −1 − ∆x2 yN
(37)
We do this using the following matlab code
In the following plot we can see the solution by the finite difference method
11 Problem 11
Solution:
∂2u ∂2u
+ 2 = 0 0 ≤ x ≤ 1; 0 ≤ y ≤ 1
∂x2 ∂y
with u(x, y) = x3 − xy 2 on boundary of the region
note that:
∂2u u(x−∆x,y)−2u(x,y)+u(x+∆x,y)
• ∂x2 (x, y) ≈ ∆x2
∂2u u(x,y−∆x)−2u(x,y)+u(x,y+∆x)
• ∂y 2 (x, y) ≈ ∆y 2