Skip to content

Commit de4b0a1

Browse files
committed
Document current behaviour for issue #1727.
1 parent 02fe210 commit de4b0a1

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

doc/en/Authoring/Answer_Tests/Equivalence.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This list is in approximate order of the size of the equivalence classes from mo
2020

2121
### AlgEquiv {#AlgEquiv}
2222

23-
This is the most commonly used test. The pseudo code
23+
This is the most commonly used test. The pseudo code (for mathematical _expressions_ at least) is
2424

2525
If
2626
simplify(ex1-ex2) = 0
@@ -38,7 +38,24 @@ Note: exactly what this answer test does depends on what objects are given to it
3838

3939
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.
4040

41-
Currently we do check multiplicity of roots, so that \( (x-2)^2=0\) and \( x=2\) are not considered to be equivalent. Similarly \(a^3b^3=0\) is not \(a=0 \text{ or } b=0\). This is a long-standing issue and we would need a separate test to ignore multiplicity of roots.
41+
Equations and expressions are very different. Two equations are equivalent if they have the same roots with the same multiplicity of roots. For example, \((x-2)^2=0\) and \(x=2\) are not considered to be equivalent. Similarly \(a^3b^3=0\) is not \(a=0 \text{ or } b=0\). To establish equivalence of equations we use the pseudo code
42+
43+
If
44+
numberp( (lhs(ex1)-rhs(ex1))/(lhs(ex2)-rhs(ex2)) )
45+
then
46+
true
47+
else
48+
false.
49+
50+
That is to say, we turn the equation `ex1` into an expression `x1:simplify(lhs(ex1)-rhs(ex1))` and the equation `ex2` into an expression `x2:simplify(lhs(ex2)-rhs(ex2))`, and then simplify the ratio of the two numerators of `x1` and `x2`:, i.e. `num(x1)/num(x2)` (with some edge case detection of course). If this is a number then we have cancelled algebraic factors precicely, and roots match (with multiplicity). Notice we do not actually "solve" the equations during this process, thereby side-stepping the decidability question. (We would need a separate test to ignore multiplicity of roots.)
51+
52+
In calculating the ratio `x1/x2` we use Maxima's simplifer, which may be modified by commands like `assume`. However, since we do not actually solve the equations we do not use `assume` to reject solutions themselves. For example, in the following situation
53+
54+
assume(x>0);
55+
eq1: a = (c*x^3)/x;
56+
eq2: a*x = c*x^3;
57+
58+
`eq1` does not have \(0\) as a solution, whereas `eq2` does have \(0\) as a solution, the ratio simplifes to `1/x` indicating that `eq2` has a zero solution which is not balanced by a corresponding solution in `eq`. Since the equations are never solved, the `assume(x>0)` never comes into play here. (We would need a separate test to use `assume` statements and reject roots.)
4259

4360
Inequalities are turned into sets of real numbers they represent. When this is done it is indicated by the answer note `ATInequality_solver.` If you want `a>1` to be _not_ the same as `x>1` then you need to test in a more syntactic way, not using algebraic equivalence.
4461

stack/maxima/stackmaxima.mac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,8 @@ ATEquation(SA, SB) := block([keepfloat, RawMark, SA1, SB1, SB2, Rationalex1, Rat
14891489
return([true, true, "ATEquation_zero", ""])
14901490
else return([true, false, "ATEquation_zero_fail", ""]),
14911491
if numberp(float(abs(Rationalex1/Rationalex2))) then
1492-
return([true, true, "", ""]), Rationalex1:num(ratsimp(Rationalex1)),
1492+
return([true, true, "ATEquation_num", ""]),
1493+
Rationalex1:num(ratsimp(Rationalex1)),
14931494
Rationalex2:num(ratsimp(Rationalex2)),
14941495
if algebraic_equivalence(abs(Rationalex1/Rationalex2), 1) then
14951496
return([true, true, "ATEquation_ratio", ""]),

tests/fixtures/answertestfixtures.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class stack_answertest_test_data {
408408
['AlgEquiv', '', 'x=2', 'x=1', 0, 'ATEquation_lhs_notrhs', ''],
409409
['AlgEquiv', '', '2=x', 'x=1', 0, 'ATEquation_default', ''],
410410
['AlgEquiv', '', 'x=x', 'y=y', 1, 'ATEquation_zero', ''],
411-
['AlgEquiv', '', 'x+y=1', 'y=1-x', 1, '', ''],
411+
['AlgEquiv', '', 'x+y=1', 'y=1-x', 1, 'ATEquation_num', ''],
412412
['AlgEquiv', '', '2*x+2*y=1', 'y=0.5-x', 1, 'ATEquation_ratio', ''],
413413
['AlgEquiv', '', '1/x+1/y=2', 'y = x/(2*x-1)', 1, 'ATEquation_ratio', ''],
414414
['AlgEquiv', '', 'y=sin(2*x)', 'y/2=cos(x)*sin(x)', 1, 'ATEquation_ratio', ''],
@@ -417,14 +417,14 @@ class stack_answertest_test_data {
417417
['AlgEquiv', '', 'y=(a-x)^6000', 'y=(x-a)^6000', 1, 'ATEquation_sides', ''],
418418
['AlgEquiv', '', 'y=(a-x)^5999', 'y=(x-a)^5999', 0, 'ATEquation_lhs_notrhs', ''],
419419
['AlgEquiv', '', 'y=(a-x)^59999', 'y=(x-a)^5999', 0, 'ATEquation_lhs_notrhs', ''],
420-
['AlgEquiv', '', 'x+y=i', 'y=i-x', 1, '', ''],
421-
['AlgEquiv', '', '(1+%i)*(x+y)=0', 'y=-x', 1, '', ''],
420+
['AlgEquiv', '', 'x+y=i', 'y=i-x', 1, 'ATEquation_num', ''],
421+
['AlgEquiv', '', '(1+%i)*(x+y)=0', 'y=-x', 1, 'ATEquation_num', ''],
422422
['AlgEquiv', '', 's^2*%e^(s*t)=0', 's^2=0', 0, 'ATEquation_default', ''],
423-
['AlgEquiv', '', '0=-x+y/A+(y-z)/B', '0=x-y/A-(y-z)/B', 1, '', ''],
423+
['AlgEquiv', '', '0=-x+y/A+(y-z)/B', '0=x-y/A-(y-z)/B', 1, 'ATEquation_num', ''],
424424
['AlgEquiv', '', 'x^6000-x^6001=x^5999', 'x^5999*(1-x+x^2)=0', 1, 'ATEquation_ratio', ''],
425425
['AlgEquiv', '', 'x^6000-x^6001=x^5999', 'x^5999*(1-x+x^3)=0', 0, 'ATEquation_default', ''],
426426
['AlgEquiv', '', '258552*x^7*(81*x^8+1)^398', 'x^3*(x^4+1)^399', 0, '', ''],
427-
['AlgEquiv', '', 'Ia*(R1+R2+R3)-Ib*R3=0', '-Ia*(R1+R2+R3)+Ib*R3=0', 1, '', ''],
427+
['AlgEquiv', '', 'Ia*(R1+R2+R3)-Ib*R3=0', '-Ia*(R1+R2+R3)+Ib*R3=0', 1, 'ATEquation_num', ''],
428428
['AlgEquiv', '', 'a=0 or b=0', 'a*b=0', 1, 'ATEquation_sides', ''],
429429
['AlgEquiv', '', 'a*b=0', 'a=0 or b=0', 1, 'ATEquation_sides', ''],
430430
// Notice here that Maxima does not know anything about a, so you can't cancel it!

0 commit comments

Comments
 (0)