<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>PT.9.8 (Expand up to nth term)</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p></p>
<p><b>(a) </b>Write down the expansion of {@p1@} and {@p2@} up to the term in {@v^k@}.</p>
&nbsp; &nbsp; &nbsp; \({@p1@} =\) [[input:ans1]] [[validation:ans1]][[feedback:prt1]]
&nbsp; &nbsp; &nbsp; \({@p2@} =\) [[input:ans2]] [[validation:ans2]][[feedback:prt2]]
<p><b>(b) </b>By multiplying together these expressions show that the expansion of \({@p1@}{@p2@}\) begins with {@p3_s@} and find the next term.</p>
&nbsp; &nbsp; &nbsp; next term:&nbsp;[[input:ans3]] [[validation:ans3]][[feedback:prt3]]]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p><b>(a) </b>Using the binomial theorem,</p><p>\[ \begin{align*}{@p1@}&amp;={@ (simp:false,apply("+",maplist(lambda([r],binomial(n1,r)*(-x)^r),[0,1,2,3,4]))) @}+\cdots \\ &amp;=&nbsp;{@ (simp:false,apply("+",maplist(lambda([r],ev(binomial(n1,r)*(-x)^r,simp)),[0,1,2,3,4]))) @}+\cdots&nbsp; &nbsp;\end{align*} \]</p><p>and</p><p>\[ \begin{align*}{@p2@}&amp;={@ (simp:false,apply("+",maplist(lambda([r],binomial(n2,r)*(a*x^2)^r),[0,1,2]))) @}+\cdots \\ &amp;=&nbsp;{@ (simp:false,apply("+",maplist(lambda([r],ev(binomial(n2,r)*(a*x^2)^r,simp)),[0,1,2]))) @}+\cdots\end{align*} \]</p><p><b>(b) </b>This gives us the product \[ ({@ta1@})({@ta2@}) \]</p><p>and we want to check the first few terms, and find the next one (which will be in \(x^3\)).</p><p>From the second bracket, the term {@secondbracket[3]@} is already degree 4 so we do not need to multiply out this term. Multiplying the other two terms from that bracket with the first bracket gives</p><p>\[ {@secondbracket[1]@}\left({@ta1@}\right)+{@secondbracket[2]@}\left({@ta1@}\right). \]</p><p>Multiplying out these brackets, we can ignore terms which end up degree 4 or higher. Doing this, and gathering terms, we get</p><p>\[&nbsp;{@p1@}{@p2@}=({@p3_s@}) + ({@ta3@}) + \cdots \]</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2020081700</text>
    </stackversion>
    <questionvariables>
      <text>powerdisp:true;
v:x;
a: rand([2,3]);
n1:rand(5)+5;
n2: rand(5)+10;
k:4
p1: (1-x)^n1
p2: (1+a*x^2)^n2
ta1:taytorat(taylor(p1,ev(v),0,k));
ta2:taytorat(taylor(p2,ev(v),0,k));
/* Possible wrong answers. */
w1:taytorat(taylor(p1,ev(v),0,k-1));
w2:taytorat(taylor(p1,ev(v),0,k+1));
w3:taytorat(taylor(p2,ev(v),0,k-2));
w4:taytorat(taylor(p2,ev(v),0,k+2));

p3: ta1*ta2;
p3_s: taytorat(taylor(p3,ev(v),0,2));
ta3: taytorat(taylor(p3,ev(v),0,3)-p3_s);

secondbracket:args(ta2);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\[{@p1@} \text{ up to } {@v^k@} \text{ is } {@ta1@}\]
\[{@p2@} \text{ up to } {@v^k@} \text{ is } {@ta2@}\]
product is \(({@p3_s@}) + ({@ta3@})\)</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:green;"><i class="fa fa-check"></i></span> Correct answer, well done.]]></text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:orange;"><i class="fa fa-adjust"></i></span> Your answer is partially correct.]]></text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:red;"><i class="fa fa-times"></i></span> Incorrect answer.]]></text>
    </prtincorrect>
    <decimals>.</decimals>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>none</multiplicationsign>
    <sqrtsign>1</sqrtsign>
    <complexno>i</complexno>
    <inversetrig>cos-1</inversetrig>
    <logicsymbol>lang</logicsymbol>
    <matrixparens>[</matrixparens>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>ans1</name>
      <type>algebraic</type>
      <tans>ta1</tans>
      <boxsize>30</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>5</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords>binomial</forbidwords>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>1</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans2</name>
      <type>algebraic</type>
      <tans>ta2</tans>
      <boxsize>30</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>5</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords>binomial</forbidwords>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans3</name>
      <type>algebraic</type>
      <tans>ta3</tans>
      <boxsize>15</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>5</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text>/* Create a list of coefficients. */
cf1:maplist(lambda([ex],coeff(ans1-ta1,ev(v),ex)),makelist(j,j,0,k));
nz1:sublist_indices(cf1,lambda([ex],not(is(ex=0))))</text>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans1</sans>
        <tans>ta1</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>1</falsenextnode>
        <falseanswernote>prt1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>GT</answertest>
        <sans>length(nz1)</sans>
        <tans>0</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0.0000000</truescore>
        <truepenalty/>
        <truenextnode>2</truenextnode>
        <trueanswernote>prt1-2-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-2-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[<p>Do you have too many terms in your expansion?</p>]]></text>
        </falsefeedback>
      </node>
      <node>
        <name>2</name>
        <description/>
        <answertest>GTE</answertest>
        <sans>2</sans>
        <tans>length(nz1)</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0.2500000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-3-T</trueanswernote>
        <truefeedback format="html">
          <text>The coefficients of the following terms appear to be incorrect:  {@maplist(lambda([ex],ev(v)^(ex-1)),nz1)@}</text>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-3-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text>/* Create a list of coefficients. */
cf2:maplist(lambda([ex],coeff(ans2-ta2,ev(v),ex)),makelist(j,j,0,k));
nz2:sublist_indices(cf2,lambda([ex],not(is(ex=0))))</text>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans2</sans>
        <tans>ta2</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt2-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>1</falsenextnode>
        <falseanswernote>prt2-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>GT</answertest>
        <sans>length(nz2)</sans>
        <tans>0</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0.0000000</truescore>
        <truepenalty/>
        <truenextnode>2</truenextnode>
        <trueanswernote>prt2-2-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-2-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[<p>Do you have too many terms in your expansion?<br></p>]]></text>
        </falsefeedback>
      </node>
      <node>
        <name>2</name>
        <description/>
        <answertest>GTE</answertest>
        <sans>2</sans>
        <tans>length(nz2)</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0.2500000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt2-3-T</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[<p>The coefficients of the following terms appear to be incorrect: {@maplist(lambda([ex],ev(v)^(ex-1)),nz2)@}<br></p>]]></text>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-3-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt3</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans3</sans>
        <tans>ta3</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt3-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt3-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>923585370</deployedseed>
    <deployedseed>2050196618</deployedseed>
    <deployedseed>341352089</deployedseed>
    <deployedseed>884251025</deployedseed>
    <deployedseed>347888139</deployedseed>
    <deployedseed>1518045531</deployedseed>
    <deployedseed>1787686431</deployedseed>
    <deployedseed>662078492</deployedseed>
    <deployedseed>76969233</deployedseed>
    <deployedseed>416497495</deployedseed>
    <deployedseed>1184141464</deployedseed>
    <deployedseed>1448762742</deployedseed>
    <deployedseed>1678749562</deployedseed>
    <deployedseed>1535558449</deployedseed>
    <deployedseed>1348066916</deployedseed>
    <deployedseed>1500940526</deployedseed>
    <deployedseed>1914523346</deployedseed>
    <deployedseed>942822427</deployedseed>
    <deployedseed>378259454</deployedseed>
    <deployedseed>1507426951</deployedseed>
    <deployedseed>152668973</deployedseed>
    <deployedseed>460570086</deployedseed>
    <deployedseed>1268417507</deployedseed>
    <deployedseed>2023669317</deployedseed>
    <deployedseed>889079668</deployedseed>
    <deployedseed>1976746729</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ta2</value>
      </testinput>
      <testinput>
        <name>ans3</name>
        <value>ta3</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt3</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt3-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>w2</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>w4</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-2-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-2-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>w1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>w3</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.2500000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-3-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.2500000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-3-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ev(ta1+1000*x^2,simp)</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ev(ta2+1000*x^2,simp)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.2500000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-3-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.2500000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-3-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>5</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ev(ta1+x^2+x^3,simp)</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ev(ta2+x^2+x^3,simp)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.2500000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-3-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.2500000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-3-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
