Elements of numerical linear algebra and quadrature
Elements of numerical linear algebra and quadrature
Emma Perracchione
Corso di Calcolo Numerico per Ingegneria Meccanica - Matr. PARI (Univ. PD)
Gli esercizi sono presi dal libro: S. De Marchi, D. Poggiali, Exercices of numerical calculus with solutions in Matlab/Octave.
A.A. 2018/2019
Elements of numerical linear algebra and quadrature Materiale
Materiale
TUTTO IL MATERIALE SI TROVA AL SEGUENTE LINK E VERRA’
AGGIORNATO AD OGNI LEZIONE.
https://www.math.unipd.it/~emma/CN1819.html
Elements of numerical linear algebra and quadrature Exercises
Exercise 1
Exercise
On a script called Esercizio 1 compare SimpsonComposto and TrapezioComposto for the following two integrals with the same number of nodes (n = 11):
Z 1
0
1 + x2 dx . Z 1
0
1/8 + 2x dx . Compute the error.
Comment the results.
Elements of numerical linear algebra and quadrature Solving systems
Matlab routines
For solving a system Ax = b, with A ∈ Rn×n,x, b ∈ Rn in Matlab, we simply have to write x=A \ b.
\ Backslash or left matrix divide.
A\B is the matrix division of A into B, which is roughly the same as INV(A)*B , except it is computed in a different way.
If A is an N-by-N matrix and B is a column vector with N components, or a matrix with several such columns, then X = A\B is the solution to the equation A*X = B. A warning message is printed if A is badly scaled or nearly singular.
A\EYE(SIZE(A)) produces the inverse of A.
Elements of numerical linear algebra and quadrature Remarks
Gauss
Given a square matrix A ∈ Rn×n of elements aik, i , k = 1, . . . , n, for performing the gaussian reduction, we need to calculate for
k = 1, . . . , n − 1
mik = a(k)ik a(k)kk
, i = k + 1, . . . , n,
and then
a(k+1)ij = a(k)ij − mika(k+1)kj , i , j = k + 1, . . . , n.
One can interpret this as a factorization of the type LU = A, where the entries of L are given by mik (and a diagonal of ones) and the
Elements of numerical linear algebra and quadrature Exercices
Exercise 2
Exercise
Write the function for LU factorisation without pivoting (and call it LUnoPiv).