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,

(%0000) a:[[1, 3, 5], [2, 4, 7]];
   [ 1  3  5 ]
a: [         ]
   [ 2  4  7 ]
(%0000) b:[2, 4];
b: [2, 4]
(%0000) a + b;
       [ 3  5  7  ]
%0000: [          ]
       [ 6  8  11 ]
(%0001) 3 + 2;
%0001: 5
(%0002) c + b;
%0002: [2 + c, 4 + c]
Operator: - minuend subtrahend
Operator: - subtrahend

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

(%0004) -[1,2,3];
%0004: [-1, -2, -3]
(%0005) 3-7;
%0005: -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.

(%0006) u:+/-3;
u: 3 %sqrt1
(%0006) u^2;
%0006: 9
(%0007) +/-(u);
%0007: 3
(%0008) u-/+3;
%0008: 0
Operator: * multiplicand1 multiplicand2

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

(%0000) (2 + 3 * a) * 4 * a * b^2;
                  2   2
%0000: (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.

(%0001) (x^2 - y^2) / (x - y);
%0001: 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 ^^.

(%0002) (1+x)^4;
                    2      3    4
%0002: 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.

(%0003) 1=2;

;;; eliminate singular-reduction [-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:

(%0003) Z1 || Z2;
        Z1 Z2
%0003: -------
       Z1 + Z2