Skip to main content
Engineering LibreTexts

6.2: Conversion of Function

  • Page ID
    121978
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)
    1. Representing Complex Periodic Waveform
      1. Exercise \(\PageIndex{1}\)

        If \(y(t)\) is given, the how could one determine amplitudes \(C_{i}\) and phases \(\phi_{i}\) in the summation?

        Answer

        Calculate the Fourier Coefficients

      2. Assume that \(y(t)\) is periodic
        1. \(y(t) = y(t+T)\): repeats at fundamental period \(T\)
        2. Period relates to cyclic and circular frequency: \(T_{1} = \frac{1}{f_{1}}= \frac{2\pi}{\omega_{1}}\)
      3. Rather than trying to calculate phase, separate amplitude coefficient into trigonometric series \[y(t) = \frac{A_{0}}{2} + \sum_{n=1}^{\infty}\left(A_{n}\cos\left(n\omega t\right) + B_{n}\sin\left(n\omega t\right)\right) \] \[y(t) = \frac{A_{0}}{2} + \sum_{n=1}^{\infty}\left(A_{n}\cos(n\frac{2\pi}{T} t) + B_{n}\sin(n\frac{2\pi}{T} t)\right) \] where subscripts of coefficients \(A_{i}\) and \(B_{i}\) correspond to integer values of \(n=\{1,2,3,\ldots\}\). [In other words, there is no such thing as \( A_{1.42}\)]
      4. Integrating the original periodic signal over its fundamental period provides the mean value \[ A_{0} = \frac{2}{T}\int_{-T/2}^{T/2} y(t) dt \] or \[ A_{0} = \frac{2}{T}\int_{0}^{T} y(t) dt \] where the user gets to define which period range is easier to integrate
      5. If the original function \(y(t)\) is multiplied by orthogonal periodic form and integrated over the fundamental period: \[\int_{0}^{T} y(t) \cos(m \omega t)dt = A_{0} \int_{0}^{T} \cos(m \omega t)dt + \sum_{n}A_{n}\int_{0}^{T} \cos(n\omega t)\cos(m \omega t)dt +B_{n}\int_{0}^{T} \sin(n\omega t)\cos(m \omega t)dt \]
        1. First integral is multiplying the mean value \(A_{0}\) by integration of full period; hence result becomes zero
        2. Last term is multiple of \(\sin\) and \(\cos\) which are out of phase with one another AND a full period; also goes to zero value
        3. Middle term becomes zero value when frequencies don't match: \(m\neq n\)
        4. Remaining result becomes \(\cos^{2}\) when \(m=n\) which eventually integrates to simple value of \(\frac{T}{2}\)
        5. Allows for direct calculation of discrete coefficients \[ A_{n} = \frac{2}{T}\int_{0}^{T} y(t)\cos(n \omega t) dt \] \[A_{n} = \frac{2}{T}\int_{-T/2}^{T/2} y(t)\cos(n\frac{2\pi}{T} t) dt \] where user selects range of period or argument form that is easiest to integrate
        6. Similar form applies to the \(\sin\) function to get \(B_{n}\) \[ B_{n} = \frac{2}{T}\int_{0}^{T} y(t)\sin(n\frac{2\pi}{T} t) dt \] \[ B_{n} = \frac{2}{T}\int_{-T/2}^{T/2} y(t)\sin(n\omega t) dt \]
        7. usually will be given \(y(t)\) or build from graph (including piecewise function) to then get values of \(A_{n}\) and \(B_{n}\) that includes \(n\) as TBD integer value
      6. Important frequency terms
        1. fundamental harmonic is the \(n=1\); represents the maximum full period \(T\) of the original signal
        2. increasing \(n\) are subsequent harmonics that increase frequency by integer multiples and decrease amplitude
    2. Special Cases of Fourier Series
      1. Even functions (will be cosine only)
        1. definition of even function is \(g(t)=g(-t)\)
        2. same as when considering \(\cos(-n\omega t) = \cos(n \omega t)\)
        3. like bouncing away from mean value in same direction from \(t=0\)
        4. all \(B_{n} = 0\)
        5. thus, simplified form \[ y(t) = A_{0} + \sum_{n=1}^{\infty} A_{n}\cos(n\omega t) \]
      2. Odd functions (will be sine only)
        1. definition of odd function is \(-h(t)=h(-t)\)
        2. same as when considering \(\sin(-n\omega t) = -\sin(n \omega t)\)
        3. function moves in opposite directions from \(t=0\)
        4. all \(A_{n} = 0\)
        5. thus, simplified form \[ y(t) = A_{0} + \sum_{n=1}^{\infty} B_{n}\sin(n\omega t) \]
      3. If neither even or odd, then Fourier Series can contain both \(A_{n}\) and \(B_{n}\)
        1. Yet still a way to solve more simply \(\ldots\) through phase shift
        2. To make sine or cosine only \[y(t) = A_{0} + \sum_{n=1}^{\infty} C_{n}\cos(n\omega t- \phi_{n}) \] \[y(t) = A_{0} + \sum_{n=1}^{\infty} C_{n}\sin(n\omega t+ \phi_{n}^{*}) \]
        3. Same trig identity rules apply \[C_{n} = \sqrt{A_{n}^{2}+B_{n}^{2}} \] \[
          \phi_{n} = \tan^{-1}(\frac{B_{n}}{A_{n}}) \] \[ \phi_{n}^{*} = \tan^{-1}(\frac{A_{n}}{B_{n}}) \]
        4. but impossible to know \(\phi_{n}\) in advance
        5. UNLESS use the phase shift in time \[ C_{n} = \frac{2}{T}\int_{0}^{T} y(t\pm t_{0})\cos\left(n \omega \left[t\pm t_{0}\right]\right) dt \] \[\phi_{n}= \pm n\omega t_{0} \]
    Exercise \(\PageIndex{1}\)

    Consider a 33% duty cycle signal with phase offset shown below. Determine the Fourier Coefficients and then show a plot with the signal produced up to the \(4^{\mathrm{th}}\) and \(10^{\mathrm{th}}\) harmonic.

    Fourier 33-percent duty.png

    Answer

    The piecewise function will have the following form: \[
    y(t) = \left\{\begin{array}{lr} -1 & -0.01\leq t < 0.03 \\ 4 & 0.03\leq t <0.05 \end{array} \right. \]
    The mean value \(A_{0}\) is the average over the period \(T=0.06\] sec which would be \[A_{0} = \frac{2}{0.06}\left(\int_{-0.01}^{0.03} -1 dt + \int_{0.03}^{0.05} 4 dt\right) \] \[A_{0} = \frac{2}{0.06} (-1(0.03+0.01)+4(0.05-0.03)) = 1.33 \]

    The coefficients for the sine and cosine terms will be \[ A_{n} = \frac{2}{0.06}\left(\int_{-0.01}^{0.03}-1 \cos\left(\frac{2\pi n t}{0.06}\right)dt +\int_{0.03}^{0.05}4 \cos\left(\frac{2\pi n t}{0.06}\right)dt\right) \]\[A_{n} = \frac{1}{\pi n}\left(-\sin\left(\frac{2\pi n t}{0.06}\right|_{-0.01}^{0.03}+ 4\sin\left(\frac{2\pi n t}{0.06}\right|_{0.03}^{0.05}\right)\] \[A_{n} = \frac{1}{\pi n}\left(-5\sin\left(\pi n\right)+\sin\left(-\pi n/3\right)+4\sin\left(\frac{10\pi n}{6}\right)\right) \]

    \[B_{n} = \frac{2}{0.06}\left(\int_{-0.01}^{0.03}-1 \sin\left(\frac{2\pi n t}{0.06}\right)dt +\int_{0.03}^{0.05}4 \sin\left(\frac{2\pi n t}{0.06}\right)dt\right) \] \[B_{n} = \frac{1}{\pi n}\left(\cos\left(\frac{2\pi n t}{0.06}\right|_{-0.01}^{0.03}- 4\cos\left(\frac{2\pi n t}{0.06}\right|_{0.03}^{0.05}\right)\] \[B_{n} = \frac{1}{\pi n}\left(5\cos\left(\pi n\right)-\cos\left(-\pi n/3\right)-4\cos\left(\frac{10\pi n}{6}\right)\right) \]

    The Matlab code for recreating the Fourier series is included in the in-class examples.

    Possibly include? Consider the other option of phase shifting the signal:
    \begin{eqnarray}
    y(t-0.03) = \left\{\begin{array}{lr} -1 & -0.04\leq (t-0.03) < 0.0 \\ 4 & 0.0\leq (t-0.03) <0.02 \end{array} \right. \nonumber
    \end{eqnarray}
    The integration then becomes a little easier:
    \begin{eqnarray}
    C_{n} =& \frac{2}{0.06}\left(\int_{-0.04}^{0.0}-1 \cos\left(\frac{2\pi n t}{0.06}\right)dt +\int_{0.0}^{0.02}4 \cos\left(\frac{2\pi n t}{0.06}\right)dt\right) \nonumber \\
    C_{n} =& \frac{1}{\pi n}\left(-\sin\left(\frac{2\pi n t}{0.06}\right|_{-0.04}^{0.0}+ 4\sin\left(\frac{2\pi n t}{0.06}\right|_{0.0}^{0.02}\right)\nonumber \\
    C_{n} =& \frac{1}{\pi n}\left[0+\sin\left(2\pi n\left(-\frac{2}{3}\right)\right)+4\sin\left(2\pi n \left(\frac{1}{3}\right)\right)-0\right] \nonumber
    \end{eqnarray}
    where the unique phase will be \(\phi_{n} = \frac{2\pi n}{0.06}(-0.03)\) which would recreate the correct \(A_{n}\) and \(B_{n}\) coefficients

    Example Matlab Code

    To reproduce Fourier Series displaying the updated signal as harmonic \(n\) increases:

    clear all; close all;
     
    % Defining signal over period with display
    t = [0,3,3,5,5,6]/100;
    T = max(t)-min(t);
    V = [-1,-1,4,4,-1,-1];
    plot(t,V,'r-','LineWidth',2.5)
    hold on;
    set(gca,'FontSize',14,'XTick',[-8:2:8]/100,'TickLength',[0.035,0.025],'XMinorTick','on','YMinorTick','on','GridLineStyle','--');
    xlabel('t (sec)');
    ylabel('y(t) (cm)');
    axis([-T*1-.5/100,1.5*T+.5/100,-1.5,4.5])
    grid on
    for i = [-2,-1,1,2]
    plot(t+i*T,V,'r-','LineWidth',2.5);
    end
    pause;
     
    % Create time domain array of the estimating signal
    ts = [-8:.01:10]/100;
    yt = 2/3*ones(size(ts));
    h = plot(ts,yt,'k','Linewidth',2.0);
     
    % Repeat calculation of coefficients at higher harmonics
    for i = 1:1:30
    BB = 1/(pi*i)*(5*cos(pi*i)-cos(-pi*i/3)-4*cos(10*pi*i/6))
    AA = 1/(pi*i)*(-5*sin(pi*i)+sin(-pi*i/3)+4*sin(10*pi*i/6))
    % sum with prior signal
    yt = yt + AA*cos(2*pi*i*ts/T)+BB*sin(2*pi*i*ts/T);
    % display updating result
    set(h,'Ydata',yt);
    title(['Harmonic n = ',num2str(i)])
    drawnow;
    if(i==4 | i==10)
    pause
    else
    pause(0.1)
    end
    end
     

    6.2: Conversion of Function is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?