I am working on the following Fourier series problem

f[x_] = Which[-1 < x < 0, 0, 0 < x < 1, x^2]
Plot[f[x], {x, -1, 1}]

enter image description here

a[n_] := (2/L)*Integrate[f[x]*Cos[2 n*Pi*x/L], {x, -L/2, L/2}]
a[0] := (1/L)*Integrate[f[x], {x, -L/2, L/2}]
b[n_] := (2/L)*Integrate[f[x]*Sin[2 n*Pi*x/L], {x, -L/2, L/2}]
F[x_, N_] := 
 a[0] + Sum[a[n]*Cos[2 n*Pi*x/L] + b[n]*Sin[2 n*Pi*x/L], {n, 1, N}]
p[N_, a_] := 
 Plot[Evaluate[F[x, N]], {x, -a, a}, PlotRange -> All, 
  PlotPoints -> 200]
L = 2;
f[x_] = If[x > 0, x^2, 0];
Simplify[%, n \[Element] Integers]
Table[F[0.1, k], {k, 0, 20}]
p[20, 1]

enter image description here

enter image description here

My question is how can I confirm Bessel's Inequality on Mathematica :

$$\frac{a_0^2}{2}+\sum_{n=1}^{\infty}(a_n^2+b_n^2)\leq \int_{-L}^{L} f^2(x) \,dx $$ where $a_n,b_n$ are the coefficients of the Fourier series of the piecewise continuous function on the interval $[-L,L]$


1 Answer 1


One of the functions were not properly defined: $f(x)$

Fixing that you can create Bessels inequality in Wolfram Language:

(a[0]^2)/2 + Sum[(a[n]^2 + b[n]^2), {n, 1, Infinity}] <= Integrate[f[x]^2, {x, -L, L}]

This should work as long as the summation in WL can be reduced to a number. However, I haven't looked into if that is true.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.