Worked questions

Choose what counts as a correct mathematical answer

Press Validate answers to inspect each interpreted response, then Check answer to grade it. After an edit, validate again.

For teachers

Choose a question to try, then change the response to see which mathematical distinctions its grading preserves. The authoring guide explains how to bring your own questions to a page.

Algebraic equivalence and written form

Equivalent rational expression

The prompt states the domain \(x\ne -n\). A cancelled fraction and the original unreduced expression both receive full credit because the question asks for any equivalent expression on that domain. A reciprocal triggers a targeted feedback branch.

For \(x\neq-{2}\), give an expression equivalent to \(\dfrac{(x+{2})(x+{5})}{(x+{2})^2}\). You may simplify it, or give any equivalent expression on this domain.

Show source
```{.stack-question}
#| file: questions/rational-equivalence.xml
#| question: Equivalent rational expression
#| variants: 3
#| review: true
#| feedback: true
#| label: rational-practice
#| feedback-policy: two-step-practice
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Example question authored by the CTM team. Licensed under CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Equivalent rational expression</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;For \(x\neq-{@n@}\), give an expression equivalent to \(\dfrac{(x+{@n@})(x+{@m@})}{(x+{@n@})^2}\). You may simplify it, or give any equivalent expression on this domain.&lt;/p&gt;&lt;p&gt;[[input:ans]] [[validation:ans]] [[feedback:prt1]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;Cancel one common factor of \(x+{@n@}\) (valid when \(x\neq-{@n@}\)) to obtain \({@ta@}\).&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>n:rand(3)+2;
m:n+rand(3)+1;
ta:(x+m)/(x+n);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>&lt;p&gt;[[feedback:prt1]]&lt;/p&gt;</text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Rational identity: (x+n)(x+m)/(x+n)^2 = ta, for x != -n</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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>ans</name>
      <type>algebraic</type>
      <tans>ta</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans</sans>
        <tans>ta</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct on the stated domain.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>1</falsenextnode>
        <falseanswernote>prt1-0-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans</sans>
        <tans>(x+n)/(x+m)</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>0.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;You inverted the fraction. Cancel a shared factor instead.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;Cancel one factor in the numerator against one in the squared denominator.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Simplified expression</description>
      <testinput>
        <name>ans</name>
        <value>(x+m)/(x+n)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Unsimplified but equivalent expression</description>
      <testinput>
        <name>ans</name>
        <value>(x+n)*(x+m)/(x+n)^2</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Reciprocal misconception</description>
      <testinput>
        <name>ans</name>
        <value>(x+n)/(x+m)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-0-F | prt1-1-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download the rational question

Its AI Feedback first asks a guiding question and then offers a worked explanation. The teaching-policy setup shows how to choose a sequence for your own course.

An imported STACK question

This unchanged Moodle export asks for a particular written form. Its author tests remain in the XML, so you can inspect how EqualComAss grades the response. If an imported question uses an unsupported feature, the site build identifies it for the author.

Simplify the following expression by collecting together like terms:
\[{4}x+{3}y-{6}x-{3}y+5.\]

Show source
```{.stack-question}
#| label: examples-algmap-6-1
#| file: questions/upstream/algmap-6-1.xml
#| question: AlgMap-6.1
#| variants: 2
#| review: true
#| feedback: true
#| context: none
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>AlgMap-6.1</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Simplify the following expression by collecting together like terms: <br /> \[{@a@}x+{@b@}y-{@c@}x-{@d@}y+5.\] <br /> [[input:ans]] [[validation:ans]]</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p>In order to collect like terms simply pull out the common factors (the x's and y's in this example) like so: <br /> \[ = {@a@}x+{@b@}y-{@c@}x-{@d@}y+5,\] <br /> \[ = \left({@a@}-{@c@}\right)x+\left({@b@}-{@d@}\right)y+5,\] <br /> \[ = {@ta@}.\]</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2019121800</text>
    </stackversion>
    <questionvariables>
      <text>a:rand(9)+2;
b:rand(9)+2;
c:rand(9)+2;
d:rand(9)+2;
ta:ev(a*x+b*y-c*x-d*y+5,simp);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text><![CDATA[<p>[[feedback:prt1]]</p>]]></text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\[{@a@}x+{@b@}y-{@c@}x-{@d@}y+5 = {@ta@}.\]</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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>ans</name>
      <type>algebraic</type>
      <tans>ta</tans>
      <boxsize>15</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords>ratsimp</forbidwords>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>1</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>EqualComAss</answertest>
        <sans>ans</sans>
        <tans>ta</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>1-0-T </trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>1-0-F </falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>1533443292</deployedseed>
    <deployedseed>1987024481</deployedseed>
    <deployedseed>1601581784</deployedseed>
    <deployedseed>1118095199</deployedseed>
    <deployedseed>1703642583</deployedseed>
    <deployedseed>804836698</deployedseed>
    <deployedseed>724324543</deployedseed>
    <deployedseed>1286480315</deployedseed>
    <deployedseed>200744727</deployedseed>
    <deployedseed>31151399</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans</name>
        <value>ta</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans</name>
        <value>a*x+b*y-c*x-d*y+5</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>1-0-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download the original STACK question

Hyperbolic equivalence

Find another expression for a logistic function. This question accepts a supported equivalent expression using hyperbolic functions, such as tanh. It checks mathematical equivalence rather than requiring one written form.

Give an expression equivalent to \(1/(1+\exp(-2x))\). You may use hyperbolic functions.

Show source
```{.stack-question}
#| label: examples-hyperbolic-equivalence
#| file: questions/hyperbolic-equivalence.xml
#| question: Hyperbolic equivalence
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authored by the CTM team. CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Hyperbolic equivalence</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;Give an expression equivalent to \(1/(1+\exp(-2x))\). You may use hyperbolic functions.&lt;/p&gt;&lt;p&gt;[[input:ans]] [[validation:ans]] [[feedback:prt1]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;A reference answer is \({@ta@}\).&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber />
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>ta:tanh(x)/2+1/2;</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>&lt;p&gt;[[feedback:prt1]]&lt;/p&gt;</text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Hyperbolic equivalence</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text />
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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>ans</name>
      <type>algebraic</type>
      <tans>ta</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>ans</sans>
        <tans>ta</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-0-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>tanh(x)/2+1/2</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>1/(1+exp(-2*x))</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>(sinh(x)+cosh(x))/(2*cosh(x))</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description>Incorrect candidate</description>
      <testinput>
        <name>ans</name>
        <value>tanh(x)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>prt1-0-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download XML

Numerical answers and precision

Three numerical checks

These fields demonstrate absolute tolerance, relative tolerance, and decimal-place precision. The final field distinguishes 17.5 from 17.50, because the written precision is part of the task. Their response trees contribute 30%, 40%, and 30% of the total.

For a measured quantity, absolute tolerance compares \(|x-a|\) to a fixed bound. Relative tolerance compares it to a fraction of the reference value. Written decimal places express the precision of a reported measurement.

A rectangle is \({7}\) cm long and \({5}\) cm wide. A right triangle has those same perpendicular side lengths.

  1. Find the rectangle perimeter in cm, within \(0.25\) cm.
  2. Find the triangle area in cm², within \(2\%\) of the exact value.
  3. Write the triangle area to exactly two decimal places (include the final zero).
Show source
```{.stack-question}
#| label: examples-rectangle-and-triangle-measurements
#| file: questions/numerical-measurement.xml
#| question: Rectangle and triangle measurements
#| review: true
#| feedback: true
#| context: measurement-context
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Example question authored by the CTM team. Licensed under CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Rectangle and triangle measurements</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;A rectangle is \({@p@}\) cm long and \({@q@}\) cm wide. A right triangle has those same perpendicular side lengths.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Find the rectangle perimeter in cm, within \(0.25\) cm. [[input:perimeter]] [[validation:perimeter]] [[feedback:prt1]]&lt;/li&gt;&lt;li&gt;Find the triangle area in cm², within \(2\%\) of the exact value. [[input:area]] [[validation:area]] [[feedback:prt2]]&lt;/li&gt;&lt;li&gt;Write the triangle area to &lt;strong&gt;exactly two decimal places&lt;/strong&gt; (include the final zero). [[input:reported]] [[validation:reported]] [[feedback:prt3]]&lt;/li&gt;&lt;/ol&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;Perimeter: \(2({@p@}+{@q@})={@ta_perimeter@}\) cm. Triangle area: \({@p@}\cdot{@q@}/2={@ta_area@}\) cm². To two decimal places, write &lt;strong&gt;17.50&lt;/strong&gt;; the final zero records the requested precision.&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>p:7;
q:5;
ta_perimeter:2*(p+q);
ta_area:p*q/2;</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>&lt;p&gt;[[feedback:prt1]] [[feedback:prt2]] [[feedback:prt3]]&lt;/p&gt;</text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Numerical checks: perimeter 24, area 17.5, two-place area 17.50</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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>perimeter</name>
      <type>numerical</type>
      <tans>ta_perimeter</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <input>
      <name>area</name>
      <type>numerical</type>
      <tans>ta_area</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <input>
      <name>reported</name>
      <type>numerical</type>
      <tans>ta_area</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>0.3000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumAbsolute</answertest>
        <sans>perimeter</sans>
        <tans>ta_perimeter</tans>
        <testoptions>0.25</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Perimeter is within 0.25 cm.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-0-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;Use twice the sum of the side lengths.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt2</name>
      <value>0.4000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>area</sans>
        <tans>ta_area</tans>
        <testoptions>0.02</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt2-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Triangle area is within 2%.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-0-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;Use half the product of the perpendicular sides.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt3</name>
      <value>0.3000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>reported</sans>
        <tans>ta_area</tans>
        <testoptions>2</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt3-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;The value and two-decimal-place formatting are both correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt3-0-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;Check the value and type two digits after the decimal point, including a trailing zero.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Exact values with two-place reporting</description>
      <testinput>
        <name>perimeter</name>
        <value>24</value>
      </testinput>
      <testinput>
        <name>area</name>
        <value>17.5</value>
      </testinput>
      <testinput>
        <name>reported</name>
        <value>17.50</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-0-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt3</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt3-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Outside tolerance and missing trailing zero</description>
      <testinput>
        <name>perimeter</name>
        <value>25</value>
      </testinput>
      <testinput>
        <name>area</name>
        <value>20</value>
      </testinput>
      <testinput>
        <name>reported</name>
        <value>17.5</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-0-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-0-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt3</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt3-0-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Acceptable approximations with precise reporting</description>
      <testinput>
        <name>perimeter</name>
        <value>24.1</value>
      </testinput>
      <testinput>
        <name>area</name>
        <value>17.65</value>
      </testinput>
      <testinput>
        <name>reported</name>
        <value>17.50</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-0-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt3</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt3-0-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download the numerical question

Numeric order of operations from the STACK collection

This unchanged question accepts numerical answers within a relative tolerance. Review mode shows its authored test case and the resulting score.

Exercise

Evaluate the expression below

\({3} + {4} \times {7} =\)

Show source
```{.stack-question}
#| label: examples-1-1-4-t2-bodmas
#| file: questions/upstream/bodmas.xml
#| question: 1.1.4.T2 BODMAS
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>1.1.4.T2 BODMAS</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p class="HELM_exercise">Exercise</p>
<p>Evaluate the expression below<p>
<p>\({@a1@} + {@a2@} \times {@a3@} =\) [[input:ans1]] [[validation:ans1]] [[feedback:prt1]]</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p>The BODMAS rule tells us to perform the multiplication before the addition. Thus</p>
<p>\(\qquad {@a1@} + {@a2@} \times {@a3@} = {@a1@} + {@a2*a3@}\)</p>
<p>We then perform addition to give the final answer</p>
<p>\(\qquad {@a1@} + {@a2*a3@} = {@ta@}\)</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>a1: rand([3,4,5])
a2: rand([2,3,4])
a3: rand([7,8])

ta: a1+(a2*a3)</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\({@a1@} + {@a2@} \times {@a3@} = {@ta@}\)</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>dot</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>numerical</type>
      <tans>ta</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords>+,-,*,/</forbidwords>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</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/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>ans1</sans>
        <tans>ta</tans>
        <testoptions>0</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>
    </prt>
    <deployedseed>436087902</deployedseed>
    <deployedseed>1488013351</deployedseed>
    <deployedseed>1576233418</deployedseed>
    <deployedseed>1723784734</deployedseed>
    <deployedseed>1925932020</deployedseed>
    <deployedseed>40937868</deployedseed>
    <deployedseed>1789626796</deployedseed>
    <deployedseed>646574411</deployedseed>
    <deployedseed>917403019</deployedseed>
    <deployedseed>500632187</deployedseed>
    <deployedseed>1226036906</deployedseed>
    <deployedseed>1044552471</deployedseed>
    <deployedseed>1393001460</deployedseed>
    <deployedseed>664354211</deployedseed>
    <deployedseed>1597237257</deployedseed>
    <deployedseed>812838757</deployedseed>
    <deployedseed>1088259409</deployedseed>
    <deployedseed>508020296</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download BODMAS XML · Read the authoring guide

Original rounding question

This unchanged question has several answer fields and checks the number of reported decimal places. Its author tests are visible in review mode.

Exercise

Write down each of these numbers rounded to 3 decimal places:

  1. \({\frac{2727}{3125}}\)
  2. \({- \frac{1543}{10000}}\)
  3. \({\frac{847981}{1000000}}\)
  4. \(−0.5555,\)
  5. \(45.6789\)
  6. \({\frac{60003}{10000}}\)

Solution

Show source
```{.stack-question}
#| label: examples-1-1-3-t1-rounding-to-n-decimal-places
#| file: questions/upstream/rounding-three-dp.xml
#| question: 1.1.3.T1 Rounding to n Decimal Places
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>1.1.3.T1 Rounding to n Decimal Places</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p class="HELM_exercise">Exercise</p>
<p>Write down each of these numbers rounded to 3 decimal places: </p>
<ol class="HELM_parts_inline">
<li>\({@a1@}\)</li>
<li>\({@a2@}\)</li>
<li>\({@a3@}\)</li>
<li>\(−0.5555,\)</li>
<li>\(45.6789\)</li>
<li>\({@a4@}\)</li>
</ol>
<h4 class="HELM_solution">Solution</h4>
<ol class="HELM_parts">
<li>[[input:ans1]] [[validation:ans1]] [[feedback:prt1]]</li>
<li>[[input:ans2]] [[validation:ans2]] [[feedback:prt2]]</li>
<li>[[input:ans3]] [[validation:ans3]] [[feedback:prt3]]</li>
<li>[[input:ans4]] [[validation:ans4]] [[feedback:prt4]]</li>
<li>[[input:ans5]] [[validation:ans5]] [[feedback:prt5]]</li>
<li>[[input:ans6]] [[validation:ans6]] [[feedback:prt6]]</li>
</ol>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<ol class="HELM_parts">
    <li>\({@a1@}\) rounded to 3 decimal places becomes \( {@ta1@}.\)</li>
    <li>\({@a2@}\) rounded to 3 decimal places becomes \( {@ta2@}.\)</li>
    <li>\({@a3@}\) rounded to 3 decimal places becomes \( {@ta3@}.\)</li>
    <li>\(−0.5555,\) rounded to 3 decimal places becomes \( {@ta4@}.\)</li>
    <li>\(45.6789\) rounded to 3 decimal places becomes \( {@ta5@}.\)</li>
    <li>\({@a4@}\) rounded to 3 decimal places becomes \( {@ta6@}.\)</li>
</ol>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>a1: rand([0.87264,0.889412]);
a2: rand([-0.1543,-0.5432]);
a3: rand([0.864321,0.847981]);
a4: rand([6.0003, 2.0002])

ta1: dispdp(a1,3)
ta2: dispdp(a2,3)
ta3: dispdp(a3,3)
ta4: -0.556
ta5: 45.679
ta6: dispdp(a4,3)</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Round to 3.d.p: \({@a1@}\), \({@a2@}\), \({@a3@}\), \(−0.5555\), \(45.6789\), \({@a4@}\)</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>dot</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>numerical</type>
      <tans>ta1</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans2</name>
      <type>numerical</type>
      <tans>ta2</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans3</name>
      <type>numerical</type>
      <tans>ta3</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans4</name>
      <type>numerical</type>
      <tans>ta4</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans5</name>
      <type>numerical</type>
      <tans>ta5</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans6</name>
      <type>numerical</type>
      <tans>ta6</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</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/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>ans1</sans>
        <tans>ta1</tans>
        <testoptions>3</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>
    </prt>
    <prt>
      <name>prt2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>ans2</sans>
        <tans>ta2</tans>
        <testoptions>3</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>
    </prt>
    <prt>
      <name>prt3</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>ans3</sans>
        <tans>ta3</tans>
        <testoptions>3</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>
    <prt>
      <name>prt4</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>ans4</sans>
        <tans>ta4</tans>
        <testoptions>3</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt4-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt4-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt5</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>ans5</sans>
        <tans>ta5</tans>
        <testoptions>3</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt5-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt5-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt6</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumDecPlaces</answertest>
        <sans>ans6</sans>
        <tans>ta6</tans>
        <testoptions>3</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt6-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt6-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>545151939</deployedseed>
    <deployedseed>291110194</deployedseed>
    <deployedseed>13434383</deployedseed>
    <deployedseed>13754906</deployedseed>
    <deployedseed>2006771970</deployedseed>
    <deployedseed>1480110575</deployedseed>
    <deployedseed>377171226</deployedseed>
    <deployedseed>1581198489</deployedseed>
    <deployedseed>557671038</deployedseed>
    <deployedseed>683697489</deployedseed>
    <deployedseed>1552589564</deployedseed>
    <deployedseed>167126779</deployedseed>
    <deployedseed>113805797</deployedseed>
    <deployedseed>1356554022</deployedseed>
    <deployedseed>1621205317</deployedseed>
    <deployedseed>1039591176</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>
      <testinput>
        <name>ans4</name>
        <value>ta4</value>
      </testinput>
      <testinput>
        <name>ans5</name>
        <value>ta5</value>
      </testinput>
      <testinput>
        <name>ans6</name>
        <value>ta6</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>
      <expected>
        <name>prt4</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt4-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt5</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt5-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt6</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt6-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>dispdp(a1,4)</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>dispdp(a2,4)</value>
      </testinput>
      <testinput>
        <name>ans3</name>
        <value>dispdp(a3,4)</value>
      </testinput>
      <testinput>
        <name>ans4</name>
        <value>-0.5555</value>
      </testinput>
      <testinput>
        <name>ans5</name>
        <value>45.6789</value>
      </testinput>
      <testinput>
        <name>ans6</name>
        <value>dispdp(a4,4)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt3</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt3-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt4</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt4-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt5</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt5-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt6</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt6-1-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download rounding XML

Equations and logic

Zero product equations

Rewrite \(ab=0\) as alternatives joined by or. Here AlgEquiv checks the solutions represented by polynomial equations, including repeated-root information; it is not simply comparing the strings on either side.

Express \(ab=0\) as a disjunction of polynomial equations. Write or between the alternatives.

Show source
```{.stack-question}
#| label: examples-zero-product-equations
#| file: questions/zero-product.xml
#| question: Zero product equations
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authored by the CTM team. CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Zero product equations</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;Express \(ab=0\) as a disjunction of polynomial equations. Write &lt;code&gt;or&lt;/code&gt; between the alternatives.&lt;/p&gt;&lt;p&gt;[[input:ans]] [[validation:ans]] [[feedback:prt1]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;A reference answer is \({@ta@}\).&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber />
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>ta:a*b=0;</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>&lt;p&gt;[[feedback:prt1]]&lt;/p&gt;</text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Zero product equations</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text />
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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>ans</name>
      <type>algebraic</type>
      <tans>ta</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>ans</sans>
        <tans>ta</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-0-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>a=0 or b=0</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>b=0 nounor a=0</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Incorrect candidate</description>
      <testinput>
        <name>ans</name>
        <value>a^3*b^3=0</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>prt1-0-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description>Incorrect candidate</description>
      <testinput>
        <name>ans</name>
        <value>a=0</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>prt1-0-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download XML

Boolean equivalence

Use De Morgan’s law to rewrite not(a and b) using or. In this question a and b are propositions, and the checker compares their truth values for every assignment in its supported finite domain.

Rewrite the negation of a and b using or. Here a and b are propositions.

Show source
```{.stack-question}
#| label: examples-boolean-equivalence
#| file: questions/boolean-equivalence.xml
#| question: Boolean equivalence
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authored by the CTM team. CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Boolean equivalence</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;Rewrite the negation of &lt;code&gt;a and b&lt;/code&gt; using &lt;code&gt;or&lt;/code&gt;. Here a and b are propositions.&lt;/p&gt;&lt;p&gt;[[input:ans]] [[validation:ans]] [[feedback:prt1]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;A reference answer is \({@ta@}\).&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber />
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>ta:not(a and b);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>&lt;p&gt;[[feedback:prt1]]&lt;/p&gt;</text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Boolean equivalence</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text />
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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>ans</name>
      <type>algebraic</type>
      <tans>ta</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>ans</sans>
        <tans>ta</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-0-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-0-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>not a or not b</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>nounnot(a) nounor nounnot(b)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Equivalent answer</description>
      <testinput>
        <name>ans</name>
        <value>not(a and b)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>prt1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description>Incorrect candidate</description>
      <testinput>
        <name>ans</name>
        <value>not a and not b</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>prt1-0-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download XML

Collections

Finite lists and sets

Compare an ordered list with an unordered set. Lists retain positions and repetitions; sets ignore order and repeated mathematical members. One field also shows feedback about extra, missing or repeated set entries.

Use square brackets for an ordered list and braces for a set. Here a = \({3}\).

Enter the list \({\left[ 3, \ 2 x\right]}\):

Enter the set \({\left\{3, 2 x\right\}}\):

Enter the same set again; this check explains duplicates and missing/extra elements:

Show source
```{.stack-question #finite-collections}
#| label: finite-collections
#| file: questions/finite-collections.xml
#| question: Finite scalar collections
#| variants: 2
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authored by the CTM team. CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Finite scalar collections</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;Use square brackets for an ordered list and braces for a set. Here a = \({@a@}\).&lt;/p&gt;&lt;p&gt;Enter the list \({@ordered@}\): [[input:sequence]] [[validation:sequence]] [[feedback:ordered]]&lt;/p&gt;&lt;p&gt;Enter the set \({@unordered@}\): [[input:members]] [[validation:members]] [[feedback:unordered]]&lt;/p&gt;&lt;p&gt;Enter the same set again; this check explains duplicates and missing/extra elements: [[input:explained]] [[validation:explained]] [[feedback:explained]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;Lists preserve order and repetitions. Sets ignore order and repeated elements.&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber />
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>a:rand_with_step(2,8,1); ordered:[a,x+x]; unordered:{a,x+x};</text>
    </questionvariables>
    <specificfeedback format="html">
      <text />
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Finite scalar collections, a = {@a@}</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text />
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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 />
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <input>
      <name>sequence</name>
      <type>algebraic</type>
      <tans>ordered</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>ordered</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>sequence</sans>
        <tans>ordered</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>ordered-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>ordered-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <input>
      <name>members</name>
      <type>algebraic</type>
      <tans>unordered</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>unordered</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>members</sans>
        <tans>unordered</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>unordered-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>unordered-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <input>
      <name>explained</name>
      <type>algebraic</type>
      <tans>unordered</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>explained</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>Sets</answertest>
        <sans>explained</sans>
        <tans>unordered</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>explained-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>explained-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <qtest>
      <testcase>1</testcase>
      <description>Flat collection control</description>
      <testinput>
        <name>sequence</name>
        <value>[a,2*x]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{2*x,a}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{a,2*x}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>ordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>unordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>explained-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Flat collection control</description>
      <testinput>
        <name>sequence</name>
        <value>[2*x,a]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{a,2*x}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{a,2*x,2*x}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>ordered-F</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>unordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>explained-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Flat collection control</description>
      <testinput>
        <name>sequence</name>
        <value>[a,2*x,a]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{a}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{a,3*x}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>ordered-F</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>unordered-F</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>explained-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description>Flat collection control</description>
      <testinput>
        <name>sequence</name>
        <value>[a,x+x]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{x+x,a,a}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{a}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>ordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>unordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>explained-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Nested collections and written form

Try a list containing another list and a set. The task keeps nested boundaries and list order; a separate written-form check can distinguish repeated entries or different arithmetic forms even when values agree.

Use lists to preserve order and sets to ignore order. Here a = \({3}\).

Reproduce the nested value \({\left[\left[3, 2x\right], \left\{1, \left\{2, 3\right\}\right\}, \left[\right]\right]}\):

Reproduce the family of collections \({\left\{\left\{1, 2\right\}, \left[3, 2x\right]\right\}}\):

Reproduce the written form (reorder only) \({\left\{\left\{x + x, 2, 2\right\}, \left[1, x + 1\right]\right\}}\):

Show source
```{.stack-question #nested-collections}
#| label: nested-collections
#| file: questions/nested-collections.xml
#| question: Nested finite collections
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authored by the CTM team. CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Nested finite collections</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;Use lists to preserve order and sets to ignore order. Here a = \({@a@}\).&lt;/p&gt;&lt;p&gt;Reproduce the nested value \({@[[a,2*x],{1,{2,3}},[]]@}\): [[input:nested]] [[validation:nested]] [[feedback:nested]]&lt;/p&gt;&lt;p&gt;Reproduce the family of collections \({@{{1,2},[a,2*x]}@}\): [[input:families]] [[validation:families]] [[feedback:families]]&lt;/p&gt;&lt;p&gt;Reproduce the written form (reorder only) \({@{{x+x,2,2},[1,x+1]}@}\): [[input:form]] [[validation:form]] [[feedback:form]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;Lists retain order. Nested sets retain their boundaries. EqualComAss also retains written repeated entries and arithmetic form.&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber />
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>a:rand_with_step(2,8,1);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text />
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Nested finite collections, a={@a@}</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text />
    </questiondescription>
    <questionsimplify>0</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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 />
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <input>
      <name>nested</name>
      <type>algebraic</type>
      <tans>[[a,2*x],{1,{2,3}},[]]</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>nested</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>nested</sans>
        <tans>[[a,2*x],{1,{2,3}},[]]</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>nested-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>nested-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <input>
      <name>families</name>
      <type>algebraic</type>
      <tans>{{1,2},[a,2*x]}</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>families</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>Sets</answertest>
        <sans>families</sans>
        <tans>{{1,2},[a,2*x]}</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>families-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>families-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <input>
      <name>form</name>
      <type>algebraic</type>
      <tans>{{x+x,2,2},[1,x+1]}</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>form</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>SameType</answertest>
        <sans>form</sans>
        <tans>{{x+x,2,2},[1,x+1]}</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>0</truescore>
        <truepenalty />
        <truenextnode>1</truenextnode>
        <trueanswernote>form-type-T</trueanswernote>
        <truefeedback format="html">
          <text />
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>form-type-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;Use the same outer collection type.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description />
        <answertest>EqualComAss</answertest>
        <sans>form</sans>
        <tans>{{x+x,2,2},[1,x+1]}</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>form-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>form-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;Keep the written arithmetic, list order and repeated set entries. Reordering set entries is allowed.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <qtest>
      <testcase>1</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>nested</name>
        <value>[[a,x+x],{{3,2},1},[]]</value>
      </testinput>
      <testinput>
        <name>families</name>
        <value>{[a,x+x],{2,1}}</value>
      </testinput>
      <testinput>
        <name>form</name>
        <value>{[1,1+x],{2,x+x,2}}</value>
      </testinput>
      <expected>
        <name>nested</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>nested-T</expectedanswernote>
      </expected>
      <expected>
        <name>families</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>families-T</expectedanswernote>
      </expected>
      <expected>
        <name>form</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>form-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>nested</name>
        <value>[[a,2*x],{1,{2,3}},[]]</value>
      </testinput>
      <testinput>
        <name>families</name>
        <value>{{1,2},[a,2*x],[a,2*x]}</value>
      </testinput>
      <testinput>
        <name>form</name>
        <value>{{2,2,2*x},[1,x+1]}</value>
      </testinput>
      <expected>
        <name>nested</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>nested-T</expectedanswernote>
      </expected>
      <expected>
        <name>families</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>families-T</expectedanswernote>
      </expected>
      <expected>
        <name>form</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>form-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>nested</name>
        <value>[[2*x,a],{1,{2,3}},[]]</value>
      </testinput>
      <testinput>
        <name>families</name>
        <value>{{1,2},[2*x,a]}</value>
      </testinput>
      <testinput>
        <name>form</name>
        <value>{{x+x,2},[1,x+1]}</value>
      </testinput>
      <expected>
        <name>nested</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>nested-F</expectedanswernote>
      </expected>
      <expected>
        <name>families</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>families-F</expectedanswernote>
      </expected>
      <expected>
        <name>form</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>form-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>nested</name>
        <value>[[a,2*x],{1,{2,3}},[]]</value>
      </testinput>
      <testinput>
        <name>families</name>
        <value>{{1,2}}</value>
      </testinput>
      <testinput>
        <name>form</name>
        <value>[[x+x,2,2],[1,x+1]]</value>
      </testinput>
      <expected>
        <name>nested</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>nested-T</expectedanswernote>
      </expected>
      <expected>
        <name>families</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>families-F</expectedanswernote>
      </expected>
      <expected>
        <name>form</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>form-type-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Finite author helpers

This question’s list and set are calculated from author variables. Learners still enter ordinary list and set literals; the helper functions are for preparing question values, not new learner syntax.

Author helpers computed this list \({\left[ 1, \ 2, \ 3\right]}\) and set \({\left\{1, 2, 3\right\}}\), with cardinality \({3}\). Enter literals below.

Ordered list:

Unordered set:

Set with explanations:

Show source
```{.stack-question #finite-author-helpers}
#| label: finite-author-helpers
#| file: questions/finite-author-helpers.xml
#| question: Finite author helpers
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Authored by the CTM team. CC BY-SA 4.0. -->
<quiz>
  <question type="stack">
    <name>
      <text>Finite author helpers</text>
    </name>
    <questiontext format="html">
      <text>&lt;p&gt;Author helpers computed this list \({@ordered@}\) and set \({@unordered@}\), with cardinality \({@size@}\). Enter literals below.&lt;/p&gt;&lt;p&gt;Ordered list: [[input:sequence]] [[validation:sequence]] [[feedback:ordered]]&lt;/p&gt;&lt;p&gt;Unordered set: [[input:members]] [[validation:members]] [[feedback:unordered]]&lt;/p&gt;&lt;p&gt;Set with explanations: [[input:explained]] [[validation:explained]] [[feedback:explained]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;Difference: \({@difference@}\). Intersection: \({@common@}\). Membership: \({@present@}\). Subset: \({@sub@}\).&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber />
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>a:3; ordered:listify({3,1,2}); unordered:union({1,2},{2,3}); size:cardinality(unordered); present:member(2,unordered); sub:subsetp({1},unordered); difference:setdifference(unordered,{2}); common:intersection(unordered,{2,3}); converted:setify([1,1,2]);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text />
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>Finite author helpers</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text />
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <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 />
    <deployedseed>17</deployedseed>
    <deployedseed>29</deployedseed>
    <deployedseed>47</deployedseed>
    <input>
      <name>sequence</name>
      <type>algebraic</type>
      <tans>ordered</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>ordered</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>sequence</sans>
        <tans>ordered</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>ordered-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>ordered-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <input>
      <name>members</name>
      <type>algebraic</type>
      <tans>unordered</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>unordered</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>AlgEquiv</answertest>
        <sans>members</sans>
        <tans>unordered</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>unordered-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>unordered-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <input>
      <name>explained</name>
      <type>algebraic</type>
      <tans>unordered</tans>
      <boxsize>18</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint />
      <syntaxattribute>0</syntaxattribute>
      <forbidwords />
      <allowwords />
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options />
    </input>
    <prt>
      <name>explained</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text />
      </feedbackvariables>
      <node>
        <name>0</name>
        <description />
        <answertest>Sets</answertest>
        <sans>explained</sans>
        <tans>unordered</tans>
        <testoptions />
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty />
        <truenextnode>-1</truenextnode>
        <trueanswernote>explained-T</trueanswernote>
        <truefeedback format="html">
          <text>&lt;p&gt;Correct.&lt;/p&gt;</text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty />
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>explained-F</falseanswernote>
        <falsefeedback format="html">
          <text>&lt;p&gt;This answer is not equivalent to the reference.&lt;/p&gt;</text>
        </falsefeedback>
      </node>
    </prt>
    <qtest>
      <testcase>1</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>sequence</name>
        <value>[1,2,3]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{3,2,1}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{1,2,3}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>ordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>unordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>explained-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>sequence</name>
        <value>[3,2,1]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{1,2,3}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{1,2,3,3}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>ordered-F</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>unordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>explained-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>sequence</name>
        <value>[1,2,3]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{1,2}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{1,2,4}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>ordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>unordered-F</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>explained-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description>Collection structure and form control</description>
      <testinput>
        <name>sequence</name>
        <value>[1,2]</value>
      </testinput>
      <testinput>
        <name>members</name>
        <value>{1,2,3,3}</value>
      </testinput>
      <testinput>
        <name>explained</name>
        <value>{1,2}</value>
      </testinput>
      <expected>
        <name>ordered</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>ordered-F</expectedanswernote>
      </expected>
      <expected>
        <name>unordered</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>unordered-T</expectedanswernote>
      </expected>
      <expected>
        <name>explained</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>explained-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Matrix conditions

Find a nonidentity matrix with determinant one

Enter any integer \(2\times2\) matrix with determinant 1, except the identity. Each of the three conditions earns one third of the score: integer entries, determinant one, and nonidentity. You are finding a matrix that satisfies conditions, rather than copying a displayed model answer.

Enter any integer \(2\times2\) matrix \(A\ne I_2\) with \(\det(A)=1\).

Show source
```{.stack-question #determinant-one}
#| label: determinant-one
#| file: questions/determinant-one.xml
#| question: A nonidentity integer matrix with determinant one
#| review: true
#| feedback: true
#| context: none
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Adapted from Erasmus-CTM/math-exercise custom-special-linear-matrix; AGPL-3.0-or-later. See determinant-example-provenance.json. -->
<quiz><question type="stack">
<name><text>A nonidentity integer matrix with determinant one</text></name>
<questionvariables><text>T:matrix([1,1],[0,1]);</text></questionvariables>
<questionsimplify>1</questionsimplify>
<questiontext format="html"><text><![CDATA[<p>Enter any integer \(2\times2\) matrix \(A\ne I_2\) with \(\det(A)=1\).</p><p>[[input:ans]] [[validation:ans]]</p><p>[[feedback:integers]] [[feedback:determinant]] [[feedback:nonidentity]]</p>]]></text></questiontext>
<generalfeedback format="html"><text><![CDATA[There are three equally weighted conditions: every entry is an integer, the determinant is one, and the matrix is not the identity. For example, a shear matrix with rows (1,k) and (0,1), where k is a nonzero integer, satisfies all three.]]></text></generalfeedback>
<defaultgrade>1</defaultgrade><penalty>0.1</penalty>
<input><name>ans</name><type>matrix</type><tans>T</tans><boxsize>8</boxsize><strictsyntax>1</strictsyntax><insertstars>0</insertstars><forbidfloat>0</forbidfloat><checkanswertype>1</checkanswertype><mustverify>1</mustverify><showvalidation>1</showvalidation></input>
<prt><name>integers</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>PythonChecker</answertest><sans>ans</sans><testoptions>{"checker": "matrix_property", "options": {"property": "integer_entries"}}</testoptions><tans>true</tans>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>integers-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>integers-F</falseanswernote><falsefeedback><text><![CDATA[Use integer entries.]]></text></falsefeedback>
</node></prt>
<prt><name>determinant</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>PythonChecker</answertest><sans>ans</sans><testoptions>{"checker": "matrix_property", "options": {"property": "determinant"}}</testoptions><tans>1</tans>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>determinant-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>determinant-F</falseanswernote><falsefeedback><text><![CDATA[Check that ad-bc=1.]]></text></falsefeedback>
</node></prt>
<prt><name>nonidentity</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>PythonChecker</answertest><sans>ans</sans><testoptions>{"checker": "matrix_property", "options": {"property": "identity"}}</testoptions><tans>false</tans>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>nonidentity-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>nonidentity-F</falseanswernote><falsefeedback><text><![CDATA[Choose a matrix different from the identity.]]></text></falsefeedback>
</node></prt>
<qtest><testcase>1</testcase><testinput><name>ans</name><value>matrix([1,1],[0,1])</value></testinput><expected><name>integers</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>integers-T</expectedanswernote></expected><expected><name>determinant</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>determinant-T</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>nonidentity-T</expectedanswernote></expected></qtest>
<qtest><testcase>2</testcase><testinput><name>ans</name><value>matrix([2,1],[1,1])</value></testinput><expected><name>integers</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>integers-T</expectedanswernote></expected><expected><name>determinant</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>determinant-T</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>nonidentity-T</expectedanswernote></expected></qtest>
<qtest><testcase>3</testcase><testinput><name>ans</name><value>matrix([0,-1],[1,0])</value></testinput><expected><name>integers</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>integers-T</expectedanswernote></expected><expected><name>determinant</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>determinant-T</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>nonidentity-T</expectedanswernote></expected></qtest>
<qtest><testcase>4</testcase><testinput><name>ans</name><value>matrix([1,0],[0,1])</value></testinput><expected><name>integers</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>integers-T</expectedanswernote></expected><expected><name>determinant</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>determinant-T</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>nonidentity-F</expectedanswernote></expected></qtest>
<qtest><testcase>5</testcase><testinput><name>ans</name><value>matrix([1/2,1],[0,2])</value></testinput><expected><name>integers</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>integers-F</expectedanswernote></expected><expected><name>determinant</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>determinant-T</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>nonidentity-T</expectedanswernote></expected></qtest>
<qtest><testcase>6</testcase><testinput><name>ans</name><value>matrix([2,0],[0,2])</value></testinput><expected><name>integers</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>integers-T</expectedanswernote></expected><expected><name>determinant</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>determinant-F</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>nonidentity-T</expectedanswernote></expected></qtest>
<qtest><testcase>7</testcase><testinput><name>ans</name><value>matrix([0,0],[0,0])</value></testinput><expected><name>integers</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>integers-T</expectedanswernote></expected><expected><name>determinant</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>determinant-F</expectedanswernote></expected><expected><name>nonidentity</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>nonidentity-T</expectedanswernote></expected></qtest>
</question></quiz>

Download XML

The question uses three normal response trees, one per condition. Named functions in the shared matrix library check integer entries, determinant one and nonidentity; see which test to choose.

A positive definite matrix

Give any real symmetric or complex Hermitian positive definite \(2\times2\) matrix, using integers or exact fractions for both real and imaginary parts. Enter %i for \(i\). The identity, \(\begin{pmatrix}2&1\\1&2\end{pmatrix}\) and matrix([2,%i],[-%i,2]) all pass. The combined is_hpd checker makes one decision and its response tree awards full credit only when both Hermitian symmetry and positivity hold. Compare this with the separate-check question below; the teacher explanation shows the exact mathematical test.

Give any real symmetric or complex Hermitian positive definite \(2\times2\) matrix. Use integers or exact fractions for real and imaginary parts; enter %i for \(i\).

Show source
```{.stack-question #spd-example}
#| label: spd-example
#| file: questions/symmetric-positive-definite.xml
#| question: A positive definite matrix
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Project example, CC BY-SA 4.0. Uses matrix-checkers.py selected in Quarto. -->
<quiz>
  <question type="stack">
    <name>
      <text>A positive definite matrix</text>
    </name>
    <questionvariables>
      <text />
    </questionvariables>
    <questionsimplify>1</questionsimplify>
    <questiontext format="html">
      <text>&lt;p&gt;Give any real symmetric or complex Hermitian positive definite \(2\times2\) matrix. Use integers or exact fractions for real and imaginary parts; enter %i for \(i\).&lt;/p&gt;&lt;p&gt;[[input:ansm]] [[validation:ansm]] [[feedback:result]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;The checker uses Sylvester’s criterion to test positivity with exact arithmetic. Full credit requires both Hermitian symmetry and positivity. For real entries, Hermitian symmetry means ordinary symmetry.&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <input>
      <name>ansm</name>
      <type>matrix</type>
      <tans>matrix([1,0],[0,1])</tans>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <forbidfloat>1</forbidfloat>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
    </input>
    <prt>
      <name>result</name>
      <value>1</value>
      <autosimplify>1</autosimplify>
      <node>
        <name>0</name>
        <answertest>PythonChecker</answertest>
        <sans>ansm</sans>
        <tans>true</tans>
        <testoptions>{"checker": "is_hpd"}</testoptions>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truenextnode>-1</truenextnode>
        <trueanswernote>spd-T</trueanswernote>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>spd-F</falseanswernote>
      </node>
    </prt>
    <qtest>
      <testcase>1</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,0],[0,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>spd-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([2,1],[1,2])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>spd-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1/2,1/4],[1/4,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>spd-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([-1,0],[0,-1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>5</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,1],[1,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>6</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,2],[0,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>7</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,2],[2,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>8</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([2,1],[0,2])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>9</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([0,1],[0,0])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>10</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([2,%i],[-%i,2])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>spd-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>11</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,%i],[%i,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>12</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,2*%i],[-2*%i,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>13</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([0,%i],[0,0])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>spd-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>14</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1/2,%i/4],[-%i/4,1])</value>
      </testinput>
      <expected>
        <name>result</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>spd-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download question XML · View the shared matrix predicates

Hermitian symmetry and positive definiteness separately

This version checks Hermitian symmetry and positivity separately, awarding half the marks for each. The checker uses Sylvester’s criterion. See the four-case comparison to compare the two scoring choices.

Give any real symmetric or complex Hermitian positive definite \(2\times2\) matrix. Use integers or exact fractions for real and imaginary parts; enter %i for \(i\).

Half the marks are for Hermitian symmetry and half for positivity of the quadratic form.

Hermitian symmetry:

Positivity:

Show source
```{.stack-question #spd-separate-example}
#| label: spd-separate-example
#| file: questions/symmetric-positive-definite-prt.xml
#| question: Hermitian symmetry and positive definiteness separately
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Project example, CC BY-SA 4.0. Uses matrix-checkers.py selected in Quarto. -->
<quiz>
  <question type="stack">
    <name>
      <text>Hermitian symmetry and positive definiteness separately</text>
    </name>
    <questionvariables>
      <text />
    </questionvariables>
    <questionsimplify>1</questionsimplify>
    <questiontext format="html">
      <text>&lt;p&gt;Give any real symmetric or complex Hermitian positive definite \(2\times2\) matrix. Use integers or exact fractions for real and imaginary parts; enter %i for \(i\).&lt;/p&gt;&lt;p&gt;Half the marks are for Hermitian symmetry and half for positivity of the quadratic form.&lt;/p&gt;&lt;p&gt;[[input:ansm]] [[validation:ansm]]&lt;/p&gt;&lt;p&gt;Hermitian symmetry: [[feedback:symmetry]]&lt;/p&gt;&lt;p&gt;Positivity: [[feedback:positivity]]&lt;/p&gt;</text>
    </questiontext>
    <generalfeedback format="html">
      <text>&lt;p&gt;The checker uses Sylvester’s criterion to test positivity with exact arithmetic. Full credit requires both Hermitian symmetry and positivity. For real entries, Hermitian symmetry means ordinary symmetry.&lt;/p&gt;</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <input>
      <name>ansm</name>
      <type>matrix</type>
      <tans>matrix([1,0],[0,1])</tans>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <forbidfloat>1</forbidfloat>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
    </input>
    <prt>
      <name>symmetry</name>
      <value>0.5</value>
      <autosimplify>1</autosimplify>
      <node>
        <truefeedback format="html">
          <text>&lt;p&gt;The matrix is Hermitian.&lt;/p&gt;</text>
        </truefeedback>
        <falsefeedback format="html">
          <text />
        </falsefeedback>
        <name>0</name>
        <answertest>PythonChecker</answertest>
        <sans>ansm</sans>
        <tans>true</tans>
        <testoptions>{"checker": "is_hermitian"}</testoptions>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truenextnode>-1</truenextnode>
        <trueanswernote>symmetry-T</trueanswernote>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>symmetry-F</falseanswernote>
      </node>
    </prt>
    <prt>
      <name>positivity</name>
      <value>0.5</value>
      <autosimplify>1</autosimplify>
      <node>
        <truefeedback format="html">
          <text>&lt;p&gt;The matrix is positive definite.&lt;/p&gt;</text>
        </truefeedback>
        <falsefeedback format="html">
          <text />
        </falsefeedback>
        <name>0</name>
        <answertest>PythonChecker</answertest>
        <sans>ansm</sans>
        <tans>true</tans>
        <testoptions>{"checker": "is_positive_definite"}</testoptions>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truenextnode>-1</truenextnode>
        <trueanswernote>positivity-T</trueanswernote>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>positivity-F</falseanswernote>
      </node>
    </prt>
    <qtest>
      <testcase>1</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,0],[0,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([2,1],[1,2])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1/2,1/4],[1/4,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([-1,0],[0,-1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>5</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,1],[1,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>6</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,2],[0,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>symmetry-F</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>7</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,2],[2,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>8</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([2,1],[0,2])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>symmetry-F</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>9</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([0,1],[0,0])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>symmetry-F</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>10</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([2,%i],[-%i,2])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>11</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,%i],[%i,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>symmetry-F</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>12</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1,2*%i],[-2*%i,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>13</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([0,%i],[0,0])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>symmetry-F</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>0</expectedscore>
        <expectedpenalty>0.1</expectedpenalty>
        <expectedanswernote>positivity-F</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>14</testcase>
      <testinput>
        <name>ansm</name>
        <value>matrix([1/2,%i/4],[-%i/4,1])</value>
      </testinput>
      <expected>
        <name>symmetry</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>symmetry-T</expectedanswernote>
      </expected>
      <expected>
        <name>positivity</name>
        <expectedscore>1</expectedscore>
        <expectedpenalty>0</expectedpenalty>
        <expectedanswernote>positivity-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>

Download the two-PRT XML · See how to author either scoring policy

Rank and bases

These three questions adapt a linear algebra course’s rank and null-space exercises.

Rank and pivot columns: ordinary STACK answer tests

This question uses AlgEquiv and two equally weighted response trees. The rank and the complete ordered pivot list each earn half the total.

Find the rank and the pivot-column numbers of \(B={\begin{pmatrix}1 & 0 & 1 \\ 0 & 1 & 1 \\ 1 & 1 & 2\end{pmatrix}}\). List the pivot-column numbers in increasing order, one number per column. Choose the number of columns yourself.

Rank:

Pivot columns:

Show source
```{.stack-question #course-b-rank-pivots}
#| label: course-b-rank-pivots
#| file: questions/course-b-rank-pivots.xml
#| question: Rank and pivot columns of B
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Adapted from Andrey Chesnokov, ingmat3a_ntnu, section 3.8; CC BY-SA 4.0. See course-examples-provenance.json. -->
<quiz><question type="stack">
<name><text>Rank and pivot columns of B</text></name>
<questionvariables><text>B:matrix([1,0,1],[0,1,1],[1,1,2]); r:2; P:matrix([1,2]);</text></questionvariables>
<questionsimplify>1</questionsimplify>
<questiontext format="html"><text><![CDATA[<p>Find the rank and the pivot-column numbers of \(B={@B@}\). List the pivot-column numbers in increasing order, one number per column. Choose the number of columns yourself.</p><p>Rank: [[input:rankans]] [[validation:rankans]] [[feedback:rankresult]]</p><p>Pivot columns: [[input:pivots]] [[validation:pivots]] [[feedback:pivotresult]]</p>]]></text></questiontext>
<generalfeedback format="html"><text><![CDATA[Row reduction gives rows (1,0,1), (0,1,1), (0,0,0). There are two pivots, in columns 1 and 2. The two parts carry equal weight; the pivot list is assessed as a whole.]]></text></generalfeedback>
<defaultgrade>1</defaultgrade><penalty>0.1</penalty>
<input><name>rankans</name><type>algebraic</type><tans>r</tans><boxsize>8</boxsize><strictsyntax>1</strictsyntax><insertstars>0</insertstars><forbidfloat>1</forbidfloat><checkanswertype>1</checkanswertype><mustverify>1</mustverify><showvalidation>1</showvalidation></input>
<input><name>pivots</name><type>matrix</type><tans>P</tans><boxsize>8</boxsize><strictsyntax>1</strictsyntax><insertstars>0</insertstars><forbidfloat>1</forbidfloat><checkanswertype>1</checkanswertype><mustverify>1</mustverify><showvalidation>1</showvalidation><matrix><rows initial="1" min="1" max="1" resizable="0"/><cols initial="1" min="1" max="3" resizable="1"/></matrix></input>
<prt><name>rankresult</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>AlgEquiv</answertest><sans>rankans</sans><tans>r</tans>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>rank-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>rank-F</falseanswernote>
</node></prt>
<prt><name>pivotresult</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>AlgEquiv</answertest><sans>pivots</sans><tans>P</tans>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>pivots-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>pivots-F</falseanswernote>
</node></prt>
<qtest><testcase>1</testcase><testinput><name>rankans</name><value>2</value></testinput><testinput><name>pivots</name><value>matrix([1,2])</value></testinput><expected><name>rankresult</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>rank-T</expectedanswernote></expected><expected><name>pivotresult</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>pivots-T</expectedanswernote></expected></qtest>
<qtest><testcase>2</testcase><testinput><name>rankans</name><value>3</value></testinput><testinput><name>pivots</name><value>matrix([1,2])</value></testinput><expected><name>rankresult</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>rank-F</expectedanswernote></expected><expected><name>pivotresult</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>pivots-T</expectedanswernote></expected></qtest>
<qtest><testcase>3</testcase><testinput><name>rankans</name><value>2</value></testinput><testinput><name>pivots</name><value>matrix([2,1])</value></testinput><expected><name>rankresult</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>rank-T</expectedanswernote></expected><expected><name>pivotresult</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>pivots-F</expectedanswernote></expected></qtest>
<qtest><testcase>4</testcase><testinput><name>rankans</name><value>2</value></testinput><testinput><name>pivots</name><value>matrix([1])</value></testinput><expected><name>rankresult</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>rank-T</expectedanswernote></expected><expected><name>pivotresult</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>pivots-F</expectedanswernote></expected></qtest>
</question></quiz>

Download XML

A basis for the null space of B

Put one proposed basis vector in each column. A basis is not a unique matrix: changing a vector’s nonzero scale can still give a correct answer. Choose the number of columns before validating. The checker uses the original matrix \(B\) to define the space, so another independent basis is accepted.

Give a basis for the null space of \(B={\begin{pmatrix}1 & 0 & 1 \\ 0 & 1 & 1 \\ 1 & 1 & 2\end{pmatrix}}\), with one vector in each column. Any basis is accepted. Choose the number of columns yourself; use exact fractions.

Show source
```{.stack-question #course-b-nullspace}
#| label: course-b-nullspace
#| file: questions/course-b-nullspace.xml
#| question: A basis for the null space of B
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Adapted from Andrey Chesnokov, ingmat3a_ntnu, section 3.8; CC BY-SA 4.0. See course-examples-provenance.json. -->
<quiz><question type="stack">
<name><text>A basis for the null space of B</text></name>
<questionvariables><text>A:matrix([1,0,1],[0,1,1],[1,1,2]);</text></questionvariables>
<questionsimplify>1</questionsimplify>
<questiontext format="html"><text><![CDATA[<p>Give a basis for the null space of \(B={@A@}\), with one vector in each column. Any basis is accepted. Choose the number of columns yourself; use exact fractions.</p><p>[[input:ans]] [[validation:ans]] [[feedback:result]]</p>]]></text></questiontext>
<generalfeedback format="html"><text><![CDATA[The equation Bz=0 gives z=(-t,-t,t). Any nonzero multiple of (-1,-1,1) is a basis. Two such columns are dependent.]]></text></generalfeedback>
<defaultgrade>1</defaultgrade><penalty>0.1</penalty>
<input><name>ans</name><type>matrix</type><tans>nullspace_basis(A)</tans><boxsize>8</boxsize><strictsyntax>1</strictsyntax><insertstars>0</insertstars><forbidfloat>1</forbidfloat><checkanswertype>1</checkanswertype><mustverify>1</mustverify><showvalidation>1</showvalidation><matrix><rows initial="3" min="3" max="3" resizable="0"/><cols initial="1" min="1" max="3" resizable="1"/></matrix></input>
<prt><name>result</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>PythonChecker</answertest><sans>ans</sans><tans>A</tans><testoptions>{"checker": "basis", "options": {"space": "nullspace"}}</testoptions>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>basis-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>basis-F</falseanswernote>
</node></prt>
<qtest><testcase>1</testcase><testinput><name>ans</name><value>matrix([-1],[-1],[1])</value></testinput><expected><name>result</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>basis-T</expectedanswernote></expected></qtest>
<qtest><testcase>2</testcase><testinput><name>ans</name><value>matrix([2],[2],[-2])</value></testinput><expected><name>result</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>basis-T</expectedanswernote></expected></qtest>
<qtest><testcase>3</testcase><testinput><name>ans</name><value>matrix([0],[0],[0])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
<qtest><testcase>4</testcase><testinput><name>ans</name><value>matrix([1],[0],[0])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
<qtest><testcase>5</testcase><testinput><name>ans</name><value>matrix([-1,2],[-1,2],[1,-2])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
</question></quiz>

Download XML

A basis for the null space of C

Here you may reorder or combine basis vectors, provided your columns remain independent and span the null space of \(C\). Entry-by-entry equality with one model matrix would reject many correct answers. The checker uses the original matrix \(C\) to define the target space.

Give a basis for the null space of \(C={\begin{pmatrix}1 & 2 & 3 \\ 2 & 4 & 6\end{pmatrix}}\), with one vector in each column. Any basis is accepted. Choose the number of columns yourself; use exact fractions.

Show source
```{.stack-question #course-c-nullspace}
#| label: course-c-nullspace
#| file: questions/course-c-nullspace.xml
#| question: A basis for the null space of C
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- Adapted from Andrey Chesnokov, ingmat3a_ntnu, section 3.8; CC BY-SA 4.0. See course-examples-provenance.json. -->
<quiz><question type="stack">
<name><text>A basis for the null space of C</text></name>
<questionvariables><text>A:matrix([1,2,3],[2,4,6]);</text></questionvariables>
<questionsimplify>1</questionsimplify>
<questiontext format="html"><text><![CDATA[<p>Give a basis for the null space of \(C={@A@}\), with one vector in each column. Any basis is accepted. Choose the number of columns yourself; use exact fractions.</p><p>[[input:ans]] [[validation:ans]] [[feedback:result]]</p>]]></text></questiontext>
<generalfeedback format="html"><text><![CDATA[Cz=0 is equivalent to z1+2*z2+3*z3=0. Every solution has the form s*(-2,1,0)+t*(-3,0,1). Any two independent vectors in this plane form a basis; they need not be these two vectors.]]></text></generalfeedback>
<defaultgrade>1</defaultgrade><penalty>0.1</penalty>
<input><name>ans</name><type>matrix</type><tans>nullspace_basis(A)</tans><boxsize>8</boxsize><strictsyntax>1</strictsyntax><insertstars>0</insertstars><forbidfloat>1</forbidfloat><checkanswertype>1</checkanswertype><mustverify>1</mustverify><showvalidation>1</showvalidation><matrix><rows initial="3" min="3" max="3" resizable="0"/><cols initial="1" min="1" max="3" resizable="1"/></matrix></input>
<prt><name>result</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>PythonChecker</answertest><sans>ans</sans><tans>A</tans><testoptions>{"checker": "basis", "options": {"space": "nullspace"}}</testoptions>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>basis-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>basis-F</falseanswernote>
</node></prt>
<qtest><testcase>1</testcase><testinput><name>ans</name><value>matrix([-2,-3],[1,0],[0,1])</value></testinput><expected><name>result</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>basis-T</expectedanswernote></expected></qtest>
<qtest><testcase>2</testcase><testinput><name>ans</name><value>matrix([-3,-2],[0,1],[1,0])</value></testinput><expected><name>result</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>basis-T</expectedanswernote></expected></qtest>
<qtest><testcase>3</testcase><testinput><name>ans</name><value>matrix([-5,-1],[1,-1],[1,1])</value></testinput><expected><name>result</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>basis-T</expectedanswernote></expected></qtest>
<qtest><testcase>4</testcase><testinput><name>ans</name><value>matrix([-4,-3],[2,0],[0,1])</value></testinput><expected><name>result</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>basis-T</expectedanswernote></expected></qtest>
<qtest><testcase>5</testcase><testinput><name>ans</name><value>matrix([-2],[1],[0])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
<qtest><testcase>6</testcase><testinput><name>ans</name><value>matrix([-2,-4],[1,2],[0,0])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
<qtest><testcase>7</testcase><testinput><name>ans</name><value>matrix([-2,1],[1,0],[0,0])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
<qtest><testcase>8</testcase><testinput><name>ans</name><value>matrix([-2,-3,-5],[1,0,1],[0,1,1])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
<qtest><testcase>9</testcase><testinput><name>ans</name><value>matrix([0,0],[0,0],[0,0])</value></testinput><expected><name>result</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>basis-F</expectedanswernote></expected></qtest>
</question></quiz>

Download XML

For both basis questions, green marks a nonzero vector in the target space when the valid submitted vectors are independent. A green family can still be incomplete. Yellow marks every member of a dependent valid family; red marks a zero vector or one outside the space. The whole answer earns credit only when it is a complete basis. Colors explain the result but do not award partial marks. Editing or resizing clears them.

Read how to author a basis question or configure its matrix input.

A custom scalar rule

Custom Python checker

Enter any positive integer multiple of the displayed number. A block checker: decides whether the submitted integer has the required property. The XML node uses it as a predicate, and the implicit checker tree contributes its score with the default weight 1. See the author API.

Enter any positive integer multiple of \(2\).

Show source
```{.stack-question #python-multiple}
#| label: python-multiple
#| file: questions/python-checker.xml
#| question: A positive integer multiple (PythonChecker)
#| checker: |
#|   def check(response, symbols):
#|       student = response["answers"]["ans"]
#|       divisor = response["variables"]["d"]
#|       if student.is_Integer is not True:
#|           return {"valid": False, "feedback": "Enter an integer value."}
#|       correct = student > 0 and student % divisor == 0
#|       return {"correct": bool(correct),
#|               "feedback": "" if correct else "Use a positive integer multiple of the given number."}
#| variants: 3
#| review: true
```
Show STACK source
<?xml version="1.0" encoding="UTF-8"?>
<!-- CTM team, CC BY-SA 4.0. PythonChecker requires this port and questions/checkers.py. -->
<quiz><question type="stack">
<name><text>A positive integer multiple (PythonChecker)</text></name>
<questionvariables><text>d:rand(3)+2;</text></questionvariables>
<questionsimplify>1</questionsimplify>
<questiontext format="html"><text><![CDATA[<p>Enter any positive integer multiple of {@d@}.</p><p>[[input:ans]] [[validation:ans]] [[feedback:prt1]]</p>]]></text></questiontext>
<generalfeedback format="html"><text><![CDATA[<p>Multiplying the given integer by any positive integer gives an answer. The Python predicate decides whether the condition holds; the response tree awards credit.</p>]]></text></generalfeedback>
<defaultgrade>1</defaultgrade><penalty>0.1</penalty>
<input><name>ans</name><type>algebraic</type><tans>d</tans><strictsyntax>1</strictsyntax><insertstars>0</insertstars><forbidfloat>0</forbidfloat><checkanswertype>1</checkanswertype><mustverify>1</mustverify><showvalidation>1</showvalidation></input>
<prt><name>prt1</name><value>1</value><autosimplify>1</autosimplify><node><name>0</name><answertest>PythonChecker</answertest><sans>ans</sans><tans>d</tans><testoptions>{"checker": "check"}</testoptions>
<truescoremode>=</truescoremode><truescore>1</truescore><truenextnode>-1</truenextnode><trueanswernote>multiple-T</trueanswernote>
<falsescoremode>=</falsescoremode><falsescore>0</falsescore><falsenextnode>-1</falsenextnode><falseanswernote>multiple-F</falseanswernote>
</node></prt>
<qtest><testcase>1</testcase><testinput><name>ans</name><value>d</value></testinput><expected><name>prt1</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>multiple-T</expectedanswernote></expected></qtest>
<qtest><testcase>2</testcase><testinput><name>ans</name><value>3*d</value></testinput><expected><name>prt1</name><expectedscore>1</expectedscore><expectedpenalty>0</expectedpenalty><expectedanswernote>multiple-T</expectedanswernote></expected></qtest>
<qtest><testcase>3</testcase><testinput><name>ans</name><value>-d</value></testinput><expected><name>prt1</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>multiple-F</expectedanswernote></expected></qtest>
<qtest><testcase>4</testcase><testinput><name>ans</name><value>d+1</value></testinput><expected><name>prt1</name><expectedscore>0</expectedscore><expectedpenalty>0.1</expectedpenalty><expectedanswernote>multiple-F</expectedanswernote></expected></qtest>
</question></quiz>

For developers

Use the authoring guide for imports, question options, tests and AI Feedback policies. The Python answer-test guide explains the basis and property choices and gives the complete positive-definiteness checker walkthrough. The questions above link to their XML; the matrix predicates live in the shared checker library. The rational activity chooses the two-step-practice policy, while other feedback activities inherit a four-step sequence; see policy setup. Run authored tests and inspect alternate correct answers before publishing.

Sources

The determinant-one question adapts a math-exercise custom-assessment example; its provenance record gives the adaptation and license. The rank/pivot and null-space questions adapt INGMat 3A week 3 exercises under CC BY-SA 4.0; their source record identifies the exact originals. The unchanged imported questions come from the STACK collection, with individual source and license details.