Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Winter 2008
a. Perform 2 iterations Using the Bisection method for finding a root in the range
[0,1] (6 pts)
x min x max
xnew 0.5
2
f (0.5) 0.1756 0 f min x min 0.5
x min x max
xnew 0.75
2
f (0.75) 0.5878 0 f max x max 0.75
b. What is the maximal error in the value of x obtained in ‘a’ (4 pts)
1−0
E𝑚𝑎𝑥 = = 0.25
22
c. What will be the maximal error after 10 iterations (Note: there is no need to
perform more iterations at this stage)
1 0
E max 9.7656e-004
210
d. Find the root using Newton-Raphson method using initial guess x=0 and stop
f ( x ) 0.1
criteria
f (0) xe x 1 1
f (0) e x xe x 1
f (0)
x0 1
f (0)
f (1) xe x 1 1.7183
f (1) e x xe x 2e 5.4366
f (1)
x 1 0.6839
f (1)
f (0.6839) xe x 1 0.3552
f (0.6839) e x xe x 3.3368
f (0.6839)
x 0.6839 0.5775
f (0.6839)
f (0.5775) xe x 1 0.0289 < 0.1
e. Find at least one point which cannot be used as an initial guess in the Newton-
Raphson method. Explain the calculation.
f ( x) xe x 1
f ( x) e x xe x
x 1 f ( x) 0
In a two dimensional world, an arrow is shot in time t=0 from the coordinate x=1,
y=0.
2x
The velocity of the arrow in x direction is given by: x' (t )
x2 y2
2y
and in the y direction y ' (t ) 1
x2 y2
a. Define the problem in terms of order, given conditions and linearity. Point
out the dependent and independent variables. (5 pts)
Euler :
2 xi
x2 y2
xi 1 xi *h
y y
i i
i 1 i 1 2 xi
xi
2
yi
2
c. Calculate the location of the arrow up to the point where y 0.15 , use the
step size h=0.1. (8 pts)
x0 1 y0 0 h 0.1
2 x0
x0 2 y0 2
x1 x0 0.8
y y 2 x0
*h
1 0 1 0.1
x0 2 y0 2
2 x1
x1 y1
x2 x1 0.6015
2 2
y y 2 x1
*h y2 0.15
2 1 1 0.1752
x12 y12
3. Winter 2008 (22 pts)
The following function ranks matrices according to the Gauss method with partial
pivoting. This function does not include the backward substitution stage.
xi 0 1 2 4
yi 1.2 2.1 2.2 0.0
splines for the given data. Plague all the known values and explain
what the unknowns are. No need to solve the equations.
Lagrange Polynom
Newton’s Polynom
Unknowns:
The following function calculate the values of midpoints using the Lagrange
interpolation for known points:
1 function AAA=Lagrange(BBB,CCC,DDD)
2 n=size(CCC,2);
3 EEE=ones(n,size(BBB,2));
4 if (size(CCC,2)~=size(DDD,2) | n < 2)
5 fprintf('Error message);
6 AAA=NaN;
7 else
8 for i=1:n
9 for j=1:n
10 if Complete 1
11 EEE(i,:)=EEE(i,:) .* (BBB-CCC(j)) / (CCC(i)-CCC(j));
12 end
13 end
14 end
15 AAA=0;
16 for i=1:n
17 AAA=AAA + DDD(i) * complete 2;
18 end
19 end
a. What is the meaning of the variables AAA, BBB, CCC, DDD and EEE?
(10pts)
b. Write the general dimentions of the variables above. Use the same subscript if
the dimentions are identical for two or more variables
c. Fill in the missing code: Complete 1,2 (6 pts)
d. What are the errors, resulting in the error message in line 5 of the code.
c. Complete 1 - 1 i ~ j
Complete 2 - EEE (i,:)
d. (1) if the number of the given points is smaller than 2 (2) If the length of x vector
is different from that of f(x) vector
b a N
5
N N4
ד. ratio= N 4
O(h 4 )
O h5
ה. ratio= O h2
Oh 3
d2y
y
dx 2
y '(1) 1
y '(3) 3
1.1 write the set of equations needed to be solved when using the finite differences
method with h 1 . Use the central approximation to calculate the 1st derivative
1.2 Solve the system using Thomas method. The matrix must be tridiagonal.
1.3 Can the problem be solved using the shooting method? Explain. No need for
calculation in this section.
d 2z
z 1
dx 2
z '(1) 1
z '(3) 3
Based on section 1.2; what is the solution for this problem? Note the difference between
the problems
d2y
f ( x)
dx 2
y '(1) 1
y '(3) 3
3.1 write the set of equations needed to be solved when using the finite differences
method with h 1 . Use the central approximation to calculate the 1st derivative.
note the similarity to section 1.3
3.2 Is there a unique solution for the system obtained? Explain. Note the values in the
coefficient matrix
111
112
For Thomas we need tridiagonal matrix so we have to substitute y(0) and y(4)
y (2) y (0)
1 y (0) y (2) 2
2
y (4) y (2)
3 y (4) 6 y (2)
2
y (0) 2 y (1) y (2) y (1) 3 y (1) 2 y (2) 2
y (1) 2 y (2) y (3) y (2) y (1) 3 y (2) y (3) 0
y (2) 2 y (3) y (4) y (3) 2 y (2) 3 y (3) 6
3 2 0 y (1) 2
1 3 1 y (2) 0
0 2 3 y (3) 6
A y d
u1 3
1
l2 1
3 0 0 3 2 0
1 1
u2 3 ( ) 2 2 1 0 0 2 1 A
1 1
3 3 3 3
2 6 6 1
l3 0 1 0 0 2
2
1 7 7 7
3 L U
6 1
u3 3 1 2
7 7
Lx d
x1 2
1 2
x2 0 2
3 3
6 2 3
x3 6 5
7 3 7
Uy x
3
5
7 8
y (3) 2
1 15
2
7
2 8
1 2
3 15 4
y (2)
1 5
2
3
4
2 2
y (1) 5 2
3 15
111
d 2z
z 1
dx 2
z '(1) 1
z '(3) 3
z y 1 satisfy this eqaution therefore
2 2
z (1) 1 1
15 15
4 1
z (2) 1
5 5
8 8
z (3) 2 1 1
15 15
111
y (2) y (0)
1 y (0) y (2) 2
2
y (4) y (2)
3 y (4) 6 y (2)
2
y (0) 2 y (1) y (2) f (1) 2 y (1) 2 y (2) 2
y (1) 2 y (2) y (3) f (2) y (1) 2 y (2) y (3) 0
y (2) 2 y (3) y (4) f (3) 2 y (2) 2 y (3) 6
2 2 0 y (1) 2
1 2 1 y (2) 0
0 2 2 y (3) 6
3.3 The rows / columns are dependent. Therefore there is an infinite number of
solutions to the problem.
another explanation:
dy
2 x y
dx
y (0) 1
1. Solve the equation by expanding a 4th order Taylor series to find the function value
at x=0.1.
2. Solve the equation using the explicit Euler method. Find the function value at x=0.1.
Use h 0.05
3. Use the solution from section 1 to estimate the error in the solution in section 2
dy
2 x y
dx
y (0) 1
exact solution
y 3e ^ x 2 x 2
y 0.9145122