Mathematica Asked by Mord Fustang199 on January 4, 2021
I am having trouble finding the Fourier series of a 2nd order ODE. Should I be using the piecewise function as well to set up the range for t?
Solve $ y” + omega^2 ? = r(t) $, where $ r(t) = |t|, -pi < t < pi $ by using Fourier series.
So far I have set up the ODE and set equal to r[t]
r[t] = y''[t] + ω^2 y[t]
Plot(r[t], {t, -π, π}]
Any help with the Mathematica code would be greatly appreciated. How can I find An
, Bn
with the function being an ODE?
Develop the driving force Abs[t] into FourierSeries and solve diff equation for the general coefficients.
FourierSeries[Abs[t], t, 3, FourierParameters -> {1, 1}]
(* -((2 E^(-I t))/[Pi]) - (2 E^(I t))/[Pi] - (2 E^(-3 I t))/(
9 [Pi]) - (2 E^(3 I t))/(9 [Pi]) + [Pi]/2 *)
fc[n_] = FourierCoefficient[Abs[t], t, n,
FourierParameters -> {1 , 1 }]
Treat n==0 separately and proofing identity yields True
FourierSeries[Abs[t], t, 9, FourierParameters -> {1, 1}] ==
fc[0] + Sum[fc[n] (E^(I n t) + E^(-I n t)), {n, 1, 9}] // Simplify
for comparison solve numericaly for Abs[t], since DSolve gave the wrong result in version 8.0, even for Sqrt[t^2]. And solve for n==0 separately.
ynr[w_] :=
y /. First@
NDSolve[{y[0] == 0, y'[0] == 0, y''[t] + w^2 y[t] == Abs[t]},
y, {t, -Pi, 3 Pi}]
ysol[0, w_] =
y /. First@
DSolve[{y[0] == 0, y'[0] == 0, y''[t] + w^2 y[t] == fc[0]}, y, t]
ysol[n_ /; n >= 1, w_] =
y /. First@
DSolve[{y[0] == 0, y'[0] == 0,
y''[t] + w^2 y[t] == fc[n] (E^(I n t) + E^(-I n t))}, y, t] //
ExpToTrig
Manipulate[
Plot[Evaluate[{ynr[2][t],
ysol[0, 2][t] + Sum[ysol[n, 2][t], {n, 1, nmax, 2}]}], {t, -Pi,
3 Pi}, GridLines -> Automatic, PlotStyle -> {Red, Blue},
PlotRange -> {0, 1.5}], {nmax, 1, 7, 1, Appearance -> "Labeled"
}]
Developing to n== 5 seems sufficient.
Answered by Akku14 on January 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP