Anteprima
Vedrai una selezione di 6 pagine su 21
Numerical Methods - Esame base - Pseudocodici ed esercizi Pag. 1 Numerical Methods - Esame base - Pseudocodici ed esercizi Pag. 2
Anteprima di 6 pagg. su 21.
Scarica il documento per vederlo tutto.
Numerical Methods - Esame base - Pseudocodici ed esercizi Pag. 6
Anteprima di 6 pagg. su 21.
Scarica il documento per vederlo tutto.
Numerical Methods - Esame base - Pseudocodici ed esercizi Pag. 11
Anteprima di 6 pagg. su 21.
Scarica il documento per vederlo tutto.
Numerical Methods - Esame base - Pseudocodici ed esercizi Pag. 16
Anteprima di 6 pagg. su 21.
Scarica il documento per vederlo tutto.
Numerical Methods - Esame base - Pseudocodici ed esercizi Pag. 21
1 su 21
D/illustrazione/soddisfatti o rimborsati
Disdici quando
vuoi
Acquista con carta
o PayPal
Scarica i documenti
tutte le volte che vuoi
Estratto del documento

1- GEM + LU factorization

Forward substitution Lx = b

Backward substitution Ux = b

GEM Ux = b

Pivoting PAx = Pb

LU factorization L(Ux) = b

2- Iterative solvers

Splitting methods

Jacobi method M = diag(A)

Gauss-Seidel method M = tril(A)

3- Eigenproblems

Power method Av = λv

Inverse power method

4- Pagerank algorithm

V1 dangling

V2 unique solution

V3 wT = wTA

5- Least squares

Linear regression ATAq = ATb

6- Nonlinear equations

Bisection method c = (a+b)/2

Newton's method xk+1 = xk - f(xk)/f'(xk)

Solution of systems F(x) = 0

7- Interpolation

Lagrange interpolation Π f = gL

8- Quadrature

Composite midpoint rule h Σ f(xi)

Composite trapezoidal rule h/2 (Σ f(x0) + f(xn))

Composite Simpson rule h/6 (Σ fi-1 + 4fi + fi+1)

9- ODE

Explicit Euler ∫a g = g(c)(d-c)

Implicit Euler ∫a g = g(d)(d-c)

Crank-Nicolson ∫a g = g(c+d)/2 (d-c)

Heun method y* = f(t)

Runge-Kutta methods

Forward substitution

Lx = b

X1 = b1 / l11X2 = [b2 - l21x1] / l22⋮xn = [bn - ∑j=1n-1 lnjxj ] / lnn

Pseudo:

Input: L∈ℝn×n, b∈ℝnb1 = b1/l11for i = 2,...,n    for j = 1,...,i-1        bi = bi - lijbj    end    bi = bi / liiendOutput: x = b

Backward substitution

Ux = b

Xn = bn / unnXn-1 = (bn-1 - un-1nxn) / un-1n-1⋮X1 = [b1 - ∑j=2n u1j xj] / u11

Pseudo:

Input: U∈ℝn×n, u∈ℝnbn = bn/unnfor i = n-1,...,1    for j = n,...,i+1        bi = bi - uijbj    end    bi = bi / uiiendOutput: x = b

Power method

Av = λv

Find the eigenvector λ1, largest in absolute value

PSEUDO:

  • Input: A∈Rnxn
  • Choose v0∈Cn with ||v0|| = 1
  • for k = 1, 2, ...
  •  W = Avk-1
  •  vk = W / ||W||
  •  Mk = (vk)TAvk
  • end (stop when ||Avk - Mkvk|| ≤ tol)

Inverse power method

Find the eigenvector closest to μ

PSEUDO:

  • Input: A∈Rnxn, μ∈C
  • Choose v0∈Cn with ||v0|| = 1
  • for k = 1, 2, ...
  •  W = (A - Inμ)-1vk
  •  vk = W / ||W||
  •  Mk = (vk)TAvk
  • end (stop when ||Avk - Mkvk|| ≤ tol)

ODES

y'(t) = f(t, y(t)) y(t0) = y0 t ∈ [0, T]

Explicit Euler

y0 given yn+1 = yn + Δt f(tn, yn) n = 0, 1, ..., N-1

Implicit Euler

y0 given yn+1 = yn + Δt f(tn+1, yn+1)

Crank-Nicolson

y0 given yn+1 = yn + Δt/2 [f(tn+1, yn+1) + f(tn, yn)] n = 0, 1, ..., N-1

Heun method

y0 given y*n+1 = yn + Δt f(tn, yn) yn+1 = yn + Δt/2 [f(tn, yn) + f(tn+1, y*n+1)] n = 0, 1, ..., N-1

Compute one step of Newton

(xy - 5x = 6y + 7.5 = 0

x2y2 - 6y2 + 5x2 = -10xy + 12y - 60 = 0

JF = ∂f1/∂x ∂f1/∂y ∂f2/∂x ∂f2/∂y

[ y - 5 ] [ x - 6 ] [ 2xy2 + 10x - 20xy ] [ 2x2y - 12y - 10x2 + 12 ]

JF(x(0)) δ = F(x(0)) → [-5 -6] [δ1] = [ 7.5 ] [0 12] [δ2] = [ -60 ] → δ = [-9] ________________________ [-5]

x(1) = x(0) - δ = [9] ______________________________ [5]

Given f(x) = x3 - 2x2 + x - 4 write T2(x) for x1 = -1, x2 = 1, x3 = 2

L1(x) = └x - x2 │┬x1 - x2 × x - x3x1 - x3 = └x - 1 + 2 │┬x - 2 + 3 = └x2 - 3x + 2│ / 6

L2(x) = └x - x1 │┬x2 - x1 × x - x3x2 - x3 = └x + 1 / 2 ▲ x + 2 └+ 1 = └x2 + x + 2│ / 2

L3(x) = └x - x1 │┬x3 - x1 × x - x2x3 - x2 = └x + 1 / 3 [ x - 1 ] │+ 1 = └x2 - 1] │ / 3

f(x1) = -1 - 2 - 1 - 4 = -8

f(x2) = 4 - 4 - 1 - 4 = -4

f(x3) = 8 - 8 + 2 - 4 = -2

T2(x) = f(x1)L1(x) + f(x2)L2(x) + f(x3)L2(x) =

= 1/3 ( └-4x4 + 12x - 8 + 6x2 - 6x - 12 - 2x2 + 2│ ) = 2x - 6

Pseudo for Composite midpoint quadrature

PSEUDO:Input: function f, extremes of the interval a,b, number of subdivisions Nfor i = 0:N Xi = a+(b-a) i Nendfor i = 1:N Xi* = Xi + Xi-1 2endintegral = 0for i = 1:N integral = integral + f(Xi*) b-a NendOutput: integral

Lagrange interpolation of degree 2 through

X1 = -π , X2 = 0 , X3 = π 2of f(x) = sin(x)L1(x) = X - X2 X - X3 = X X - π - X X - π 2X - 2πX X1 - X2 X1 - X3 π 2 3π 2 3π (3π)2L2(x) = X - X1 X - X3 = X - -π X X - π = - (2X+π)X(x-π) -2X2 + πX + π2 X2 - X1 X2 - X3 π 2 π (π)2L3(x) = x - X1 X - X2 = 2X - + πX X = X2 + πX X3 - X1 X3 - X2 3π π (3π)2f(x1) = -1 ; f(x2) = 0 ; f(x3) = 0Π2(x) = f(x1)L1(x) + f(x2)L2(x) + f(x3)L3(x) = - 2X2 + 2πX = 2 x2 + 2 X ----------------------- ---------------- ----- 3(π)22
Dettagli
Publisher
A.A. 2022-2023
21 pagine
SSD Scienze matematiche e informatiche MAT/08 Analisi numerica

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher Teoscard di informazioni apprese con la frequenza delle lezioni di Numerical methods in engineering sciences e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Università degli Studi di Pavia o del prof Sangalli Giancarlo.