Next: Matrix Parts, Previous: Matrices and Tensors, Up: Matrices and Tensors [Contents][Index]

- Operator:
**bunch***elt_1 elt_2 …*¶ `[`

`elt_1`,`elt_2`, …]To collect any number of Jacal objects into a bunch, simply enclose them in square brackets. For example, to make the bunch whose elements are

`1`

,`2`

,`4`

, type`[1, 2, 4]`

. One can also nest bunches, for example,`[1, [[1, 3], [2, 5]], [1, 4]]`

. Note however that the bunch whose only element is`[1, 2, 3]`

is`[1 2 3]`

. It is importance to notice that one has commas and the other doesn’t.e3 : a:bunch(1, 2, 3); e3: [1, 2, 3] e4 : b:[a]; e4: [1 2 3] e5 : c:[b]; e5: [[1, 2, 3]] e6 : [[[1, 2, 3]]]; e6: [[1, 2, 3]]

- Operator:
**flatten***bnch*¶ -
Removes bunch nesting from

`bnch`, returning a single bunch of the constituent expressions and equations.e0 : flatten([a, [b, [c, d]], [5]]); e0: [a, b, c, d, 5]

- Command:
**ident***n*¶ The command

`ident`

takes as argument a positive integer`n`and returns an`n`x`n`identity matrix. This is sometimes more convenient than obtaining this same matrix using the command`scalarmatrix`

.e6 : ident(4); [1 0 0 0] [ ] [0 1 0 0] e6: [ ] [0 0 1 0] [ ] [0 0 0 1]

- Command:
**scalarmatrix***size entry*¶ The command

`scalarmatrix`

takes as inputs a positive integer`size`and an algebraic expression`entry`and returns an

diagonal matrix whose diagonal entries are all equal to`n`*`n``entry`, where

.`n`=`size`e1 : scalarmatrix(3, 6); [6 0 0] [ ] e1: [0 6 0] [ ] [0 0 6]

- Command:
**diagmatrix***list*¶ The Jacal command

`diagmatrix`

takes as input a list of objects and returns the diagonal matrix having those objects as diagonal entries. In case one wants all of the diagonal entries to be equal, it is more convenient to use the command`scalarmatrix`

.e3 : diagmatrix(12,3,a,s^2); [12 0 0 0 ] [ ] [0 3 0 0 ] e3: [ ] [0 0 a 0 ] [ ] [0 0 0 2] [ s ] e4 : diagmatrix([1,2],2); [[1, 2] 0] e4: [ ] [ 0 2]

- Command:
**sylvester***poly_1 poly_2 var*¶ Here,

`poly_1`and`poly_2`are polynomials and`var`is a variable. The function`sylvester`

returns the matrix introduced by Sylvester (A Method of Determining By Mere Inspection the Derivatives from Two Equations of Any Degree, Phil.Mag.`16`

(1840) pp. 132-135, Mathematical Papers, vol. I, pp. 54-57) for computing the resultant of the two polynomials`poly_1`and`poly_2`with respect to the variable`var`. If one wants to compute the resultant itself, one can simply use the command`resultant`

with the same syntax.e5 : sylvester(a0 + a1*x + a2*x^2 + a3*x^3, b0 + b1*x + b2*x^2, x); [a3 a2 a1 a0 0 ] [ ] [0 a3 a2 a1 a0] [ ] e5: [b2 b1 b0 0 0 ] [ ] [0 b2 b1 b0 0 ] [ ] [0 0 b2 b1 b0]

- Command:
**genmatrix***function rows cols*¶ The function

`genmatrix`

takes as arguments a`function`of two variables and two positive integers,`rows`and`cols`. It returns a matrix with the indicated numbers of rows and columns in which the $(i,j)$th entry is obtained by evaluating`function`at $(i,j)$. The function may be defined in any of the ways available in Jacal, i.e previously by an explicit algebraic definition, by an explicit lambda expression or by an implicit lambda expression.e4 : @1^2+@2^2; 2 2 e4: lambda([@1, @2], @1 + @2 ) e5 : genmatrix(e4,3,5); [2 5 10 17 26] [ ] e5: [5 8 13 20 29] [ ] [10 13 18 25 34]

Next: Matrix Parts, Previous: Matrices and Tensors, Up: Matrices and Tensors [Contents][Index]