links - NumCSE

Info

  • exam
    • mid+endterm: 10min reading + 30min writting; closed-book; optional
    • final exam: 30min reading + 180min writing; open-book; codeExpert + paper
  • exercises

  • practice classes

Hilfsmittel NumericalMethodsForCSE

  • final exam: [course script, Eigen documentation, C++ documentation]
  • mid-/endterm (optional for bonus): closed book

Quote

The course content is quite interesting, but the material is really chaotic. Subsubsubsubsections, missing links, wrongly named files, incoherent structure, overly detailed script - it really does not help that on top of all that, the curse is teached in a flipped classroom mode.
The course is far too much effort for only 9 credits, but it is probably the most important course for CSE, so I would recommend to pay attention and try to do as much as possible.

-> 20250918_NumCSE_Eigen_cheatsheet
-> HS2025_tasks

Exercises








week8


week9


week 10


week 11


problem 12

Videos

week 1


week 2


week 3


week 4


week 5


week 6


week 7 (no review quesitons solved)


week 8 (no review quesitons solved)


week 9 (no review questitons solved)


week 10


week 11


week 12

Midterm

Q&A

#timestamp 2025-11-24
Q&A Week 11

Compisute quadrature rules vs global Gauss quadrature

When choosing quadrature rule, always first consider Gauss (global)

  • benefits from function smoothness / analyticity
  • if fC0([a,b]), but M-p.w. smooth (piece-wise in Mesh cells, only non-linear at Mesh nodes) -> composite Q.R. will cvg. alg. with max rate -> use composite Q.R.
  • equidistant trapezoidal rule is exact for trigonometric polynomials (periodic functions)
Equidistant TR cvg. exponentially for periodic integrands

  • integrand has anlytic extension (on C beyond integration interval)
  • integration is over a period

Vorlesung

#timestamp 20250918

Video 1.4: Complexity introduction, tricks to improve complexity

tricks to improve complexity

y=a(bx)O(n)instead ofy=(ab)xO(n2) y=triu(AB)xO(n2p)

but yi=jiaibjxj=aijibjxj

Video 1.5: Machine numbers, relative errors, gram-schmidt orthogonalisation

Never exactly compare floats (always compare with small diff)

Video 1.5.4 cancellation + how to avoid

cancellation in difference quotients

f(x)f(x+h)f(x)h

-> cancellation in numerator
-> divided by tiny h -> error "blows up"

Minimal relative error for hEPS

#todo look at Vieta's formula

log10 rel. error no. of decimal digits of accuracy

#todo where to find review questions?

Video 1.5.5 Numerical Stability

Problem =^ function/mapping from data to result space (usually normed vector space)

Pasted image 20250921193546.png
stable algorithm =^ an algorithm, which gives a slightly perturbed result. The result has to be reachable by the problem (which is exact) from a slightly perturbed data(point), near the exact data. This has to be true for every data(point)

ω(x)=#ops
impact of roundoff of stable algorithm is the same order of magnitude as perturbations because rounding of input data

Video 2.1

square LSE -> uniqueness of solution, if A invertible / A regular / det(A)0 / cols lin. indep. / rows lin. indep.

(do not use matrix inversion function to solve LSE with numerical libraries)

Video 2.1.0.3

Pasted image 20250923091946.png

Video 2.2.2 Sensitivity/Conditioning of LSE

quantifies how small (relative) perturbation of data lead to changes of the output

Pasted image 20250923092509.png

condition of a matrix ARn×n:

cond(A):=||A1|| ||A||

cond(A)1: LSE well-conditioned
cond(A)1: LSE ill-conditioned (result relatively useless)

if condition number of matrix is very large, it's columns/rows are almost linearly dependent (=^parallel)

Video 2.3 Gaussian Elimination (GE), LU-decomposition

Ax=bL(Ux)=bLz=b,Ux=z

-> three-stage splitting of GE

X = A.lu().solve(B)

Video 2.6 Exploiting structure when solving linear systems

Pasted image 20250925223215.png

Video 2.7.1 sparse matrix: how to store

Video 2.7.2 sparse matrices in Eigen

standard CRS/CSS format

#include<Eigen/Sparse>
Eigen::SparseMatrix<int, Eigen::RowMajor> Bsp(rows, cols);

#initalise
std::vector <Eigen::Triplet<double>> triplets;
Bsp.setFromTriplets(triplets.begin(), triplets.end());

alternative: allocate enough space at start (see 2.7.2.1) / squeeze out zeroes -> slightly more effizient than triplets, but the non-zero data size is not always known in advance

Video 2.7.3 direct solutions of sparse LSE (LGS)

mat.solve(vec);
// note: matrix is
Eigen::SparseLU<Eigen::SparseMatrix<double>> mat;

-> sparse solution is stable

(sparse elimination for combinatorial graph laplacian: asymptotic runtime O(n1.5))

=> in practice: Cost(sparse solution of Ax=b) = O((nnz(A))α), α1.52.5

Video 3.0.1 Overdetermined linear systems

You cannot afford not to use every piece of information available

Video 3.1.1 Least squares solution

idea: find vector x~ for Ax=b, s.t. the residual r:=bAx is as small as possible

notation: lsq(A,b) :=xargminyRn||Ayb||22

Video 3.1.2 solving least square problems

Pasted image 20250929103952.png Pasted image 20250929110426.png

Video 3.1.3 Moore-Penrose-Pseudoinverse

LSQ solution not unique:

-> Additional selection criterium:
Pasted image 20250929110058.png
Pasted image 20250929110334.png

4.1 Filters and Convolutions

Video 4.1.1 Filters and Convolutions

discrete finite linear time-invariant casual channels/filters

Video 4.1.2 LT-FIR linear Mappings + convolutions

Video 4.1.3 Discrete Convolutions

Pasted image 20251001081307.png

Video 4.1.4 Periodic convolutions

Video 4.2.1 Diagonalizing circulant matrizes

All circulant matrices have the same eigenvectors! Cn

n-th root of unity

ωn=e2πn

Pasted image 20251010165754.png


Fn1=1nFnH=1nFn

Video 4.2.2 Discrete Convolution via DFT

Pasted image 20251010170716.png

Eigen::FFT<double> fft;
fft.inv(
	(
		(fft.fwd(u)).cwiseProduct(fft.fwd(x))
	).eval()
)

explanation:
Pasted image 20251010171006.png

Video 4.2.3 Frequency filtering via DFT

DFT is a computer's eye for periodic patterns in data

Pasted image 20251010172559.png

Video 4.2.5 Two dimensional DFT

Pasted image 20251012165911.png

Video 4.2 FFT

The execution time for fft depends on the length of the transform. It is fastest for powers of two. It is almost as fast for lengths that have only small prime factors. It is typically several times slower for lengths that are prime or which have large prime factors

Video 4.5 Toeplitz Matrix Techniques

Toeplitz matrices:

Pasted image 20251012173508.png

overdetermined LSE -> least squares estimator

Video 5.1 AI (Abstract Interpolation)

get unique solution y only if m=n (matrix square)

if A square, regular => can write Interpolant as linear combination of basis functions

f(t)=j=0

interpolant can be recovered by forming a matrix-vector product

#todo write down end of video

Video 5.2 Uni-Variate Polynomials

Polynomials form a Vectorspace with

dimPk=k+1

convention for storing polynomials:

p=[anan1a0]Rn+1

Video 5.2.2 Polynomial Interpolation Theory

Pasted image 20251030114840.png
B1 - Lagrangian basis
B2 - Newton basis
B3 - monomial basis

Video 5.2.3 Polynomial Interpolation Algorithms

Pasted image 20251016115256.png
O(n2construction+Nneval())

Pasted image 20251016115609.png

O(n2)

-> adding one more point (=^ one diagonal) O(n)

Video 5.2.3.3 Extrapolation to Zero

Video 5.2.3.4 Newton Basis

Homer-like scheme
Pasted image 20251017231124.png

Video 5.2.4 Polynomial Interpolation: sensitivity

sensitivity: amplification of perturbation of data (of a problem)

Pasted image 20251028120258.png
-> tiny errors will have huge impact on the interpolation result
-> not suitable for data interpolation

6. Approximations of functions in 1D

Video 6.1 Introduction

in 5: create function to combine data points
in 6: find easier function, because 5 too costly

-> find simple (easy to evaluate) function with small approximation error (norm)

Video 6.2.1 Polynomial approximation: theory

bernstein theorem: if f nearly continuous -> can be approximated by polynomial

jackson theorem: Max-norm of best-approximation error
Pasted image 20251030143913.png
how to move from interval [1,1] to [a,b]:
Pasted image 20251030144157.png

Video 6.2.2 Convergence of interpolation errors

Pasted image 20251030145312.png
Pasted image 20251030145858.png
what can you tell from algebraic divergence?
-> how to increase polynomial degree to achieve certain reduction of error

Video 6.2.2.2 Interpolands of finite smoothness

Runge's Counterexample: f(t)=11+t2, I=[5,5] -> approximation has exponential blow-up of error

Pasted image 20251030154000.png
τt is not known, so usually we use the lest tight bound with the max norm:
Pasted image 20251030154249.png

Quantitative interpolation error estimates rely on smoothness!

Video 6.2.2.3

real analytic function
-> if has convergent taylor series for every point in interval I

Every real-analytic function on IR can be extended to a complex-analytic function on some open set DC with ID.

Pasted image 20251030165738.png
Pasted image 20251030170438.png
Pasted image 20251030170548.png

Video 5.2.3.1 Chebychev Interpolation

The n-th Chenychev polynomial is

Tn(t)=cos(ncos1(t))

Pasted image 20251110163312.png
Pasted image 20251110163538.png

Video 5.2.3.2 Chebyshev INterpolation Error Estimates

equidistnt nodes affected by oscillations close to endpoints

Lebeseque links best approximation error and interpolation errors

Lebesque constant for Chebychev nodes:

λτ2πlog(n+1)

-> increase verys slowly

(compare with equid. nodes: λτCen/2)


trick: plug in lebesque constant in between interpolation error and best approximation error

Pasted image 20251110164344.png

Line in lin-log plot -> exponential convergence
Line in log-log plot -> algebraic convergence
smoothness is crucial, also for chebyshev nodes

Suitebla integration path: elippsis around [1,1]:

γ(θ)=cos(θ0ilog(ρ))

ρ>1
-> cos, to cancel out with chebyshev polynomials
Pasted image 20251110165002.png
for chebyshev polynomials for analytic functions

slower for smaller domain of analyticity DC

Video 6.5 Approximation by Trigonometric Polynomials

space of 1-periodic functions of trigonometric functions of degree 2n

P2nT=span{1,sin(2πt),cos(2πt),sin4pi}

Video 6.5.2 Trigenometric Interpolation Error Estimates (fourier series)
#todo didn't quite understand the video

Pasted image 20251110214025.png
-> c^j bounded

Pasted image 20251110214336.png

Video 6.6.1 Piecewise Polynomial Lagrange Interpolation

approximation by piecewise polynomials

piece-wise polynomials; benefit:

Pasted image 20251110220514.png

H: mesh


lagrange interpolation for function that is n+1 times continously differentiable (Cn+1)

Pasted image 20251110220838.png

for mesh width 0 (hm0) we have algebraic convergence with rate n+1

7. Numerical Quadrature

Video 7.1 Introduction

Numerical Quadrature (Integration)

Video 7.2 Quadrature Formulas Rules

f given in procedural form

double f(double)

Pasted image 20251113115805.png

transformation:
Pasted image 20251113115834.png
Pasted image 20251113115949.png

interpolation schemes (5) -> approximation schemes (6) (simple functions) -> quadrature schemes (7)


quadrature erros can often be computer easily, especially for quadrature rules arising from interpolation schemes

(bounded by max norm of interpolation error)

Video 7.3 Polynomial Quadrature Formulas

Use Lagrangian polynomial interpolation

Pasted image 20251113120802.png

(ba)f(12(a+b)) ba2(f(a)+f(b))
midpoint, trapezoidal

Dangerous for n1: huge weights with alternating sign: cancellation

solution:

error estimates for polynomial quadrature:
Pasted image 20251113121328.png

Video 7.4.1 Gauss Quadrature / Order of a Quadrature Rule

order of polynomial n-pt. quadrature rule = n, since n-1 polynomail -> n+1 of that order of quadrature rule

Pasted image 20251113121811.png
Pasted image 20251113121924.png

7.4.1.7: how to compute weights to achieve order n by solving a suitable linear system:
Pasted image 20251113122118.png
-> solve weights to get quadrature rule of at least order n

Video 7.4.2: Maximal-Order Quadrature Rules

Pasted image 20251113124452.png

how to find maximum order quadrature rule?

Pasted image 20251113124519.png

how to find n-point quadrature rule of order 2n?

Pasted image 20251113125224.png

Pasted image 20251113125353.png
Pasted image 20251113125406.png
Note that Hiptmair mostly proves lemmas indirectly.

Pasted image 20251113125511.png

Video 7.4.3 Quadrature Error Estimates

Pasted image 20251113194654.png
very important property for quadrature error:
Pasted image 20251113195529.png
from chapter 6);

high smoothness fast convergence

restoring smoothness (removing singularity by transformation):

The message of asymptotic estimates:


Eigen::ArrayXd::LinSpaced(n,a,b)

builds a sequence of n values

(a+ban1j)j=0n1

Video 7.5 Composite Quadrature

split interval into mesh, integrate very mesh individually
-> cost = number of mesh cells (* integral)

good approximation for local error:
Pasted image 20251117161159.png

"h-covergence": convergence by making mesh finer
Pasted image 20251117161855.png
-> for equidistant meshes, use Gauss-Legendre Q.R. instead of composite quadrature
-> for trigonometric polynomials (periodic functions):
Pasted image 20251117162711.png
with

P2n=Span{te2πikt,nkn}

best approximation error estimeted by triag.pol.:
Pasted image 20251117162948.png

Video 7.6 Adaptive Quadrature (13 min)

goal: choosing mesh such that local errors are equidistribution
-> choose mesh a priori (based on prior knowledge about f) (often not known)
-> choose mesh a posteriori (automatic based on informatio gained during the computation)

Pasted image 20251117163628.png

with initial mesh M={xj}j=0m

  1. compute estimate for each mes cell: (simpson - trepezoidal Q.R.)
  2. sum up to get estimate for total error
  3. if error too large, find intervals contribute above average to the total error
  4. add their midpoints to the new refined mesh. start anew.
estimate is normally not good, but always on the large side

8. Iterative Methods for Non-linear Systems of Equations

Video 8.1 Iterative Methods for Non-Linear Systems of Equations: Introduction (5 min)

form:

F(x)=0F:DRnRn

8.2 Iterative Methods

Video 8.2.1 Fundamental Concepts (6 min)

solve by "getting closer and closer" iteratively
-> will this solution converge?

m-point method:

x(k+1)=ΦFiteration function(x(k),,x(km+1))last m iterates

-> insert last m iterates to get next one

consistent: vector at which iteration becomes stationary -> vector must be solution
Pasted image 20251117165154.png
-> consequence: assume

=>

F(x)=0

local convergence:

questions

  • how fast will the convergence of the sequence solution be? 8.2.2
  • what is the initial region of local convergence? partially answered by 8.3

Video 8.2.2 Speed of Convergence (15 min)

How fast will the norm converge?

How fast ||x(k)x||0?

Pasted image 20251117165937.png
smallest L: rate of cvg.

Detect linear convergence:
Pasted image 20251117170255.png

Error points aligned in lin-log plot

Pasted image 20251117170522.png

Detect p>1 convergence:
Pasted image 20251117170659.png

No easy graphical way to see

quadratic convergence (p=2): doubling of correct digits in each step

Video 8.2.3 Termination Criteria/Stopping Rules (14 min)

Ideal stopping rule:
stop iteration if prescribed absolute or relative tolerance reacher
-> not working, since exact value not known

practical stopping rules

error estimate:
Pasted image 20251117175325.png
-> Reliable error estimate, even if we only know upper bound L, LL<1

8.3 Fixed-Point Iterations

Video 8.3 Fixed-Point Iterations (12 min)

we do not always know x, so assume:

x=limkx(k)ϕ continuousx=ϕ(x)

Pasted image 20251117180201.png
Pasted image 20251117180343.png
Pasted image 20251117180724.png
Pasted image 20251117180907.png

Video 8.4.1 Finding Zeros of Scalar Functions: Bisection (6 min)

find xR with F(x)=0

intermediate value theorem

If on interval I, istart negative, iend positive -> continous function must have zero somewhere in I

Idea: geometrically decrease interval
-> linear convergence, factor 12

+ guaranteed cenverence -> robust
+ F - only evluations needed -> procedural ok
+ derivative-free
+ works continuous F
- not extremely fast

Video 8.4.2.1 Newton Method in the Scalar Case (20 min)

Idea: replace function locally around x(k) with a simpler method F(x)Fk(x)

Newton: use tangent on x(k),F(x(k))
Pasted image 20251121182439.png

F(x(k))0 required

Pasted image 20251121182747.png
Pasted image 20251121182758.png

Ex. 8.4.2.4: functions with same x may have different Newton iterations -> advantageous to first recast function before calculating Newton iteration

Find F(x) implicit with implicit differentiation

Pasted image 20251123153836.png

If (F) is hard to solve but close to an easily invertible F^, define

g(x)=F^1(F(x)),G(x)=g(x)F^1(0).

Then F(x)=0G(x)=0, and G is almost linear.
Newton on (G) converges faster and from farther away because the preconditioning makes the problem closer to the identity map.
Pasted image 20251123154638.png

Video 8.4.2.3 Multi-Point Methods (12 min)

Pasted image 20251123154854.png
secant method:
Pasted image 20251123155000.png

Pasted image 20251123155818.png

Newton, multi-point methods converge only locally!

-> secant method more efficient (see 8.4.3) than Newton method!

8.4 Finding Zeros of Scalar Functions

Video 8.4.3 Asymptotic Efficiency of Iterative Methods for Zero Finding (9 min)

Efficiency=gain - no, of correct digitwork - #F-eval + #F’-eval

Pasted image 20251123160220.png
Pasted image 20251123160512.png
lower bound for number of required steps:
Pasted image 20251123160528.png
Pasted image 20251123160804.png

8.5 Newtons Method in Rn

Video 8.5.1 The Newton Iteration in Rn (I) (10 min)

The standard method for solving (generic) non-linear systems of equations.

Pasted image 20251123161923.png

Newton method if affine invariant (invariant to multiplicaiton with matrix from left)
-> should also be desireable for stopping rules

Video 8.5.1.15 Multi-dimensional Differentiation (20 min)

Matrix * Vector is general way to write linear mapping RnRn
Pasted image 20251123173219.png
Pasted image 20251123173229.png
bilinear =^ linear in every argument

Pasted image 20251123173337.png
Pasted image 20251123173443.png

Pasted image 20251123173548.png

Video 8.5.1 The Newton Iteration in Rn (II) (15 min)

Pasted image 20251123204656.png
Pasted image 20251123190130.png
Pasted image 20251123190919.png

Simplified Newton method: O(n2) instead of O(n3) from solving LSE by "freezing" Jacobian

#todo look video again to understand better

Video 8.5.2 Convergence of Newton’s Method (9 min)

Convergence of Newton's method:
n=1 local quadratic cvg.

Pasted image 20251123192547.png

Video 8.5.3 Termination of Newton Iteration (7 min)

terminate, when ||x(k)x|| small

=> ||x(k)x||||x(k)x(k+1)||, but unnecseeary iteration k+1 (O(n3))

Pasted image 20251123205028.png
-> affine invariant: does not change when

FAF,ARn×n regular

Video 8.5.4 Damped Newton Method (11 min)

Pasted image 20251123205712.png
=> goal: enlarge domain of cvg.

Pasted image 20251123210004.png
Pasted image 20251123210108.png
if quadratic cvg. =>

||Δx(k)||12||Δx(k)||

if NMT (natural monotonicity test) fails

called a reject=accept approch

-> works, because of affine invariant property of Newton method

8.6 Quasi-Newton Method

Video 8.6 Quasi-Newton Method (15 min)

Drawback of Netwon method: DF required

Pasted image 20251125074732.png

Pasted image 20251125075051.png
(BC)+(SC) unique determine Jk

Pasted image 20251125075109.png

for k=1 (see also problem 8.10)d) from week 11), the Sherman-Morrison-Woodbury formula can be simplified to:
Pasted image 20251125075418.png
Pasted image 20251125075732.png

  1. solve n×n LSE
  2. vector arithmetic from then on (very cheap)

Pasted image 20251125075908.png

can have stability problems! (because of SMW-formula)

8.7 Non-linear Least Squares

Video 8.7 Non-linear Least Squares (7 min)

minimize Euclidean norm of residual (same as linear case)
Pasted image 20251125080250.png

linear case:
Pasted image 20251125080615.png
linear combination of basis function

non-linear case:
Pasted image 20251125080723.png

Video 8.7.1 Non-linear Least Squares: (Damped) Newton Method (13 min)

with FC2, ϕ:RnR
Pasted image 20251125081553.png
Pasted image 20251125081700.png

Pasted image 20251125081903.png
then the LSE for Newton crrection sRn is:
Pasted image 20251125082059.png
-> normal equation in case F(x)=Axb (see paper notes W11)

Video 8.7.2 (Trust-region) Gauss-Newton Method (13 min)

Pasted image 20251125083438.png
Pasted image 20251125083557.png

Pasted image 20251125083756.png
Advantages over Newton-method:
+ 2nd-derivativ free
+ Larger domain of cvg.
- no local quadratic cvg.

-> no global cvg., but we can also use damping (called trust region Method =^ implicitly damped Gauss-Newton method)

Pasted image 20251125084246.png
Pasted image 20251125084321.png

11. Numerical Integration - Single Step Methods

Video 11.1 Initial-Value Problems (IVPs) for Ordinary Differential Equations (35 min)

Pasted image 20251125085615.png
Pasted image 20251125091925.png

Pasted image 20251125092146.png
Pasted image 20251125092213.png

time-dependent ODEs can be converted to autonomous ODEs
Pasted image 20251125092736.png

conversion: from higher-order ODEs for first-order ODEs
Pasted image 20251125093156.png

both time-dependent and higher-order ODEs can be converted to 1st-order autonomous IVPs:

y˙=f(y),y(0)=y0RN

Pasted image 20251125093607.png
Pasted image 20251125093805.png

Pasted image 20251125094219.png
left:

tϕty0

right:

yϕtyt const.

=> as time progresses, the evolution operator takes a "part of the space" and "flows" it forward

Recovering the ODE from the Flow: the vector field f(y) (which defines the differential equation) is simply the initial velocity of the evolution operator.

f(y)=Φt(0,y)
Numerical integration is concerned with the approximation of evolution operators.
ϕsϕt=ϕs+t