The Formula question type is the most general math question type. Answers can be any kind of formula, entered in calculator syntax, or using the system Symbolic Editor entry mode. Independent of entry method, answers are encoded as MathML, enabling the system to grade equivalent answers correctly. Answers can include variables and standard functions.
Notes
The \answer field is a calculated field. It must be in calculator syntax, not in TeX. Enter the answer as you expect the student to enter it (although equivalent answers are graded correct).
If the answer is a number (that is, does not have any variables), it is recommended that you specify in the question text whether an exact response or an approximation is required. In the case of an approximation, the margin of error must be specified in your correct answer. This can be done by:
Specifying a margin of error using the ? operator
For example, if the answer field were
{2.34 ? 0.01}
any response between 2.33 and 2.35 (inclusive) would be graded correct. In other words, the number following the ? operator is the margin of error. For more information on tolerances, see Setting a Margin of Error in Non-numeric Questions.
\begin{question}{Formula}
\qutext{What is the derivative of $x^3+3\cos(x)-1$?}
% Use calculator syntax for the answer, not TeX.
\answer{3x^2-3*sin(x)}
\end{question}
\begin{question}{Formula}
\qutext{Compute the exact value of $f'(2)$ if $f(x)=x^3+3\cos(x)-1$.}
\answer{12-3*sin(2)}
% Any numerical approximation is graded incorrect.
\end{question}
\begin{question}{Formula}
\qutext{Compute $f'(2)$ if $f(x)=x^3+3\cos(x)-1$. Round your answer to
5 significant digits.}
\answer{9.2721}
% In this case, a more (or less) accurate response is graded incorrect.
\end{question}
\begin{question}{Formula}
\qutext{Compute $f'(2)$ if $f(x)=x^3+3\cos(x)-1$. Your answer should be
correct to an accuracy of at least 5 decimal places.}
\answer{9.27211 ? 0.00001}
% Any response between 9.27210 and 09.27212 is graded correct.
% The response '12-3*sin(2)' is also acceptable.
\end{question}
\begin{question}{Formula}
% This question uses randomized variables.
\qutext{Find the formula for the inverse of the function
$f(x)=\var{a}x+\var{b}$.}
\answer{(x-\var{b})/\var{a}}
\code{
$a=int(rint(9)+2);
$b=int(rint(9)+2);
}
% The above code chooses random integer coefficients a and b between
% 2 and 10.
\end{question}