Computer Algebra Commands 4-55
1≡
1≡
Flags: Exact mode must be set (flag –105 clear).
Numeric mode must not be set (flag -3 clear).
Radians mode must be set (flag –17 set).
Example: Find the product of 2x and 38x
2
, modulo the default modulus, 3.
Command:
MULTMOD(2*X,38*X^2)
Result: X^3
NEXTPRIME
Type: Function
Description: Given an integer, returns the next prime number larger than the integer. Like ISPRIME?, it
uses a pseudoprime check for large numbers.
Access: Arithmetic, !Þ
INTEGER L
Input: An integer or an expression that evaluates to an integer.
Output: The next prime number larger than the integer.
Example: Find the closest, larger prime number to 145.
Command:
NEXTPRIME(145)
Result: 149
See also: ISPRIME?, PREVPRIME
P2C
Type: Command
Description: Takes a list representing a permutation as an argument, and returns the permutation
decomposed into lists that represent cycles.
Access: !Þ PERM
Input: A list representing a permutation. For example, the list {3,1,2,5,4} defines a permutation P,
such that
P(1)=3, P(2)=1, P(3)=2, P(4)=5, and P(5)=4
Output: Level 2/Item 1:A list of cycles equivalent to the permutation. For example, the list {3,1,2,5,4}
defines a cycle
C, such that C(3)=1, C(1)=2, C(2)=5, C(5)=4, and C(4)=3
Level 1, Item 2: The signature of the permutation, 1 or -1.
Example: Convert the permutation given by {3,4,5,2,1} into cycles:
Command: P2C({3,4,5,2,1})
Result: {{{1,3,5},{2,4}},-1}
See also: C2P, CIRC
PA2B2
Type: Function
Description: Takes a prime number, p, such that p=2 or modulo 4, and returns a Gaussian integer a +
ib such that p = a
2
+ b
2
. This function is useful for factorizing Gaussian integers.
Access: Arithmetic, !Þ INTEGER L
Input: A prime number, p, such that p=2 or modulo 4
Output: A Gaussian integer a+ib such that p=a
2
+b
2
Flags: Exact mode must be set (flag –105 clear).
Numeric mode must not be set (flag -3 clear).
Complex mode must be set (flag –103 set).