<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>isPrime -- whether a integer, polynomial, or ideal is prime</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_is__Primitive.html">next</a> | <a href="_is__Polynomial__Ring.html">previous</a> | <a href="_is__Primitive.html">forward</a> | <a href="_is__Polynomial__Ring.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>isPrime -- whether a integer, polynomial, or ideal is prime</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>isPrime f</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>f</tt>, <span>an <a href="___Z__Z.html">integer</a></span>, or an element in a <a href="___Polynomial__Ring.html">polynomial ring</a>, or an <span>an <a href="___Ideal.html">ideal</a></span> in a polynomial ring</span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><span>a <a href="___Boolean.html">Boolean value</a></span>, <a href="_true.html" title="">true</a> if <tt>f</tt> is either a prime integer or an irreducible polynomial and <a href="_false.html" title="">false</a> otherwise</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><table class="examples"><tr><td><pre>i1 : ZZ/2[t];</pre> </td></tr> <tr><td><pre>i2 : isPrime(t^2+t+1) o2 = true</pre> </td></tr> <tr><td><pre>i3 : isPrime(t^2+1) o3 = false</pre> </td></tr> <tr><td><pre>i4 : isPrime 101 o4 = true</pre> </td></tr> <tr><td><pre>i5 : isPrime 158174196546819165468118574681196546811856748118567481185669501856749 o5 = true</pre> </td></tr> <tr><td><pre>i6 : isPrime 158174196546819165468118574681196546811856748118567481185669501856749^2 o6 = false</pre> </td></tr> </table> <p>Since <a href="_factor.html" title="factor a ring element or a ZZ-module">factor</a> returns factors guaranteed only to be pseudoprimes, it may be useful to check their primality, as follows.</p> <table class="examples"><tr><td><pre>i7 : f = factor 28752093487520394720397634653456 4 o7 = 2 109*1831*3014311519*2987077659845341 o7 : Expression of class Product</pre> </td></tr> <tr><td><pre>i8 : peek'_2 f o8 = Product{Power{2, 4}, Power{109, 1}, Power{1831, 1}, Power{3014311519, ------------------------------------------------------------------------ 1}, Power{2987077659845341, 1}}</pre> </td></tr> <tr><td><pre>i9 : first \ toList f o9 = {2, 109, 1831, 3014311519, 2987077659845341} o9 : List</pre> </td></tr> <tr><td><pre>i10 : isPrime \ oo o10 = {true, true, true, true, true} o10 : List</pre> </td></tr> </table> This function can be used also to determine whether an ideal in a polynomial ring is prime.<table class="examples"><tr><td><pre>i11 : R = QQ[a..d];</pre> </td></tr> <tr><td><pre>i12 : I = monomialCurveIdeal(R,{1,5,8}) 2 2 3 2 2 3 3 5 3 5 4 o12 = ideal (a*c - b d, b*c - a d , b c - a d, c - a*b*d , b - a c) o12 : Ideal of R</pre> </td></tr> <tr><td><pre>i13 : isPrime I o13 = true</pre> </td></tr> </table> <p>Primality testing for integers is handled by <a href="_pari.html" title="">pari</a>.</p> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_factor.html" title="factor a ring element or a ZZ-module">factor</a> -- factor a ring element or a ZZ-module</span></li> <li><span><a href="_is__Pseudoprime_lp__Z__Z_rp.html" title="whether an integer is a pseudoprime">isPseudoprime</a> -- whether an integer is a pseudoprime</span></li> </ul> </div> <div class="waystouse"><h2>Ways to use <tt>isPrime</tt> :</h2> <ul><li>isPrime(Ideal)</li> <li>isPrime(ZZ)</li> </ul> </div> </div> </body> </html>