Next: , Previous: Algebra, Up: Algebra


2.1 Algebraic Operators

— Operator: + augend addend

Addition of scalar quantities or componentwise addition of bunches is accomplished by means of the infix operator +. For example,

          e2 : a:[[1, 3, 5], [2, 4, 7]];
          
              [1  3  5]
          e2: [       ]
              [2  4  7]
          
          e3 : b:[2, 4];
          
          e3: [2, 4]
          
          e4 : a + b;
          
              [3  5  7 ]
          e4: [        ]
              [6  8  11]
          
          e5 : 3 + 2;
          
          e5: 5
          
          e6 : c + b;
          
          e6: [2 + c, 4 + c]
          
          e7 : e1 + e5;
          
                   2   2
          e7: 5 + (8 a + 12 a ) b
— Operator: - minuend subtrahend
— Operator: - subtrahend

The symbol - is used to denote either the binary infix operator subtraction or the unary minus.

          e1 : -[1,2,3];
          
          e1: [-1, -2, -3]
          
          e2 : 3-7;
          
          e2: -4
— Operator: +/- minuend subtrahend
— Operator: -/+ minuend subtrahend
— Operator: +/- augend
— Operator: -/+ augend

Jacal allows the use of +/- and -/+ as ambiguous signs (unary plus-or-minus, unary minus-or-plus) and as ambiguous infix operators (binary plus-or-minus, binary minus-or-plus). The value +/- is also represented by the constant %sqrt1, while -/+ is represented by -%sqrt1.

          e7 : u:+/-3;
          
          e7: 3 %sqrt1
          
          e8 : u^2;
          
          e8: 9
          
          e9 : +/-(u);
          
          e9: 3
          
          e10 : u-/+3;
          
          e10: b-/+(3 %sqrt1, 3)
— Operator: * multiplicand1 multiplicand2

Multiplication of scalar expressions such as numbers, polynomials, rational functions and algebraic functions is denoted by the infix operator *. For example,

          e1 : (2 + 3 * a) * 4 * a * b^2;
          
                         2   2
          e1: (8 a + 12 a ) b

One can also use * as an infix operator on bunches. In that case, it operates componentwise, in an appropriate sense. If the bunches are square matrices, the operator * multiplies corresponding entries of the two factors. It does not perform matrix multiplication. To multiply matrices one instead uses the operator . (i.e., a period). More generally, any binary scalar operator other than ^ can be used on bunches and acts componentwise.

— Operator: / dividend divisor

The symbol for division in Jacal is /. For example, the value returned by 6 / 2 is 3.

          e3 : (x^2 - y^2) / (x - y);
          
          e3: x + y
— Operator: ^ expression exponent

The infix operator ^ is used for exponentiation of scalar quantitites or for componentwise exponentiation of bunches. For example, 2^5 returns 32. Unlike the other scalar infix operators, one cannot use ^ for component-wise operations on bunches. Furthermore, one should not try to use ^ to raise a square matrix to a power. Instead, one should use ^^.

          e7 : (1+x)^4;
          
                           2      3    4
          e7: 1 + 4 x + 6 x  + 4 x  + x
— Operator: = expression1 expression2

In Jacal, the equals sign = is not used for conditionals and it is not used for assignments. To assign one value to another, use either : or :=. The operator = merely returns a value of the form 0 = expression. The value returned by a = b, for example is 0 = a - b.

          e6 : 1=2;
          
          e6: 0 = -1
— Operator: || Z1 Z2

The infix operator || is from electrical engineering and represents the effective impedance of the parallel connection of components of impedances Z1 and Z2:

          e1 : Z1 || Z2;
          
               Z1 Z2
          e1: -------
              Z1 + Z2