Skip to content

Commit

Permalink
Update the documentation, and add in test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
sangwinc committed Jan 2, 2025
1 parent 5d2d9d1 commit 8bef817
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions doc/en/Authoring/Answer_Tests/Equivalence.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.

Expand Down
2 changes: 2 additions & 0 deletions doc/en/Authoring/Inputs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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.


Expand Down
1 change: 1 addition & 0 deletions doc/en/CAS/Numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
| `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`.
3 changes: 1 addition & 2 deletions stack/cas/cassecurity.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class stack_cas_security {

/**
* 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.
* Actually, not lower case, Maxima is not case insensitive just check "ModeMatrix" for an example.
* These correspond to Maxima names, and should follow the case in maxima, e.g. "ModeMatrix" for an example.
*/
public static $keywordlists = [
'[[basic-algebra]]' => [
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/answertestfixtures.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class stack_answertest_test_data {
['AlgEquiv', '', 'lowesttermsp(-y/-x)', 'true', 1, 'ATLogic_True.', ''],
['AlgEquiv', '', 'lowesttermsp((x^2-1)/(x-1))', 'true', 0, '', ''],
['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', '', '1/(R-r)', '1', 0, '', ''],
['AlgEquiv', '', 'exdowncase(X)', 'x', 1, '', ''],
Expand Down Expand Up @@ -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+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).
['EqualComAss', '', 'rationalized(1+sqrt(3)/3)', 'true', 1, '', 'Bad things in denominators'],
['EqualComAss', '', 'rationalized(1+1/sqrt(3))', '[sqrt(3)]', 1, '', ''],
Expand Down

0 comments on commit 8bef817

Please sign in to comment.