



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




function fact=factorial(n)
% Computes the factorial of n for an integer n positive
if(n<0) error(’n must be a positive integer’) end fact=1; for k=1:n, fact=fact*k; end
Note that the previous function, indeed computes n! for n ≥ 0. In particular for n = 0, the for...end loop is never started as [1:n] does not have any element.
Consider the matrix A =
− (2) ← (2) − λ 21 (1) with λ 21 = −1, − (3) ← (3) − λ 31 (1) with λ 31 = 1.
The result of this operation can be written as a decomposition for A:
A(1)
The second step of the Forward Elimination procedure aims at canceling the coefficients below the second pivot coefficient a 22 = −3 in the second column of the modified A(1). The following row
operation is performed (3) ← (3) − λ 32 (2) with λ 32 = 2. The result of this operation can be written as the following decomposition for A(1):
From these two steps we can write:
The LU decomposition of A is therefore:
A = L · U, with L =
(^) and U =
|A| = 6
Ay(1)^ =
(^) , Ay(2)^ =
(^) , Ay(3)^ =
Using the LU decomposition of A we can replace these three systems by three pairs of triangular systems: (^) { Lz(k)^ = b Uy(k)^ = z(k)^
for 1 ≤ k ≤ 3.
− First column y(1):
(^) z(1)^ =
(^) =⇒ z(1)^ =
(^) y(1)^ =
(^) =⇒ y(1)^ =
2 3 3
f ′(1) = 5 6 = 0 therefore Newton-Raphson’s method will lead to a quadratic convergence if the initial guess is close enough from the root ˜x = 1. f ′(x) = 3x^2 + 2, so a possible fixed point iterative scheme x(n+1)^ = g(x(n)) is
g(x) = x −
f (x) f ′(x) = x −
x^3 + 2x − 3 3 x^2 + 2
The general form of the Taylor Series of a function F (x) in 0 up to O(x^4 ) is given by
F (x) = F (0) + xF ′(0) + x^2 2
x^3 6
F ′′′(0) + O(x^4 ). (1)
− f ′(x) = − (^) (1+^1 x) 2 ⇒ f ′(0) = −1, − f ′′(x) = (^) (1+^2 x) 3 ⇒ f ′′(0) = 2,
− f ′′′(x) = − (^) (1+^6 x) 4 ⇒ f ′′′(0) = −6.
Substituting in (1), we obtain the requested Taylor Series for f (x):
f (x) = 1 − x + x^2 − x^3 + O(x^4 ).
g(x) = 1 − x 1 + x
= (1 − x)
1 − x + x^2 − x^3 + O(x^4 )
= 1 − x − x(1 − x) + x^2 (1 − x) − x^3 (1 − x) + O(x^4 )
which is equivalent to g(x) = 1 − 2 x + 2x^2 − 2 x^3 + O(x^4 ).
− h′(y) = 2 √^1 1+y ⇒ h′(0) = 12 ,
− h′′(y) = − (^) 4(1+^1 x) 3 / 2 ⇒ h′′(0) = − 14 ,
− h′′′(y) = (^) 8(1+^3 x) 5 / 2 ⇒ h′′′(0) = 38.
After substitution into (1), we find the requested Taylor Series expansion of h(y) near 0:
h(y) = 1 + y 2
y^2 8
y^3 16
Using the expansion (2), obtained from
1 + y near 0, we find (noticing that O(y^4 ) = O(x^4 )),
p(x) =
1 − x 1 + x
1 + y
y 2
y^2 8
y^3 16
=1 +
− 2 x + 2x^2 − 2 x^3 + O(x^4 )
− 2 x + 2x^2 − 2 x^3 + O(x^4 )
− 2 x + 2x^2 − 2 x^3 + O(x^4 )
=1 +
− 2 x + 2x^2 − 2 x^3 + O(x^4 )
4 x^2 − 8 x^3
− 8 x^3
p(x) = 1 − x +
x^2 2
x^3 2
b 1 c 1 0 0 0 a 2 b 2 c 2 0 0 0 a 3 b 3 c 3 0 0 0 a 4 b 4 c 4 0 0 0 a 5 b 5
− The Forward Elimination is designed to set all the coefficient of the subdiagonal equal to zeros. The actual operation is not performed by the function as it would be a useless additional cost: since they are thereafter equal to zeros, the coefficients of a will not be used again. The routine understands them as being equal to zero (they will not be called during the Backward Substitution) but does not perform the operation as it already knows the result. − All the elements above any cj are equal to zero. Therefore, the Forward Elimination leaves them unchanged and no operation is necessary.