# Fourier Series¶

Provides methods to compute Fourier series.

class sympy.series.fourier.FourierSeries[source]

Represents Fourier sine/cosine series.

This class only represents a fourier series. No computation is performed.

For how to compute Fourier series, see the fourier_series() docstring.

scale(s)[source]

Scale the function by a term independent of x.

f(x) -> s * f(x)

This is fast, if Fourier series of f(x) is already computed.

Examples

>>> from sympy import fourier_series, pi
>>> from sympy.abc import x
>>> s = fourier_series(x**2, (x, -pi, pi))
>>> s.scale(2).truncate()
-8*cos(x) + 2*cos(2*x) + 2*pi**2/3

scalex(s)[source]

Scale x by a term independent of x.

f(x) -> f(s*x)

This is fast, if Fourier series of f(x) is already computed.

Examples

>>> from sympy import fourier_series, pi
>>> from sympy.abc import x
>>> s = fourier_series(x**2, (x, -pi, pi))
>>> s.scalex(2).truncate()
-4*cos(2*x) + cos(4*x) + pi**2/3

shift(s)[source]

Shift the function by a term independent of x.

f(x) -> f(x) + s

This is fast, if Fourier series of f(x) is already computed.

Examples

>>> from sympy import fourier_series, pi
>>> from sympy.abc import x
>>> s = fourier_series(x**2, (x, -pi, pi))
>>> s.shift(1).truncate()
-4*cos(x) + cos(2*x) + 1 + pi**2/3

shiftx(s)[source]

Shift x by a term independent of x.

f(x) -> f(x + s)

This is fast, if Fourier series of f(x) is already computed.

Examples

>>> from sympy import fourier_series, pi
>>> from sympy.abc import x
>>> s = fourier_series(x**2, (x, -pi, pi))
>>> s.shiftx(1).truncate()
-4*cos(x + 1) + cos(2*x + 2) + pi**2/3

truncate(n=3)[source]

Returns the first n (non-zero)terms of the series.

If n is None returns an iterator.

sympy.series.fourier.fourier_series(f, limits=None)[source]

Computes Fourier sine/cosine series expansion.

Returns a FourierSeries object.

Notes

Computing Fourier series can be slow due to the integration required in computing an, bn.

It is faster to compute Fourier series of a function by using shifting and scaling on an already computed Fourier series rather than computing again.

e.g. If the Fourier series of x**2 is known the Fourier series of x**2 - 1 can be found by shifting by -1.

References

 [R431] mathworld.wolfram.com/FourierSeries.html

Examples

>>> from sympy import fourier_series, pi, cos
>>> from sympy.abc import x

>>> s = fourier_series(x**2, (x, -pi, pi))
>>> s.truncate(n=3)
-4*cos(x) + cos(2*x) + pi**2/3


Shifting

>>> s.shift(1).truncate()
-4*cos(x) + cos(2*x) + 1 + pi**2/3
>>> s.shiftx(1).truncate()
-4*cos(x + 1) + cos(2*x + 2) + pi**2/3


Scaling

>>> s.scale(2).truncate()
-8*cos(x) + 2*cos(2*x) + 2*pi**2/3
>>> s.scalex(2).truncate()
-4*cos(2*x) + cos(4*x) + pi**2/3


Sequences

#### Next topic

Formal Power Series