Numeric Questions in LaTeX

Question Mode: Numeric

 

The Numeric question type accepts either a number in decimal or scientific notation, or a number with units for an answer.

 

You must specify units as an optional argument to the \answer macro. For example:

\answer[m/s^2]{9.8}

Because it is natural to specify the units after the number, you can use the format:

\answer{9.8}[m/s^2]

 

Notes:

    m (meter)

    kg (kilogram)

    s (second)

    A (amp)

    K (kelvin)

    cd (Candela)

 

Important: Because the system converts between systems of units using inexact conversion factors, it is recommended that you accept responses in a margin of error in questions with units.

 

 

 

Example 1

\begin{question}{numeric}

\qutext{Compute the exact value of the function $f(x)=3x^4-2x^2-1$ at

$x=2.1$.}

\answer{48.5243} % exact value grading

\end{question}

Example 2

\begin{question}{numeric}

\qutext{Compute the value of $\log(45)$. Round your answer to 5

significant digits.}

\answer{1.6532} % This question uses exact grading because \digits is not used

% In this case, a more accurate response is graded incorrect.

\end{question}

Example 3

\begin{question}{numeric}

\qutext{Compute the value of $\log(45)$. Your answer must be correct

to at least 5 decimal places.}

\answer{1.653212514}

\err{0.00001} % absolute tolerance

% Any numerical response between 1.653202514 and 1.653222514 is

% graded correct.

\end{question}

Example 4

\begin{question}{numeric}

% This question uses algorithmic variables.

\qutext{Compute the value of $\log(\var{a})$. Your answer must be

correct to at least 5 decimal places.}

\answer{\var{ans}}

\err{0.00001}

\code{

$a=rand(1,100,4);

$ans=log($a);

}

% The above code chooses a random value a between 1 and 100, to four

% significant figures. The value of log(a) is then calculated.

\end{question}

  Example 5

\begin{question}{numeric}

\qutext{A man is on the top of a tower that is 800 feet above ground.

How far can he see?

\newline\newline

Use 3960 miles for the radius of the earth.\newline

Express your answer to an accuracy of at least 6 significant digits.}

\answer{34.64134750325308}[mi]

\err{0.0001} % Note: Using \digits{6} would allow no tolerance, and would

             % cause '182906 ft' and '34.6413 mi' to be graded incorrect

             % because the values do not match the correct answer.

\end{question}

Example 6

\begin{question}{numeric}

% If the ability to convert units is not an important part of the

% question, do not use units.

\qutext{A cat is on the top of a tower that is 800 feet above ground.

How far (in miles) can it see?

\newline\newline

Use 3960 miles for the radius of the earth.\newline

Express your answer to an accuracy of at least 4 decimal places.\newline

Do NOT include any units in your answer.}

\answer{34.64134750325308}

\err{0.0001}

\end{question}

Example 7

\begin{question}{numeric}

% An algorithmic version of the previous question.

% The height is a multiple of 50 in [400,900).

\code{$height = int(range(400,900,50));

      $answer = sqrt((3960 + $height/5280)^2 - 3960^2);}

\qutext{A woman is on the top of a tower that is \var{height} feet above

ground. How far (in miles) can she see?

\newline\newline

Use 3960 miles for the radius of the earth.\newline

Express your answer to an accuracy of at least 6 significant digits.}

\answer[mi]{\var{answer}}

\err{2}    % Accept any response within +/- 2 units

\digits{6} % in the sixth significant digit.

\end{question}