"AlgebraicValue" (Comparison Method)
Details
- The algebra solution comparison method considers two expressions to be equivalent if they are mathematically equal without performing any solving operations, e.g. Solve, SolveValues, Fit, Reduce, etc.
- The values of the key and answer can both be specified as held expressions with Hold[expr] to maintain the values exactly as provided. However, even when the values are held, evaluation of non-algebra functions (i.e. excluding Solve and similar functions) is performed during assessment. It is recommended to always hold the answer.
- "AlgebraicValue" assessments accept the setting "OptionalResultName" for specifying the variable of interest in a question: AssessmentFunction[key,<|"ComparisonMethod""AlgebraicValue","OptionalResultName"setting|>]
- The supported values of setting include:
-
var accept the variable var in the submitted result False (default) only match answers provided as ans True attempt to infer var from the key - When using "OptionalResultName"var, any of the following forms are accepted as correct for an answer ans:
-
ans Hold[var=ans] Hold[var==ans] varans - Equations and inequalities are supported in the answer key, and any equivalent form is considered correct.
- The following tables show comparisons of "AlgebraicValue" with other comparison methods for typical answer keys:


Examples
open all close allBasic Examples (1)
Create an AssessmentFunction for an algebra question:
Scope (5)
Create an assessment function to find where a line intersects a circle:
Define code that finds a solution:
The code is not marked as correct because it contains algebraic solving code:
Allowing the code to evaluate to a correct answer before assessment gives a correct marking:
Calculate a solution to an equation:
Create an assessment that accepts alternate forms of answers containing the variable x as the result name:
The regular answer does not need to include the variable name that is searched for:
The alternate forms accepted are:
The use of any other variable name results in a false assessment:
The variable name can be inferred from the answer key if it uses any of the allowed alternate forms:
The variable name needs not to figure in the answer:
Compute the solution to an equation reduction problem:
Define an assessment function:
All equations equivalent to the correct answer are accepted:
The original question is not accepted as an answer:
Create an assessment function for an inequality:
Equivalent inequalities are marked as correct:
Use "AlgebraicForm" to more tightly limit accepted answers:
Applications (3)
Create a QuestionObject for an algebra problem with multiple correct answers:
Create a QuestionObject for a geometry question:
Create a polynomial solving problem including a plot to help find values. Setting "OptionalResultName" allows flexibility in the accepted answer forms:
Properties & Relations (3)
Evaluation for operations not considered to be algebra occurs even when the answer is held:
When values are held, global definitions are ignored during assessment:
Global definitions may also conflict with the name specified for the "OptionalResultName", if the variable is not held:
Wrap the variable into Hold or HoldPattern to ignore the global definition:
"AlgebraicValue" method allows functions, like Plus, that do not solve algebraic problems to evaluate:
Functions that do solve algebraic problems do not evaluate and are marked incorrect:
"CalculusResult" allows the algebraic solving functions to evaluate:
Possible Issues (1)
Create an answer key using Solve for multiple variables:
Creating an AssessmentFunction with the default "ListAssessment" setting treats each list in the key as a single answer:
Only answers identical to the keys are considered as correct:
Even with the setting "OptionalResultName"True, values without variable names are marked as incorrect:
Instead, use "AllElementsOrderless" or "AllElementsOrdered" as the "ListAssessment" setting to assess each subvalue independently:
Each individual element of the key and answer is matched separately, and the "OptionalResultName" setting works as expected:
Mathematically equivalent results that differ only by arithmetic are accepted:
To provide answers using an equal sign, use Hold to prevent setting values:
See Also
AssessmentFunction QuestionObject Solve SolveValues Reduce
Question Interface Types: ShortAnswer MultipleShortAnswers
Comparison Methods: ArithmeticResult CalculusResult PolynomialResult