13 is(equal(false,false));
16 is(equal(false,true));
23 is(equal(rat(matrix([x])),matrix([x])));
26 is (equal (ident (2), rat (ident (2))));
30 is(equal([x],[rat(x)]));
34 is(equal((%e^(%i*z)-%e^-(%i*z)), 0));
39 is(equal(rat((x+y+a)^3,x),rat((x+y+a)^3,y)));
50 is(equal([a,0],[a,1]));
53 is(equal([a,b],[a,c]));
58 is(equal(x/(2*x*sqrt(2)) - 1/(2*x*sqrt(2)), (x-1)/(2*x*sqrt(2))));
61 is(equal(1/sqrt(2),sqrt(2)/2));
74 (assume(equal(i,j)),0);
77 is(equal(x[i], x[j]));
83 (forget(equal(i,j)),0);
86 is(equal(inf,infinity));
92 is(equal(minf,infinity));
108 is(equal(%i,x + %i));
120 is(equal(infinity,x));
126 is(equal(0.23, 9.78));
129 is(equal(0.23, 9.78b0));
132 is(equal(23/10, 9.78b0));
135 is(equal(7,[1,2,3]));
141 is(equal(1/sqrt(2), sqrt(2)/2));
150 is(equal((x+1)^2, x^2 + 2*x+1));
162 is(equal(x^2+1,x^2/5));
171 is(equal([a],[a,b]));
177 is(equal(a < b, a <= b));
180 is(equal(a <= b, a <= b));
186 is(equal(matrix([x]), rat(matrix([x]))));
189 is(equal(matrix([x,y]), matrix([x,z])));
192 is(equal(matrix([x,y],[p,q]), matrix([p,q],[x,y])));
195 is(equal(matrix([x,y],[p,q]), matrix([p,q,s],[x,y,8])));
198 is(equal(set(u,n,k), set(u,n,k,u,n,k)));
201 is(equal(set(a,b,c), set(b,a,a)));
204 is(equal(abs(1 + %i*z), z - %i));
208 (assume(equal(x,y),equal(y,z)),0);
217 is(equal(f(x), f(z)));
220 is(equal(f(x,y) + %pi, f(y,z) + %pi));
223 is(equal(rat(x,y), rat(z,x)));
226 is(equal(matrix([x,y],[4,5]), matrix([y,z],[4,5])));
229 is(equal(matrix([x,y],[4,5]), matrix([y,z],[4,15])));
232 is(equal(set(x,z),set(x)));
235 is(equal(set(x,sqrt(2)), set(z,sqrt(2))));
238 is(equal(x + %i * y, y + %i * z));
241 is(equal(exp(%i * x), exp(%i * z)));
244 is(equal([x,x],[y,z]));
247 is(equal([y,y],[x,z]));
253 is(equal(x+y+z/3, 7*x/3));
256 is(equal(max(x,a),max(y,a)));
259 is(equal(max(x,y,z,8), max(x,8)));
262 (forget(equal(x,y), equal(y,z)),0);
265 is(equal(zeroa, zerob));
268 is(equal([zeroa],[zerob]));
271 is(equal(matrix(),matrix()));
274 is(equal(matrix([]),matrix([])));
277 is(equal(matrix([]),matrix([],[])));
283 is(equal(set(),set()));
286 is(equal(a = b, a = b));
289 is(equal(a = b, b = a));
292 is(equal(a < b, b < a));
301 is(equal([a,b], a = b));
304 is(equal(a=b,[a,b]));
307 is(equal(a < b, b <= b))$
310 is(equal([true], []));
313 is(equal([true], [true]));
316 is(equal([false], [true]));
319 is(equal(false,[false]));
322 (oak : set(macrocarpa, rubra, alba),0);
325 is(equal([macrocarpa, rubra, alba],oak)) ;
328 is(equal(oak, [macrocarpa, rubra, alba]));
331 is(equal(set(macrocarpa, rubra, alba),oak));
334 is(equal(oak, set(macrocarpa, rubra, alba)));
337 (assume(equal(macrocarpa, burr), equal(rubra,red), equal(alba,white)),0);
340 is(equal(oak,set(burr,red,white)));
346 (forget(equal(macrocarpa, burr), equal(rubra,red), equal(alba,white)),0);
349 (assume(equal(a,b),equal(b,c),equal(c,d)),0);
355 is(equal(a+b+c, 2*a+d));
358 is(equal(a+b^2-c^3, b + a^2 - a^3));
361 is(equal(f(a,b,c),f(d,b,a)));
364 is(equal(set(1,a,d^2), set(1+a-d,d,a,b,c-a+d,a^2)));
367 (forget(equal(a,b),equal(b,c),equal(c,d)),0);
370 is(equal(lambda([], 9), lambda([], 9)));
373 is(equal(lambda([], x), lambda([], y)));
376 is(equal(lambda([x], x), lambda([z],z)));
379 is(equal(lambda([x], x), lambda([z],z^2)));
382 is(equal(lambda([x,y], x), lambda([z],z)));
385 is(equal(lambda([x],true), lambda([z],false)));
388 is(equal(lambda([x],false), lambda([z],false)));
391 (assume(equal(p,0)),0);
394 is(equal(lambda([x],x+p), lambda([y],y-p)));
397 (forget(equal(p,0)),0);
400 is(equal(sum(1/kk,kk,1,n), sum(1/ii,ii,1,n)));
403 is(equal(sum(1/kk,kk,1,m), sum(1/ii,ii,1,n)));
406 is(equal(sqrt(5) - sum(%pi/kk,kk,1,n), sqrt(5) - sum(%pi/ii,ii,1,n)));
409 is(equal(sqrt(5) - sum(%pi/kk,kk,1,m), sqrt(5) - sum(%pi/ii,ii,1,n)));
412 is(equal(sum(sqrt(2)/i^2,i,1,inf), sum(sqrt(2)/j^2,j,1,inf)));
415 is(equal(sum(sum(1/(i+j),i,1,j),j,1,n), sum(sum(1/(ii+jj),ii,1,jj),jj,1,n)));
418 is(equal(sum(product((ii+jj)^2,ii,1,42*jj),jj,-7,n), sum(product((i+j)^2,i,1,42*j),j,-7,n)));
421 is(equal(set(a), set(inf)));
424 is(equal([a], [inf]));
427 is(equal(set(a,b,c), set(a,b,c,minf)));
430 is(equal(set(a,b,c), set(a,b,c,d)));
433 is(equal(set(a), set(und)));
436 is(equal(set(inf,und), set(inf,und)));
439 is(equal(set(a), set(a,inf)));
442 is(equal(set(a,inf),set(a)));
445 is(equal(set(a,b), set(a,inf)));
448 /* Ensure that equal is happy to compare objects of any
449 * Maxima or Lisp types.
451 * Stuff checked here (various Lisp types omitted):
455 * Maxima declared array
456 * Maxima undeclared array
463 larray1a : make_array (any, 5),
464 fillarray (larray1a, makelist (i, i, 1, 5)),
465 larray1b : make_array (any, 5),
466 fillarray (larray1b, makelist (i, i, 1, 5)),
467 larray2 : make_array (any, 5),
468 fillarray (larray2, makelist (i^2, i, 1, 5)),
469 larray3 : make_array (any, 10),
470 fillarray (larray3, makelist (i, i, 1, 10)),
472 array (marray_declared_1, fixnum, 3, 4),
473 fillarray (marray_declared_1, makelist (i, i, 1, 20)),
474 array (marray_declared_2, fixnum, 3, 4),
475 fillarray (marray_declared_2, makelist (i, i, 1, 20)),
476 array (marray_declared_3, flonum, 3, 4),
477 fillarray (marray_declared_3, makelist (float(i), i, 1, 20)),
478 array (marray_declared_4, fixnum, 4, 3),
479 fillarray (marray_declared_4, makelist (2*i, i, 1, 20)),
481 marray_undeclared_1 [foo, bar] : 1234,
482 marray_undeclared_1 [baz, quux] : 2345,
483 marray_undeclared_2 [foo, bar] : 1234,
484 marray_undeclared_2 [baz, quux] : 2345,
485 marray_undeclared_3 [foo, bar] : 3456,
486 marray_undeclared_3 [baz, quux] : 4567,
487 marray_undeclared_4 [foo, bar, baz] : 5678,
489 marray_array_fcn_1 [u, v, w] := u*v*w,
490 marray_array_fcn_1 [2, 3, 4],
491 marray_array_fcn_1 [a, b, c],
492 marray_array_fcn_2 [u, v, w] := u*v*w,
493 marray_array_fcn_2 [2, 3, 4],
494 marray_array_fcn_2 [a, b, c],
495 marray_array_fcn_3 [u, v, w] := u*v*w,
496 marray_array_fcn_3 [7, x, 4],
497 marray_array_fcn_3 [a, 3, c],
498 marray_array_fcn_4 [u, v, w] := u + v + w,
499 marray_array_fcn_4 [2, 3, 4],
500 marray_array_fcn_4 [a, b, c],
502 marray_subscripted_fcn_1 [a, b] (x, y) := x^a + y^b,
503 marray_subscripted_fcn_1 [3, 2] (u, 7),
504 marray_subscripted_fcn_1 [m, n] (2, z),
505 marray_subscripted_fcn_2 [a, b] (x, y) := x^a + y^b,
506 marray_subscripted_fcn_2 [3, 2] (u, 7),
507 marray_subscripted_fcn_2 [m, n] (2, z),
508 marray_subscripted_fcn_3 [a, b] (x, y) := x^a + y^b,
509 marray_subscripted_fcn_3 [2, 5] (8, q),
510 marray_subscripted_fcn_3 [1, t] (9, e),
511 marray_subscripted_fcn_4 [a, b] (x, y) := a*x - b*y,
512 marray_subscripted_fcn_4 [3, 2] (u, 7),
513 marray_subscripted_fcn_4 [m, n] (2, z),
518 /* Comparisons to same type */
520 is (equal (string1a, string1b));
523 is (equal (string1a, string2));
526 is (equal (larray1a, larray1b));
529 is (equal (larray1a, larray2));
532 is (equal (larray1a, larray3));
535 is (equal (marray_declared_1, marray_declared_2));
538 is (equal (marray_declared_1, marray_declared_3));
541 is (equal (marray_declared_1, marray_declared_4));
544 is (equal (marray_undeclared_1, marray_undeclared_2));
547 is (equal (marray_undeclared_1, marray_undeclared_3));
550 is (equal (marray_undeclared_1, marray_undeclared_4));
553 is (equal (marray_array_fcn_1, marray_array_fcn_2));
556 /* This test fails at present because array functions are
557 * compared via arrayinfo and listarray output,
558 * but array functions should be compared via their AEXPR properties.
560 is (equal (marray_array_fcn_1, marray_array_fcn_3));
563 is (equal (marray_array_fcn_1, marray_array_fcn_4));
566 is (equal (marray_subscripted_fcn_1, marray_subscripted_fcn_2));
569 /* This test fails at present because subscripted functions are
570 * compared via arrayinfo and listarray output,
571 * but subscripted functions should be compared via their AEXPR properties.
573 is (equal (marray_subscripted_fcn_1, marray_subscripted_fcn_3));
576 is (equal (marray_subscripted_fcn_1, marray_subscripted_fcn_4));
577 unknown; /* comparison of non-identical lambda expressions yields unknown */
579 /* Comparisons to different type */
581 /* No automatic type conversion */
582 is (equal (string1a, larray1a));
585 is (equal (string1a, 1234));
588 /* No automatic type conversion */
589 is (equal (string1a, 'FOO));
592 is (equal (string1a, sin('x)));
596 is (equal (larray1a, string1a));
599 is (equal (larray1a, 1234));
602 is (equal (larray1a, 'FOO));
605 is (equal (larray1a, sin('x)));
608 /* No automatic conversions between array types */
610 (similar_lisp_array : make_array (fixnum, 4, 5),
611 fillarray (similar_lisp_array, makelist (i, i, 1, 20)),
612 is (equal (marray_declared_1, similar_lisp_array)));
617 do similar_undeclared_marray [i, j] : i*5 + j + 1,
618 is (equal (marray_declared_1, similar_undeclared_marray)));
621 /* No automatic conversions between array and list or matrix */
623 (similar_nested_list : [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],
624 is (equal (marray_declared_1, similar_nested_list)));
627 (similar_matrix : apply (matrix, similar_nested_list),
628 is (equal (marray_declared_1, similar_matrix)));
631 /* Comparisons via = */
633 /* Comparisons to same type */
635 is (string1a = string1b);
638 is (string1a = string2);
641 is (larray1a = larray1b);
644 is (larray1a = larray2);
647 is (larray1a = larray3);
651 /* Comparisons to different type */
653 /* No automatic type conversion */
654 is (string1a = larray1a);
657 is (string1a = 1234);
660 /* No automatic type conversion */
661 is (string1a = 'FOO);
664 is (string1a = sin('x));
668 /* No automatic type conversion */
669 is (larray1a = string1a);
672 is (larray1a = 1234);
675 is (larray1a = 'FOO);
678 is (larray1a = sin('x));
682 /* Comparison of arrays with multiple dimensions and non-literal elements */
684 (a1 : make_array (any, 10),
685 a2a : make_array (any, 2, 5),
686 a2b : make_array (any, 2, 5),
687 a3 : make_array (any, 3, 5),
691 [is (equal (a1, a2a)), is (equal (a1, a3)), is (equal (a2a, a3))];
692 [false, false, false];
694 (a2a [1, 4] : 1234, a2b [1, 4] : '(x/(1 - x)), is (equal (a2a, a2b)));
697 (a2a [1, 4] : '(1/(1/x - 1)), a2b [1, 4] : '(x/(1 - x)), is (equal (a2a, a2b)));
700 is(notequal(exp(x),0));
703 is(notequal(exp(%i * x),0));
706 is(notequal(exp(x - sqrt(3) * x^2 + 42*%i),0));
709 is(notequal(%i * exp(x),0));
712 is(notequal(exp(minf),0));
715 is(equal(sqrt(1-x^2), conjugate(sqrt(1-x^2))));
718 (assume(-1 < x, x < 1),0);
721 is(equal(sqrt(1-x^2), conjugate(sqrt(1-x^2))));
726 is(equal(exp(%i * x),0));
729 is(equal(0, exp(%i * x)));
732 (forget(-1 < x, x < 1),0);
735 /* verify literal equality of specreps, especially as subexpressions */
737 (kill (a, foo, spec_cmp),
739 block ([x : fn (a), y : fn (a)],
740 every (lambda ([z], z = true),
743 is (matrix ([x]) = matrix ([y])),
744 is (foo (x) = foo (y))])),
745 [spec_cmp (rat), spec_cmp (intopois)]);
748 (kill (spec_cmp), 0);
751 /* from mailing list 2014-08-16 "bind stack overflow in loop"
752 * is(equal(n, m)) needlessly poops n and m into assume database
753 * can't examine assume database directly so here just verify there's no stack overflow
755 for i thru 10000 do is (equal (i, 10000));
758 /* SF bug # 2768: "notequal" tries to put multiprecision rational numbers into floats */
760 /* substitute X for x in original expression to work around
761 * leftover database stuff about x (that's a bug btw)
763 (foo : 84644440725961403098463183554485799389772425728699536724546678651368471662755793858191462623325951275455550962101277270763335324980423888503086416881487600951168887632284102290001262851926718316596582705934285641705714110547524777517804311041930987129930496818273454551255885915706318740821679919000000000000000000000*X/422165920314471048721358275854632323285179941428330150821135511815100042994592631347355397175387243022779234708963662480477375868719044084318634583443223137428890926160543699705457864438134730545535596936604372279922247951010042249163649352110753480952771747316504857000652757440826179465253453626540111934123296968384641+2097152/10460353203, 0);
766 is (notequal (foo, 0));