Hei.
Har et lite spørsmål relatert til følgende oppgave:
Find a discrete approximation to the differential equation [tex]u^{\prime \prime} + 2u^{\prime} + 2u = 3\cos(6t)[/tex] using Equation 3.12 for these values of [tex]n[/tex]: [tex]n = 16, n = 64[/tex], and [tex]n = 256[/tex]. You will need to use MATLAB or similar software to compute the FFT and inverse FFT invovled.
OK. Så hvis vi har diff-ligninger av typen:
[tex]au^{\prime \prime} + bu^{\prime} + cu = f(t)[/tex]
så sier ligningen det refereres til her (3.12) at den diskré løsningen er gitt ved:
[tex]\hat{u_j} = \frac{h^{2} \hat{f_j}}{aw^{j} + \beta + \gamma \bar{w}^{j}}[/tex]
Her er [tex]h = 2 \pi/n[/tex], [tex]\beta = ch^2 + bh - 2a[/tex], [tex]\gamma = a-bh[/tex], [tex]w = \exp(2 \pi i/n)[/tex], og [tex]f_k = f(2 \pi k/n)[/tex] for [tex]1 \leq k \leq n-1[/tex]
Jeg klarer å fint å skrive en MATLAB algoritme som løser dette for et gitt input av [tex]n[/tex]. Først defineres alle variablene, før jeg i en vektor regner ut alle verdiene for [tex]f[/tex]. Deretter bruker jeg MATLAB sin fft-rutine til å finne den diskré Fourier transformen til [tex]f[/tex]. Og til slutt setter jeg opp alt slik som i likning 3.12, og tar den inverse transformasjonen til uttrykket.
Det jeg imidlertid lurer på er følgende: Når jeg skriver dette som en algoritme og senere plotter løsningen [tex]u[/tex] som en funksjon av tid, så får jeg en fin trigonometrisk kurve. Men med slike andreordens diff.ligninger vil det jo kunne være et uendelig antall mulige løsningskurver basert på initialverdiene. Så hvor kommer initialverdiene inn i denne oppgaven? Som sagt så får jeg en fin løsningskurve når jeg plotter dette, men kan ikke se noen sted at vi tar hensyn til initialverdier. Hva er det da som gjør at vi får en unik løsning?
Dersom noen med peiling på dette kan svare meg så vil jeg være ekstremt takknemlig! Jeg kan godt supplementere med mer informasjon angående hvordan formelen over et utredet, samt MATLAB koden min, dersom det er ønskelig. Men hvis noen kan svare meg på dette basert på det jeg har skrevet over, så hadde det vært glimrende!
Numerisk løsning av diff.ligning ved Fast Fourier Transform
Moderatorer: Vektormannen, espen180, Aleks855, Solar Plexsus, Gustav, Nebuchadnezzar, Janhaa
Hei.
Fra læreboken:
As anoter application of the DFT, we consider the differential equation [tex]au^{\prime \prime} + bu^{\prime} + cu = f(t)[/tex], and take [tex]f[/tex] to be a continuous, [tex]2 \pi[/tex]-periodic function of [tex]t[/tex]. There is a well-known analytic method for finding the unique periodic solution of this equation (cf. [3. §3.7.2]), provided that [tex]f[/tex] is known for all [tex]t[/tex]. On the other hand, if we only know [tex]f[/tex] at the points [tex]t_j = 2 \pi j/n[/tex], for some integer [tex]n \geq 1[/tex], this method is no longer applicable.
Instead of trying to work directly with the differential equation itself, we work with a discretized version of it. There are many ways of discretizing. With [tex]h = 2 \pi/n[/tex], the one that we use here involves the following approximations:
[tex]u^{\prime} (t) \approx \frac{u(t) - u(t-h)}{h}[/tex]
[tex]u^{\prime \prime}(t) \approx \frac{u(t+h) + u(t-h) - 2u(t)}{h^2}[/tex]
We let [tex]t_k = 2 \pi k/n[/tex] and [tex]u_k = u(t_k)[/tex] for [tex]0 \leq k \leq n[/tex]. Since [tex]u[/tex] is periodic, [tex]u_n = u_0[/tex].
At [tex]t = t_k[/tex], the preceding difference formulas become
[tex]u^{\prime} (t_k) \approx \frac{u_k - u_{k-1}}{h}[/tex]
[tex]u^{\prime \prime}(t_k) \approx \frac{u_{k+1} + u_{k-1} - 2u_k}{h^2}[/tex]
for [tex]1 \leq k \leq n-1[/tex]. Substituting these values into the differential equation and collecting terms yields the following difference equation:
[tex]au_{k+1} + \beta u_k + \gamma u_{k-1} = h^2 f_k[/tex] for [tex]1 \leq k \leq n-1[/tex]
where [tex]f_k = f(2 \pi k/n), \beta = ch^2 + bh - 2a[/tex], and [tex]\gamma = a - bh[/tex].
Suppose that [tex]u \in S_n[/tex] is a solution to the difference equation above. Let [tex][tex][/tex]\hat{u} = \mathcal{F}[/tex] and [tex]\hat{f} = \mathcal{F}[f][/tex] and [tex]w = \exp(2 \pi i/n)[/tex]. By taking the DFT of both since and using the first part of Theorem 3.4 we can show that
[tex]\hat{u_j} = \frac{h^{2} \hat{f_j}}{aw^{j} + \beta + \gamma \bar{w}^{j}}[/tex]
provided that [tex]aw^{j} + \beta + \gamma \bar{w}^{j}[/tex] is never [tex]0[/tex]. This gives us [tex]\hat{u}[/tex]. We get [tex]u[/tex] by applying the inverse DFT to [tex]\hat{u}[/tex]
Fra læreboken:
As anoter application of the DFT, we consider the differential equation [tex]au^{\prime \prime} + bu^{\prime} + cu = f(t)[/tex], and take [tex]f[/tex] to be a continuous, [tex]2 \pi[/tex]-periodic function of [tex]t[/tex]. There is a well-known analytic method for finding the unique periodic solution of this equation (cf. [3. §3.7.2]), provided that [tex]f[/tex] is known for all [tex]t[/tex]. On the other hand, if we only know [tex]f[/tex] at the points [tex]t_j = 2 \pi j/n[/tex], for some integer [tex]n \geq 1[/tex], this method is no longer applicable.
Instead of trying to work directly with the differential equation itself, we work with a discretized version of it. There are many ways of discretizing. With [tex]h = 2 \pi/n[/tex], the one that we use here involves the following approximations:
[tex]u^{\prime} (t) \approx \frac{u(t) - u(t-h)}{h}[/tex]
[tex]u^{\prime \prime}(t) \approx \frac{u(t+h) + u(t-h) - 2u(t)}{h^2}[/tex]
We let [tex]t_k = 2 \pi k/n[/tex] and [tex]u_k = u(t_k)[/tex] for [tex]0 \leq k \leq n[/tex]. Since [tex]u[/tex] is periodic, [tex]u_n = u_0[/tex].
At [tex]t = t_k[/tex], the preceding difference formulas become
[tex]u^{\prime} (t_k) \approx \frac{u_k - u_{k-1}}{h}[/tex]
[tex]u^{\prime \prime}(t_k) \approx \frac{u_{k+1} + u_{k-1} - 2u_k}{h^2}[/tex]
for [tex]1 \leq k \leq n-1[/tex]. Substituting these values into the differential equation and collecting terms yields the following difference equation:
[tex]au_{k+1} + \beta u_k + \gamma u_{k-1} = h^2 f_k[/tex] for [tex]1 \leq k \leq n-1[/tex]
where [tex]f_k = f(2 \pi k/n), \beta = ch^2 + bh - 2a[/tex], and [tex]\gamma = a - bh[/tex].
Suppose that [tex]u \in S_n[/tex] is a solution to the difference equation above. Let [tex][tex][/tex]\hat{u} = \mathcal{F}[/tex] and [tex]\hat{f} = \mathcal{F}[f][/tex] and [tex]w = \exp(2 \pi i/n)[/tex]. By taking the DFT of both since and using the first part of Theorem 3.4 we can show that
[tex]\hat{u_j} = \frac{h^{2} \hat{f_j}}{aw^{j} + \beta + \gamma \bar{w}^{j}}[/tex]
provided that [tex]aw^{j} + \beta + \gamma \bar{w}^{j}[/tex] is never [tex]0[/tex]. This gives us [tex]\hat{u}[/tex]. We get [tex]u[/tex] by applying the inverse DFT to [tex]\hat{u}[/tex]