It is easy to find the fourier coefficient and fourier expansion of $f(x)$ function.

But I want solve the inverse problem by using Mathematica

How to find the function $f(x)$, if I know its fourier coefficient (or fourier expantion)?

for example:



$$a_0=\frac{1}{6}$$ or


I tried:

Simplify[1/6 - Sum[Cos[2 x Pi n]/(Pi n)^2, {n, 1, Infinity}]]

enter image description here

Plot[%, {x, -3, 3},PlotRange -> 1]

enter image description here

this is a fourier series of $f(x)=x(1-x).$ with $0 \leq x \leq 1$

but how can I get $x(1-x)$ from $\frac{1}{6}-\sum_{n=1}^{\infty}\frac{\cos2xn\pi}{(n\pi)^2}$?

or in other word,

How to solve the system of integral equations for $f(x)$ by using Mathematica?

$$ \begin{cases} \int_{a}^{b}f(x)dx=conts.\\ \int_{a}^{b}f(x)\sin(n x)dx=A(n)\\ \int_{a}^{b}f(x)\cos(n x)dx=B(n) \end{cases} $$

| improve this question | | | | |

Note that the expression returned by Sum is correct and equals $x(1-x)$ for $0 \leq x \leq 1$.

I assume your question is how to simplify the expression into $x(1-x)$?

I was able to hack a solution, and unfortunately I don't think it scales very well to other expressions. But here goes:

First, evaluate the sum:

sum = 1/6 - Sum[Cos[2 x Pi n]/(Pi n)^2, {n, 1, Infinity}];

Non rigorous approach

If you don't care about complete rigor and abuse some mathematical rules, we can get your answer very easily:

1 - (1 - x)^2 - x

Rigorous approach

If you want to be 100% sure things are correct, you need to give PowerExpand your assumptions:

rigor = PowerExpand[FunctionExpand[sum], Assumptions -> 0 < x < 1]

enter image description here

Ok, gross. Here's where Mathematica starts to have a hard time and we need to explicitly tell it what to do :(

Seeing all the Floor[], maybe we should express it as a piecewise function, and simplify each part separately. This will hopefully get rid of all the Floor[]:

rigor = FullSimplify[PiecewiseExpand[rigor, 0 < x < 1]]

enter image description here

Now, we see we are left with Arg. The system seems to have a hard time dealing with Arg, so I transform the relations in terms of Re and Im:

rigor = rigor /. {
 Arg[expr_] <= 0 :> (ComplexExpand[Im[expr] < 0 || Im[expr] == 0 && Re[expr] >= 0])

enter image description here

Finally, we want to simplify each piecewise condition with Reduce:

ReducePiecewise[expr_, x_, assum_: True] :=
    expr /. HoldPattern[Piecewise][l_, r___] :> 
      Piecewise[Transpose[{#1, Reduce[# && assum, x]& /@ #2}& @@ Transpose[l]], r], 

ReducePiecewise[rigor, x, 0 < x < 1]
-(-1 + x) x

In summary

Being a bit handwavy you get easily get your answer. To be completely rigorous takes a bit more work. I wanted to share my thought processes on coercing Mathematica to give us what we want when it gets stuck.

| improve this answer | | | | |
  • 1
    $\begingroup$ Here's the whole business in one line: Assuming[0 <= x <= 1, FullSimplify[FunctionExpand[FourierSequenceTransform[If[k == 0, 1/6, -(1/(2 (π k)^2))], k, x, FourierParameters -> {1, -2 π}]] // PowerExpand]] $\endgroup$ – J. M.'s technical difficulties Dec 19 '16 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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