You are on page 1of 7

EXERCISES

1) Find the least positive value of x that makes 0 the function:


1 ) sin( 8 ) ( =
x
e x x f .
Use the method of Newton-Raphson
Use one iteration of the method of False Position to obtain an initial value to
start iteration in Newton-Raphson
Obtain the solution with an accuracy of 3 decimal digits

SOLUTION:

Since the method of Newton-Raphson is required we are going to need the
derivative of the function that is:
x x
e x e x x f

= ) sin( 8 ) cos( 8 ) ( '

Since we have to perform one iteration of the False Position Method to obtain an
initial value for Newton-Raphson, we need an interval at which at its ends the
function changes its sign.

We try:

326 . 1 ) 5 . 0 ( ; 1 ) 0 ( = = f f . The interval [0,0.5] seems to be suitable

First iteration of the False Position Method
215 . 0
) 1 ( 326 . 1
5 . 0 ) 1 (
0
) ( ) (
) )( (
=


=


=
a f b f
a b a f
a x
Newton Raphson:
Recursive Formula :
) ( '
) (
x f
x f
x x =

x f(x) f(x)
0.215 0.3766 4.9272
0.1386 -0.0380 5.9360
0.1450 -0.0003 5.8481
0.1450

We have finished since the results of the latest two iterations coincide with three
decimal digits.

The solution is x=0.145








2. We have the following MATLAB code stored in a file called f.m:

function[s]=f(v)
m=v(1);
p=v(2);
k=2;
s=sin(pi/m);
d=abs(m/2^(m-1)
while k<=m-1 & d>p
s=s*sin(k*pi/m)
k=k+1
end

Which result is obtained in the variable q if we introduce in the Command
Window the commands:
>>w=[4,0.00005]
>>q=f(w)

SOLUTION:

With the call of the function the computer makes:
m=4
p=0.00005
Then the program continues:
k=2
s=sin(3.1415926/4)=0.7071
The evaluation of the following sentence accordingly to the rule of priority of
operators is:
d= s
m
m

1
2
=0.2071
Now it comes the evaluation of condition (proposition) of the while:
k (=2) is less or equal than (m-1) (=3)? : YES
d( =0.2071) is greater than p (=0.00005)? : YES
The proposition therefore is TRUE and the program continues:
s=s*sin(k*pi/m)=0.7071*sin(pi/2)=0.7071
k=k+1=2+1=3
It comes to evaluate again the proposition:
k (=3) is less or equal than (m-1) (=3)? : YES
d( =0.2071) is greater than p (=0.00005)? : YES
The proposition is TRUE and the Program continues:
s=s*sin(k*pi/m)=0.7071*sin(3*pi/4)=0.5000
k=k+1=4
It comes to evaluate the proposition again:
k (=4) is less or equal than (m-1) (=3)? : NO
The proposition is FALSE . The Program continues after the end (nothing) and
gives back the control to the Calling Program (Command Windows in this case)
storing the result of its output argument ,s, in q

The result is q=0.5



3. Given the A Matrix:

4 -1 1
A= -1 2 1
1 1 8

Find the two 3 3 matrices L and U such as:

a) U is upper triangular
b) L is lower triangular with 1s in the diagonal
c) A U L =

If
|
|
|
.
|

\
|
=
10
2
4
B
Using the L,U obtained matrices find the vector X that satisfies the system (in
matrix form) : AX=B

SOLUTION:

L, U matrices

We are going to apply the triangulation Gauss algorithm

Since we have been asked to obtain the matrices L and U which product is exactly A
we cannot apply pivoting

The size of the matrix is 3 therefore we need 2 steps

1
st
step :
First row as it is : 4 -1 1
Second row :
Factor = A(2,1)/A(1,1)=-1/4=-0.25
A(2,1)=A(2,1)-FACTOR A(1,1)=0
A(2,2)=A(2,2)-FACTOR A(1,2)=2+0.25(-1)= 1.75
A(2,3)=A(2,3)-FACTOR A(1,3)=1+0.251=1.25
The Factor of row 2 in step 1 is the element of row 2 column 1 of matrix L
L(2,1)=-0.25
Third row:
Factor=A(3,1)/A(1,1)=1/4=0.25
A(3,1)=A(3,1)-Factor A(1,1)=0
A(3,2)=A(3,2)-Factor A(1,2)=1-0.25(-1)=1.25
A(3,3)=A(3,3)-Factor A(1,3)=8-0.25(1)=7.75
The factor of row 3 in step 1 is the element row 3 column 1 of matrix L
L(3,1)=0.25



The result after step 1 is :
U
4.0000 -1.0000 1.0000
0 1.7500 1.2500
0 1.2500 7.7500
L =

1.0000 0 0
-0.2500 1.0000 0
0.2500 L(3,2) 1.0000

Step 2
First and second row remain as they are
Third Row :
Factor = U(3,2)/U(2,2)=1.25/1.75=0.7143
U(3,2)=U(3,2)-Factor*U(2,2)=0
U(3,3)=U(3,3)-Factor*U(2,3)=7.75-0.7143*1.25=6.8571
The factor for row 3 in step 2 is the element row 3 column 2 of matrix L

So the final results for matrices L and U are:

L =

1.0000 0 0
-0.2500 1.0000 0
0.2500 0.7143 1.0000


U =

4.0000 -1.0000 1.0000
0 1.7500 1.2500
0 0 6.8571

We can check that L * U = A

Solving the system AX=B

First we solve by a descending algorithm LD=B
1.0000 0 0 D1 =4
-0.2500 1.0000 0 D2=2
0.2500 0.7143 1.0000 D3=10,

Therefore : D1=4; -1+D2=2;D2=3;1+2.1429+D3=10;D3=6.8571
Then we solve the system UX=D
4.0000 -1.0000 1.0000 X1=4
0 1.7500 1.2500 X2=3
0 0 6.8571 X3=6.8571
Therefore X3=1 ; 1.75 X2+ 1.25=3 ; X2 = 1; 4X1-1+1=4;x1=1
The solution is then X= [1 1 1]
4. Given the following tabulated function:
x -2 -0.5 1 2.5 4
y 4 10.375 10 23.125 70

a) Compute the Finite Divided Differences
b) Obtain the Collocation Polynomial by the Newton Method
c) Obtain the coefficients a, b of the Regression Line, y=a+bx , of y over x

a)
x y f1 f2 f3 f4
-2 4
4,25
-0,5 10,375 -1,5
-0,25 1
1 10 3 0
8,75 1
2,5 23,125 7,5
31,25
4 70

b) The divided finite differences different from 0 reach until f3 therefore the
Collocation Polynomial is of third degree

4
1 2 5 . 0 5 . 0 5 . 1 75 . 3 5 . 1 5 . 8 25 . 4 4
) 5 . 0 5 . 0 )( 2 ( ) 1 5 . 2 ( 5 . 1 5 . 8 25 . 4 4
) 1 )( 5 . 0 )( 2 ( 1 ) 5 . 0 )( 2 ( 5 . 1 ) 2 ( 25 . 4 4 ) (
3
2 2 3 2
2 2
+
= + + + +
= + + + + + +
= + + + + + + + =
x x
x x x x x x x x
x x x x x x
x x x x x x x P


d) coefficients of the Regression Line

We build in the following table being the last row the sums of cells above




We apply the formulae of coefficients of the Regression Line:


=
2 2
) (
i i
i i i i
x x n
y x y x n
b = 65 , 9
25 5 . 27 5
5 . 117 5 625 . 334 5
=



x b y
n
x b y
a
i i
=

=

= 85 . 13
5
5 65 , 9 5 . 117
=




x y x2 xy
-2 4 4 -8
-0,5 10,375 0,25 -5,1875
1 10 1 10
2,5 23,125 6,25 57,8125
4 70 16 280
5 117,5 27,5 334,625

5 Obtain an approximated numerical value of the integral:
}
2
4
)) ln(sin(
t
t
dx x , considering the interval ]
2
,
4
[
t t
divided in 11 subintervals of same
amplitude and applying Simpson 3/8 Rule to the first three adjacent subintervals
(starting from
4
t
) and Simpson 1/3 Multiple application Rule to the other 8
subintervals.

SOLUTION:

Amplitude of the Subinterval: = = 11 / )
4 2
(
t t
h 0.0714
We build the following table (11 subintervals=12 points)

0
x
1
x
2
x
3
x
4
x
5
x
6
x
7
x
8
x
9
x
10
x
11
x
x
0.7854 0.8568 0.9282 0.9996 1.071 1.1424 1.2138 1.2852 1.3566 1.428 1.4994 1.5708
) (x f
-0.3466 -0.28 -0.2225 -0.1279 -0.1305 -0.0947 -0.0651 -0.0414 -0.0231 -0.0102 -0.0026 0



Simpson 3/8 to the three first subintervals ] , [
3 0
x x :

0543 . 0
) 1279 . 0 ) 2225 . 0 28 . 0 ( 3 3466 . 0 ( 0714 . 0
8
3
)) ( ) ( 3 ) ( 3 ) ( (
8
3
3 2 1 0 1
=
= + = + + + = x f x f x f x f h I


Simpson 1/3 To the other subintervals ] , [
11 3
x x

0214 . 0 )) ( )) ( ) ( ) ( ( 2 )) ( ) ( ) ( ) ( ( 4 ) ( (
3
1
11 9 7 5 10 8 6 4 3 2
= + + + + + + + + = x f x f x f x f x f x f x f x f x f h I

The solution is 0757 . 0
2 1
= + = I I I

You might also like