Provides methods to compute Fourier series.
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.
See also
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
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 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
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
Computes Fourier sine/cosine series expansion.
Returns a FourierSeries object.
See also
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