Maxima – 44 – Operatori – operatori per equazioni

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.133.

#
Represents the negation of syntactic equality =.

Note that because of the rules for evaluation of predicate expressions (in particular because not expr causes evaluation of expr), not a = b is equivalent to is(a # b), instead of a # b.

(%i1) a = b;
(%o1)                                a = b
(%i2) is (a = b);
(%o2)                                false
(%i3) a # b;
(%o3)                                a # b
(%i4) not a = b;
(%o4)                                true
(%i5) is (a # b);
(%o5)                                true
(%i6) is (not a = b);
(%o6)                                true

=
The equation operator.

An expression a = b, by itself, represents an unevaluated equation, which might or might not hold. Unevaluated equations may appear as arguments to solve and algsys or some other functions.

The function is evaluates = to a Boolean value. is(a = b) evaluates a = b to true when a and b are identical. That is, a and b are atoms which are identical, or they are not atoms and their operators are identical and their arguments are identical.

Otherwise, is(a = b) evaluates to false; it never evaluates to unknown. When is(a = b) is true, a and b are said to be syntactically equal, in contrast to equivalent expressions, for which is(equal(a, b)) is true. Expressions can be equivalent and not syntactically equal.

The negation of = is represented by #. As with =, an expression a # b, by itself, is not evaluated. is(a # b) evaluates a # b to true or false.

In addition to is, some other operators evaluate = and # to true or false, namely if, and, or, and not.

Note that because of the rules for evaluation of predicate expressions (in particular because not expr causes evaluation of expr), not a = b is equivalent to is(a # b), instead of a # b.

rhs and lhs return the right-hand and left-hand sides, respectively, of an equation or inequation.

See also equal and notequal.

An expression a = b, by itself, represents an unevaluated equation, which might or might not hold.

(%i7) eq_1 : a * x - 5 * y = 17;
(%o7)                           a x - 5 y = 17
(%i8) eq_2 : b * x + 3 * y = 29;
(%o8)                           3 y + b x = 29
(%i9) solve ([eq_1, eq_2], [x, y]);
                               196         29 a - 17 b
(%o9)                 [[x = ---------, y = -----------]]
                            5 b + 3 a       5 b + 3 a
(%i10) subst (%, [eq_1, eq_2]);
          196 a     5 (29 a - 17 b)         196 b     3 (29 a - 17 b)
(%o10) [--------- - --------------- = 17, --------- + --------------- = 29]
        5 b + 3 a      5 b + 3 a          5 b + 3 a      5 b + 3 a
(%i11) ratsimp (%);
(%o11)                        [17 = 17, 29 = 29]

is(a = b) evaluates a = b to true when a and b are syntactically equal (that is, identical). Expressions can be equivalent and not syntactically equal.

(%i12) a : (x + 1) * (x - 1);
(%o12)                          (x - 1) (x + 1)
(%i13) b : x^2 - 1;
                                     2
(%o13)                              x  - 1
(%i14) [is (a = b), is (a # b)];
(%o14)                           [false, true]
(%i15) [is (equal (a, b)), is (notequal (a, b))];
(%o15)                           [true, false]

Some operators evaluate = and # to true or false.

(%i16) if expand ((x + y)^2) = x^2 + 2 * x * y + y^2 then FOO else BAR;
(%o16)                                FOO
(%i17) eq_3 : 2 * x = 3 * x;
(%o17)                             2 x = 3 x
(%i18) eq_4 : exp(2) = %e^2;
                                     2     2
(%o18)                             %e  = %e
(%i19) [eq_3 and eq_4, eq_3 or eq_4, not eq_3];
(%o19)                        [false, true, true]

Because not expr causes evaluation of expr, not a = b is equivalent to is(a # b).

(%i20) [2 * x # 3 * x, not (2 * x = 3 * x)];
(%o20)                         [2 x # 3 x, true]
(%i21) is (2 * x # 3 * x);
(%o21)                               true

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.

%d blogger hanno fatto clic su Mi Piace per questo: