2

I am trying to solve for the coefficients in the fourier series between $0$ and $\pi$.

$$ \sum_{n=1}^{\infty}\sum_{m=1}^{\infty}A_{nm}\sin(nx)\sin(mx) = 1 $$.

I determined the coefficients to be are as follows.

$$ A_{nm} = \frac{4}{\pi^2}\frac{(1-(-1)^n)(1-(-1)^m)}{nm} $$

However upon putting these into matlab I find that the coefficients are incorrect, as can be seen below.

graph not equalling 1 everywhere

How exactly would you go about determining the coefficients of this series?

finlay morrison
  • 303
  • 1
  • 7
  • Well, I'd at least include a DC term (a term with $m = n = 0$). I'd probably also include all the other terms with either $m = 0$ or $n = 0$ that you have excluded from your Fourier series. Then, the coefficients are all zero except for the $(m,n) = (0,0)$ coefficient, which is $1$. – Eric Towers Dec 13 '21 at 15:30
  • @EricTowers this problem arose when I was solving the heat equation in 2 dimensions and there isn't a constant term, it is just those sinusoids and the coefficients at when t=0 – finlay morrison Dec 13 '21 at 15:31
  • Then you have restricted away the solution. Either examine where your restriction comes from, or recognize you have left no possibility of solution. – Eric Towers Dec 13 '21 at 15:32
  • since I am solving in the range 0 to pi for it to equal 1 I would have thought that is possible since in the range -pi to 0 it would be equal to 0 and thus the average is 0 and there is no constant term. – finlay morrison Dec 13 '21 at 15:35
  • To rephrase: If your system must have zero temperature at the walls for all time, then there can be no net heat in the volume to diffuse to the walls. You say the volume is filled with uniform heating, but that none of that heat is allowed to diffuse to the walls... – Eric Towers Dec 13 '21 at 15:35
  • In fact, your plot already tells you this. Turn on time in that picture: the excess heat in the middle of the square region will diffuse radially outward to raise the temperature at the walls, until the heat is uniformly distributed. – Eric Towers Dec 13 '21 at 15:37
  • Yet another way to see this: $1$ is $1$ everywhere, including at the boundary. You cannot capture a function that is nonzero at the boundary as a linear combination of functions that are all zero at the boundary. – Eric Towers Dec 13 '21 at 15:39
  • When I run the time in the plot I have there the heat dissipates over time and the temperature just keeps decreasing, I have however found another stack exchange answer trying to answer just this so I will take a look at it. – finlay morrison Dec 13 '21 at 15:43
  • 1
    What precisely is the plot of? A finite sum? – Sal Dec 13 '21 at 16:24

1 Answers1

4

Your expression for the coefficients is fine, up to some constants. Taking $f(x)=1$, we have $$ \int _0^{\pi }dx\int _0^{\pi }dy\, \frac{2 }{\pi }\sin (n x) \sin (m y)f(x) = \frac{2 }{\pi }\frac{(\cos (\pi m)-1) (\cos (\pi n)-1)}{m n} = \frac{2 }{\pi }\frac{1-\left((-1)^m\right) \left(1-(-1)^n\right)}{m n}\,. $$ Then, when we reconstruct a truncation of the Fourier series, i.e., $$ \sum _{n=1}^N \sum _{m=1}^N \frac{2 }{\pi }\frac{1-\left((-1)^m\right) \left(1-(-1)^n\right)}{m n} \frac{2 }{\pi }\sin (n x) \sin (m x)\,, $$ we get an approximation of the constant-1 function. Below is some Mathematica code and the corresponding results. You can see that there is significant Gibbs ringing at the boundaries due to the discontinuity there (due to the mismatch between the boundary conditions of the function and of the basis functions), but otherwise, you can see that it's converging to 1.

This means that you must have something wrong in your MatLab code.

Simplify[Integrate[2/π Sin[n x] Sin[m y], {x, 0, π}, {y, 0, π}], {m, n} ∈ Integers]
u[x_] = Sum[% 2/π Sin[n x] Sin[m y], {n, 1, 20}, {m, 1, 20}];
Plot3D[u[x], {x, 0, π}, {y, 0, π}]

enter image description here

march
  • 1,267