Numerical Methods 2 Test

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play

1/54

encourage image

There are no tags or description

Looks like no tags are added yet.

55 Terms

1
New cards
What does 'n-th order accurate' mean?
Error โˆhn\propto h^n. Halve hh and the error drops by 2n2^n: 1st order halves it, 2nd order quarters it, 4th order divides it by 16. [In notes: Note 1]
2
New cards
Forward and backward difference for fโ€ฒf', and their order?
Forward fj+1โˆ’fjh\frac{f_{j+1}-f_j}{h}, backward fjโˆ’fjโˆ’1h\frac{f_j-f_{j-1}}{h}. Both 1st order, O(h)O(h). [In notes: Note 1]
3
New cards
Central difference for fโ€ฒf', and its order?
fj+1โˆ’fjโˆ’12h\frac{f_{j+1}-f_{j-1}}{2h}. 2nd order, O(h2)O(h^2). [In notes: Note 1]
4
New cards
Central difference for fโ€ฒโ€ฒf'', and its order?
fj+1โˆ’2fj+fjโˆ’1h2\frac{f_{j+1}-2f_j+f_{j-1}}{h^2}. 2nd order. Exact (zero error) for polynomials up to x3x^3. [In notes: Note 1]
5
New cards
Three-point backward difference for fโ€ฒf'?
3fjโˆ’4fjโˆ’1+fjโˆ’22h\frac{3f_j-4f_{j-1}+f_{j-2}}{2h}. 2nd order. Lesson: the number of points is NOT the order. [NOT in notes: memorise]
6
New cards
Quick way to find the order of any finite difference formula?
Apply it at x=0x=0 to x2x^2, then x3x^3, then x4x^4... The first power that gives a wrong (non-zero) answer is order + 1. Or compare errors at hh and h/2h/2. [NOT in notes: memorise]
7
New cards
Why is the error the first dropped Taylor term?
Taylor writes ff as powers of hh, each much smaller than the last. A formula keeps some terms, so the error is roughly the first term left over. Its power of hh is the order. [In notes: Note 1 (truncation error)]
8
New cards
Modified wavenumber of the central difference for ddx\frac{d}{dx}?
Exact derivative of eiฮบxe^{i\kappa x} uses ฮบ\kappa; the scheme behaves as if it were ฮบโˆ—=sinโก(ฮบh)h\kappa^*=\frac{\sin(\kappa h)}{h}. Compare ฮบโˆ—\kappa^* with ฮบ\kappa to judge accuracy. [In notes: Note 1 p.6-7, Note 6 p.34]
9
New cards
What does ฮบโˆ—=sinโก(ฮบh)h\kappa^*=\frac{\sin(\kappa h)}{h} tell you?
Small ฮบh\kappa h (long waves): ฮบโˆ—โ‰ˆฮบ\kappa^*\approx\kappa, accurate. Larger ฮบh\kappa h: always underestimates. At ฮบh=ฯ€\kappa h=\pi: ฮบโˆ—=0\kappa^*=0, zero derivative. Expansion ฮบโˆ—=ฮบโˆ’ฮบ3h26\kappa^*=\kappa-\frac{\kappa^3h^2}{6} (the expansion is not in the notes). [Partly in notes: formula and 'small k good, large k bad' in Note 1 p.7]
10
New cards
The model problem and the amplification factor ฯƒ\sigma?
Apply the method to yโ€ฒ=ฮปyy'=\lambda y; each step gives yn+1=ฯƒyny_{n+1}=\sigma y_n, so yn=ฯƒny0y_n=\sigma^n y_0. Stable when โˆฃฯƒโˆฃโ‰ค1|\sigma|\le 1. [In notes: Note 2]
11
New cards
Stable or not: ฯƒ=โˆ’0.6\sigma=-0.6? ฯƒ=โˆ’1.4\sigma=-1.4?
Judge the SIZE, not the sign. โˆฃโˆ’0.6โˆฃ=0.6โ‰ค1|-0.6|=0.6\le1: stable (flips sign each step while shrinking). โˆฃโˆ’1.4โˆฃ=1.4>1|-1.4|=1.4>1: unstable. [In notes: Note 2]
12
New cards
Explicit Euler: ฯƒ\sigma and step limit (real ฮป<0\lambda\lt0)?
ฯƒ=1+hฮป\sigma=1+h\lambda. Stable for โˆ’2โ‰คhฮปโ‰ค0-2\le h\lambda\le0, so hโ‰ค2โˆฃฮปโˆฃh\le\frac{2}{|\lambda|}. Remember the 1. Dividing by negative ฮป\lambda flips the inequality. [In notes: Note 2]
13
New cards
Explicit Euler with complex ฮป=ฮปR+iฮปI\lambda=\lambda_R+i\lambda_I?
โˆฃฯƒโˆฃ2=(1+hฮปR)2+(hฮปI)2|\sigma|^2=(1+h\lambda_R)^2+(h\lambda_I)^2. Stable region: circle of radius 1 centred at โˆ’1-1. Purely imaginary ฮป\lambda: โˆฃฯƒโˆฃ=1+h2ฮปI2>1|\sigma|=\sqrt{1+h^2\lambda_I^2}>1, always unstable. [In notes: Note 2]
14
New cards
Size of a complex number / fraction?
โˆฃa+biโˆฃ=a2+b2|a+bi|=\sqrt{a^2+b^2}. For a fraction: size of top divided by size of bottom. [In notes: Note 2]
15
New cards
Implicit (backward) Euler: update and ฯƒ\sigma?
yn+1=yn+hf(yn+1,tn+1)y_{n+1}=y_n+hf(y_{n+1},t_{n+1}). For the model problem ฯƒ=11โˆ’hฮป\sigma=\frac{1}{1-h\lambda}. Unconditionally stable for ฮป<0\lambda\lt0; ฯƒโ†’0\sigma\to0 for big โˆฃhฮปโˆฃ|h\lambda| (kills fast decay). 1st order. [In notes: Note 3 p.13]
16
New cards
Trapezoidal method: update and ฯƒ\sigma?
yn+1=yn+h2(fn+fn+1)y_{n+1}=y_n+\frac{h}{2}\left(f_n+f_{n+1}\right). ฯƒ=1+hฮป/21โˆ’hฮป/2\sigma=\frac{1+h\lambda/2}{1-h\lambda/2}. 2nd order. [In notes: Note 3 p.15-16]
17
New cards
Trapezoidal stability region?
The whole left half-plane Re(hฮป)โ‰ค0\mathrm{Re}(h\lambda)\le0 (A-stable). On the imaginary axis โˆฃฯƒโˆฃ=1|\sigma|=1 exactly. For very negative hฮปh\lambda, ฯƒโ†’โˆ’1\sigma\to-1: stable but oscillates. [In notes: Note 3 p.16 ('unconditionally stable')]
18
New cards
RK2 ฯƒ\sigma and step limit?
ฯƒ=1+hฮป+(hฮป)22\sigma=1+h\lambda+\frac{(h\lambda)^2}{2}. Real axis limit hฮปโ‰ฅโˆ’2h\lambda\ge-2. 2nd order. [In notes: Note 3 p.18]
19
New cards
RK4 ฯƒ\sigma and step limit?
ฯƒ=1+hฮป+(hฮป)22+(hฮป)36+(hฮป)424\sigma=1+h\lambda+\frac{(h\lambda)^2}{2}+\frac{(h\lambda)^3}{6}+\frac{(h\lambda)^4}{24}. Real axis limit hฮปโ‰ฅโˆ’2.79h\lambda\ge-2.79. 4th order. [Partly in notes: RK4 steps in Note 3 p.18; sigma and limit NOT]
20
New cards
Why does every explicit method have a step limit?
Its ฯƒ\sigma is a polynomial in hฮปh\lambda; for big negative hฮปh\lambda the top power takes over and โˆฃฯƒโˆฃ|\sigma| blows up. Implicit methods have ฯƒ\sigma as a fraction, which can stay small. [NOT in notes: memorise]
21
New cards
Explicit vs implicit?
Explicit: next yy straight from known values (Euler, RK2, RK4). Implicit: next yy on both sides, solve for it (backward Euler, trapezoidal). Implicit vs explicit decides stability, not accuracy. [In notes: Note 3]
22
New cards
Global order of each ODE method?
Explicit Euler 1, implicit Euler 1, trapezoidal 2, RK2 2, RK4 4. Euler's per-step error is O(h2)O(h^2) but over Th\frac{T}{h} steps it becomes O(h)O(h). [In notes: Notes 2-3]
23
New cards
Euler by hand when ff is not ฮปy\lambda y?
No ฯƒ\sigma shortcut. Step: yn+1=yn+hf(yn,tn)y_{n+1}=y_n+hf(y_n,t_n) with tnt_n (start of the step). Number of steps =Th=\frac{T}{h}; the last step uses t=Tโˆ’ht=T-h. Recompute the slope every step. [In notes: Note 2]
24
New cards
'Use MATLAB ode45' questions?
ode45 is an accurate adaptive RK45 solver, so its answer equals the exact solution to 4 d.p. Solve exactly if you can. [NOT in notes: memorise]
25
New cards
What is a stiff problem?
Eigenvalues of very different size, e.g. ฮป=โˆ’1\lambda=-1 and โˆ’1000-1000. The fast part dies almost at once, but explicit methods still need hโ‰ค21000h\le\frac{2}{1000} to stay stable. [In notes: Note 4 p.21-22]
26
New cards
Best method for stiff problems, and why?
Implicit Euler: no step limit, and ฯƒ=11โˆ’hฮปโ†’0\sigma=\frac{1}{1-h\lambda}\to0 crushes the fast part, so hh is picked for the slow part. Trapezoidal is stable too but oscillates (ฯƒโ†’โˆ’1\sigma\to-1), so it isn't always better. [In notes: Note 4 p.22]
27
New cards
Two ways to solve a BVP yโ€ฒโ€ฒ=fy''=f with y(a),y(b)y(a),y(b) given?
Shooting: guess the missing yโ€ฒ(a)y'(a), march as an IVP, check y(b)y(b), improve the guess (secant). Direct: finite differences at every grid point, solve all the equations together. [In notes: Note 4 p.23]
28
New cards
Direct method, NN subintervals: how many unknowns?
N+1N+1 grid points, ends known from the BCs, so Nโˆ’1N-1 unknowns and Nโˆ’1N-1 equations (one per inside point). [NOT in notes: memorise]
29
New cards
Shortcut when yโ€ฒโ€ฒ=constanty''=\text{constant}?
Then yy is a quadratic and the central formula is exact, so the finite difference answer = exact answer. Integrate twice and apply the BCs. [NOT in notes: memorise]
30
New cards
Linear vs non-linear BVP?
Linear: yy and its derivatives only to power 1 (e.g. yโ€ฒโ€ฒ=3y+xy''=3y+x): one solution, secant hits it in one go. Non-linear (e.g. yโ€ฒโ€ฒ=โˆ’y2y''=-y^2): may have 0 or several solutions; shooting needs a good first guess. [NOT in notes: memorise]
31
New cards
Secant method for shooting?
Straight line through two (guess, end value) points, read off the guess giving the target BB: v3=v2+(Bโˆ’u2)v1โˆ’v2u1โˆ’u2v_3=v_2+(B-u_2)\frac{v_1-v_2}{u_1-u_2}. Only track the component that changes. [In notes: Note 5 p.25]
32
New cards
Notation uinu_i^n?
ii = grid point in space, nn = time level (a label, not a power). ui+1nu_{i+1}^n: next point right; uin+1u_i^{n+1}: next time step. [In notes: Notes 5-6]
33
New cards
Semi-discretisation (method of lines)?
Discretise space only, keep time continuous, giving one ODE per grid point. Heat equation: dujdt=ฮฑฮ”x2(uj+1โˆ’2uj+ujโˆ’1)\frac{du_j}{dt}=\frac{\alpha}{\Delta x^2}\left(u_{j+1}-2u_j+u_{j-1}\right). Then march with any ODE method. [In notes: Note 5 p.26-29]
34
New cards
FTCS update for the heat equation ut=ฮฑuxxu_t=\alpha u_{xx}?
uin+1=uin+ฮฑฮ”tฮ”x2(ui+1nโˆ’2uin+uiโˆ’1n)u_i^{n+1}=u_i^n+\frac{\alpha\Delta t}{\Delta x^2}\left(u_{i+1}^n-2u_i^n+u_{i-1}^n\right). All of the bracket at time nn. ฮ”t\Delta t is only in the update, not in the semi-discrete ODE. [In notes: Note 5 (ODE) + Euler step]
35
New cards
FTCS stability limit, 1D heat equation?
ฮ”tโ‰คฮ”x22ฮฑ\Delta t\le\frac{\Delta x^2}{2\alpha}. Smaller ฮ”x\Delta x makes it stricter (halve ฮ”x\Delta x, quarter ฮ”t\Delta t). [In notes: Note 5 p.29, Note 6 p.33]
36
New cards
Explicit stability limit, 2D heat equation (ฮ”x=ฮ”y\Delta x=\Delta y)?
ฮ”tโ‰คฮ”x24ฮฑ\Delta t\le\frac{\Delta x^2}{4\alpha}. General: ฮ”tโ‰ค12ฮฑ(1ฮ”x2+1ฮ”y2)\Delta t\le\frac{1}{2\alpha\left(\frac{1}{\Delta x^2}+\frac{1}{\Delta y^2}\right)}. [NOT in notes: memorise]
37
New cards
Semi-discrete ฮป\lambda for heat vs advection?
Heat: ฮป=โˆ’ฮฑ(kโ€ฒ)2\lambda=-\alpha(k')^2, real and negative, so Euler has a step limit. Advection: ฮป=โˆ’ickโ€ฒ\lambda=-ick', purely imaginary. [In notes: Note 6 p.32-34]
38
New cards
FTCS on the advection equation ut+cux=0u_t+cu_x=0?
Unstable for every ฮ”t\Delta t: ฮป\lambda is purely imaginary and explicit Euler gives โˆฃฯƒโˆฃ=1+h2ฮปI2>1|\sigma|=\sqrt{1+h^2\lambda_I^2}>1. [Partly in notes: lambda in Note 6 p.34; 'always unstable' not stated]
39
New cards
Crank-Nicolson for the heat equation?
Trapezoidal in time + central in space. Unconditionally stable, so ฮ”t\Delta t can exceed the explicit limit. For large ฮฑฮ”tฮ”x2\frac{\alpha\Delta t}{\Delta x^2}, Gโ†’โˆ’1G\to-1 (oscillations). [In notes: Note 6 p.35-36]
40
New cards
Overall accuracy of a PDE scheme like FTCS?
FTCS: 1st order in time, 2nd order in space. Overall limited by the lowest order, and shrinking ฮ”x\Delta x alone won't help if the time error dominates. [NOT in notes: memorise]
41
New cards
4th order central difference for fโ€ฒf'?
fjโˆ’2โˆ’8fjโˆ’1+8fj+1โˆ’fj+212h\frac{f_{j-2}-8f_{j-1}+8f_{j+1}-f_{j+2}}{12h}, error O(h4)O(h^4). Uses 2 points each side of xjx_j (not fjf_j itself). The notes print the last term as fjโˆ’2f_{j-2}: it should be fj+2f_{j+2}. [In notes: Note 1 p.5 (with typo)]
42
New cards
Linearising a non-linear ODE: what is ฮป\lambda?
ฮป=โˆ‚fโˆ‚y\lambda=\frac{\partial f}{\partial y} at the given (y0,t0)(y_0,t_0). E.g. f=y2โˆ’tf=y^2-t at y0=โˆ’2y_0=-2: ฮป=2y0=โˆ’4\lambda=2y_0=-4. Terms without yy go into the ignored inhomogeneous part. 'Largest stable hh' means the boundary h=2โˆฃฮปโˆฃh=\frac{2}{|\lambda|}, not just any stable hh. [In notes: Note 2 p.10]
43
New cards
Why do stability questions assume ฮป<0\lambda\lt0 (or Re(ฮป)โ‰ค0\mathrm{Re}(\lambda)\le0)?
Stability only matters when the exact solution decays. If ฮป>0\lambda\gt0 the exact solution grows itself, so there is nothing to be 'stable' about. Read 'stable' / 'unconditionally stable' statements in that decaying case. [Partly in notes: Re(lambda) <= 0 is assumed in Note 4 p.19; the reason isn't stated]
44
New cards
How do you get a method's order from its ฯƒ\sigma?
Compare ฯƒ\sigma with eฮปh=1+ฮปh+(ฮปh)22+(ฮปh)36+โ€ฆe^{\lambda h}=1+\lambda h+\frac{(\lambda h)^2}{2}+\frac{(\lambda h)^3}{6}+\dots Order ฮฑ\alpha = matches up to and including the (ฮปh)ฮฑฮฑ!\frac{(\lambda h)^\alpha}{\alpha!} term. Explicit Euler 1+ฮปh1+\lambda h: order 1. RK2 1+ฮปh+(ฮปh)221+\lambda h+\frac{(\lambda h)^2}{2}: order 2. [In notes: Note 3 p.15]
45
New cards
Order when ฯƒ\sigma is a fraction (implicit Euler, trapezoidal)?
Expand with 11โˆ’x=1+x+x2+โ€ฆ\frac{1}{1-x}=1+x+x^2+\dots Implicit Euler: 11โˆ’ฮปh=1+ฮปh+(ฮปh)2+โ€ฆ\frac{1}{1-\lambda h}=1+\lambda h+(\lambda h)^2+\dots (1 instead of 12\frac12), order 1. Trapezoidal: 1+ฮปh+(ฮปh)22+(ฮปh)34+โ€ฆ1+\lambda h+\frac{(\lambda h)^2}{2}+\frac{(\lambda h)^3}{4}+\dots (14\frac14 instead of 16\frac16), order 2. [Partly in notes: implicit Euler expansion Note 3 p.15; trapezoidal expansion not shown]
46
New cards
Checking stability when ฯƒ\sigma is a fraction?
Don't use โˆ’1โ‰คฯƒโ‰ค1-1\le\sigma\le1 (that's for 1+hฮป1+h\lambda). Use size of top / size of bottom. Implicit Euler: โˆฃฯƒโˆฃ=1โˆฃ1โˆ’hฮปโˆฃ|\sigma|=\frac{1}{|1-h\lambda|}; for ฮป<0\lambda\lt0 the bottom is 1+hโˆฃฮปโˆฃ>11+h|\lambda|\gt1 for every hh, so stable for all hh. Quick check: ฮป=โˆ’10\lambda=-10, h=10h=10 gives ฯƒ=1101\sigma=\frac{1}{101}. [NOT in notes: memorise]
47
New cards
Implicit Euler by hand for a linear ff, e.g. yโ€ฒ=โˆ’3y+2y'=-3y+2?
Write yn+1=yn+h(โˆ’3yn+1+2)y_{n+1}=y_n+h(-3y_{n+1}+2), then collect yn+1y_{n+1}: yn+1=yn+2h1+3hy_{n+1}=\frac{y_n+2h}{1+3h}. Use this for every step. [Partly in notes: method Note 3 p.13; the rearranging is yours]
48
New cards
RK2 (midpoint) step by hand?
k1=hf(yn,tn)k_1=hf(y_n,t_n), k2=hf(yn+k12,tn+h2)k_2=hf\left(y_n+\frac{k_1}{2},t_n+\frac{h}{2}\right), yn+1=yn+k2y_{n+1}=y_n+k_2. Both inputs move to the midpoint for k2k_2. [In notes: Note 3 p.17-18]
49
New cards
Leapfrog step by hand?
yn+1=ynโˆ’1+2hf(yn,tn)y_{n+1}=y_{n-1}+2hf(y_n,t_n). Start from the point TWO back (ynโˆ’1y_{n-1}), slope at the middle point yny_n. Needs a starting scheme (e.g. one Euler step) for y1y_1. [In notes: Note 4 p.19]
50
New cards
Leapfrog roots: which is accurate, and why second order?
ฯƒ1,2=ฮปhยฑฮป2h2+1\sigma_{1,2}=\lambda h\pm\sqrt{\lambda^2h^2+1}. Expand the root, 1+x2โ‰ˆ1+x22\sqrt{1+x^2}\approx1+\frac{x^2}{2}: ฯƒ1โ‰ˆ1+ฮปh+(ฮปh)22\sigma_1\approx1+\lambda h+\frac{(\lambda h)^2}{2}, second order. ฯƒ2โ‰ˆโˆ’1+ฮปh\sigma_2\approx-1+\lambda h is spurious (no match to eฮปhe^{\lambda h}). Don't judge order from the lone ฮปh\lambda h. [In notes: Note 4 p.19-20]
51
New cards
Leapfrog general solution and the spurious part?
yn=C1ฯƒ1n+C2ฯƒ2ny_n=C_1\sigma_1^n+C_2\sigma_2^n with y0=C1+C2y_0=C_1+C_2, y1=C1ฯƒ1+C2ฯƒ2y_1=C_1\sigma_1+C_2\sigma_2. If the starting scheme gives exactly y1=ฯƒ1y0y_1=\sigma_1y_0, then C2=0C_2=0 and the spurious part is completely suppressed. [In notes: Note 4 p.20]
52
New cards
Second-order ODE, e.g. yโ€ฒโ€ฒ+3yโ€ฒ+2y=0y''+3y'+2y=0, with Euler?
Set u=yu=y, v=yโ€ฒv=y'. Then uโ€ฒ=vu'=v and vโ€ฒ=โˆ’3vโˆ’2uv'=-3v-2u (rearrange for yโ€ฒโ€ฒy''). Step both together with old values: un+1=un+hvnu_{n+1}=u_n+hv_n, vn+1=vn+h(โˆ’3vnโˆ’2un)v_{n+1}=v_n+h(-3v_n-2u_n). Answer is uu. [Partly in notes: systems with Euler Note 4 p.21; the u, v substitution isn't shown]
53
New cards
hmaxh_{max} for a system yโ€ฒ=Ayy'=Ay: which eigenvalue?
The LARGEST โˆฃฮปโˆฃ|\lambda|, since hh must be stable for every eigenvalue at once. Explicit Euler: hmax=2โˆฃฮปโˆฃmaxh_{max}=\frac{2}{|\lambda|_{max}}. E.g. eigenvalues โˆ’2,โˆ’200-2,-200: hmax=0.01h_{max}=0.01. [In notes: Note 4 p.22]
54
New cards
Exact hmaxh_{max} for the semi-discrete heat equation?
ฮปj=ฮฑฮ”x2(โˆ’2+2cosโกjฯ€N)\lambda_j=\frac{\alpha}{\Delta x^2}\left(-2+2\cos\frac{j\pi}{N}\right), j=1..Nโˆ’1j=1..N-1. Largest โˆฃฮปโˆฃ|\lambda| is j=Nโˆ’1j=N-1, so compute only that one, then hmax=2โˆฃฮปโˆฃmaxh_{max}=\frac{2}{|\lambda|_{max}}. 'Exact' means don't use ฮ”x22ฮฑ\frac{\Delta x^2}{2\alpha} (large-NN approx). Radians. [In notes: Note 5 p.28-29]
55
New cards
Crank-Nicolson equation for an interior node?
ฮฒ=ฮฑฮ”t2ฮ”x2\beta=\frac{\alpha\Delta t}{2\Delta x^2}. Unknown side: โˆ’ฮฒฯ•jโˆ’1n+1+(1+2ฮฒ)ฯ•jn+1โˆ’ฮฒฯ•j+1n+1-\beta\phi_{j-1}^{n+1}+(1+2\beta)\phi_j^{n+1}-\beta\phi_{j+1}^{n+1}. Known side: ฮฒฯ•jโˆ’1n+(1โˆ’2ฮฒ)ฯ•jn+ฮฒฯ•j+1n\beta\phi_{j-1}^n+(1-2\beta)\phi_j^n+\beta\phi_{j+1}^n. It's half the bracket at nn plus half at n+1n+1, not an explicit update. [In notes: Note 6 p.35]