Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Mat297
Views: 115
%auto typeset_mode(True, display=False)

Exemple: On considère la fonction f(x)={0si1x<01si0x1f(x) = \left\{ \begin{array}{ccc} 0 & \mbox{si} & -1\leq x <0 \\ 1 &\mbox{si} & 0\leq x\leq 1\end{array} \right. et prolongée par périodicité. Calculons sa série de Fourier.

Ici la période est T=2T=2, de sorte que la féquence fondamentale est ω=2πT=π\omega = \frac{2\pi}{T} = \pi

f1(x)=0 f2(x)=1 f = piecewise([[(-1,0),f1],[(0,1),f2]]) CF = plot(f, thickness=4,figsize=5) show(CF)

Bâtissons une liste avec les premiers coefficients de fourier de la fonction ff, d'abord les coefficients correspondant aux cosinus.

Que produit la commande [n^2 for n in range(10)] ?

[f.fourier_series_cosine_coefficient(j,1) for j in range(10)]
[11, 00, 00, 00, 00, 00, 00, 00, 00, 00]
[f.fourier_series_sine_coefficient(j,1) for j in range(10)]
[0, 2/pi, 0, 2/3/pi, 0, 2/5/pi, 0, 2/7/pi, 0, 2/9/pi]

On voit clairement que les coefficients de la partie en cosinus sont tous (sauf le 0-ième) nuls, tandis que bn={0si n est pair2nπsi non b_n = \left\{\begin{array}{ll} 0 & \mbox{si } n \mbox{ est pair}\\ \frac{2}{n\pi}& \mbox{si non}  \end{array} \right.

Fourier = plot(f.fourier_series_partial_sum(6,1),x,-2,2,color='red', thickness=1) show(Fourier + CF, figsize = 4)
@interact def _(j=(2..30)): F = f.fourier_series_partial_sum(j,1) CourbeF=plot(F,-2,2,color='red', thickness=1) show(CF + CourbeF, figsize = 4)
Interact: please open in CoCalc

Exemple

On considère la fonction f(x)={xsi2x<0xsi0x2f(x) = \left\{ \begin{array}{ccc} -x & \mbox{si} & -2\leq x < 0 \\ x &\mbox{si} & 0\leq x\leq 2\end{array} \right.

f = piecewise([[(-2,0),-x],[(0,2),x]]) CF = plot(f, thickness=2,figsize=5) show(CF)
[f.fourier_series_cosine_coefficient(j,2) for j in range(10)]
[2, -8/pi^2, 0, -8/9/pi^2, 0, -8/25/pi^2, 0, -8/49/pi^2, 0, -8/81/pi^2]
[f.fourier_series_sine_coefficient(j,2) for j in range(10)]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Fourier = plot(f.fourier_series_partial_sum(3,2),x,-2,2,color='red', thickness=1) show(Fourier + CF)

Exemple

Voyons un phénomène intéressant :  on s'intéresse à la fonction f(x)=xf(x)=x, sur l'intervalle [0,1][0,1]. Le domaine de la fonction n'est pas symétrique. Que faire? Comment définir la fonction ff sur [1,0][-1,0]? Il y a quelques choix plus ou moins naturels: 

  1. On pourrait poser f(x)f(x)=0 sur [1,0][-1,0].
  2. On pourrait prolonger ff de sorte à obtenir une fonction paire, ou
  3. On pourrait obtenir ff de sorte à obtenir une fonction impaire.

Voyons les deux dernières options, ce qui est à noter c'est que la série qui correspond au prolongement pair de la fonction converge beuacoup plus rapidement.

f1(x)=-x f2(x)=x f = piecewise([[(-1,0),f1],[(0,1),f2]]) g= piecewise([[(-1,0),f2],[(0,1),f2]]) Cf=plot(f, color='blue') Cg=plot(g, color='green') show(Cf+Cg,aspect_ratio=1,figsize=5)
@interact def _(j=(2..30)): F = f.fourier_series_partial_sum(j,1) CourbeF=plot(F,-2,2,color='red', thickness=1) show(Cf + CourbeF, aspect_ratio=1,figsize=6) G = g.fourier_series_partial_sum(j,1) CourbeG=plot(G,-2,2,color='red', thickness=1) show(Cg+CourbeG,aspect_ratio=1,figsize=6)
Interact: please open in CoCalc

Afin de voir pourquoi, calculons quelques coefficients:

Attention, ici ce sont les coefficients de la fonction originale.
[f.fourier_series_cosine_coefficient(j,1) for j in range(10)]
[11, 4π2-\frac{4}{\pi^{2}}, 00, 49π2-\frac{4}{9 \, \pi^{2}}, 00, 425π2-\frac{4}{25 \, \pi^{2}}, 00, 449π2-\frac{4}{49 \, \pi^{2}}, 00, 481π2-\frac{4}{81 \, \pi^{2}}]
[g.fourier_series_sine_coefficient(j,1) for j in range(10)]
[00, 2π\frac{2}{\pi}, 1π-\frac{1}{\pi}, 23π\frac{2}{3 \, \pi}, 12π-\frac{1}{2 \, \pi}, 25π\frac{2}{5 \, \pi}, 13π-\frac{1}{3 \, \pi}, 27π\frac{2}{7 \, \pi}, 14π-\frac{1}{4 \, \pi}, 29π\frac{2}{9 \, \pi}]

On voit bien, dans le prolongement pair, il y a un terme en 1n2\displaystyle \frac{1}{n^2}, tandis que pour le prolongement impair c'est de l'ordre de 2n\displaystyle\frac{2}{n}...

Exemple : On considère une tige de longueur =50cm\ell = 50 cm, à l'instant initial, elle a une température constante égale à 2020^\circ. Pour étudier la température on doit résoudre {ut=α22ux2u(0,t)=0u(l,t)=0u(x,0)=20\left\{\begin{array}{lcl} \frac{\partial u}{\partial t} & = & \alpha^2 \frac{\partial^2 u}{\partial x^2}\\ u(0,t) & = & 0\\ u(l,t) & = & 0\\ u(x,0)& =& 20^\circ \end{array} \right.  

Supposons α2=1\alpha^2 =1.

var('x,t')
(xx, tt)

[ u(x,t) = \frac{40}{\pi} \sum_{n=1}^{\infty}\frac{(1-(-1)^n)}{n}\sin \left(\frac{n\pi x}{50} \right) e^{-\left(\frac{n\pi}{50}\right)^2 t} ]

U=[1/n*(1-(-1)^n)*sin(n*pi*x/50)*exp(-(n^2*pi^2/50^2)*t) for n in range(1,71)]
u(x,t)=40/pi*sum(U)
cmsel = [colormaps['autumn'](i) for i in sxrange(0,1,0.05)] plot3d(u,(x,0,50),(t,0,500),adaptive=True, color=cmsel, frame_aspect_ratio=[10,1,10])
3D rendering not yet implemented

Exemple :  Sur la région R=[0,3]×[0,2]\mathcal{R}=[0,3]\times[0,2] on cherche à résoudre l'équation de Laplace 2u=0\nabla^2 u =0 avec les conditions de Dirichlet u(x,0)=0u(0,y)=0u(x,2)=0u(3,y)=f(y)\begin{darray}{rcl} u(x,0) & = & 0 \\ u(0,y)& =& 0\\ u(x,2) & = & 0 \\ u(3,y)& = & f(y)\end{darray}

La fonction ff est définie par f(y)={ ysi0y1 2ysi1y2f(y) = \left\{\begin{array}{lcl}  y &\mbox{si} & 0\leq y \leq 1  \\ 2-y & \mbox{si} & 1 \leq y \leq 2 \end{array} \right.

Solution : Il a été vu en classe que la solution est donnée par u(x,y)=n=18n2π2sin(nπ2)sinh(3nπ2)sinh(nπx2)sin(nπy2)u(x,y) = \sum_{n=1}^\infty \frac{8}{n^2\pi^2}\cdot \frac{\sin{\left(\frac{n\pi}{2}\right)}}{\sinh\left(\frac{3n\pi}{2}\right)}\cdot \sinh{\left(\frac{n\pi x}{2}\right)} \cdot \sin{\left(\frac{n\pi y}{2}\right)}

var('x,y') U=[1/n^2 * sin(n*pi/2) *sinh(n*pi*x/2) * sin(n*pi*y/2)/sinh(3*n*pi/2) for n in range (1,20)]
(xx, yy)
u(x,y)=(8/pi^2)*sum(U) cmsel = [colormaps['hot'](i) for i in sxrange(0,1,0.05)] plot3d(u,(x,0,3),(y,0,2),adaptive=True, color=cmsel,frame_aspect_ratio=[1,1,1])
3D rendering not yet implemented

Exemple : Résoudre l'équation d'onde utt=4uxxu_{tt} = 4 u_{xx},  (donc c=2c=2) pour une corde de longueur =30cm\ell = 30cm avec conditions u(x,0)=f(x)={x/10si0x10$30x)/20si10<x30.u(x,0)=f(x)=\left\{\begin{array}{lcl}x/10 & \mbox{si} & 0\leq x \leq 10$30-x)/20 & \mbox{si} & 10<x\leq 30. \end{array}\right.

Solution : Il a été établi en classe que la solution est u(x,t)=n=1Ansinnπx30cos2nπt30u(x,t) = \sum_{n=1}^\infty A_n \sin{\frac{n\pi x}{30}}\cos{\frac{2n\pi t}{30}} où les AnA_n sont les coefficients de la série de Fourier en sinus de la fonction ff sur [0,30][0,30].

f = piecewise([[(0,10),x/10],[(10,30),(30-x)/20]])
[f.fourier_series_sine_coefficient(j,30) for j in range(10)]
<string>:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details.
[00, 934π2\frac{9 \, \sqrt{3}}{4 \, \pi^{2}}, 9316π2\frac{9 \, \sqrt{3}}{16 \, \pi^{2}}, 00, 9364π2-\frac{9 \, \sqrt{3}}{64 \, \pi^{2}}, 93100π2-\frac{9 \, \sqrt{3}}{100 \, \pi^{2}}, 00, 93196π2\frac{9 \, \sqrt{3}}{196 \, \pi^{2}}, 93256π2\frac{9 \, \sqrt{3}}{256 \, \pi^{2}}, 00]
U=[1/n^2 * sin(n*pi*x/30)*cos(2*n*pi*t/30)*sin(n*pi/3) for n in range (1,20)] u(x,t)=9/pi^2*sum(U) cmsel = [colormaps['hot'](i) for i in sxrange(0,1,0.05)] plot3d(u,(x,0,30),(t,0,40),adaptive=True, color=cmsel, frame_aspect_ratio=[1,1,10])
3D rendering not yet implemented
F1=[plot(u(x,n),(x,0,30),color='red') for n in range(10)] show(sum(F1), figsize=4)

On voit ici quelle est la forme que la corde épouse à différents moments. L'onde se déplace vers la droite.