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

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]

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

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.

e45 : factor(120);

e45: [2, 2, 2, 3, 5]

e46 : factor(-120);

e46: [-1, 2, 2, 2, 3, 5]

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

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

     [           9     ]
     [[-5 + 476 x ]    ]
     [               1 ]
     [     34          ]
     [               -1]
e11: [         2       ]
     [ [1 + 5 x ]    -1]
     [                 ]
     [     [x]       -5]

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

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

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

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

e37: [[x, y]  1]

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

     [               4        ]
e38: [[-1, a + x, - y  + z]  1]

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

     [      3           4        ]
e39: [[-1, a  u + x, - y  + z]  1]

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

     [          4                ]
     [      [- y  + z]           ]
     [                         1 ]
     [        3                  ]
e40: [      [a  u + x]         2 ]
     [                           ]
     [[u + v, - u + v, 1 + x]  -1]

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

     [         6                      4           ]
e43: [[200, - r  + u, 1 - x + y, 2 - t  + 21 x]  1]

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

     [[-2, a + u, - b + v]  1]
e28: [                       ]
     [     [a x + y]        2]

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

     [ [2, a + u, - b + v]   1 ]
     [                         ]
e29: [      [a x + y]        2 ]
     [                         ]
     [[11, 5 + x, - u + v,   -1]
     [                         ]
     [       u + v]            ]

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

    [[2, a + u, - b + v]  1 ]
    [                       ]
    [     [a x + y]       2 ]
e1: [                       ]
    [[11, 5 + x, - u +    -1]
    [                       ]
    [    v, u + v]        -4]
    [                       ]
    [        [x]            ]

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

    [    2      2  2           3      ]
e1: [[a b  + c p  q  v, a b + c  u]  1]

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

    [      2    3         2                   ]
e1: [[- a x  + y , y + b z , - x + y + 2 z]  1]

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

     [      2               2      ]
e35: [[d + a  b z, c + 2 a b  z]  1]

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

     [          2         2                       ]
e38: [[c + 2 a b  z, d + a  b z, 1 + (a + u) x]  1]

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

e7: [[b + a z, c + b z, a + c z]  1]

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

     [       2        2                  2      ]
e15: [[d + (a  b w + a  b x) z, c + 2 a b  z]  1]

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

     [             [-1]                ]
     [                                1]
e16: [                          2      ]
     [[- c + 2 a b z, - d u + (w  +   1]
     [                                 ]
     [                 2               ]
     [        2 w x + x ) z]           ]

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

    [                            5     ]
    [[-1, c + 200 %i x, d - x + z ]    ]
    [                                1 ]
e9: [        3                         ]
    [    [- b  + (a + u) z, a]       -1]

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.