Skip to content
Snippets Groups Projects
Commit 8bef817b authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Update the documentation, and add in test cases.

parent 5d2d9d12
Branches
No related tags found
No related merge requests found
...@@ -32,9 +32,9 @@ This is the most commonly used test. The pseudo code ...@@ -32,9 +32,9 @@ This is the most commonly used test. The pseudo code
This test will work with a variety of [types of object](../../CAS/Maxima_background.md#Types_of_object) of mathematical objects, including lists, sets, equations, inequalities and matrices. This test will work with a variety of [types of object](../../CAS/Maxima_background.md#Types_of_object) of mathematical objects, including lists, sets, equations, inequalities and matrices.
* This test disregards whether [simplification](../../CAS/Simplification.md) is switched on, it always fully simplifies all its arguments. * This test disregards whether [simplification](../../CAS/Simplification.md) is switched on, it always fully simplifies all its arguments.
* Use `AlgEquiv(predicate(ex),true)` with [predicate functions](../../CAS/Predicate_functions.md). * Use `AlgEquiv(predicate(ex),true)` with [predicate functions](../../CAS/Predicate_functions.md), to test the result is true. But note that many predicate functions only work without simplification! In particular, testing for "form" such as scientific notation need `simp:false`, in which case use `EqualComAss(predicate(ex),true)` rather than algebraic equivalence.
Note: exactly what it does depends on what objects are given to it. In particular the pseudo code above only applies to expressions. We cannot subtract one list or set from another, so we have to use other tests. Note: exactly what this answer test does depends on what objects are given to it. In particular the pseudo code above only applies to expressions. We cannot subtract one list or set from another, so we have to use other tests.
For sets, the CAS tries to write the expression in a canonical form. It then compares the string representations these forms to remove duplicate elements and compare sets. This is subtly different from trying to simplify the difference of two expressions to zero. For example, imagine we have \(\{(x-a)^{6000}\}\) and \(\{(a-x)^{6000}\}\). One canonical form is to expand out both sides. While this work in principal, in practice this is much too slow for assessment. For sets, the CAS tries to write the expression in a canonical form. It then compares the string representations these forms to remove duplicate elements and compare sets. This is subtly different from trying to simplify the difference of two expressions to zero. For example, imagine we have \(\{(x-a)^{6000}\}\) and \(\{(a-x)^{6000}\}\). One canonical form is to expand out both sides. While this work in principal, in practice this is much too slow for assessment.
......
...@@ -109,6 +109,8 @@ There are groups of common keywords which you can forbid simply as ...@@ -109,6 +109,8 @@ There are groups of common keywords which you can forbid simply as
* `[[BASIC-CALCULUS]]` common calculus operations such as `int`, `diff`, `taylor`, etc. * `[[BASIC-CALCULUS]]` common calculus operations such as `int`, `diff`, `taylor`, etc.
* `[[BASIC-MATRIX]]` common matrix operations such as `transpose`, `invert`, `charpoly`, etc. * `[[BASIC-MATRIX]]` common matrix operations such as `transpose`, `invert`, `charpoly`, etc.
These list are hard-wired into the code [here](https://github.com/maths/moodle-qtype_stack/blob/master/stack/cas/cassecurity.class.php#L56).
If you have suggestions for more lists, or additional operations which should be added to the existing lists, please contact the developers. If you have suggestions for more lists, or additional operations which should be added to the existing lists, please contact the developers.
......
...@@ -155,3 +155,4 @@ The following commands generate displayed forms of numbers. These will not be m ...@@ -155,3 +155,4 @@ The following commands generate displayed forms of numbers. These will not be m
| `anyfloatex(ex)` | Decides if any floats are in the expression. | `anyfloatex(ex)` | Decides if any floats are in the expression.
| `scientific_notationp(ex)` | Determines if \(ex\) is written in the form \(a10^n\) where \(a\) is an integer or float, and \(n\) is an integer. | `scientific_notationp(ex)` | Determines if \(ex\) is written in the form \(a10^n\) where \(a\) is an integer or float, and \(n\) is an integer.
Please note that these predicate functions need to be used with `simp:false`. Some answer tests, including the default algebraic equivalence (`ATAlgEquiv`) always simplify their arguments. Instead use a non-simplifying answer test such as `EqualComAss`.
...@@ -49,8 +49,7 @@ class stack_cas_security { ...@@ -49,8 +49,7 @@ class stack_cas_security {
/** /**
* These lists are used by question authors for groups of words. * These lists are used by question authors for groups of words.
* They should be lower case, because Maxima is lower case, and these correspond to Maxima names. * These correspond to Maxima names, and should follow the case in maxima, e.g. "ModeMatrix" for an example.
* Actually, not lower case, Maxima is not case insensitive just check "ModeMatrix" for an example.
*/ */
public static $keywordlists = [ public static $keywordlists = [
'[[basic-algebra]]' => [ '[[basic-algebra]]' => [
......
...@@ -75,6 +75,7 @@ class stack_answertest_test_data { ...@@ -75,6 +75,7 @@ class stack_answertest_test_data {
['AlgEquiv', '', 'lowesttermsp(-y/-x)', 'true', 1, 'ATLogic_True.', ''], ['AlgEquiv', '', 'lowesttermsp(-y/-x)', 'true', 1, 'ATLogic_True.', ''],
['AlgEquiv', '', 'lowesttermsp((x^2-1)/(x-1))', 'true', 0, '', ''], ['AlgEquiv', '', 'lowesttermsp((x^2-1)/(x-1))', 'true', 0, '', ''],
['AlgEquiv', '', 'lowesttermsp((x^2-1)/(x+2))', 'true', 1, 'ATLogic_True.', ''], ['AlgEquiv', '', 'lowesttermsp((x^2-1)/(x+2))', 'true', 1, 'ATLogic_True.', ''],
['AlgEquiv', '', 'scientific_notationp(4.1561*10^16)', 'true', 0, '', ''],
['AlgEquiv', '', 'X', 'x', 0, 'ATAlgEquiv_WrongCase.', 'Case sensitivity'], ['AlgEquiv', '', 'X', 'x', 0, 'ATAlgEquiv_WrongCase.', 'Case sensitivity'],
['AlgEquiv', '', '1/(R-r)', '1', 0, '', ''], ['AlgEquiv', '', '1/(R-r)', '1', 0, '', ''],
['AlgEquiv', '', 'exdowncase(X)', 'x', 1, '', ''], ['AlgEquiv', '', 'exdowncase(X)', 'x', 1, '', ''],
...@@ -997,6 +998,9 @@ class stack_answertest_test_data { ...@@ -997,6 +998,9 @@ class stack_answertest_test_data {
['EqualComAss', '', 'lowesttermsp((x^2-1)/(x-1))', 'true', 0, 'ATEqualComAss (AlgEquiv-false).', ''], ['EqualComAss', '', 'lowesttermsp((x^2-1)/(x-1))', 'true', 0, 'ATEqualComAss (AlgEquiv-false).', ''],
['EqualComAss', '', 'lowesttermsp((x^2-1)/(x+2))', 'true', 1, '', ''], ['EqualComAss', '', 'lowesttermsp((x^2-1)/(x+2))', 'true', 1, '', ''],
['EqualComAss', '', 'scientific_notationp(1/3)', 'true', 0, 'ATEqualComAss (AlgEquiv-false).', ''],
['EqualComAss', '', 'scientific_notationp(4.1561*10^16)', 'true', 1, '', ''],
// We can't use ATAlgEquiv with rationalized as Maxima simplified sqrt(3)/3 to 1/sqrt(3). // We can't use ATAlgEquiv with rationalized as Maxima simplified sqrt(3)/3 to 1/sqrt(3).
['EqualComAss', '', 'rationalized(1+sqrt(3)/3)', 'true', 1, '', 'Bad things in denominators'], ['EqualComAss', '', 'rationalized(1+sqrt(3)/3)', 'true', 1, '', 'Bad things in denominators'],
['EqualComAss', '', 'rationalized(1+1/sqrt(3))', '[sqrt(3)]', 1, '', ''], ['EqualComAss', '', 'rationalized(1+1/sqrt(3))', '[sqrt(3)]', 1, '', ''],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment