// Numbas version: exam_results_page_options {"name": "Fourier series", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Fourier series", "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "

Consider the following periodic function

\n

\\[f(t)=\\left\\{\\matrix{\\simplify{{p}*t}&\\text{if }0\\leq t<\\pi\\\\\\var{q}&\\text{if }\\pi\\leq t<2\\pi}\\right.\\]

\n

where $f(t+2\\pi)=f(t)$.

", "advice": "

First calculate $a_0$ as the mean value of $f(t)$ over one period:

\n

\\[a_0=\\frac{1}{2}\\times\\var{p}\\times\\frac{\\pi}{2}+\\frac{1}{2}\\times\\var{q}=\\var{a0}\\]

\n

Now calculate the coefficients $a_n$:

\n

\\[a_n=\\frac{1}{\\pi}\\int_0^{2\\pi}f(t)\\cos(nt)\\;dt=\\frac{\\var{p}}{\\pi}\\int_0^\\pi t\\cos(nt)\\;dt+\\frac{\\var{q}}{\\pi}\\int_\\pi^{2\\pi}\\cos(nt)\\;dt\\]

\n

The first integral is performed by parts:

\n

\\[\\frac{\\var{p}}{\\pi}\\int_0^\\pi t\\cos(nt)\\;dt=\\frac{\\var{p}}{n\\pi}\\left[t\\sin(nt)\\right]_0^\\pi-\\frac{\\var{p}}{n\\pi}\\int_0^\\pi\\sin(nt)\\;dt=\\frac{\\var{p}}{n\\pi}\\left[t\\sin(nt)\\right]_0^\\pi+\\frac{\\var{p}}{n^2\\pi}\\left[\\cos(nt)\\right]_0^\\pi\\]

\n

Therefore

\n

\\[a_n=\\frac{\\var{p}}{n\\pi}\\left[t\\sin(nt)\\right]_0^\\pi+\\frac{\\var{p}}{n^2\\pi}\\left[\\cos(nt)\\right]_0^\\pi+\\frac{\\var{q}}{n\\pi}\\left[\\sin(nt)\\right]_\\pi^{2\\pi}\\]

\n

When $n$ is odd,

\n

\\[a_n=\\frac{\\var{p}}{n\\pi}\\left(0-0\\right)+\\frac{\\var{p}}{n^2\\pi}\\left(-1-1\\right)+\\frac{\\var{q}}{n\\pi}\\left(0-0\\right)=\\simplify{-2*{p}/(n^2*pi)}\\]

\n

And when $n$ is even,

\n

\\[a_n=\\frac{\\var{p}}{n\\pi}\\left(0-0\\right)+\\frac{\\var{p}}{n^2\\pi}\\left(1-1\\right)+\\frac{\\var{q}}{n\\pi}\\left(0-0\\right)=0\\]

\n

Therefore we obtain the following coefficients:

\n

\\[a_1=\\simplify{-2*{p}/pi}=\\var{a1}\\qquad a_2=0\\qquad a_3=\\simplify{-2*{p}/(3^2*pi)}=\\var{a3}\\]

\n

Now calculate the coefficients $b_n$:

\n

\\[b_n=\\frac{1}{\\pi}\\int_0^{2\\pi}f(t)\\sin(nt)\\;dt=\\frac{\\var{p}}{\\pi}\\int_0^\\pi t\\sin(nt)\\;dt+\\frac{\\var{q}}{\\pi}\\int_\\pi^{2\\pi}\\sin(nt)\\;dt\\]

\n

The first integral is performed by parts:

\n

\\[\\frac{\\var{p}}{\\pi}\\int_0^\\pi t\\sin(nt)\\;dt=-\\frac{\\var{p}}{n\\pi}\\left[t\\cos(nt)\\right]_0^\\pi+\\frac{\\var{p}}{n\\pi}\\int_0^\\pi \\cos(nt)\\;dt=-\\frac{\\var{p}}{n\\pi}\\left[t\\cos(nt)\\right]_0^\\pi+\\frac{\\var{p}}{n^2\\pi}\\left[\\sin(nt)\\right]_0^\\pi\\]

\n

Therefore

\n

\\[b_n=-\\frac{\\var{p}}{n\\pi}\\left[t\\cos(nt)\\right]_0^\\pi+\\frac{\\var{p}}{n^2\\pi}\\left[\\sin(nt)\\right]_0^\\pi+\\frac{\\var{-q}}{n\\pi}\\left[\\cos(nt)\\right]_\\pi^{2\\pi}\\]

\n

When $n$ is odd,

\n

\\[b_n=-\\frac{\\var{p}}{n\\pi}\\left(-\\pi-0\\right)+\\frac{\\var{p}}{n^2\\pi}\\left(0-0\\right)+\\frac{\\var{-q}}{n\\pi}\\left(1--1\\right)=\\simplify{{p}/n-2*{q}/(n*pi)}\\]

\n

And when $n$ is even,

\n

\\[b_n=-\\frac{\\var{p}}{n\\pi}\\left(\\pi-0\\right)+\\frac{\\var{p}}{n^2\\pi}\\left(0-0\\right)+\\frac{\\var{-q}}{n\\pi}\\left(1-1\\right)=\\simplify{-{p}/n}\\]

\n

Therefore we obtain the following coefficients:

\n

\\[b_1=\\simplify{{p}-2*{q}/pi}=\\var{b1}\\qquad b_2=\\simplify{-{p}/2}=\\var{b2}\\qquad b_3=\\simplify{{p}/3-2*{q}/(3*pi)}=\\var{b3}\\]

\n

The Fourier series for $f(t)$ (to the third harmonic) is:

\n

\\[f(t)=a_0+a_1\\cos(t)+a_2\\cos(2t)+a_3\\cos(3t)+b_1\\sin(t)+b_2\\sin(2t)+b_3\\sin(3t)\\]

\n

On substituting the values of the coefficients $a_n$ and $b_n$ this becomes:

\n

\\[f(t)=\\simplify{{a0}+{a1}*cos(t)+{a2}*cos(2t)+{a3}*cos(3t)+{b1}*sin(t)+{b2}*sin(2t)+{b3}*sin(3t)}\\]

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"p": {"name": "p", "group": "Setup", "definition": "random(1..5)", "description": "", "templateType": "anything", "can_override": false}, "q": {"name": "q", "group": "Setup", "definition": "random(-3..3 except [0,p])", "description": "", "templateType": "anything", "can_override": false}, "a0": {"name": "a0", "group": "an coefficients", "definition": "(p*pi+2*q)/4", "description": "", "templateType": "anything", "can_override": false}, "b1": {"name": "b1", "group": "bn coefficients", "definition": "p-2*q/pi", "description": "", "templateType": "anything", "can_override": false}, "b2": {"name": "b2", "group": "bn coefficients", "definition": "-p/2", "description": "", "templateType": "anything", "can_override": false}, "b3": {"name": "b3", "group": "bn coefficients", "definition": "p/3-2*q/(3*pi)", "description": "", "templateType": "anything", "can_override": false}, "a3": {"name": "a3", "group": "an coefficients", "definition": "-2*p/(3^2*pi)", "description": "", "templateType": "anything", "can_override": false}, "a1": {"name": "a1", "group": "an coefficients", "definition": "-2*p/pi", "description": "", "templateType": "anything", "can_override": false}, "a2": {"name": "a2", "group": "an coefficients", "definition": "0", "description": "", "templateType": "anything", "can_override": false}, "t1": {"name": "t1", "group": "Ungrouped variables", "definition": "2-6/pi", "description": "", "templateType": "anything", "can_override": false}, "t2": {"name": "t2", "group": "Ungrouped variables", "definition": "2/1-2/pi", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["t1", "t2"], "variable_groups": [{"name": "an coefficients", "variables": ["a0", "a1", "a2", "a3"]}, {"name": "bn coefficients", "variables": ["b1", "b2", "b3"]}, {"name": "Setup", "variables": ["p", "q"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Determine the Fourier series (up to the third harmonic) of $f(t)$.

\n

$f(t)=$ [[0]]

\n

Using graphing software (e.g. GeoGebra or Desmos), plot the graphs of both the original function and your Fourier series on the same axes.

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "10", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "{a0}+{a1}*cos(t)+{a2}*cos(2t)+{a3}*cos(3t)+{b1}*sin(t)+{b2}*sin(2t)+{b3}*sin(3t)", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": true, "singleLetterVariables": true, "allowUnknownFunctions": false, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": [{"name": "t", "value": ""}]}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Martin Jones", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/145/"}]}]}], "contributors": [{"name": "Martin Jones", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/145/"}]}