Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2014-02-20 02:21:17

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Fourier series

Hi;

At the request of Agnishom, this thread will now deal with Fourier series and how to do them using your package.

We will start with the simple y = x between -π and π.

We have the equations:

f[x_] := x;
a[n_] := 1/\[Pi] Integrate[f[x] Cos[n*x], {x, -\[Pi], \[Pi]}]
b[n_] := 1/\[Pi] Integrate[f[x] Sin[n*x], {x, -\[Pi], \[Pi]}]

a[0],a[1],...a[4] will all be 0

b[0] = 0
b[1] = 2
b[2] = -1
b[3] = 2 / 3
b[4] = - 1 / 2

So the Fourier series is

b[0] + b[1] Sin[x] + b[2] Sin[2 x] + b[3] Sin[3 x]+b[4] Sin[4x]

Plot[{2 Sin[x] - Sin[2 x] + 2/3 Sin[3 x] - 1/2 Sin[4 x], 
  x}, {x, -\[Pi], \[Pi]}]

In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#2 2014-02-20 02:54:00

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

Hmm

(%i1) load(fourie)$

(%i2) f(x) = y$

(%i3) fourier(f,x,1);
(%t3)                               a  = f
                                     0

                                   2 f sin(%pi n)
(%t4)                         a  = --------------
                               n       %pi n

(%t5)                               b  = 0
                                     n

(%o5)                           [%t3, %t4, %t5]

EDIT: Sorry, I did not see the edited portion of your last post, the last time

Last edited by Agnishom (2014-02-20 02:55:48)


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#3 2014-02-20 02:59:09

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Please use Mathematica else we will get confused over differences in packages. Also follow what I did in post 1 so that you can see the workings.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#4 2014-02-20 03:03:03

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

bobbym wrote:

We have the equations:

f[x_] := x;
a[n_] := 1/\[Pi] Integrate[f[x] Cos[n*x], {x, -\[Pi], \[Pi]}]
b[n_] := 1/\[Pi] Integrate[f[x] Sin[n*x], {x, -\[Pi], \[Pi]}]
(%i1) f(x) := x$

(%i2) a(n) := (1/%pi)*(integrate(f(x)*cos(n*x),x,-%pi,%pi))$

(%i3) b(n) := (1/%pi)*(integrate(f(x)*sin(n*x),x,-%pi,%pi))$

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#5 2014-02-20 03:04:06

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

bobbym wrote:

Please use Mathematica else we will get confused over differences in packages. Also follow what I did in post 1 so that you can see the workings.

OK, sorry for the confusion. I will do that when I get a chance to reboot.


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#6 2014-02-20 03:06:22

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Hi;

This is what it looks like.

View Image: 2014-02-20_062517.gif

In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#7 2014-02-20 03:20:43

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

I will do the Mathematica part once I reboot. For now, Is this ok?

(%i1)  f(x) := x$

(%i2) a(n) := (1/%pi)*(integrate(f(x)*cos(n*x),x,-%pi,%pi))$

(%i3) b(n) := (1/%pi)*(integrate(f(x)*sin(n*x),x,-%pi,%pi))$

(%i4) b(0) + b(1)*sin(x) + b(2)*sin(2*x) + b(3)*sin(3*x)+b(4)*sin(4*x);
                   sin(4 x)   2 sin(3 x)
(%o4)            - -------- + ---------- - sin(2 x) + 2 sin(x)
                      2           3
(%i5) print("Hmmm");
Hmmm 
(%o5)                                Hmmm
(%i6) plot2d (%o4, [x, -%pi, %pi])$

The image is attached

View Image: toothsaw.jpg

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#8 2014-02-20 03:26:02

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

That looks okay, very good.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#9 2014-02-20 03:35:02

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

a[0],a[1],...a[4] will all be 0

So, why calculate any of them? Why declare the a[n_] function at all?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#10 2014-02-20 03:38:43

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Because most of the time they will not be 0. Usually there are cos and sin terms.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#11 2014-02-20 03:44:13

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

What does a fourier series look like without the sigma notaiton


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#12 2014-02-20 03:54:28

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Sigma notation was not used. That is a fine point. It looks like a big polynomial except powers of x are replaced with trig functions.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#13 2014-02-20 04:16:36

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

Show me one such poly please.

By the way, the attached image looks interesting.

(%i12) b(0);(%o12)                                 0
(%i13) b(0) + b(1)*sin(x)
;
(%o13)                             2 sin(x)
(%i14) b(0) + b(1)*sin(x) + b(2)*sin(2*x);
(%o14)                        2 sin(x) - sin(2 x)
(%i15) b(0) + b(1)*sin(x) + b(2)*sin(2*x) + b(3)*sin(3*x);
                       2 sin(3 x)
(%o15)                 ---------- - sin(2 x) + 2 sin(x)
                           3
(%i16) b(0) + b(1)*sin(x) + b(2)*sin(2*x) + b(3)*sin(3*x)+b(4)*sin(4*x);                   sin(4 x)   2 sin(3 x)
(%o16)           - -------- + ---------- - sin(2 x) + 2 sin(x)
                      2           3
(%i17) b(0) + b(1)*sin(x) + b(2)*sin(2*x) + b(3)*sin(3*x)+b(4)*sin(4*x)+b(5)*sin(5*x);
           2 sin(5 x)   sin(4 x)   2 sin(3 x)
(%o17)     ---------- - -------- + ---------- - sin(2 x) + 2 sin(x)
(%i22) plot2d ([%o12,%o13,%o14,%o15,%o16,%o17,f], [x, -%pi, %pi],[box, false])$

I remember that M has an Animate command that could produce a cooler animation

View Image: fourier_series.jpg

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#14 2014-02-20 04:25:08

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Hi;

I did not say that they were polynomials, they just look like them.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#15 2014-02-20 04:36:49

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

Why is this not a polynomial?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#16 2014-02-20 04:42:06

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

A polynomial is an expression made up of integer powers of x.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#17 2014-02-20 05:26:03

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

Non-negative inteher


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#18 2014-02-20 05:32:23

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Yes, that is correct.

Tomorrow we will try another.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#19 2014-02-20 13:15:07

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

It should have been integer rather than inteher.

Tomorrow with respect to whom?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#20 2014-02-20 13:50:34

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

For you of course.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#21 2014-02-20 14:39:49

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

OK, it is now tomorrow with respect to me


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#22 2014-02-20 14:59:00

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Yes, I need some time to prepare another example. Also, I am making dinner.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#23 2014-02-20 15:09:37

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

Will you feed me tonight?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

#24 2014-02-20 15:11:10

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,159

Re: Fourier series

Of course, ever had pizza?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#25 2014-02-20 15:17:13

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,308
Website

Re: Fourier series

Of course, do you know what a gel candle is?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Offline

Board footer

Powered by FluxBB