# B.2 Some Commands

The following are some Maple commands that are used in the examples. Some, such as `phi`, are built into Maple. Others, such as `addell`, are in the Maple notebook available at

``bit.ly/2TzKFec``

If you want to suppress the output, use a colon instead.

The argument of a function is enclosed in round parentheses. Vectors are enclosed in square brackets. Entering `matrix(m,n,[a,b,c,...,z])` gives the  matrix with first row `a,b, ...` and last row `...z`. To multiply two matrices  and  type `evalm(A&*B)`.

If you want to refer to the previous output, use %. The next-to-last output is %%, etc. Note that % refers to the most recent output, not to the last displayed line. If you will be referring to an output frequently, it might be better to name it. For example, `g:=phi(12345)` defines `g` to be the value of  Note that when you are assigning a value to a variable in this way, you should use a colon before the equality sign. Leaving out the colon is a common cause of hard-to-find errors.

Exponentiation is written as `` However, we will need to use modular exponentiation with very large exponents. In that case, use `` For modular exponentiation, you might need to use a  between & and ``. Use the right arrow to escape from the exponent.

Some of the following commands require certain Maple packages to be loaded via the commands

``with(numtheory), with(linalg), with(plots), with(combinat)``

These are loaded when the math.mws notebook is loaded. However, if you want to use a command such as `nextprime` without loading the notebook, first type `with(numtheory):` to load the package (once for the whole session). Then you can use functions such as `nextprime`, `isprime`, etc. If you type `with(numtheory)` without the colon, you’ll get a list of the functions in the package, too.

The following are some of the commands used in the examples. We list them here for easy reference. To see how to use them, look at the examples. We have used `txt` to refer to a string of letters. Such strings should be enclosed in quotes (`"string"`).

`addell([x,y], [u,v], b, c, n)` finds the sum of the points  and  on the elliptic curve  The integer  should be odd.

`affinecrypt(txt,m,n)` is the affine encryption of `txt` using 

`allshifts(txt)` gives all 26 shifts of `txt`.

`chrem([a,b,...], [m,n,...])` gives a solution to the simultaneous congruences 

`choose(txt,m,n)` lists the characters in `txt` in positions that are congruent to 

`coinc(txt,n)` is the number of matches between `txt` and `txt` displaced by 

`corr(v)` is the dot product of the vector  with the 26 shifts of the alphabet frequency vector.

`phi(n)` computes  (don’t try very large values of ).

`igcdex(m,n,’x’,’y’)` computes the gcd of  and  along with a solution of  To get `x` and `y`, type `x;y` on this or a subsequent command line.

`ifactor(n)` factors 

`frequency(txt)` lists the number of occurrences of each letter `a` through `z` in `txt`.

`gcd(m,n)` is the gcd of  and 

`inverse(M)` finds the inverse of the matrix 

`lfsr(c,k,n)` gives the sequence of  bits produced by the recurrence that has coefficients given by the vector  The initial values of the bits are given by the vector 

`lfsrlength(v,n)` tests the vector  of bits to see if it is generated by a recurrence of length at most 

`lfsrsolve(v,n)` computes the coefficients of a recurrence, given a guess  for the length of the recurrence that generates the binary vector 

`max(v)` is the largest element of the list 

`a mod n` is the value of 

`multell([x,y], m, b, c, n)` computes  times the point  on the elliptic curve 

`multsell([x,y], m, b, c, n)` lists the first  multiples of the point  on the elliptic curve 

`nextprime(x)` gives the next prime 

`num2text(n)` changes a number  to letters. The successive pairs of digits must each be at most 26 space is 00,  is 01,  is 26.

`primroot(p)` finds a primitive root for the prime 

`shift(txt,n)` shifts `txt` by 

`text2num(txt)` changes `txt` to numbers, with `space=00, a=01, ..., z=25`.

`vigenere(txt,v)` gives the Vigenère encryption of `txt` using the vector  as the key.

`vigvec(txt,m,n)` gives the frequencies of the letters `a` through `z` in positions congruent to