Go to the first, previous, next, last section, table of contents.


Algebra

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

Algebraic Commands

Command: eliminate [eqn_1 eqn_2 ...] [var_1 var_2 ...]

Here eqn_i is an equation for i = 1 ... n and where var_j is a variable for j = 1 ... m. eliminate returns a list of equations obtained by eliminating the variables var_1, ..., var_m from the equations eqn_1, ..., eqn_n.

e39 : eliminate([x^2+y=0,x^3+y=0],[x]);

                2
e39: 0 = - y - y

e40 : eliminate([x+y+z=3,x^2+y^2+z^2=3,x^3+y^3+z^3=3],[x,y]);

e40: 0 = 1 - z

Command: suchthat var eqn

The equation eqn must contain an occurence of variable var. suchthat returns an expression for all complex values of var satisfying eqn.

e0 : a*x+b*y+c;

e0: c + a x + b y

e1 : suchthat(x, e0 = 0);

    - c - b y
e1: ---------
        a

Command: suchthat var exp

If an expression rather than an equation is given to suchthat, it is as though the equation exp=0 was given.

e2 : suchthat(x, e0);

    - c - b y
e2: ---------
        a

Operator: | var exp_or_eqn

An alternative infix notation is also available for suchthat.

When used in combination with the `{ }' notation for or, the set notation used by some textbooks results.

If var in eqn has multiple roots, a named field extension will be introduced to represent any one of those roots. When multiple values are returned, the result (in disp2d and standard grammars) is wrapped with `{ }'.

e3 : x | a*x^2 + b*x + c;

                               2
ext3: {:@ | 0 = c + b :@ + a :@ }
e3: ext3

e4 : e3 ^ 2;

    - c - b ext3
e4: ------------
         a

Command: or expr_1 ...
Command: or eqn_1 ...

The function or takes as inputs one or more equations or values. If the inputs are equations, then or returns an equation which is equivalent to the assertion that at least one of the input equations holds. If the inputs to or are values instead of two equations, then the function or returns a multiple value. If the inputs to or consist of both equations and values, then or will return the multiple values.

e1 : or(x=2,y=3);

e1: 0 = -6 + 3 x + (2 - x) y

e2 : or(2,3);

                            2
e2: {:@ | 0 = -6 + 5 :@ - :@ }

e3 : e2^2;

                              2
e3: {:@ | 0 = -36 + 13 :@ - :@ }

e4 : or(x=2,17);

e4: 17

`{eqn, ... }' can be used as an alternate syntax for or:

e5 : {+1, -1};

                     2
e5: {:@ | 0 = -1 + :@ }

Rational Expression

Command: num expr

The function num takes a rational expression as input and returns a numerator of the expression.

e25 : num((x^2+y^2)/(x^2-y^2));

        2    2
e25: - x  - y

e26 : num(7/4);

e26: 7

e27 : num(7/(4/3));

e27: 21

Operator: denom rational-expression

The Jacal command denom is used to obtain the denominator of a rational expression.

e26 : denom(4/5);

e26: 5

Command: listofvars expr

The command listofvars takes as input a rational expression and returns a list of the variables that occur in that expression.

e7 : listofvars(x^2+y^3);

e7: [x, y]

e8 : listofvars((x^2+y^3)/(2*x^7+y*x+z));

e8: [z, x, y]

Command: imagpart z
Returns the coefficient of %i in expression z;

Command: realpart z
Returns all but the coefficient of %i in expression z;

Command: abs z
Command: cabs z
| z |

Returns the square root of the sum of the squares of the realpart and the imagpart of z.

Polynomials

Operator: coeff poly var
Operator: coeff poly var deg
Operator: coeffs poly var

The command coeff is used to determine the coefficient of a certain power of a variable in a given polynomial. Here poly is a polynomial and var is a variable. If the optional third argument is omitted, then Jacal returns the coefficient of the variable var in poly. Otherwise it returns the coefficient of var^deg in poly. The function coeffs returns a list of all of the coefficients. For example,

e14 : coeff((x + 2)^4, x, 3);

e14: 8

e15 : (x + 2)^4;

                     2      3    4
e15: 16 + 32 x + 24 x  + 8 x  + x

e16 : coeff((x + 2)^4, x);

e16: 32

e18 : coeffs((x + 2)^4, x);

e18: [16, 32, 24, 8, 1]

Operator: poly coeffs
The function poly provides an inverse to the function coeffs, allowing one to recover a polynomial from its list of coefficients.

Operator: content poly var

Returns a list of content and primitive part of a polynomial with respect to the variable. The content is the GCD of the coefficients of the polynomial in the variable. The primitive part is poly divided by the content.

e24 : content(2*x*y+4*x^2*y^2,y);

                     2
e24: [2 x, y + 2 x y ]

Operator: divide dividend divisor var
Operator: divide dividend divisor

The command divide treats divident and divisor as polynomials in the variable var and returns a pair `[quotient, remainder]' such that dividend = divisor * quotient + remainder. If the third argument var is omitted Jacal will choose a variable on its own with respect to which it will do the division. In particular, of dividend and divisor are both numerical, one can safely omit the third argument.

e5 : divide(x^2+y^2,x-7*y^2,x);

            2    2       4
e5: [x + 7 y , y  + 49 y ]

e6 : divide(-7,3);

e6: [-2, -1]

e11 : divide(x^2+y^2+z^2,x+y+z);

                       2              2
e11: [- x - y + z, 2 x  + 2 x y + 2 y ]

e14 : divide(x^2+y^2+z^2,x+y+z,y);

                       2              2
e14: [- x + y - z, 2 x  + 2 x z + 2 z ]

e15 : divide(x^2+y^2+z^2,x+y+z,z);

                       2              2
e15: [- x - y + z, 2 x  + 2 x y + 2 y ]

Command: mod poly1 eqn var
Command: mod poly1 poly2 var
Command: mod poly1 poly2
Returns poly1 reduced with respect to poly2 (or eqn) and var. If poly2 is univariate, the third argument is not needed.

Command: mod poly1 n
Returns poly1 with all the coefficients taken modulo n.
Command: mod poly1
Returns poly1 with all the coefficients taken modulo the current modulus.

If the modulus (n or the current modulus) is negative, then the results use symmetric representation.

e19 : x^4+4 mod 3;

          4
e19: 1 + x

e20 : x^4+4 mod x^2=2;

e20: 8

e22 : mod(x^3*a*7+x*8+34, -3);

                3
e22: 1 - x + a x

e23 : mod(5,2);

e23: 1

e24 : mod(x^4+4,x^2=2,x);

e24: 8

Command: gcd poly_1 poly_2

The Jacal function gcd takes as arguments two polynomials with integer coefficients and returns a greatest common divisor of the two polynomials. This includes the case where the polynomials are integers.

e1 : gcd(x^4-y^4,x^6+y^6);

     2    2
e1: x  + y

e2 : gcd(4,10);

e2: 2

Command: poly_discriminant poly var

Here poly is a polynomial and var is a variable. This function returns the square of the product of the differences of the roots of the polynomial poly with respect to the variable var.

e7 : poly_discriminant(x^3 - 1, x);

e7: -27

Command: resultant poly_1 poly_2 var

The function resultant returns the resultant of the polynomials poly_1 and poly_2 with respect to the variable var.

e2 : resultant(x^2 + a, x^3 + a, x);

     2    3
e2: a  + a

Command: equatecoeffs z1 z2 var
Returns the list of equations formed by equating each coefficient of variable var^n in z1 to the corresponding coefficient of var^n in z2. z1 and z2 can be polynomials or ratios of polynomials.

Factoring

Command: factor int
The Jacal command factor takes as input an integer and returns a list of the prime numbers that divide it, each occurring with the appropriate multiplicity in the list. If the number is negative, the list will begin with -1.

The results of the factor command are shown in a special factored format, which appears as the product of the factors.

e0 : factor(120);

     3
e0: 2  3 5

e1 : factor(-120);

        3
e1: -1 2  3 5

Command: factor polyratio
Given a univariate ratio of polynomials polyratio, returns a matrix of factors and exponents.

As above, the results are shown in factored form.

e2 : factor((14*x^4-10/68*x^-5)/(5*x^2+1));

                 9
       -5 + 476 x
e2: ------------------
                 2   5
    2 17 (1 + 5 x ) x

e3 : (14*x^4-10/68*x^-5)/(5*x^2+1);

               9
     -5 + 476 x
e3: --------------
        5        7
    34 x  + 170 x

e4 : (476*x^9-5)/(34*(5*x^2+1)*x^5);

               9
     -5 + 476 x
e4: --------------
        5        7
    34 x  + 170 x
e5 : factor(x*y);

e5: y x

e6 : factor((x+a)*(y^4-z));

                   4
e6: -1 (a + x) (- y  + z)

e7 : factor((x+u*a^3)*(y^4-z));

         3            4
e7: -1 (a  u + x) (- y  + z)

e8 : factor((x+u*a^3)^2*(y^4-z)/((x+1)*(u^2-v^2)));

         4        3       2
     (- y  + z) (a  u + x)
e8: -------------------------
    (1 + x) (- u + v) (u + v)

e9 : factor(200*(-1*x+1+y)*(u-r^6)*(21*x+2-t^4));

     3  2     6                        4
e9: 2  5  (- r  + u) (1 - x + y) (2 - t  + 21 x)

e10 : factor(2*(a+u)*(-v+b)*(a*x+y)^2);

                                     2
e10: -1 2 (a + u) (- b + v) (a x + y)

e11 : factor(2*(a+u)*(-v+b)*(a*x+y)^2/((u^2-v^2)*(11*x+55)));

                                  2
     2 (a + u) (- b + v) (a x + y)
e11: ------------------------------
      11 (5 + x) (- u + v) (u + v)

e12 : factor(2*(a+u)*(-v+b)*(a*x+y)^2/((u^2-v^2)*x^4*(11*x+55)));

                                  2
     2 (a + u) (- b + v) (a x + y)
e12: -------------------------------
                                   4
     11 (5 + x) (- u + v) (u + v) x

e13 : factor((c^3*u+b*a)*(b*b*a+v*p^2*q^2*c));

             3        2      2  2
e13: (a b + c  u) (a b  + c p  q  v)

e14 : factor((2*z+y-x)*(y^3-a*x^2)*(b*z^2+y));

                             2        2    3
e14: (- x + y + 2 z) (y + b z ) (- a x  + y )

e15 : factor((a*a*b*z+d)*(2*a*b*b*z+c));

           2                2
e15: (d + a  b z) (c + 2 a b  z)

e16 : factor((a*a*b*z+d)*(2*a*b*b*z+c)*((u+a)*x+1));

                           2                2
e16: (1 + (a + u) x) (d + a  b z) (c + 2 a b  z)

e17 : factor((c*z+a)*(a*z+b)*(b*z+c));

e17: (b + a z) (c + b z) (a + c z)

e18 : factor((a*a*b*(x+w)*z+d)*(2*a*b*b*z+c));

            2        2                   2
e18: (d + (a  b w + a  b x) z) (c + 2 a b  z)

e19 : factor(((x+w)^2*z-u*d)*(-2*a*b*z+c));

                                   2            2
e19: -1 (- c + 2 a b z) (- d u + (w  + 2 w x + x ) z)

e20 : factor((-200*%i*x-c)*(x-d-z^5)/(a*(b^3-(a+u)*z)));

                                 5
     -1 (c + 200 %i x) (d - x + z )
e20: ------------------------------
                3
          a (- b  + (a + u) z)

The rest of this section documents commands from the factoring package. To use this package, execute the following command from the JACAL prompt:

require("ff");

Several of these commands return a matrix. The first column contains the factors and the second column contains the corresponding exponent.

Command: sff poly
Given a primitive univariate polynomial poly, calculate the square free factorisation of poly. A primitive polynomial is one with no factors (other than units) common to all its coefficients.

Command: ffsff poly p
Command: ffsff poly p m
Given a monic polynomial poly, a prime p, and a positive integer m, calculate the square free factorisation of poly in GF(p^m)[x]. If m is not supplied, 1 is assumed.

e0 : ffsff(x^5+x^3+1, 53);

    [                2    3   ]
    [16 - 22 x + 26 x  + x   1]
e0: [                         ]
    [       -13 + x          2]

Command: berl poly n
Given a square-free univariate polynomial poly and an integer power of a prime, q, returns (as a bunch) the irreducible factors of poly.

e2 : berl(x^5+x^3+2, 53);

                        2               2
e2: [1 + x, 5 - 26 x + x , 11 + 25 x + x ]

Command: parfrac polyratio
Returns the partial fraction expansion of a rational univariate polynomial polyratio. The denominator of polyratio must be square free. This code is still being developed.


Go to the first, previous, next, last section, table of contents.