1
$\begingroup$

I already know that there are built-in functions to compute the Fourier coefficients but I want to derive their formulas manually. In fact, I want to obtain the final well-known formulas for the coefficients with Mathematica carrying a step by step approach. Like the way we do on paper by hand.

So I consider an arbitrary function $f(x)$. I want to start with the known equation

$$f(x)=a_0+\sum _{i=1}^n \left[a_i \cos \frac{i\,\pi}{L} x +b_i \sin \frac{i\, \pi}{L} x \right] \tag{1}$$

and then use the orthogonality relations of trigonometric functions over $[-L,L]$ to derive $a_i$ and $b_i$. Specifically, the steps are

  1. Multiplying by $\cos \frac{j\,\pi}{L} x$ and $\sin \frac{j\,\pi}{L} x$.
  2. Integrating over $[-L,L]$.
  3. Using orthogonality relations.
  4. Finding coefficients.

As I am new to Mathematica I do not know that what is the best way to proceed.

This is my little effort. But I don't know how to simplify further. I need to distribute the integration over summations and get any constant out of the integrals. Then I should use orthogonality and finally I should find the coefficients $a_i$.

Any hint or help is appreciated. :)

Eq = f[x] == Subscript[a, 0] + Sum[Subscript[a, i]*Cos[((i*Pi)/L)*x] + 
      Subscript[b, i]*Sin[((i*Pi)/L)*x], {i, 1, n}]
For[i = 1, i <= 2, i++,
Eq[[i]] = Inactive[Integrate][Cos[(j \[Pi])/L x] Eq[[i]], {x, -L, L}];
]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ I recently implemented it and compared to the built-in commands, but I did it for the Discrete Fourier Transform (DFT) as explained in dspguide.com/CH8.PDF Let me know if you are interested in this case, $\endgroup$ Mar 17, 2016 at 17:20

1 Answer 1

1
$\begingroup$

How do you want to "use" orthogonality relation? There is a straightforward formula for a and b Here is a formula for a

A[f_, n_, L_] := 1/L Integrate[(f[x]) Cos[Pi x n /L], {x, -L, L}];

So here are your first ten coefficients for an "arbitrary" function:

f[x_] := Cos[Pi x/L] + 8 Cos[4 Pi x/L];
Table[A[f, i, L], {i, 0, 10}]
(*{0, 1, 0, 0, 8, 0, 0, 0, 0, 0, 0}*)
$\endgroup$
7
  • $\begingroup$ (+1) Thanks for the attention. I know the final formula but I want to obtain it by Mathematica. :) $\endgroup$ Mar 17, 2016 at 17:13
  • $\begingroup$ The formula comes directly from definition of metrics. When you call something orthogonal you do this in regards to the metrics (or inner product definition). You can ask Mathematica to check if selected set of functions is orthogonal in regards to metrics. $\endgroup$
    – BlacKow
    Mar 17, 2016 at 17:17
  • $\begingroup$ As I stated in my question, I want to start from $(1)$, do the regular arithmetic that we both know and obtain $a_i$ and $b_i$. That is all I want. But I just want to write a code for it. :) $\endgroup$ Mar 17, 2016 at 17:18
  • $\begingroup$ My A does precisely (1) and (2). You want to see intermediate steps how Mathematica figured out the integral "used orthogonality"? $\endgroup$
    – BlacKow
    Mar 17, 2016 at 17:22
  • 1
    $\begingroup$ I kinda see what you want... You want some sort of analytical proof made by Mathematica.. I'm not sure if it's a good tool for that. I will be interested to see other answers. $\endgroup$
    – BlacKow
    Mar 17, 2016 at 17:30

Your Answer

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

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