Sharedwww / sage_summer / users.dviOpen in CoCalc
����;G TeX output 2004.06.23:1142����������Kf���
�����7��&�
cmb10�User's�O\Guide��'э���to��).����ěP��l(ARI�O\/�GP��%��Y���K�`y

cmr10�C.�UUBatut,�K.�Belabas,�D.�Bernardi,�H.�Cohen,�M.�Olivier����v&�Lab�Goratoire�UUA2X,�U.M.R.�9936�du�C.N.R.S.����h�Univ���ersit���Ge�UUBordeaux�I,�351�Cours�de�la�Lib����eration�����q�33405�UUT��*�ALENCE�Cedex,�FRANCE���������<x

cmtt10�e-mail:�
�[email protected]��?�⍒�Q��Home�UUP���age:����� �http://pari.math.u-bordeaux.fr/�������\a�Primary�UU�ftp��site:����p )�ftp://pari.math.u-bordeaux.fr/pub/pari/��%����last�UUup�Gdated�11�Decem���b�er�2003������?for�UUv���ersion�2.2.7�����*�����Kf���^�I��Cop���yrigh�t�����r���c�������UU�!",�

cmsy10�
��������2000{2003�UUThe�P��*�ARI�Group��lU�P���ermission��[is�gran�ted�to�mak�e�and�distribute�v�erbatim�copies�of�this�man�ual�pro�vided�the�cop�yrigh�t���notice�UUand�this�p�Germission�notice�are�preserv���ed�on�all�copies.���P���ermission���is�gran�ted�to�cop�y�and�distribute�mo�Gdied�v�ersions,���or�translations,�of�this�man���ual���under��4the�conditions�for�v���erbatim�cop�ying,���pro�vided�also�that�the�en�tire�resulting�deriv�ed�w�ork�is���distributed�UUunder�the�terms�of�a�p�Germission�notice�iden���tical�to�this�one.���P��*�ARI/GP�UUis�Cop���yrigh�t�����r���c�������UU�
��������2000{2003�UUThe�P�ARI�Group���P��*�ARI/GP���is���free�soft���w�are;���y�ou���can�redistribute�it�and/or�mo�Gdify�it�under�the�terms�of�the�GNU���General��Public�License�as�published�b���y�the�F��*�ree�Soft�w�are�F��*�oundation.�V�It�is�distributed�in�the�hop�Ge���that�UUit�will�b�Ge�useful,�but�WITHOUT�ANY�W���ARRANTY�WHA��*�TSOEVER.��������Kf���ʙ卒��@�T��*�able�UUof�Con���ten�ts��vb�Chapter�UU1:�q�Ov���erview�of�the�P��*�ARI�system������<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.��
�5��'v��9��ٓ�Rcmr7�1.1���In���tro�7duction�����.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.��ݑ5����9�1.2���The�P��Z�ARI�t���yp�7es��Y���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.��ݑ6����9�1.3���Op�7erations�and�functions�V����.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.��ݑ9����Chapter�UU2:�q�Sp�Gecic�Use�of�the�GP�Calculator��ԍ��<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.��
��13����9�2.1���Defaults�and�output�formats����.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���14����9�2.2���Simple�metacommands��-���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���21����9�2.3���Input�formats�for�the�P��Z�ARI�t���yp�7es�K捑�.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���25����9�2.4���GP�op�7erators��r���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���28����9�2.5���The�general�GP�input�line������.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���31����9�2.6���The�GP/P��Z�ARI�programming�language��6���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���32����9�2.7���Errors�and�error�reco���v�ery�,1���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���42����9�2.8���In���terfacing�GP�with�other�languages�V
���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���46����9�2.9���The�preferences�le�A���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���47����9�2.10���Using�GP�under�GNU�Emacs��㍑�.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���49����9�2.11���Using�GP�with�readline�M����.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���50����Chapter�UU3:�q�F��*�unctions�and�Op�Gerations�Av��q�ailable�in�P�ARI�and�GP�/��<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.��
��53����9�3.1���Standard�monadic�or�dy���adic�op�7erators�A����.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���54����9�3.2���Con���v�ersions�and�similar�elemen�tary�functions�or�commands������.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���58����9�3.3���T��Z�ranscenden���tal�functions�j���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���68����9�3.4���Arithmetic�functions��|���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���76����9�3.5���F��Z�unctions�related�to�elliptic�curv���es�s퍑�.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���89����9�3.6���F��Z�unctions�related�to�general�n���um�b�7er���elds��Í��.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���96����9�3.7���P���olynomials�and�p�7o�w�er�series������.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@135����9�3.8���V��Z�ectors,�matrices,�linear�algebra�and�sets�s<���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@141����9�3.9���Sums,�pro�7ducts,�in���tegrals�and�similar�functions��Ӎ��.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@153����9�3.10���Plotting�functions�!���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@156����9�3.11���Programming�under�GP������.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@162����Chapter�UU4:�q�Programming�P��*�ARI�in�Library�Mo�Gde�=���<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.����171����9�4.1���In���tro�7duction:��:initializations,�univ�ersal�ob�n9jects�H���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@171����9�4.2���Imp�7ortan���t�tec�hnical�notes�]���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@172����9�4.3���Creation�of�P��Z�ARI�ob�n9jects,�assignmen���ts,�con�v�ersions��+���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@175����9�4.4���Garbage�collection�yԍ��.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@179����9�4.5���Implemen���tation�of�the�P��Z�ARI�t�yp�7es������.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@186����9�4.6���P��Z�ARI�v���ariables�����.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@190����9�4.7���Input�and�output�mc���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@192����9�4.8���A�complete�program������.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@197����9�4.9���Adding�functions�to�P��Z�ARI�Ч���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@201����Chapter�UU5:�q�T��*�ec���hnical�Reference�Guide�for�Lo�w-Lev�el�F��*�unctions��0���<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.����207����9�5.1���Lev���el�0�k�ernel�(op�7erations�on�unsigned�longs)�5i���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@207����9�5.2���Lev���el�1�k�ernel�(op�7erations�on�longs,�in�tegers�and�reals)�F	���.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@208����9�5.3���Lev���el�2�k�ernel�(op�7erations�on�general�P��Z�ARI�ob�n9jects)�mэ��.��˕���.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.�����.���@215����App�Gendix�UUA:�Installation�Guide�for�the�UNIX�V��*�ersions�	'؍��<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.����221���App�Gendix�UUB:�A�Sample�program�and�Mak���ele�	�����<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.����229���App�Gendix�UUC:�Summary�of�Av��q�ailable�Constan���ts������<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.����231���Index������<.��˕���<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.�����<.����233�����8�����Kf���C������Kf�����卒����2X�Qffcmr12�Chapter��/1:������z��Ov���erview��/of�the�P���4ARI�system��B��4��N�cmbx12�1.1��In��tro�`duction�.���0�The��5P��*�ARI��system�is�a�pac���k��q�age�whic�h�is�capable�of�doing�formal�computations�on�recursiv�e�t�yp�Ges�at���high�E�sp�Geed;�J�it�is�primarily�aimed�at�n���um�b�er�E�theorists,�H�but�can�b�e�used�b���y�an�yb�Go�dy�E�whose�primary���need�UUis�sp�Geed.��a���Although��gquite�an�amoun���t�of�sym�b�Golic�manipulation�is�p�ossible�in�P��*�ARI,�this�system�do�es�v���ery���badly���compared�to�m���uc�h���more�sophisticated�systems�lik���e�Axiom,���Macsyma,�Maple,�Mathematica���or��EReduce�on�suc���h�manipulations�(e.g.�m�ultiv��q�ariate�p�Golynomials,�
formal�in�tegration,�
etc���b>

cmmi10�:���:�:��
UO�).�*�On���the���other�hand,��the�three�main�adv��q�an���tages�of�the�system�are�its�sp�Geed�(whic�h�can�b�Ge�b�et���w�een���5���and�!�100�times�b�Getter�on�man���y�computations),�U
the�p�ossibilit���y�of�using�directly�data�t�yp�Ges�whic�h���are��familiar�to�mathematicians,�3Zand�its�extensiv���e�algebraic�n�um�b�Ger�theory�mo�dule�whic���h�has�no���equiv��q�alen���t�UUin�the�ab�Go�v�e-men�tioned�systems.����It�UUis�p�Gossible�to�use�P��*�ARI�in�three�dieren���t�w�a�ys:����1)��vas�a�library��*�,��whic���h�can�b�Ge�called�from�an�upp�er-lev���el�language�application,��for�instance���written�UUin�C�or�C++;����2)��as�a�sophisticated�programmable�calculator,�.�named���"V

cmbx10�GP�,�whic���h�con�tains�most�of�the���con���trol�UUinstructions�of�a�standard�language�lik�e�C;����3)�`4the�compiler�GP2C�`1can�translate�GP�co�Gde�to�C,�and�load�them�in���to�the�GP�in���terpreter.���A�<Gt���ypical�<Mscript�compiled�b�y�GP2C�<Gwill�t�ypically�run�3�to�10�times�faster.�ioThe�C�<Gco�Gde�can�also�b�e���edited�UUand�optimized�b���y�hand.����The���use�of�GP��gis�explained�in�c���hapters�2�and�3,��Mand�the�programming�in�library�mo�Gde�is���explained�UUin�c���hapters�3,�4�and�5.�q�In�the�presen�t�Chapter�1,�w�e�giv�e�an�o�v�erview�of�the�system.��%#��Imp�Q�ortan��9t���note:�S��A��tutorial��for�GP�is�pro���vided�in�the�standard�distribution�(�tutorial.dvi�)�and���y���ou��Gshould�read�this�rst�(at�least�the�b�Geginning�of�it,���y�ou�can�skip�the�sp�Gecialized�topics�y�ou're�not���in���terested��1in).�ZY��*�ou�can�then�start�o�v�er�and�read�the�more�b�Goring�stu�whic�h�lies�ahead.�ZBut�y�ou���should��ado�that�ev���en�tually��*�,���at��athe�v���ery�least�the�v��q�arious�Chapter�headings.���Y�ou�can�ha���v�e��aa�quic���k���idea��_of�what�is�a���v��q�ailable�b�y�lo�Goking�at�the�GP��9reference�card�(�refcard.dvi��or��refcard.ps�).�*�In���case�UUof�need,�y���ou�can�then�refer�to�the�complete�function�description�in�Chapter�3.����Ho��9w��Tto�get�the�latest�v�ersion?��a���This���pac���k��q�age�can�b�Ge�obtained�b�y�anon�ymous�ftp�from�quite�a�n�um�b�Ger�of�sites�(ask�y�our�fa�v�ourite���W��*�eb�a�searc���h�engine�for�the�site�nearest�to�y�ou).��hBut,�eif�y�ou�w�an�t�the�v�ery�latest�v�ersion�(including���dev���elopmen�t�UUv�ersions),�y�ou�should�use�the�anon�ymous�ftp�address�����ftp://pari.math.u-bordeaux.fr/pub/pari����where� qy���ou�will�nd�all�the�dieren�t�p�Gorts�and�p�ossibly�some�binaries.�`&A� dlot�of�v���ersion�information,���mailing�UUlist�arc���hiv�es,�UUand�v��q�arious�tips�can�b�Ge�found�on�P��*�ARI's�home�page:�����http://pari.math.u-bordeaux.fr/��������5���C卟���Kf�������Implemen��9tation���notes:����(Y��*�ou�`3can�skip�this�section�and�switc���h�to�Section�1.2�if�y�ou're�not�in�ter-���ested�UUin�hardw���are�tec�hnicalities.�q�Y��*�ou�w�on't�miss�an�ything�that�w�ould�b�Ge�men�tioned�here.)���
��The�fwP��*�ARI�fspac���k��q�age�con�tains�essen�tially�three�v��q�arian�ts.��.See�App�Gendix�A�fsfor�ho�w�to�set�up�one���of�UUthese�on�y���our�system.����In���a�rst�v���ersion,��some�time-critical�parts�of�the�m�ultiprecision�k�ernel�are�written�in�assem�bler,���a�r.few�h���undred�lines�at�most.��QA�t�presen�t�there�exists�three�v�ersions�for�the�Sparc�arc�hitecture:���one�b�for�Sparc�v���ersion�7�(e.g.�Sparcstation�1,���1+,�IPC,�b�IPX�bUor�2),���one�for�Sparc�v�ersion�8�with���Sup�GerSparc�b�pro�cessors�(e.g.�SparcStation�10�and�20)�and�one�for�Sparc�v���ersion�8�with�MicroSparc���I�For�yI�GI�pro�cessors�y(e.g.�SparcClassic�or�SparcStation�4�and�5).��3No�sp�ecic�v���ersion�is�written�for���the�f�UltraSparc�since�it�can�use�the�MicroSparc�I�GI�f�v���ersion.��UIn�addition,�k;v�ersions�exist�for�the�DEC���Alpha�@]64-bit�pro�Gcessors,�D�and�nally�the�whole�ix86�family�(In���tel,�AMD,�Cyrix)�starting�at�the�386���(up���to�the�Xb�Go���x�gaming�console!).�h�Finally��*�,��3there�are�unmain�tained,��3m�uc�h�less�optimized�and�not���really�(Yusable�an���ymore,�1Xmicro-k�ernels�(Yfor�the�HP-P��*�A�(Marc���hitecture�(only�for�HPUX�9,�1Xdo�Ges�not�w���ork���with�UUHPUX�10),�and�for�the�P���o�w�erPC�UUarc�hitecture�(only�for�the�601,�do�Ges�not�compile�an�ymore).����A��Zsecond��qv���ersion�uses�the�GNU�MP�library�to�implemen���t�its�m�ultiprecision�k�ernel,�8and�should���run���on�an���y�platform�where�GMP��could�b�Ge�installed.�PEThe�GMP�k���ernel�is�ab�Gout�as�fast�as�the�nativ�e���one��	for�small�op�Gerands,���and�m���uc�h��	faster�for�h���uge�ones�(sa�y��*�,���ab�Gout�t�wice�faster�around�10000�decimal���digits).����A�d8third�d<v���ersion�is�written�en�tirely�in�ANSI�d8C,�with�a�C++-compatible�syn�tax,�g�and�should�b�Ge���p�Gortable��without�m���uc�h��trouble�to�an���y�32�or�64-bit�computer�ha�ving�no�real�memory�constrain�ts.�O�It���is��'ab�Gout�2�times�slo���w�er��'than�v���ersions�including�an�assem�bly�k�ernel.�AcThis�v�ersion�has�b�Geen�tested�for���example�i�on�MIPS�i�based�DECstations�3100�and�5000�and�SGI�computers,�n�on�v��q�arious�Macs�(based���on�4U680x0�c���hips�or�more�recen�t�P�o�w�erPCs,�:�lik�e�the�G3�or�G4),�:�new�In�tel�c�hips�lik�e�ARM�4L(handheld���devices)�Por�ia64�(Itanium).�WIn�addition,�QP��*�ARI�<has�b�Geen�p�orted�to�a�considerable�n���um�b�er�Pof�smaller���and��larger�mac���hines,�xfor�example�the�V���AX,�68000-based�mac�hines�lik�e�the�A�tari,�xMac�Classic�or���Amiga�UU500,�68020�mac���hines�suc�h�as�the�Amiga�2500�or�3000,�or�mainframes�lik�e�the�IBM/S390.����An�Z{historical�v���ersion�of�the�P��*�ARI/GP�Z7k�ernel,���written�in�1985,�w���as�sp�Gecic�to�680x0�based���computers,���and�GRw���as�en�tirely�writen�in�MC68020�assem�bly�language�(around�6000�lines).�G�It�ran���on�3SUN-3/xx,�1*Son���y�News,�NeXT�cub�Ges�and�on�680x0�based�Macs.��aSince�1997,�this�v���ersion�w�as���unmain���tained;�cit��jhas�b�Geen�remo�v�ed�from�the�P��*�ARI��Tdistribution�in�v�ersion�2.2.5.�S�T��*�o�run�P�ARI��Twith���a�UU68k�assem���bler�micro-k�ernel,�one�no�w�uses�the�GMP�v�ersion.��#XQ��1.2��The�P���ARI�t��yp�`es�.���k�The�crucial�w���ord�in�P��*�ARI��is�recursiv�eness:��Rmost�of�the�t�yp�Ges�it�kno�ws�ab�Gout�are�recursiv�e.��F��*�or���example,�the���basic�t���yp�Ge��Complex��exists�(actually�called��t_COMPLEX�).�Ho�w�ev�er,�the�comp�Gonen�ts���(i.e.��qthe�real�and�imaginary�part)�of�suc���h�a�\complex�n�um�b�Ger"�can�b�e�of�an���y�t�yp�Ge.�6&The�only�sensible���ones���are�in���tegers�(w�e�are�then�in��Z�[�i�]),��Xrational�n�um�b�Gers�(�Q�[�i�]),��Xreal�n�um�b�Gers�(�R�[�i�]�=��C�),��Xor���ev�en���elemen���ts��of��Z�=n�Z��((�Z�=n�Z�)[�i�]�when�this�mak�es�sense),�Dor��p�-adic�n�um�b�Gers�when��p�����3����mo�d���4��(�Q����	0e�rcmmi7�p���R�[�i�]).����This��feature�m���ust�of�course�not�b�Ge�used�to�o�rashly:�;wfor�example�y���ou�are�in�principle�allo�w�ed�to���create�.&ob��8jects�whic���h�are�\complex�n�um�b�Gers�of�complex�n�um�b�Gers",�5�but�don't�exp�ect�P��*�ARI�.to�mak���e���sensible�UUuse�of�suc���h�ob��8jects:�q�y�ou�will�mainly�get�nonsense.����On��[the�other�hand,��one�thing�whic���h��$�':

cmti10�is��|�allo�w�ed�is�to�ha�v�e�comp�Gonen�ts�of�dieren�t,��but�com-���patible,�4,t���yp�Ges.�c�F��*�or�+�example,�taking�again�complex�n���um�b�Gers,�4,the�real�part�could�b�e�of�t���yp�e�in���teger,���and�UUthe�imaginary�part�of�t���yp�Ge�rational.��������6���Q獟���Kf�����卑�By��_compatible,���w���e�mean�t�yp�Ges�whic�h�can�b�Ge�freely�mixed�in�op�erations�lik���e�+�or���.��F��*�or���example�V�if�the�real�part�is�of�t���yp�Ge�real,�V�the�imaginary�part�cannot�b�e�of�t���yp�e�in���tegermo�d�(in���tegers���mo�Gdulo�UUa�giv���en�n�um�b�Ger��n�).���֍�Let�	�us�no���w�describ�Ge�the�t�yp�Ges.�X�As�explained�ab�o���v�e,��they�	�are�built�recursiv���ely�from�basic�t�yp�Ges���whic���h��are�as�follo�ws.�]�W��*�e�use�the�letter��T�}&�to�designate�an�y�t�yp�Ge;�-�the�sym�b�Golic�names�corresp�ond�to���the�UUin���ternal�represen�tations�of�the�t�yp�Ges.���䍍���Zt���yp�Ge�UU�t_INT�����bUp�Z�������P�In���tegers�UU(with�arbitrary�precision)���������Zt���yp�Ge�UU�t_REAL�����bUp�R�������P�Real�UUn���um�b�Gers�(with�arbitrary�precision)���������Zt���yp�Ge�UU�t_INTMOD�����bUp�Z�=n�Z�������P�In���tegermo�Gds�UU(in�tegers�mo�Gdulo��n�)���������Zt���yp�Ge�UU�t_FRAC�����bUp�Q�������P�Rational�UUn���um�b�Gers�(in�irreducible�form)���������Zt���yp�Ge�UU�t_FRACN�����bUp�Q�������P�Rational�UUn���um�b�Gers�(not�necessarily�in�irreducible�form)���������Zt���yp�Ge�UU�t_COMPLEX�����bUp�T�c��[�i�]�������PComplex�UUn���um�b�Gers���������Zt���yp�Ge�UU�t_PADIC�����bUp�Q����p��������P�p�-adic�UUn���um�b�Gers���������Zt���yp�Ge�UU�t_QUAD�����bUp�Q�[�w�D�]�������PQuadratic�UUNum���b�Gers�(where�[�Z�[�w�D�]��:��Z�]�=�2)���������Zt���yp�Ge�UU�t_POLMOD�����bUp�T�c��[�X���]�=P��(�X��)�T��[�X��]�������PP���olmo�Gds�UU(p�olynomials�mo�dulo��P�c��)���������Zt���yp�Ge�UU�t_POL�����bUp�T�c��[�X���]�������PP���olynomials���������Zt���yp�Ge�UU�t_SER�����bUp�T�c��((�X���))�������PP���o�w�er�UUseries�(nite�Lauren���t�series)���������Zt���yp�Ge�UU�t_RFRAC�����bUp�T�c��(�X���)�������PRational�UUfunctions�(in�irreducible�form)���������Zt���yp�Ge�UU�t_RFRACN�����bUp�T�c��(�X���)�������PRational�UUfunctions�(not�necessarily�in�irreducible�form)���������Zt���yp�Ge�UU�t_VEC�����bUp�T��c���^��n��������P�Ro���w�UU(i.e.�horizon�tal)�v�ectors���������Zt���yp�Ge�UU�t_COL�����bUp�T��c���^��n��������P�Column�UU(i.e.�v���ertical)�v�ectors���������Zt���yp�Ge�UU�t_MAT�����bUp�M����m;n����(�T�c��)�������PMatrices���������Zt���yp�Ge�UU�t_LIST�����bUp�T��c���^��n��������P�Lists���������Zt���yp�Ge�UU�t_STR�������P�Character�UUstrings�����and�UUwhere�the�t���yp�Ges��T���in�recursiv�e�t�yp�Ges�can�b�e�dieren���t�in�eac�h�comp�Gonen�t.����In���addition,�&there�exist�t���yp�Ges��t_QFR��;�and��t_QFI��for�binary�quadratic�forms�of�resp�Gectiv���ely���p�Gositiv���e���and�negativ�e�discriminan�ts,�d
whic�h�can�b�Ge�used�in�sp�ecic�op�erations,�d
but�whic���h�ma�y���disapp�Gear�UUin�future�v���ersions.����Ev���ery�E�P��*�ARI�E�ob��8ject�(called��GEN��in�the�sequel)�b�Gelongs�to�one�of�these�basic�t���yp�es.�l�Let�us�ha���v�e���a�UUcloser�lo�Gok.������1.2.1��In��9tegers�and�reals�:���they�kpare�of�arbitrary�and�v��q�arying�length�(eac���h�n�um�b�Ger�carrying�in�its���in���ternal��represen�tation�its�o�wn�length�or�precision)�with�the�follo�wing�mild�restrictions�(giv�en�for���32-bit�(�mac���hines,�1�the�restrictions�for�64-bit�mac�hines�b�Geing�so�w�eak�as�to�b�Ge�considered�inexisten�t):���in���tegers��m�ust�b�Ge�in�absolute�v��q�alue�less�than�2���^��268435454��'n��(i.e.�roughly�80807123�digits).�Z7The�precision���of�a�real�n���um�b�Gers�a�is�also�at�most�80807123�signican���t�decimal�digits,�e
and�the�binary�exp�onen���t�m�ust���b�Ge�UUin�absolute�v��q�alue�less�than�2���^��23��?��=��8388608.����Note��Mthat�P��*�ARI��.has�b�Geen�optimized�so�that�it�w���orks�as�fast�as�p�ossible�on�n���um�b�ers��Mwith�at���most�ia�few�thousand�decimal�digits.��In�particular,�Ennot�to�Go�m���uc�h�ieort�has�b�een�put�in���to�fancy���m���ultiplication�|2tec�hniques�(only�the�Karatsuba�m�ultiplication�is�implemen�ted).��^Hence,���although�it���is�JIp�Gossible�to�use�P��*�ARI�JFto�do�computations�with�10���^��7��Ƽ�decimal�digits,�Lm���uc�h�JIb�etter�programs�can�b�e���written�UUfor�suc���h�h�uge�n�um�b�Gers.����In���tegers�3�and�real�n�um�b�Gers�are�completely�non-recursiv�e�t�yp�Ges�and�are�sometimes�called�the����leaves�.��������7���e�����Kf�������1.2.2�̑In��9tegermo�Q�ds,�
`rational�n�um�b�Q�ers�(irreducible�or�not),�
`�p�-adic�n�um�b�Q�ers,�
`p�olmo�ds,���and��Trational�functions�:��these�UUare�recursiv���e,�but�in�a�restricted�w�a�y��*�.��K=��F��*�or�r�in���tegermo�Gds�or�p�olmo�ds,�zthere�are�t���w�o�r�comp�onen�ts:��vthe�r�mo�dulus,�zwhic�h�r�m�ust�b�Ge�of�t�yp�Ge���in���teger�UU(resp.�p�Golynomial),�and�the�represen�tativ�e�n�um�b�Ger�(resp.�p�olynomial).����F��*�or�˵rational�n���um�b�Gers�˵or�rational�functions,��<there�are�also�only�t���w�o�˵comp�onen�ts:�,�the�˵n�umerator���and�UUthe�denominator,�whic���h�m�ust�b�Goth�b�e�of�t���yp�e�in���teger�(resp.�p�olynomial).����Finally��*�,��ױp�-adic�rwn���um�b�Gers�ha�v�e�three�comp�Gonen�ts:�Xthe�prime��p�,���the�\mo�Gdulus"��p���^��k��됫,�and�an�appro���x-���imation�,to�the��p�-adic�n���um�b�Ger.�^Here�,�Z����p���~�is�considered�as����6�lim����� �����UX�������6��Z�=p���^��k����Z�,�&and��Q����p���as�its�eld�of�fractions.����Lik���e���real�n�um�b�Gers,���the�co�dew���ords�con�tain�an�exp�Gonen�t�(giving�essen�tially�the��p�-adic�v��q�aluation�of���the���n���um�b�Ger)�and�also�the�information�on�the�precision�of�the�n�um�b�Ger�(whic�h�is�in�fact�redundan�t���with�UU�p���^��k��됫,�but�is�included�for�the�sak���e�of�eciency).���z��1.2.3��/Complex�n��9um�b�Q�ers��/and�quadratic�n��9um�b�ers�:���quadratic�ln���um�b�Gers�are�n�um�b�Gers�of�the���form�2��a��J�+��bw�D�,�9where��w�wm�is�suc���h�that�[�Z�[�w��]��:��Z�]�=�2,�9and�more�precisely��w���=�����zP�p���o��zP�fe4r�����d����P�=�2�when��d����0����mo�Gd���4,���and�8߱w���=��(1���+�����zP�p���
UK��zP�fe4r�����d�������)�=�2�when��d�����1����mo�Gd���4,�>�where��d��is�the�discriminan���t�of�a�quadratic�order.�hJComplex���n���um�b�Gers�UUcorresp�ond�to�the�v���ery�imp�ortan���t�sp�ecial�case��w���=������$��p���o��$��fe�����1�����.����Complex���and�quadratic�n���um�b�Gers���are�partially�recursiv���e:��the�t�w�o�comp�Gonen�ts��a��and��b��can�b�Ge���of��'t���yp�Ge�in�teger,��[real,�rational,�in�tegermo�Gd��'or��p�-adic,��[and�can�b�e�mixed,��[sub��8ject�to�the�limitations���men���tioned�$.ab�Go�v�e.�aeF��*�or�example,�.�a�֓�+��bi��with��a��and��b�p�-adic�is�in��Q����p���R�[�i�],�.but�this�is�equal�to��Q����p��À�when����p�����1����mo�Gd���4,�UUhence�w���e�m�ust�exclude�these��p��when�one�explicitly�uses�a�complex��p�-adic�t�yp�Ge.���z��1.2.4�\uP��9olynomials,�~=p�Q�o�w�er�series,�~=v�ectors,�matrices�\uand�lists�:�
��they���are�completely�recur-���siv���e:��their���comp�Gonen�ts�can�b�Ge�of�an�y�t�yp�Ge,���and�t�yp�Ges�can�b�e�mixed�(ho���w�ev�er�b�Gew�are�when�doing���op�Gerations).�Q�Note�J�in�particular�that�a�p�olynomial�in�t���w�o�J�v��q�ariables�is�simply�a�p�olynomial�with���p�Golynomial�UUco�ecien���ts.����Note��othat�in�the�presen���t�v�ersion�2.2.7�of�P��*�ARI,�there�is�a�bug�in�the�handling�of�p�Go�w�er�series�of���p�Go���w�er��-series�(i.e.�p�o���w�er��-series�in�sev���eral�v��q�ariables).�K�Ho�w�ev�er�p�Go�w�er�series�of�p�Golynomials�(whic�h�are���p�Go���w�er�
series�in�sev���eral�v��q�ariables�of�a�sp�ecial�t���yp�e)�are�OK.�The�reason�for�this�bug�is�kno���wn,�but�it���is��
dicult�to�correct�b�Gecause�the�mathematical�problem�itself�con���tains�some�amoun�t�of�imprecision.���z��1.2.5��TStrings�:�q�These�UUcon���tain�ob��8jects�just�as�they�w�ould�b�Ge�prin�ted�b�y�the�GP�calculator.����1.2.6��TNotes�:��(��1.2.6.1�UQExact�and�imprecise�ob���jects�:�P^w���e�ġha�v�e�already�said�that�in�tegers�and�reals�are�called���the��lea���v�es�b�Gecause�they�are�ultimately�at�the�end�of�ev�ery�branc�h�of�a�tree�represen�ting�a�P��*�ARI���ob��8ject.�O�Another���imp�Gortan���t�notion�is�that�of�an��exact�_cob���ject�:�>�b�y�denition,�In�um�b�Gers�of�basic�t�yp�Ge���real,����p�-adic�~for�p�Go���w�er�~fseries�are�imprecise,�and�w���e�will�sa�y�that�a�P��*�ARI�~\ob��8ject�ha�ving�one�of�these���imprecise�?t���yp�Ges�an�ywhere�in�its�tree�is�not�exact.�W�All�other�P��*�ARI�,ob��8jects�will�b�Ge�called�exact.�This���is�
�a�v���ery�imp�Gortan�t�notion�since�no�n�umerical�analysis�is�in�v�olv�ed�when�dealing�with�exact�ob��8jects.����1.2.6.2��DScalar�t��9yp�Q�es�:��the���rst�nine�basic�t���yp�Ges,�(!from��t_INT��ͫto��t_POLMOD�,�will�b�e�called�scalar���t���yp�Ges�ūb�ecause�they�essen���tially�o�ccur�as�co�ecien���ts�of�other�more�complicated�ob��8jects.���Note�that���t���yp�Ge�UU�t_POLMOD��is�used�to�dene�algebraic�extensions�of�a�base�ring,�and�as�suc�h�is�a�scalar�t�yp�Ge.��������8���	v#�����Kf�������1.2.6.3���What�is�zero?�_Y�This�
is�a�crucial�question�in�all�computer�systems.�The�answ���er�w�e�giv�e�in���P��*�ARI�!~is�!�the�follo���wing.�`�F�or�exact�t���yp�Ges,�+�all�zeros�are�equiv��q�alen�t�and�are�exact,�+�and�th�us�are�usually���represen���ted���as�an�in�teger�zero.�h�The�problem�b�Gecomes�non-trivial�for�imprecise�t�yp�Ges.�h�F��*�or��p�-adics���the�ޟansw���er�is�as�follo�ws:��[ev�ery��p�-adic�n�um�b�Ger�(including�0)�has�an�exp�onen���t��e��and�a�\man�tissa"���(a���purist�w���ould�sa�y�a�\signicand")��u��whic�h�is�a��p�-adic�unit,���except�when�the�n�um�b�Ger�is�zero�(in���whic���h�(Dcase��u��is�zero),�1Hthe�signicand�ha�ving�a�certain�\precision"��k�x۫(i.e.�b�Geing�dened�mo�dulo��p���^��k��됫).���Then�9this��p�-adic�zero�is�understo�Go�d�9to�b�Ge�equal�to��O��(�p���^��e��KK�),�ri.e.�there�are�innitely�man���y�distinct����p�-adic�UUzeros.�q�The�n���um�b�Ger�UU�k���is�th���us�irrelev��q�an�t.��e���F��*�or�Up�Go���w�er�series�the�situation�is�similar,�Uwith��p��replaced�b�y��X���,�Ui.e.�a�p�Go�w�er�series�zero�will�b�Ge����O�G�(�X�����^��e��-�),�UUthe�n���um�b�er�UU�k���(here�the�length�of�the�p�o���w�er�UUseries)�b�eing�also�irrelev��q�an���t.����F��*�or�*�real�n���um�b�Gers,�3the�*�precision��k�{�is�also�irrelev��q�an���t,�and�a�real�zero�will�in�fact�b�Ge��O��(2���^��e��KK�)�where����e�M��is�no���w�usually�a�negativ�e�binary�exp�Gonen�t.�[�This�of�course�will�b�Ge�prin�ted�as�usual�for�a�real���n���um�b�Ger��:(0�:�0000���������M��in��f��format�or�0�:E���xx��in��e��format)�and�not�with�a��O��()�sym���b�ol�as�with��p�-adics�or���p�Go���w�er�arseries.��With�resp�ect�to�the�natural�ordering�on�the�reals�w���e�mak�e�the�follo�wing�con�v�en�tion:���whatev���er�-�its�exp�Gonen�t�a�real�zero�is�smaller�than�an�y�p�Gositiv�e�n�um�b�Ger,�5}and�an�y�t�w�o�real�zero�Ges�are���equal.��%0ލ�1.3��Op�`erations�and�functions�.�����1.3.1��yThe�P��
�ARI��xphilosoph��9y�.�y�The�Xbasic�philosoph���y�whic�h�go�v�erns�P��*�ARI�Xis�that�op�Gerations�and���functions��should,�%�rstly��*�,�giv���e�as�exact�a�result�as�p�Gossible,�and�secondly��*�,�b�Ge�p�ermitted�if�they�mak���e���an���y�UUkind�of�sense.����More�>�sp�Gecically��*�,�y if�y���ou�do�an�op�eration�(not�a�transcenden���tal�one)�b�et���w�een�>�exact�ob��8jects,���y���ou��ewill�get�an�exact�ob��8ject.��F��*�or�example,���dividing�1�b�y�3�do�Ges�not�giv�e�0�:�33333���������ഫas�y�ou�migh�t���exp�Gect,��3but��msimply�the�rational�n���um�b�er��m(1�=�3).�GIf�y���ou�really�w�an�t�the�result�in�t�yp�Ge�real,��3ev��q�aluate���1�:=�3�UUor�add�0�:��to�(1�=�3).����The�9�result�of�op�Gerations�b�et���w�een�9�imprecise�ob��8jects�will�b�e�as�precise�as�p�ossible.�h�Consider�for���example�-�one�of�the�most�dicult�cases,�dthat�is�the�addition�of�t���w�o�-�real�n���um�b�Gers�-�x��and��y�[٫.���The���accuracy���of�the�result�is��a��+priori����unpredictable;���it�dep�Gends�on�the�precisions�of��x��and��y�[٫,���on�their���sizes�p!(i.e.�their�exp�Gonen���ts),�v�and�also�on�the�size�of��x�J��+��y�[٫.��+P��*�ARI�pw�orks�p!out�automatically�the�righ�t���precision���for�the�result,�)^ev���en�when�it�is�w�orking�in�calculator�mo�Gde�GP���where�there�is�a�default���precision.����In�U�particular,���this�means�that�if�an�op�Geration�in���v�olv�es�U�ob��8jects�of�dieren���t�accuracies,�some���digits���will�b�Ge�disregarded�b���y�P��*�ARI.�It�is�a�common�source�of�errors�to�forget,��Nfor�instance,�that�a���real��n���um�b�Ger�is�giv�en�as��r��Z�+�U=2���^��e��KK�"��where��r����is�a�rational�appro�ximation,����e��a�binary�exp�Gonen�t�and��"��is���a�]�nondescript�real�n���um�b�Ger�]�less�than�1�in�absolute�v��q�alue*.���Hence,�`an���y�n�um�b�Ger�less�than�2���^��e���B�ma�y�b�Ge���treated�UUas�an�exact�zero:������?�?�0.E-28�+�1.E-100��!�%1�?�=�0.E-28����?�?�0.E100�+�1����%2�?�=�0.E100����As�UUan�exercise,�if��a�?�=�2^(-100)�,�UUwh���y�do��a�?�+�0.�qǫand�UU�a�*�1.��dier�UU?��߬�ff��ߟ����	��*��this�UUis�actually�not�quite�true:�q�in���ternally��*�,�the�format�is�2���^��b��D�(�a�8�+��"�),�UUwhere��a��and��b��are�in�tegers��������9���
�܍����Kf�����卑�The�<9second�part�of�the�P��*�ARI�;�philosoph���y�is�that�P�ARI�;�op�Gerations�are�in�general�quite�p�ermissiv���e.���F��*�or�y2instance�taking�the�exp�Gonen���tial�of�a�v�ector�should�not�mak�e�sense.��_Ho�w�ev�er,��)it�frequen�tly���happ�Gens���that�a�computation�comes�out�with�a�result�whic���h�is�a�v�ector�with�man�y�comp�Gonen�ts,�
land���one�)�w���an�ts�to�get�the�exp�Gonen�tial�of�eac�h�one.��This�could�easily�b�Ge�done�either�under�GP�)�or�in���library��hmo�Gde,���but�in�fact�P��*�ARI��Nassumes�that�this�is�exactly�what�y���ou�w�an�t�to�do�when�y�ou�tak�e���the��exp�Gonen���tial�of�a�v�ector,�5wso�no�w�ork�is�necessary��*�.���Most�transcenden�tal�functions�w�ork�in�the���same�UUw���a�y�(see�Chapter�3�for�details).��xN��An���am���biguit�y�w�ould�arise�with�square�matrices.�DfP��*�ARI��xalw�a�ys�considers�that�y�ou�w�an�t�to�do���comp�Gonen���t�wise��function�ev��q�aluation,�khence�to�get�for�example�the�exp�onen���tial�of�a�square�matrix���y���ou��mw�ould�need�to�use�a�function�with�a�dieren�t�name,��i�matexp��for�instance.�I�In�the�presen�t�v�ersion���2.2.7,���this��is�not�y���et�implemen�ted.�4\See�ho�w�ev�er�the�program�in�App�Gendix�C,�whic�h�is�a�rst�attempt���for�UUthis�particular�function.����The���a���v��q�ailable�op�Gerations�and�functions�in�P��*�ARI���are�describ�ed�in�detail�in�Chapter�3.��Here�is���a�UUbrief�summary:��h��1.3.2��TStandard�op�Q�erations�.���Of��course,��the�four�standard�op�Gerators��+�,��-�,��*�,��/��exist.�'It�should�once�more�b�Ge�emphasized�that���division��is,��2as�far�as�p�Gossible,�an�exact�op�Geration:��)4�divided�b���y�3�giv�es��(4/3)�.�'�In�addition�to���this,�<op�Gerations�
�on�in���tegers�or�p�olynomials,�<lik���e��\��(Euclidean�division),��%��(Euclidean�remainder)���exist�7�(and�for�in���tegers,�p��\/��computes�the�quotien�t�suc�h�that�the�remainder�has�smallest�p�Gossible���absolute�yv��q�alue).�_�There�is�also�the�exp�Gonen���tiation�op�erator��^�,�*?when�the�exp�onen���t�is�of�t�yp�Ge�in�teger.���Otherwise,��it��His�considered�as�a�transcenden���tal�function.�BnFinally��*�,�the�logical�op�Gerators��!�Bn�(�not��prex���op�Gerator),��!�&&��+�(�and��op�erator),��!�||��(�or��op�erator)�exist,��!giving�as�results��1��(true)�or��0��(false).��JNote���that����&��and��|��are�also�accepted�as�synon���yms�resp�Gectiv�ely�for��&&��and��||�.�DBHo�w�ev�er,��there�is�no�bit�wise����and�UU�or��or�.��h��1.3.3��TCon��9v�ersions�and�similar�functions�.���Man���y�uOcon�v�ersion�functions�are�a�v��q�ailable�to�con�v�ert�b�Get�w�een�dieren�t�t�yp�Ges.�ѵF��*�or�example�
o�or,���ceiling,��rounding,�truncation,�etc��:���:�:��
UO�.�PrOther���simple�functions�are�included�lik���e�real�and�imaginary���part,��conjugation,�norm,�absolute���v��q�alue,�c���hanging�precision�or�creating�an�in�tegermo�Gd�or�a�p�olmo�d.��h��1.3.4��TT��
�ranscenden��9tal�functions�.���They�C�usually�op�Gerate�on�an���y�ob��8ject�in��C�,�G+and�some�also�on��p�-adics.�k�The�list�is�ev�erexpanding�and���of��course�con���tains�all�the�elemen�tary�functions,�/plus�already�a�n�um�b�Ger�of�others.�L�Recall�that�b�y���extension,�cP��*�ARI�v�usually�v�allo���ws�a�transcenden�tal�function�to�op�Gerate�comp�onen���t�wise�v�on�v���ectors�or���matrices.��h��1.3.5��TArithmetic�functions�.���Apart��}from�a�few�lik���e�the�factorial�function�or�the�Fib�Gonacci�n�um�b�Gers,��Fthese�are�functions�whic�h���explicitly�aquse�the�prime�factor�decomp�Gosition�of�in���tegers.��The�standard�functions�are�included.�In���the��presen���t�v�ersion�2.2.7,���a�primitiv�e,���but�useful�v�ersion�of�Lenstra's�Elliptic�Curv�e�Metho�Gd�(ECM)���has�UUb�Geen�implemen���ted.����There���is�no���w�a�v�ery�large�pac�k��q�age�whic�h�enables�the�n�um�b�Ger�theorist�to�w�ork�with�ease�in�alge-���braic�AOn���um�b�Ger�elds.�kAll�the�usual�op�erations�on�elemen���ts,�EPideals,�prime�ideals,�etc��:���:�:��
UO�are�a���v��q�ailable.����More�U�sophisticated�functions�are�also�implemen���ted,���lik�e�U�solving�Th���ue�equations,�nding�in���tegral���bases�hand�discriminan���ts�of�n�um�b�Ger�elds,���computing�class�groups�and�fundamen�tal�units,���computing�������10����卟���Kf�����卫in��,relativ���e�n�um�b�Ger�eld�extensions�(including�explicit�class�eld�theory),��"and�also�man�y�functions���dealing�UUwith�elliptic�curv���es�o�v�er��Q��or�o�v�er�lo�Gcal�elds.����1.3.6��TOther�functions�.���Quite�u>a�n���um�b�Ger�u>of�other�functions�dealing�with�p�olynomials�(e.g.�nding�complex�or��p�-adic�ro�ots,���factoring,�X�etc),�p�Go���w�er�X5series�(e.g.�substitution,�X�rev���ersion),�linear�X5algebra�(e.g.�determinan�t,�X�c�harac-���teristic��ep�Golynomial,��blinear�systems),�and�dieren���t�kinds�of�recursions�are�also�included.�FwIn�addition,���standard���n���umerical�analysis�routines�lik�e�Rom�b�Gerg�in�tegration�(op�Gen�or�closed,���on�a�nite�or�innite���in���terv��q�al),�P�real��ro�Got�nding�(when�the�ro�ot�is�brac���k�eted),�P�p�olynomial��in�terp�olation,�P�innite��series���ev��q�aluation,�UUand�plotting�are�included.�q�See�the�last�sections�of�Chapter�3�for�details.�������11����荟���Kf�����12���
�����Kf�����卒����Chapter��/2:��O~��nT�Sp�dCecic��/Use�of�the�GP�Calculator��/7�Originally��*�,�1�GP�(�w���as�(�designed�as�a�debugging�to�Gol�for�the�P�ARI�(�system�library�,�1�and�hence�not�m���uc�h���though���t�<fhad�b�Geen�giv�en�to�making�it�user-friendly��*�.�iwThe�situation�has�no�w�c�hanged�somewhat,�Acand���GP��;is��Ov���ery�useful�as�a�stand-alone�to�Gol.�d�The�op�erations�and�functions�a���v��q�ailable�in�P��*�ARI��;and�GP���will�͘b�Ge�describ�ed�in�the�next�c���hapter.�ڏIn�the�presen�t�one,��w�e�describ�Ge�the�sp�ecic�use�of�the�GP���programmable�UUcalculator.�����F��*�or�UUstarting�the�calculator,�the�general�command�line�syn���tax�is:�����gp�?�[-s���stacksize��+�X�]�[-p���primelimit��3�4�]�[��les�����]����where�i�items�within�brac���k�ets�i�are�optional*.��5The�[��les�����]�argumen���t�is�a�list�of�les�written�in�the�GP���scripting��language,�(:whic���h�will�b�Ge�loaded�on�startup.�^�The�ones�starting�with�a�min�us�sign�are��
ags��!�,���setting���some�in���ternal�parameters�of�GP��*�,�or���defaults��$���.�8BSee�Section�2.1�b�Gelo�w�for�a�list�and�explanation���of�tall�defaults,�'�there�are�man���y�more�than�just�those�t�w�o.�^�These�defaults�can�b�Ge�c�hanged�b�y�adding���parameters�p�to�the�input�line�as�ab�Go���v�e,�w�or�p�in�teractiv�ely�during�a�GP�p�session�or�in�a�preferences�le���(also�UUkno���wn�as��gprc�).�������q�UNIX:�Some�<�features�w���ere�dev�elop�Ged�on�UNIX�<�platforms,�A�and�dep�end�hea���vily�on�the�op�erating�system�in���use.�xIt�is��p��}'ossible��t�that�some�of�these�will�b�Ge�p�orted�to�other�op�erating�systems�(BeOS,�MacOS,���DOS,�q�OS/2,�x�Windo���ws,�etc.)��in�future�v���ersions�(most�of�them�should�b�Ge�relativ�ely�easy�tasks).��As���for��	no���w,��Kmost�of�them�w�ere�not.�L�So,��Kwhenev�er�a�sp�Gecic�feature�of�the�UNIX���v�ersion�is�discussed�in���a���paragraph,�oa�UNIX���sign�stic���ks�out�in�the�left�margin,�lik���e�here.�T=Just�skip�these�if�y�ou're�stranded���on���a�dieren���t�op�Gerating�system:�-�the�core�GP�̲functions�(i.e.�at�least�ev�erything�whic�h�is�ev�en�fain�tly���mathematical��in�nature)�will�still�b�Ge�a���v��q�ailable�to�y�ou.�=�It�should�also�b�Ge�p�ossible�(and�then�denitely���advisable)�UUto�install�Lin���ux�or�F��*�reeBSD�on�y�our�mac�hine.��F���Note��2(added�in�v��9ersion�2.0.12):�5��Most�7NUNIX�7go�Go�dies�are�no���w�a�v��q�ailable�for�DOS,�OS/2�and���Windo���ws,�YXthanks�X�to�the��EMX�/�RSX�X��run�time�pac�k��q�age�(�install��excluded�under�DOS,�since�DLLs�are���not�3supp�Gorted�b���y�the�OS).�F��*�or�Windo�ws�95�and�higher,�9�y�ou�can�also�use�the��Cygwin��compatibilit�y���library��Wto�run�GP��@almost�as�if�running�a�gen���uine�Unix�system.�v�Note�that�a�nativ�e��Lin��9ux��binary���will��b�Ge�faster�than�one�using�an���y�of�these�compatibilit�y�pac�k��q�ages�(see�the��MACHINES��o�b�Genc�hmark�le,���included�UUin�the�distribution).�����ҕQEMA���CS:�If��y���ou�ha�v�e�GNU��Emacs,��y�ou�can�w�ork�in�a�sp�Gecial�Emacs�shell�(see�Section�2.10),��whic�h�is�started���b���y�
�t�yping��M-x�?�gp��(where�as�usual��M�
W�is�the��Meta��k�ey)�if�y�ou�accept�the�default�stac�k,�7�prime�and���buer�ǂsizes,��
or��C-u�?�M-x�gp�ǂ�whic���h�will�ask�y�ou�for�the�name�of�the�gp�executable,��
the�stac�k�size,���the��prime�limit�and�the�buer�size.�D�Sp�Gecic�features�of�this�Emacs�shell�will�b�e�indicated�b���y�an���EMA���CS�UUsign.��e��If��a�preferences�file�(or��gprc�,��;to�b�Ge�discussed�in�Section�2.9)�can�b�e�found,��;GP��will�then�read�it���and��execute�the�commands�it�con���tains.�G[This�pro�vides�an�easy�w�a�y�to�customize�GP���without�ha�ving���to���delv���e�in�to�the�co�Gde�to�hardwire�it�to�y�our�likings.�QCThe���les�����argumen�t�is�pro�Gcessed�righ�t�after�the����gprc�.�����ff��ߟ����	��*��On��the�Macin���tosh,��zev�en��after�clic���king�on�the�gp�icon,�once�in�the�MPW���Shell,�y���ou�still�need���to�UUt���yp�Ge�explicitly�a�command�of�the�ab�o���v�e�UUform.�������13����7�����Kf�����卑�A��Ucop���yrigh�t���message�then�app�Gears�whic���h�includes�the�v�ersion�n�um�b�Ger,��Band�a�lot�of�useful���tec���hnical���information.��The�presen�t�man�ual�is�written�for�v�ersion�2.2.7,�� and�has�undergone�ma��8jor���c���hanges�UUsince�the�1.39.xx�v�ersions.���ʍ�After��the�cop���yrigh�t,�%�the��computer�w���orks�for�a�few�seconds�(it�is�in�fact�computing�and�storing���a�
table�of�primes),�%�writes�the�top-lev���el�help�information,�some�initial�defaults,�and�then�w���aits�after���prin���ting�UUits�prompt�(b�y�default:�q��?�).����Note��3that�at�an���y�p�Goin�t�the�user�can�t�yp�Ge��Ctrl-C���(that�is�press�sim�ultaneously�the��Control����and�r�C�d�k���eys):�V�the�curren�t�computation�will�b�Ge�in�terrupted�and�con�trol�giv�en�bac�k�to�the�user�at�the���GP�UUprompt.����The�Žtop-lev���el�help�information�tells�y�ou�that�(as�in�man�y�systems)�to�get�help,��uy�ou�should�t�yp�Ge���a��	�?�.���When�y���ou�do�this�and�hit�return,��6a�men�u�app�Gears,��6describing�the�elev�en�main�categories�of���a���v��q�ailable�%Zfunctions�and�what�to�do�to�get�more�detailed�help.�a�If�y�ou�no�w�t�yp�Ge��?�n��with�1�����n����11,���y���ou���will�get�the�list�of�commands�corresp�Gonding�to�category��n��and�sim�ultaneously�to�Section�3�:n����of�UUthis�man���ual.����If�z7y���ou�t�yp�Ge��?��functionname��?�o�where���functionname��B���is�the�name�of�a�P��*�ARI�z.function,��py�ou�will�get���a�UUshort�explanation�of�this�function.������q�UNIX:�If��extended�help�(see�Section�2.2.1)�is�a���v��q�ailable�on�y�our�system,� �y�ou�can�double�or�triple�the��?�[�sign���to�'Nget�m���uc�h�'Nmore:�Z�resp�Gectiv�ely�the�complete�description�of�the�function�(e.g.��??�?�sqrt�),�0�or�a�list�of���GP�UUfunctions�relev��q�an���t�to�y�our�query�(e.g.���???�?�"elliptic�curve"�UU�or��???�?�"quadratic�field"�).����If���GP��`w���as�compiled�with�the�righ�t�options�(see�App�Gendix�A),�a�line�editor�will�b�e�a���v��q�ailable���to�V�correct�the�command�line,�W;get�automatic�completions,�and�so�on.�vVSee�Section�2.11.1�for�a�short���summary�UUof�a���v��q�ailable�commands.�q�This�migh�t�not�b�Ge�a�v��q�ailable�for�all�arc�hitectures.����Whether�G�extended�on-line�help�and�line�editing�are�a���v��q�ailable�or�not�is�indicated�in�the�GP���banner,�UUb�Get���w�een�the�v�ersion�n�um�b�Ger�and�the�cop�yrigh�t�message.����If�UUy���ou�t�yp�Ge��?\��y�ou�will�get�a�short�description�of�the�metacommands�(k�eyb�Goard�shortcuts).����Finally��*�,��t���yping����?.�>��will�return�the�list�of�a�v��q�ailable�(pre-dened)�mem�b�Ger�functions.�>�These���are�/bfunctions�attac���hed�to�sp�Gecic�kind�of�ob��8jects,�e�used�to�retriev�e�easily�some�information�from���complicated�<7structures�(y���ou�can�dene�y�our�o�wn�but�they�w�on't�b�Ge�sho�wn�here).�&nW��*�e�will�so�Gon���describ�Ge�UUthese�commands�in�more�detail.����As�#0a�general�rule,�V�under�GP��*�,�commands�starting�with��\�?��or�with�some�other�sym���b�Gols�lik�e��?����or��q�#�,���are�not�computing�commands,�but�are�metacommands�whic���h�allo�w�the�user�to�exc�hange���information�C:with�GP��*�.�The�a���v��q�ailable�metacommands�can�b�Ge�divided�in�to�default�setting�commands���(explained�UUb�Gelo���w)�and�simple�commands�(or�k�eyb�Goard�shortcuts,�to�b�e�dealt�with�in�Section�2.2).�������14����w�����Kf�������2.1��Defaults�and�output�formats�.����There���are�man���y�in�ternal�v��q�ariables�in�GP��*�,�dening�ho�w�the�system�will�b�Geha�v�e�in�certain�situations,���unless���a�sp�Gecic�o���v�erride���has�b�een�giv���en.�SQMost�of�them�are�a�matter�of�basic�customization�(colors,���prompt)���and�will�b�Ge�set�once�and�for�all�in�y���our�preferences�file�(see�Section�2.9),��but�some�of�them���are�UUuseful�in���teractiv�ely�UU(set�timer�on,�increase�precision,�etc.).��:.��The�>�function�used�to�manipulate�these�v��q�alues�is�called��default�,�y>whic���h�is�describ�Ged�in�Sec-���tion�UU3.11.2.4.�q�The�basic�syn���tax�is�����default(��def����,��?��value��<
�)�,���whic���h�=�sets�the�default���def��`��to���value��9��.�*�In�in�teractiv�e�use,�w�most�of�these�can�b�Ge�abbreviated�using���historic�K�GP�K�metacommands�(mostly��*�,�M�starting�with��\)�,�whic���h�w�e�shall�describ�Ge�in�the�next�section.����Here���w���e�will�only�describ�Ge�the�a�v��q�ailable�defaults�and�ho�w�they�are�used.��xJust�b�Ge�a�w�are�that���t���yping�l�default��b�y�itself�will�list�all�of�them,�)gas�w�ell�as�their�curren�t�v��q�alues�(see��\d�).�_yJust�after�the���default�name,�$Ow���e�giv�e�b�Get�w�een�paren�theses�the�initial�v��q�alue�when�GP��starts�(assuming�y�ou�did�not���tamp�Ger�UUwith�it�using�command-line�switc���hes�or�a��gprc�).�����Note:�|�the��ysuxes��k�,����M��V�or��G��can�b�Ge�app�ended�to�a���value�����whic���h�is�a�n�umeric�argumen�t,���with�the���eect���of�m���ultiplying�it�b�y�10���^��3��|s�,�˚10���^��6��0f�and�10���^��9���resp�Gectiv���ely��*�.���Case�is�not�tak�en�in�to�accoun�t�there,�˚so���for�M�instance��30k��and��30K�M��b�Goth�stand�for�30000.�o-This�is�mostly�useful�to�mo�dify�or�set�the�defaults����primelimit�UU�or��stacksize��whic���h�t�ypically�in�v�olv�e�a�lot�of�trailing�zero�Ges.����(somewhat�1tec��9hnical)�Note:�W�As��w���e�will�see�in�Section�2.6.6,��the�second�argumen�t�to��default����will�ib�Ge�sub��8ject�to�string�con���text�expansion,�<�whic�h�means�y�ou�can�use�run-time�v��q�alues.��In�other���w���ords,�UUsomething�lik�e���荑��a�?�=�3;��h����default(logfile,�?�"\var{some�filename}"�a�".log")��:.���logs�UUthe�output�in���some���lename��A���3.log�.����Some��defaults�will�b�Ge�expanded�further�when�the�v��q�alues�are�used,���after�the�ab�o���v�e��expansion���has�UUb�Geen�p�erformed:���������time�:�expansion�:�.�the�string�is�sen���t�through�the�library�function��strftime�.�D�This�means�that����%��char��>��com���binations�!.ha�v�e�a�sp�Gecial�meaning,�+�usually�related�to�the�time�and�date.�`eF��*�or�instance,��%H����=�Q�hour�(24-hour�clo�Gc���k)�and��%M��=�min�ute�[00,59]�(on�a�Unix�system,�RGy�ou�can�try��man�?�strftime��at���y���our��shell�prompt�to�get�a�complete�list).��This�is�applied�to��prompt�,����psfile�,�and���logfile�.�F��*�or���instance,�����default(prompt,"(%H:%M)�?�?�")����will�UUprep�Gend�the�time�of�da���y��*�,�in�the�form��(��hh��
�C�:��mm��c�)��to�GP's�usual�prompt.�������H�en��9vironmen�t�K�expansion�:�?�When�the�string�con���tains�a�sequence�of�the�form��$��SOMEV���PAR�����(e.g.�Nq�$HOME�)�Nothe�en���vironmen�t�Nqis�searc���hed�and�if���SOMEV���PAR��9-X�is�dened,�O�the�sequence�is�replaced�b�y���the��Rcorresp�Gonding�v��q�alue.��Also�the���&f�~��J��sym���b�ol�has�the�same�meaning�as�in�the�C��Eand�bash�shells�|�����&f�~�����b���y�~�itself�stands�for�y�our�home�directory��*�,���and���&f�~����user��is�expanded�to��user�'s�home�directory�.��This���is�UUapplied�to�all�lenames.�������15����������Kf�������2.1.1�^�buffersize��R�(default��30k�):�>EGP��8input�is�buered,��whic���h�means�only�so�man�y�b�ytes�of�data�can���b�Ge��Uread�at�a�time�b�efore�a�command�is�executed.�2This�used�to�b�e�a�v���ery�imp�ortan���t�v��q�ariable,���to�allo�w���for���v���ery�large�input�les�to�b�Ge�read�in�to�GP��*�,�for�example�large�matrices,�"�without�it�complaining���ab�Gout��Z\un���used�c�haracters".�9Curren�tly��*�,��Y�buffersize��is�automatically�adjusted�to�the�size�of�the�data���that��lare�to�b�Ge�read.�
It�will�nev���er�go�do�wn�b�y�itself�though.�
Th�us�this�option�ma�y�come�in�handy���to��tdecrease�the�buer�size�after�some�un���usually�large��read�,��<when�y�ou�don't�need�to�k�eep�gigan�tic���buers�UUaround�an���ymore.��6d����q�UNIX:��2.1.2�r�colors��ū(default��""�):�F�this�default�is�only�usable�if�GP��^is�running�within�certain�color-capable���terminals.��F��*�or��instance��rxvt�,���color���E�ff&f��ǫxterm��and�mo�Gdern�v���ersions�of��xterm��under�X��Windo�ws,��or���standard��{Lin���ux/DOS��Qtext�consoles.�^9It�causes�GP�to�use�a�small�palette�of�colors�for�its�output.���With�O�xterms,�P�the�colormap�used�corresp�Gonds�to�the�resources��Xterm*color�n��where��n��ranges�from���0�U�to�15�(see�the�le��misc/color.dft��for�an�example).�r�Legal�v��q�alues�for�this�default�are�strings����"�a����1��|s�,��:���:�:��
UO�,�a����k����"�UU�where��k������7�and�eac���h��a����i�����is�either���2���UU�the�k���eyw�ord�UU�no��(use�the�default�color,�usually�blac���k�on�transparen�t�bac�kground)�����UU�an�in���teger�b�Get�w�een�0�and�15�corresp�Gonding�to�the�aforemen�tioned�colormap�����ʥ�a�triple�[�c����0��|s�;���c����1���;�c����2���]�ʥwhere��c����0��	G�stands�for�foreground�color,�'��c����1���for�bac���kground�color,�'�and��c����2���for���attributes�UU(0�is�default,�1�is�b�Gold,�4�is�underline).����The�-�output�ob��8jects�th���us�aected�are�resp�Gectiv�ely�error�messages,�c�history�n�um�b�Gers,�c�prompt,���input�5[line,�m\output,�help�messages,�timer�(that's�sev���en�of�them).��If��k��<�<u�7,�the�remaining��a����i�����are���assumed�UUto�b�Ge��no�.�q�F��*�or�instance���퍑�default(colors,�?�"9,�5,�no,�no,�4")����t���yp�Gesets�֟error�messages�in�color�9,���history�n�um�b�Gers�in�color�5,���output�in�color�4,�and�do�Ges�not�aect���the�UUrest.����A�Rset��of�default�colors�for�dark�(rev���erse�video�or�PC�console)�and�ligh���t�bac�kgrounds�resp�Gectiv�ely���is�S�activ��q�ated�when��colors��is�set�to��darkbg�,�S�resp.��lightbg��(or�an���y�prop�Ger�prex:�p��d��is�recognized�as���an���abbreviation�for��darkbg�).��A���b�Gold�v��q�arian���t�of��darkbg�,���called��boldfg�,�is�pro���vided�if�y�ou�nd�the���former�UUto�Go�pale.�����ҕQEMA���CS:�In���the�presen���t�v�ersion,��tthis�default�is�incompatible�with�Emacs.�G�Changing�it�will�just�fail�silen�tly���(the�*jalternativ���e�w�ould�b�Ge�to�displa�y�escap�Ge�sequences�as�is,�_�since�Emacs�will�refuse�to�in�terpret���them).���On�q_the�other�hand,�xby���ou�can�customize�highligh�ting�in�y�our��.emacs��so�as�to�mimic�exactly���this�UUb�Geha���viour.�q�See��emacs/pariemacs.txt�.����If��y���ou�use�an�old��readline��library�(v�ersion�n�um�b�Ger�less�than�2.0),�J�y�ou�should�do�as�in�the���example��ab�Go���v�e�and�lea�v�e��a����3��d�and��a����4���(prompt�and�input�line)�strictly�alone.�)�Since�old�v���ersions�of����readline�!ʫdid�not�handle�escap�Ge�c���haracters�correctly�(or�more�accurately��*�,�,treated�them�in�the�only���sensible�z�w���a�y�since�they�did�not�care�to�c�hec�k�all�y�our�terminal�capabilities:��	it�just�ignored�them),���c���hanging�UUthem�w�ould�result�in�man�y�anno�ying�displa�y�bugs.����The��ihac���k�er's�w�a�y�to�c�hec�k�if�this�is�the�case�w�ould�b�Ge�to�lo�ok�in�the��readline.h��include�le���(wherev���er�4ly�our�readline�include�les�are)�for�the�string��RL���E�ff&f��ǫPROMPT���E�ff&f��START���E�ff&f��IGNORE�.�If�it's�there,�;y���ou���are�UUsafe.����A��omore���sensible�w���a�y���is�to�mak���e�some�exp�Gerimen�ts,��Xand�get�a�more�recen�t��readline��if�y�ours���do�Gesn't�UUw���ork�the�w�a�y�y�ou�w�ould�lik�e�it�to.�q�See�the�le��misc/gprc.dft��for�some�examples.�������16���ۇ�����Kf�������2.1.3���compatible�	��(default��0�):��yThe�GP�	function�names�and�syn���tax�ha�v�e�c�hanged�tremendously���b�Get���w�een�+�v�ersions�1.xx�and�2.00.��HT��*�o�help�y�ou�cop�Ge�with�this�w�e�pro�vide�some�kind�of�bac�kw�ard���compatibilit���y��*�,�UUdep�Gending�on�the�v��q�alue�of�this�default:��'1���compatible�뫫=�0:��tno�bac���kw�ard��compatibilit�y��*�.�4�In�this�mo�Gde,�Aa�v�ery�handy�function,�Ato�b�Ge���describ�Ged��"in�Section�3.11.2.27,�!is��whatnow�,�whic���h�tells�y�ou�what�has�b�Gecome�of�y�our�fa�v�ourite���functions,�UUwhic���h�GP�suddenly�can't�seem�to�remem�b�Ger.�����compatible����=�1:��[w���arn�when�using�obsolete�functions,�̱but�otherwise�accept�them.���The���output��Juses�the�new�con���v�en�tions��Jthough,�'Hand�there�ma���y�b�Ge�subtle�incompatibilities�b�et���w�een��Jthe���b�Geha���viour���of�former�and�curren�t�functions,�mev�en�when�they�share�the�same�name�(the�curren�t���function�O=is�used�in�suc���h�cases,�Puof�course!).�o�W��*�e�though�t�of�this�one�as�a�transitory�help�for�GP�O;old-���timers.�q�Th���us,�UUto�encourage�switc�hing�to��compatible�=0,�it�is�not�p�Gossible�to�disable�the�w�arning.�����compatible�c��=�2:��use�only�the�old�function�naming�sc���heme�(as�used�up�to�v�ersion�1.39.15),���but���taking���c��}'ase�into�ac�c�ount��ث.���Th���us���I���(��=�����$��p������$��fe�����1�����)�is�not�the�same�as��i��(user�v��q�ariable,�߹un���b�Gound�b�y���default),�UUand�y���ou�w�on't�get�an�error�message�using��i��as�a�lo�Gop�index�as�used�to�b�e�the�case.�����compatible���=�3:��Ltry�to�mimic�exactly�the�former�b�Geha���viour.�BThis�is�not�alw�a�ys�p�Gossible���when���functions�ha���v�e���c�hanged�in�a�fundamen�tal�w�a�y��*�.�G�But�these�dierences�are�usually�for�the�b�Getter���(they�UUw���ere�mean�t�to,�an�yw�a�y),�and�will�probably�not�b�Ge�disco�v�ered�b�y�the�casual�user.����One�&�adv���erse�side�eect�is�that�an�y�user�functions�and�aliases�that�ha�v�e�b�Geen�dened��b��}'efor�e����c���hanging����compatible��will�get�erased�if�this�c�hange�mo�Gdies�the�function�list,�i.e.�if�y�ou�mo�v�e���b�Get���w�een���groups��f�0�;����1�g��and��f�2�;��3�g��(v��q�ariables�are�unaected).�q�W��*�e�of�course�strongly�encourage�y���ou���to�UUtry�and�get�used�to�the�setting��compatible�=0.����Note�xthat�the�default��new_galois_format��is�another�compatibilit���y�setting,��Wwhic�h�is�completely���indep�Genden���t�UUof��compatible�.��Nb��2.1.4�w�datapath��K�(default:�I�the�lo�Gcation�of�installed�precomputed�data):�the�name�of�directory���con���taining���the�optional�data�les.�	F��*�or�no�w,��Xonly�the��galdata��pac�k��q�age,��Xneeded�b�y�p�Golgalois�in���degrees�UU8�to�11.����2.1.5�9�debug��ë(default��0�):� �debugging�lev���el.�xIf�it�is�non-zero,�žsome�extra�messages�ma�y�b�Ge�prin�ted���(some�UUof�it�in�F��*�renc���h),�according�to�what�is�going�on�(see��\g�).����2.1.6��debugfiles����(default��0�):�ile�usage�debugging�lev���el.�84If�it�is�non-zero,��&GP��nwill�prin�t�information���on�UUle�descriptors�in�use,�from�P��*�ARI's�p�Goin���t�of�view�(see��\gf�).����2.1.7��debugmem��<�(default��0�):�ǖmemory�debugging�lev���el.��}If�it�is�non-zero,���GP��1will�regularly�prin�t���information�B�on�memory�usage.�3If�it's�greater�than�2,�y�it�will�indicate�an���y�imp�Gortan�t�garbage�collecting���and�UUthe�function�it�is�taking�place�in�(see��\gm�).��'1��Imp�Q�ortan��9t��Note:��b�As�h�it�noticeably�slo���ws�do�wn�the�p�Gerformance�(and�triggers�bugs�in�some�v�ersions���of��9a�p�Gopular�compiler),��1the�rst�functionalit���y�(memory�usage)�is�disabled�if�y�ou're�not�running�a���v���ersion�UUcompiled�for�debugging�(see�App�Gendix�A).����2.1.8���ec��9ho�D1�(default��0�):�i5this�is�a�toggle,�G�whic���h�can�b�Ge�either�1�(on)�or�0�(o��).�lWhen��echo��mo�de�is���on,�Seac���h�R~command�is�reprin�ted�b�Gefore�b�eing�executed.�p�This�can�b�e�useful�when�reading�a�le�with���the��N�\r��or��read��commands.�d�F��*�or�example,���it�is�turned�on�at�the�b�Geginning�of�the�test�les�used�to���c���hec�k�UUwhether�GP�has�b�Geen�built�correctly�(see��\e�).�������17���챍����Kf�������2.1.9��format���(default��"g0.28"��and��"g0.38"��on�32-bit�and�64-bit�mac���hines,���resp�Gectiv�ely):��Aof��the���form��rx�m:n�,���where�x�is�a�letter�in��f�e�;����f�;��g�g�,�and��r�n�,��m��are�in���tegers.��If�x�is��f�,�real�n���um�b�Gers��rwill�b�e���prin���ted��-in�fixed�floating�p�Goin�t�format�with�no�explicit�exp�Gonen�t�(e.g.��0.000033�),���unless�their�in�teger���part��}is�not�dened�(not�enough�signican���t�digits);�pif�the�letter�is��e�,�they�will�b�Ge�prin�ted�in�scien�tific���format,���alw���a�ys�G�with�an�explicit�exp�Gonen���t�(e.g.��3.3e-5�).�IbIf�the�letter�is��g�,�real�n���um�b�Gers�G�will�b�e���prin���ted���in��f��format,��Dexcept�when�their�absolute�v��q�alue�is�less�than�2���^��O!�cmsy7��32��Kȫor�they�are�real�zero�Ges�(of���arbitrary�UUexp�Gonen���t),�in�whic�h�case�they�are�prin�ted�in��e��format.���1��The�&�n���um�b�Ger��n��is�the�n�um�b�Ger�of�signican�t�digits�prin�ted�for�real�n�um�b�Gers,�[[except�if��n�$t<��0���where�ܣall�the�signican���t�digits�will�b�Ge�prin�ted�(initial�default�28,��wor�38�for�64-bit�mac�hines),��wand���the�xZn���um�b�Ger��m��is�the�n�um�b�Ger�of�c�haracters�to�b�Ge�used�for�prin�ting�in�tegers,��but�is�ignored�if�equal���to�UU0�(whic���h�is�the�default).�q�This�is�a�feeble�attempt�at�formatting.���b����q�UNIX:��2.1.10�;help����(default:�"�the�lo�Gcation�of�the��gphelp��script):�the�name�of�the�external�help�program���whic���h���will�b�Ge�used�from�within�GP�Ӹwhen�extended�help�is�in�v�ok�ed,��zusually�through�a��??��S�or��???����request�UU(see�Section�2.2.1),�or��M-H��under�readline�(see�Section�2.11.1).����2.1.11���histsize�n�(default��5000�):��:GP�nk���eeps�a�history�of�the�last��histsize��results�computed�so�far,���whic���h�y�ou�can�reco�v�er�using�the��%��notation�(see�Section�2.2.4).�^	When�this�n�um�b�Ger�is�exceeded,�%�the���oldest��
v��q�alues�are�erased.�D�T��*�amp�Gering�with�this�default�is�the�only�w���a�y��
to�get�rid�of�the�ones�y���ou���don't�UUneed�an���ymore.����2.1.12�Allines��T�(default��0�):�-�if�set�to�a�p�Gositiv���e�v��q�alue,���GP��<prin�ts�at�most�that�man�y�lines�from�eac�h���result,�/�terminating��the�last�line�sho���wn�with��[+++]��if�further�material�has�b�Geen�suppressed.�}�The���v��q�arious����print��commands�(see�Section�3.11.2)�are�unaected,��so�y���ou�can�alw�a�ys�t�yp�Ge��print(%)�,���\a�,���or�V�\b��to�view�the�full�result.�s�If�the�actual�screen�width�cannot�b�Ge�determined,�V1a�\line"�is�assumed���to�UUb�Ge�80�c���haracters�long.����2.1.13�
Tlog���(default��0�):��+this�can�b�Ge�either�0�(o��)�or�1,��42,�3��(on,�see�b�Gelo���w�for�the�v��q�arious�mo�des).���When�S�logging�mo�Gde�is�turned�on,���GP�S�op�ens�a�log�le,���whose�exact�name�is�determined�b���y�the����logfile�r��default.�ɍSubsequen���tly��*�,�y�all�the�commands�and�results�will�b�Ge�written�to�that�le�(see��\l�).���In���case�a�le�with�this�precise�name�already�existed,��sit�will�not�b�Ge�erased:�	zy���our�data�will�b�e��app��}'ende�d����at�UUthe�end.���1��The�UUsp�Gecic�p�ositiv���e�v��q�alues�of��log��ha�v�e�the�follo�wing�meaning����1:�q�plain�UUlogle����2:�q�emit�UUcolor�co�Gdes�to�the�logle�(if��colors��is�set).����3:�q�write�UUT��*�eX�output�to�the�logle�(can�b�Ge�further�customized�using��TeXstyle�).����2.1.14�xRlogfile���(default��"pari.log"�):��=name�of�the�log�le�to�b�Ge�used�when�the��log��toggle�is�on.���En���vironmen�t�UUand�time�expansion�are�p�Gerformed.����2.1.15���new_galois_format�!�(default��0�):�R-if�this�is�set,�"�the��polgalois��command�will�use�a�dieren���t,���more�m�consisten���t,�s�naming�sc�heme�for�Galois�groups.���This�default�is�pro�vided�to�ensure�that�scripts���can�con���trol�this�b�Geha�viour�and�do�not�break�unexp�Gectedly��*�.�WNote�that�the�default�v��q�alue�of�0�(unset)���will�UUc���hange�to�1�(set)�in�the�next�ma��8jor�v�ersion.�������18����������Kf�������2.1.16��%output��o�(default��1�):���there�are�four�p�Gossible�v��q�alues:�0�(=���r��}'aw��m�),�F�1�(=���pr��}'ettymatrix��;�̫),�2���(=����pr��}'ettyprint��4"E�),�TJor��3�(=���external���pr��}'ettyprint��Z`ǫ).�	<This�means�that,�indep�Genden���tly�of�the�default����format�ܳ�for�reals�whic���h�w�e�explained�ab�Go�v�e,�>�y�ou�can�prin�t�results�in�four�w�a�ys:���either�in��r��}'aw���format��ث,�/i.e.�%�a�format�whic���h�is�equiv��q�alen�t�to�what�y�ou�input,�/including�explicit�m�ultiplication�signs,���and��eev���erything�t�yp�Ged�on�a�line�instead�of�t�w�o�dimensional�b�Go�xes.�CwThis�can�ha�v�e�sev�eral�adv��q�an�tages,���for�|�instance�it�allo���ws�y�ou�to�pic�k�the�result�with�a�mouse�or�an�editor,���and�to�paste�it�somewhere���else.���(��The��Qsecond�format�is�the��pr��}'ettymatrix���format��ث.���The�only�dierence�to�ra���w�format�is�that���matrices��"are�prin���ted�as�b�Go�xes�instead�of�horizon�tally��*�.�0-This�is�prettier,�Ubut�tak�es�more�space�and���cannot�UUb�Ge�used�for�input.�q�Column�v���ectors�are�still�prin�ted�horizon�tally��*�.����The�b]third�format�is�the��pr��}'ettyprint���format��ث,�e�or�b�Geautied�format.���In�the�presen���t�v�ersion�2.2.7,���this�UUis�not�b�Geautiful�at�all.������q�UNIX:��The�f�fourth�format�is��external���pr��}'ettyprint��ث,��/whic���h�pip�Ges�all�GP�f�output�in�T��*�eX�format�to�an���external��vprett���yprin�ter,�)�according�to�the�v��q�alue�of��prettyprinter�.�p)The�default�script�(�tex2mail�)���con���v�erts�UUits�input�to�readable�t���w�o-dimensional�UUtext.����Indep�Genden���tly��of�the�setting�of�this�default,��Pan�ob��8ject�can�b�e�prin���ted�in�an�y�of�the�three�formats���at�UUan���y�time�using�the�commands��\a�,��\m��and��\b��resp�Gectiv�ely�(see�b�Gelo�w).���P��2.1.17�@�parisize���(default,���1M���b���ytes�on�the�Mac,�4M���otherwise):�1 GP��*�,�and�in�fact�an���y�program�using���the��P��*�ARI�blibrary�,�2�needs�a�stac���k�in�whic�h�to�do�its�computations.��x�parisize��is�the�stac�k�size,�2�in���b���ytes.�d�It�.Sis�strongly�recommended�y�ou�increase�this�default�(using�the��-s��command-line�switc�h,�6 or���a�(��gprc�)�if�y���ou�can�aord�it.�b�Don't�increase�it�b�Gey�ond�the�actual�amoun�t�of�RAM�(�installed�on�y�our���computer�UUor�GP�will�sp�Gend�most�of�its�time�paging.����In���case�of�emergency��*�,��!y���ou�can�use�the��allocatemem��function�to�increase��parisize�,�once�the���session�UUis�started.���P��2.1.18��{path�ū(default��".:��&f~��?�:��&f~��/gp"�ūon�UNIX��systems,�{�".;C:\;C:\GP��on��DOS,�OS/2�and�Windo���ws,���and�`�"."��otherwise):��[This�is�a�list�of�directories,�b�separated�b���y�colons�':'�(semicolons�';'�e�in�the�DOS���w���orld,���since���colons�are�pre-empted�for�driv�e�names).�K'When�ask�ed�to�read�a�le�whose�name�do�Ges���not�D�con���tain��/��(i.e.�no�explicit�path�w�as�giv�en),�HGP�D�will�lo�Gok�for�it�in�these�directories,�in�the�order���they��Qw���ere�written�in��path�.�L�Here,���as�usual,�'.'�L�means�the�curren���t�directory��*�,�and�'�:���:�'�its�immediate���paren���t.�q�En�vironmen�t�UUexpansion�is�p�Gerformed.������q�UNIX:��2.1.19�-�prett��9yprin�ter��c�(default��"tex2mail�?�-TeX�-noindent�-ragged�-by���E�ff&f��ǫpar"�)��cthe�name�of�an���external�<�prett���yprin�ter�to�use�when��output��is�3�(��alternate���pr��}'ettyprinter��b/ͫ).�K�This���is�exp�Q�erimen��9tal��but���the��\default��tex2mail��lo�Goks�already�m���uc�h��\nicer�than�the�built-in�\b�eautied�format"�(��output��"G�=��2).����2.1.20��primelimit�|�(default��200k��on�the�Mac,���and��500k��otherwise):��,GP�{�precomputes�a�list�of�all���primes�� less�than��primelimit��at�initialization�time.�E`These�are�used�b���y�man�y�arithmetical�functions.���If�UUy���ou�don't�plan�to�in�v�ok�e�an�y�of�them,�y�ou�can�just�set�this�to�1.�������19���
r�����Kf�������2.1.21�rWprompt��ޫ(default��"?�
�"�):���a�string�that�will�b�Ge�prin���ted�as�prompt.�aNote�that�most�usual���escap�Ge��csequences�are�a���v��q�ailable�there:����\e��for�Esc,��'�\n��for�Newline,���:���:�:���v�,��\\��for��\�.�
�Time�expansion�is���p�Gerformed.��X��This�Bkstring�is�sen���t�through�the�library�function��strftime��(on�a�Unix�system,�F3y�ou�can�try��man���strftime�%��at�y���our�shell�prompt).��This�means�that��%��constructs�ha�v�e�a�sp�Gecial�meaning,�Y�usually���related��Wto�the�time�and�date.�MF��*�or�instance,��W�%H��;�=�hour�(24-hour�clo�Gc���k)�and��%M��=�min���ute�[00,59]�(use����%%�UU�to�get�a�real��%�).����If�NEy���ou�use��readline�,�O�escap�Ge�sequences�in�y�our�prompt�will�result�in�displa�y�bugs.�olIf�y�ou�ha�v�e���a���relativ���ely�recen�t��readline��(see�the�commen�t�at�the�end�of�Section�2.1.2),�y�ou�can�brace�them���with�#�sp�Gecial�sequences�(�\[��and��\]�),�Wland�y���ou�will�b�e�safe.��3If�these�just�result�in�extra�spaces�in���y���our��xprompt,��then�y�ou'll�ha�v�e�to�get�a�more�recen�t��readline�.�D/See�the�le��misc/gprc.dft��for�an���example.�����ҕQEMA���CS:��Caution�:��Emacs��needs�to�kno���w�ab�Gout�the�prompt�pattern�to�separate�y�our�input�from�previous�GP���results,��8without��pam���biguit�y��*�.�@&It's�not�a�trivial�problem�to�adapt�automatically�this�regular�expression���to�"�an�arbitrary�prompt�(whic���h�can�b�Ge�self-mo�difying!).�`�Th���us,�,�in�this�v�ersion�2.2.7,�,�Emacs�relies�on���the��4prompt�b�Geing�the�default�one.�B�So,��ndo�not�tamp�er�with�the��prompt��v��q�ariable��unless��U�y���ou�mo�dify�it���sim���ultaneously�O�in�y�our��.emacs��le�(see��emacs/pariemacs.txt��and��misc/gprc.dft��for�examples).���8��2.1.22�=prompt_con��9t���(default��""�):�&�a�string�that�will�b�Ge�prin���ted�to�prompt�for�con�tin�uation�lines���(e.g.��iin�n�b�Get���w�een�braces,�uCor�after�a�line-terminating�bac�kslash).��iEv�erything�that�applies�to��prompt����applies�UUto��prompt���E�ff&f��ǫcont��as�w���ell.����2.1.23�p�psfile��}�(default��"pari.ps"�):��name�of�the�default�le�where�GP��[is�to�dump�its�P���ostScript���dra���wings���(these�will�alw�a�ys�b�Ge�app�ended,���so�that�no�previous�data�are�lost).�CPEn���vironmen�t���and�time���expansion�UUare�p�Gerformed.����2.1.24�h0readline��m�(default��1�):�BSswitc���hes�readline�line-editing�facilities�on�and�o.�R%This�ma�y�b�Ge�useful���if�=�y���ou�are�running�GP�=uin�a�Sun��cmdtool�,�w�whic�h�in�teracts�badly�with�readline.�*�Of�course,�w�un�til���readline��zis�switc���hed�on�again,���adv��q�anced�editing�features�lik�e�automatic�completion�and�editing���history�UUare�not�a���v��q�ailable.����2.1.25��Vrealprecision�%��(default��28��and��38��on�32-bit�and�64-bit�mac���hines�resp�Gectiv�ely):�Y�the�n�um�b�Ger���of��usignican���t�digits�and,���at�the�same�time,�the�n���um�b�Ger��uof�prin���ted�digits�of�real�n�um�b�Gers�(see��\p�).���Note��[that�P��*�ARI��Fin���ternal�precision�w�orks�on�a�w�ord�basis�(32�or�64�bits),���hence�ma�y�not�coincide���with��the�n���um�b�Ger��of�decimal�digits�y���ou�input.�lF��*�or�instance�to�get�2�decimal�digits�y�ou�need�one���w���ord�UUof�precision�whic�h,�on�a�32-bit�mac�hine,�actually�giv�es�y�ou�9�digits�(9���<���log����ğqƮ10��*��(2���^��32��x�)��<��10):��u{���?�?�default(realprecision,�2)��_��3�realprecision�?�=�9�significant�digits�(2�digits�displayed)����2.1.26���secure�@�(default��0�):�gthis�is�a�toggle�whic���h�can�b�Ge�either�1�(on)�or�0�(o��).�j�If�on,�DGthe��system����and��}�extern��command�are�disabled.��@These�t���w�o��}commands�are�p�Goten���tially�dangerous�when�y�ou���execute��}foreign�scripts�since�they�let�GP��&execute�arbitrary�UNIX�commands.�k?GP�will�ask�for���conrmation�UUb�Gefore�letting�y���ou�(or�a�script)�unset�this�toggle.����2.1.27�t�seriesprecision���(default��16�):��n���um�b�Ger���of�signican���t�terms�when�con�v�erting�a�p�Golynomial���or�UUrational�function�to�a�p�Go���w�er�UUseries�(see��\ps�).�������20��������Kf�������2.1.28�}ksimplify��(default��1�):�K�this�is�a�toggle�whic���h�can�b�Ge�either�1�(on)�or�0�(o��).�XLWhen�the�P��*�ARI���library�gcomputes�something,���the�t���yp�Ge�of�the�result�is�not�alw�a�ys�the�simplest�p�Gossible.�"\The�only�t�yp�Ge���con���v�ersions��whic�h�the�P��*�ARI���library�do�Ges�automatically�are�rational�n�um�b�Gers�to�in�tegers�(when�they���are��of�t���yp�Ge��t_FRAC����and�equal�to�in�tegers),���and�similarly�rational�functions�to�p�Golynomials�(when���they�:are�of�t���yp�Ge��t_RFRAC�9ӫand�equal�to�p�olynomials).��This�feature�is�useful�in�man���y�cases,�s=and���sa���v�es��time,��but�can�b�Ge�anno���ying�at�times.�Hence�y�ou�can�disable�this�and,��whenev�er�y�ou�feel�lik�e���it,�M
use�J�the�function��simplify��(see�Chapter�3)�whic���h�allo�ws�y�ou�to�simplify�ob��8jects�to�the�simplest���p�Gossible�UUt���yp�es�recursiv���ely�(see��\y�).���b��2.1.29�<�strictmatc��9h�п�(default��1�):�/|this�is�a�toggle�whic���h�can�b�Ge�either�1�(on)�or�0�(o��).�E�If�on,��Cun�used���c���haracters�u�after�a�sequence�has�b�Geen�pro�cessed�will�pro�duce�an�error.�ӜOtherwise�just�a�w���arning�is���prin���ted.�_�This��can�b�Ge�useful�when�y�ou're�not�sure�ho�w�man�y�paren�theses�y�ou�ha�v�e�to�close�after���complicated�UUnested�lo�Gops.����2.1.30��T��
�eXst��9yle��s�(default��0�):��the�bits�of�this�default�allo���w�GP��Mto�use�less�rigid�T��*�eX�formatting���commands���in�the�logle.�eTThis�default�is�only�tak���en�in�to�accoun�t�when���log��_��=��3.�eTThe�bits�of����TeXstyle�UU�ha���v�e�the�follo�wing�meaning��W1��1:�q�use�UU�\frac��instead�of��\over��for�fractions.����2:�q�insert�UU�\right��/��\left��pairs�where�appropriate.����4:�dfinsert�:�discretionary�breaks�in�p�Golynomials,�?�to�enhance�the�probabilit���y�of�a�go�o�d�line�break.����2.1.31�G
timer��ի(default��0�):���this�is�a�toggle�whic���h�can�b�Ge�either�1�(on)�or�0�(o��).�6FIf�on,��4ev�ery���instruction��sequence�(an���ything�ended�b�y�a�newline�in�y�our�input)�is�timed,�Ppto�some�accuracy���dep�Gending��Uon�the�hardw���are�and�op�erating�system.�(�The�time�measured�is�the�user�CPU��Etime,����not����including�UUthe�time�for�prin���ting�the�results�(see��#��and��##�).����2.1.32��TNote�on�output�formats.��W1��A�@�zero�A7real�n���um�b�Ger�A7is�prin���ted�in��e��format�as�0�:E���xx��where��xx��is�the�(usually�negativ�e)��de��}'cimal����exp�Gonen���t���of�the�n�um�b�Ger�(cf.�Section�1.2.6.3).�P�This�allo�ws�the�user�to�c�hec�k�the�accuracy�of�the�zero���in�UUquestion�(this�could�also�b�Ge�done�using��\x�,�but�that�w���ould�b�e�more�tec���hnical).����When��wthe�in���teger�part�of�a�real�n�um�b�Ger��x��is�not�kno�wn�exactly�b�Gecause�the�exp�onen���t�of��x��is���greater�׸than�the�in���ternal�precision,��Qthe�real�n�um�b�Ger�is�prin�ted�in��e��format�(note�that�in�v�ersions���b�Gefore�UU1.38.93,�this�w���as�instead�prin�ted�with�a����at�the�end).����Note�Z,also�that�in�b�Geautied�format,��ha�n���um�b�er�Z,of�t���yp�e�in���teger�or�real�is�written�without�enclosing���paren���theses,�/Zwhile�%�most�other�t�yp�Ges�ha�v�e�them.�a�Hence,�/Zif�y�ou�see�the�expression�(3�:�14),�/Zit�is�not�of���t���yp�Ge�Hbreal,�J�but�probably�of�t�yp�Ge�complex�with�zero�imaginary�part�(if�y�ou�w�an�t�to�b�Ge�sure,�J�t�yp�Ge��\x����or�UUuse�the�function��type�).�������21���-^�����Kf�������2.2��Simple�metacommands�.��p��Simple���metacommands�are�mean���t�as�shortcuts�and�should�not�b�Ge�used�in�GP��Nscripts�(see�Sec-���tion��]3.11).�O�Bew���are�that�these,���as�all�of�GP��input,�are��c��}'ase�Èsensitive��[�.�O�F��*�or�example,��\Q���is�not���iden���tical�kBto��\q�.���In�the�follo�wing�list,���braces�are�used�to�denote�optional�argumen�ts,���with�their���default���v��q�alues�when�applicable,�e.g.��f�n��#�=�0�g��ëmeans�that�if��n��is�not�there,�it�is�assumed�to�b�Ge�0.���Whitespace�u�(or�spaces)�b�Get���w�een�u�the�metacommand�and�its�argumen���ts�and�within�argumen�ts�is���optional.�h_(This�9can�cause�problems�only�with��\w�,�>�when�y���ou�insist�on�ha�ving�a�lename�whose�rst���c���haracter��is�a�digit,�τand�with��\r��or��\w�,�if�the�lename�itself�con���tains�a�space.��In�suc�h�cases,�τjust���use�UUthe�underlying��read��or��write��function;�see�Section�3.11.2.28).�����2.2.1��?���f��c��}'ommand��*n߷g�:���GP��con-line��ohelp�in���terface.�As�already�men���tioned,��uif�y�ou�t�yp�Ge��?�n��where��n��is���a���n���um�b�Ger�from�1�to�11,��8y�ou�will�get�the�list�of�functions�in�Section�3�:n��of�the�man�ual�(the�list�of���sections�UUb�Geing�obtained�b���y�simply�t�yping��?�).��Tu��These��names�are�in�general�not�informativ���e�enough.�g
More�details�can�b�Ge�obtained�b�y�t�yping����?��function��$�q�,��whic���h��>giv�es�a�short�explanation�of�the�function's�calling�con�v�en�tion�and�eects.�7�Of���course,��to��:ha���v�e�complete�information,��read�Chapter�3�of�this�man�ual�(the�source�co�Gde�is�at�y�our���disp�Gosal�H�as�w���ell,��Uthough�a�tri
e�less�readable!).�KbMuc�h�b�Getter�help�can�b�e�obtained�through�the���extended�UUhelp�system�(see�b�Gelo���w).������q�UNIX:�If�H�the�line�b�Gefore�the�cop���yrigh�t�H�message�indicates�that�extended�help�is�a���v��q�ailable�(this�means��perl����is�њinstalled�on�y���our�system,���GP��xw�as�told�ab�Gout�it�at�compile�time,���and�the�whole�P��*�ARI��xdistribution���w���as�UUcorrectly�installed),�y�ou�can�add�more��?�qǫsigns�for�extended�functionalities:�����??��?��keywor��}'d��,d�yields�z�the�functions�description�as�it�stands�in�this�man���ual,��9usually�in�Chapter�2���or���3.�[�If�y���ou're�not�satised�with�the�default�c�hapter�c�hosen,�!iy�ou�can�imp�Gose�a�giv�en�c�hapter�b�y���ending��Athe�k���eyw�ord��Awith��@��follo���w�ed��Ab�y�the�c�hapter�n�um�b�Ger,��e.g.��??�?�[email protected]��will�lo�ok�in�Chapter�2���for�UUsection�heading��Hello��(whic���h�do�Gesn't�exist,�b�y�the�w�a�y).����All�s�op�Gerators�(e.g.��+�,���&&�,�etc.)��zare�s�accepted�b���y�this�extended�help,��as�w�ell�as�a�few�other���k���eyw�ords���describing�k���ey�GP���concepts,���e.g.��readline��(the�line�editor),��integer�,��nf��(\n���um�b�Ger���eld"���as�UUused�in�most�algebraic�n���um�b�Ger�UUtheory�computations),��ell��(elliptic�curv���es),�etc.����In�IKcase�of�con
icts�b�Get���w�een�IKfunction�and�default�names�(e.g��log�,�K��simplify�),�the�IKfunction�has���higher�UUpriorit���y��*�.�q�Use��??�
�default�?�/��defaultname��8���to�get�the�default�help.�����???��?��p��}'attern��([
�pro�Gduces��\a�list�of�sections�in�Chapter�3�of�the�man���ual�related�to�y�our�query��*�.��As���b�Gefore,��if���T�p��}'attern��'l\�ends��Tb���y��@��follo�w�ed�b�y�a�c�hapter�n�um�b�Ger,��that�c�hapter�is�searc�hed�instead;�:�y�ou���also��^ha���v�e�the�option�to�app�Gend�a�simple��@��(without�a�c�hapter�n�um�b�Ger)�to�bro�wse�through�the�whole���man���ual.����If��	y���our�query�con�tains�dangerous�c�haracters�(e.g��?�9Y�or�blanks)�it�is�advisable�to�enclose�it�within���double�UUquotes,�as�for�GP�strings�(e.g��???�?�"elliptic�curve"�).����Note�e+that�extended�help�is�m���uc�h�e+more�p�Go���w�erful�e+than�the�short�help,�� since�it�kno���ws�ab�out���op�Gerators�dbas�w���ell:���y�ou�dbcan�t���yp�e��??�?�*��or��??�&&�,��%whereas�a�single��?���w���ould�just�yield�a�not�to�Go���helpful�����***�?�unknown�identifier.����message.��Also,�ky���ou��can�ask�for�extended�help�on�section�n�um�b�Ger��n��in�Chapter�3,�kjust�b�y�t�yping����??�?��n�Uӫ(where��?�n��w���ould�yield�merely�a�list�of�functions).�sAFinally��*�,���a�few�k�ey�concepts�in�GP�U�are���do�Gcumen���ted�I�in�this�w�a�y:�lmetacommands�(e.g��??�?�"??"�),�LCdefaults�(e.g��??�psfile�)�and�t���yp�Ge�names�������22���;	�����Kf�����卫(e.g�
��t_INT�
ȫor��integer�),��as�w���ell�as�v��q�arious�miscellaneous�k�eyw�ords�suc�h�as��edit��(short�summary�of���line�UUeditor�commands),��operator�,��member�,��"user�?�defined"�,��nf�,��ell�,���:���:�:����l���Last��but�not�least:�G��??�U��without�argumen���t�will�op�Gen�a��dvi��preview�er�(�xdvi��b�y�default,���$GPXDVI����if� it�is�dened�in�y���our�en�vironmen�t)�con�taining�the�full�user's�man�ual.�[`�??tutorial��and��??refcard����do�UUthe�same�with�the�tutorial�and�reference�card�resp�Gectiv���ely��*�.���	��T��
�ec��9hnical�~�note:��īthese���functionalities�are�pro���vided�b�y�an�external��perl��script�that�y�ou�are�free���to�;�use�outside�an���y�GP�;�session�(and�mo�Gdify�to�y�our�liking,�ulif�y�ou�are�p�Gerl-kno�wledgeable).�%2It�is���called�U�gphelp�,�"lies�in�the��doc��sub�Gdirectory�of�y���our�distribution�(just�mak�e�sure�y�ou�run��Configure����rst,���see���App�Gendix�A)���and�is�really�t���w�o���programs�in�one.�9aThe�one�whic���h�is�used�from�within�GP���is��$�gphelp��whic���h�runs�T���U>�'E���xX�on�a�selected�part�of�this�man�ual,��Wthen�op�Gens�a�preview�er.��3�gphelp���-detex����is�a�text�mo�Gde�equiv��q�alen���t,��whic�h���lo�oks�often�nicer�esp�ecially�on�a�colour-capable�terminal���(see��e�misc/gprc.dft��for�examples).�T�The�default��help��selects�whic���h�help�program�will�b�Ge�used�from���within��GP��*�.�Y�ou�are�w���elcome�to�impro�v�e�this�help�script,��Mor�write�new�ones�(and�w�e�really�w�ould���lik���e�7�to�kno�w�ab�Gout�it�so�that�w�e�ma�y�include�them�in�future�distributions).�g�By�the�w�a�y��*�,�=�outside�of���GP�UUy���ou�can�giv�e�more�than�one�k�eyw�ord�as�argumen�t�to��gphelp�.��ٍ�2.2.2�u��/*...*/�:��zcommen���t.��Ev�erything��b�Get�w�een�the�stars�is�ignored�b�y�GP��*�.�These�commen�ts�can���span�UUan���y�n�um�b�Ger�of�lines.����2.2.3��T�\\�:�q�one-line�UUcommen���t.�The�rest�of�the�line�is�ignored�b���y�GP��*�.����2.2.4���\a��W�f�n�g�:���prin���ts�the�ob��8ject�n�um�b�Ger��n��(%�n�)�in�ra�w�format.�1�If�the�n�um�b�Ger��n��is�omitted,��Xprin�t���the�UUlatest�computed�ob��8ject�(%).����2.2.5��T�\b�UU�f�n�g�:�q�Same�as��\a�,�in�prett���yprin�t�UU(i.e.�b�Geautied)�format.����2.2.6�˹�\c�:�Iprin���ts�+�the�list�of�all�a�v��q�ailable�hardco�Gded�functions�under�GP��*�,�not�including�op�erators���written�`�as�sp�Gecial�sym���b�ols�(see�Section�2.4).��iMore�information�can�b�e�obtained�using�the��?��i�meta-���command�UU(see�ab�Go���v�e).�q�F��*�or�UUuser-dened�functions�/�mem���b�er�functions,�see��\u��and��\um�.����2.2.7���\d�:��prin���ts�l�the�defaults�as�describ�Ged�in�the�previous�section�(shortcut�for��default()�,���see���Section�UU3.11.2.4).����2.2.8��T�\e�UU�f�n�g�:�q�switc���hes�the��echo��mo�Gde�on�(1)�or�o�(0).�If��n��is�explicitly�giv���en,�set�ec�ho�to��n�.����2.2.9��T�\g�UU�f�n�g�:�q�sets�the�debugging�lev���el��debug��to�the�non-negativ�e�in�teger��n�.����2.2.10��T�\gf�UU�f�n�g�:�q�sets�the�le�usage�debugging�lev���el��debugfiles��to�the�non-negativ�e�in�teger��n�.����2.2.11��T�\gm�UU�f�n�g�:�q�sets�the�memory�debugging�lev���el��debugmem��to�the�non-negativ�e�in�teger��n�.����2.2.12����\h�&�f�m�-�n�g�:�Z�outputs�some�debugging�info�ab�Gout�the�hash���table.�bQIf�the�argumen�t�is�a�n�um�b�Ger����n�,��Noutputs���the�con���ten�ts���of�cell��n�.�t�Ranges�can�b�Ge�giv���en�in�the�form��m�-�n��(from�cell��m��to�cell��n�,�$���=�Filast�cell).�l�If�a�function�name�is�giv���en�instead�of�a�n�um�b�Ger�or�range,�Ieoutputs�info�on�the�in�ternal���structure��of�the�hash�cell�this�function�o�Gccupies�(a��struct�?�entree��in�C).�If�the�range�is�reduced�to���a�UUdash�('�-�'),�outputs�statistics�ab�Gout�hash�cell�usage.�������23���L������Kf�������2.2.13�7��\l��#�f��lo��}'gle��Hطg�:�-.switc���hes��log��mo�Gde�on�and�o.�DIf�a���lo��}'gle����argumen�t�is�giv�en,��c�hange�the�default���logle�UUname�to���lo��}'gle���and�switc���h�log�mo�Gde�on.��q��2.2.14��T�\m�:�q�as�UU�\a�,�but�using�prett���ymatrix�format.����2.2.15�u��\o��J�f�n�g�:�E�sets��output��mo�Gde�to��n��(0:�ra���w,��1:�prett�ymatrix,��2:�prett�yprin�t,��3:�external���prett���yprin�t).����2.2.16��T�\p�UU�f�n�g�:�q�sets��realprecision��to��n��decimal�digits.�Prin���ts�its�curren�t�v��q�alue�if��n��is�omitted.����2.2.17�-��\ps����f�n�g�:��sets��seriesprecision��to��n��signican���t�terms.��Prin�ts�its�curren�t�v��q�alue�if��n��is���omitted.����2.2.18�za�\q�:���quits���the�GP��session�and�returns�to�the�system.� WShortcut�for�the�function��quit��(see���Section�UU3.11.2.20).����2.2.19��>�\r�V �f��lename��%
A�g�:�s^reads�in���to�GP�all�the�commands�con�tained�in�the�named�le�as�if�they�had���b�Geen��3t���yp�ed�from�the�k���eyb�oard,���one�line�after�the�other.�O`Can�b�e�used�in�com���bination�with�the��\w����command�w](see�b�Gelo���w).���Related�but�not�equiv��q�alen�t�to�the�function��read��(see�Section�3.11.2.21);��ain���particular,��if��the�le�con���tains�more�than�one�line�of�input,�there�will�b�Ge�one�history�en���try�for�eac�h�of���them,�~<whereas�v�read��w���ould�only�record�the�last�one.���If���lename��+�]�is�omitted,�re-read�the�previously���used��_input�le�(fails�if�no�le�has�ev���er�b�Geen�successfully�read�in�the�curren�t�session).�> If�a�GP��8�binary���file���(see�Section�3.11.2.30)�is�read�using�this�command,�"it�is�silen���tly�loaded,�without�cluttering���the�UUhistory��*�.���􍍑�q�UNIX:�This���command�accepts�compressed�les�in�compressed�(�.Z�)���or�gzipp�Ged�(�.gz��or��.z�)�format.�q�They���will�UUb�Ge�uncompressed�on�the�
y�as�GP�reads�them,�without�c���hanging�the�les�themselv�es.����2.2.20��w�\s�:���prin���ts��the�state�of�the�P��*�ARI��stac�k�and�heap.��OThis�is�used�primarily�as�a�debugging���device�UUfor�P��*�ARI,�and�is�not�in���tended�for�the�casual�user.����2.2.21��F�\t�:���prin���ts�_the�in�ternal�longw�ord�format�of�all�the�P��*�ARI�/t�yp�Ges.���The�detailed�bit�or�b�yte���format�nAof�the�initial�co�Gdew���ord(s)�is�explained�in�Chapter�4,�t|but�its�kno�wledge�is�not�necessary�for���a�UUGP�user.����2.2.22��T�\u�:�q�prin���ts�UUthe�denitions�of�all�user-dened�functions.����2.2.23��T�\um�:�q�prin���ts�UUthe�denitions�of�all�user-dened�mem�b�Ger�functions.����2.2.24����\v�:�prin���ts�y�the�v�ersion�n�um�b�Ger�and�implemen�tation�arc�hitecture�(680x0,���Sparc,�Alpha,�other)���of�3the�GP�executable�y���ou�are�using.�WfIn�library�mo�Gde,�y�ou�can�use�instead�the�t�w�o�c�haracter�strings����PARIVERSION�>˫and�>��PARIINFO�,�whic���h�corresp�Gond�to�the�rst�t�w�o�lines�prin�ted�b�y�GP�>�just�b�Gefore�the���Cop���yrigh�t�UUmessage.����2.2.25�>��\w��H�f�n�g�f��lename��%
A�g�:�0Awrites�the�ob��8ject�n���um�b�Ger��H�n��(�%�n��)�in���to�the�named�le,��~in�ra�w�format.�FIf���the�In���um�b�Ger��n��is�omitted,�K}writes�the�latest�computed�ob��8ject�(�%�).�m�If���lename��+�O�is�omitted,�app�Gends���to�>�logfile��(the�GP�/function��write��is�a�tri
e�more�p�Go���w�erful,�%Cas�>y�ou�can�ha�v�e�arbitrary�lenames).�������24���[������Kf�������2.2.26�?�\x�:�)�prin���ts��Qthe�complete�tree�with�addresses�and�con�ten�ts�(in�hexadecimal)�of�the�in�ternal���represen���tation��Zof�the�latest�computed�ob��8ject�in�GP��*�.�As�for��\s�,���this�is�used�primarily�as�a�debugging���device�b�for�P��*�ARI,�and�the�format�should�b�Ge�self-explanatory�(a����b�efore�an�ob��8ject�{�t���ypically�a���mo�Gdulus�
�{�means�the�corresp�onding�comp�onen���t�is�out�of�stac�k).�Y�Ho�w�ev�er,�)used�on�a�P��*�ARI�
�in�teger,���it�UUcan�b�Ge�used�as�a�decimal�!�hexadecimal�con���v�erter.��c0��2.2.27��T�\y�UU�f�n�g�:�q�switc���hes��simplify��on�(1)�or�o�(0).�If��n��is�explicitly�giv���en,�set�simplify�to��n�.����2.2.28��T�#�:�q�switc���hes�UUthe��timer��on�or�o.����2.2.29�o~�##�:�E�prin���ts���the�time�tak�en�b�y�the�latest�computation.�TCUseful�when�y�ou�forgot�to�turn�on�the����timer�.��&ƍ�2.3��Input�formats�for�the�P���ARI�t��yp�`es�.���ˍBefore�0�describing�more�sophisticated�functions�in�the�next�section,�g�let�us�see�here�ho���w�to�input���v��q�alues��of�the�dieren���t�data�t�yp�Ges�kno�wn�to�P��*�ARI.�Recall�that�blanks�are�ignored�in�an�y�expression���whic���h�UUis�not�a�string�(see�b�Gelo�w).��c0��2.3.1���In��9tegers����(t���yp�Ge�YE�t_INT�):�t�yp�Ge�the�in�teger�(with�an�initial��+��or��-�,�ZAif�desired)�with�no�decimal���p�Goin���t.����2.3.2��UReal�n��9um�b�Q�ers����(t���yp�Ge�|��t_REAL�):�t�yp�Ge�the�n�um�b�Ger�with�a�decimal�p�oin���t.�)�The�in�ternal�precision���of�\�the�real�n���um�b�Ger�\�will�b�e�the�suprem���um�of�the�input�precision�and�the�default�precision.��>F��*�or���example,���if���the�default�precision�is�28�digits,�t���yping��2.���will�giv�e�a�n�um�b�Ger�with�in�ternal�precision���28,�1but�(t���yping�a�45�signican�t�digit�real�n�um�b�Ger�will�giv�e�a�n�um�b�Ger�with�in�ternal�precision�at�least���45�UU(although�less�ma���y�b�Ge�prin�ted).������Y��*�ou�B�can�also�use�scien���tic�notation�with�the�letter��E�B��or��e�,�~$in�whic�h�case�the�(non�leading)���decimal�X�p�Goin���t�ma�y�b�Ge�omitted�(lik�e��6.02�?�E�23�X�or��1e-5�,�Y�but��not�K��e10�).�|�By�denition,��0.E�?��N�p�(or��0���E�?��N��)�Z�returns�a�real�0�of�(decimal)�exp�Gonen���t��N��,�\>whereas��0.��]�returns�a�real�0�\of�default�precision"���(of�UUexp�Gonen���t����defaultprecision��S�Ы),�see�Section�1.2.6.3.����2.3.3���In��9tegermo�Q�ds�=��(t���yp�Ge��t_INTMOD�):�to�en�ter��n�����mo�Gd����m�,�u�t�yp�Ge��Mod(n,m)�,�u��not�0k�n%m��(see�Section�3.2.3).����2.3.4��tRational�n��9um�b�Q�ers�%��(t���yp�Ges��t_FRAC�%��and��t_FRACN�):�under�GP��*�,�all�fractions�are�automatically���reduced���to�lo���w�est���terms,��so�it�is�in�principle�imp�Gossible�to�w���ork�with�reducible�fractions�(of�t�yp�Ge����t_FRACN�),�.although�of�course�in�library�mo�Gde�this�is�easy��*�.�V�T�o�.en���ter��n=m��just�t�yp�Ge�it�as�written.�V�As���explained�UUin�Section�3.1.4,�division�will��not�H-�b�Ge�p�erformed,�only�reduction�to�lo���w�est�UUterms.������If�y���ou�really�w�an�t�a�reducible�fraction�under�GP��*�,�y�ou�m�ust�use�the��type��function�(see�Sec-���tion���3.11.2.26),��Mb���y�t�yping��type(x,FRACN)�.�Be�w�arned�ho�w�ev�er�that�this�function�m�ust�b�Ge�used�with���extreme�UUcare.����2.3.5��&Complex�n��9um�b�Q�ers����(t���yp�Ge��t_COMPLEX�):�to�en�ter��x��#�+��iy�[٫,��t�yp�Ge����x�?�+�I*y��(�not�z��x+i*y�).�-RThe�letter����I����stands���for�����$��p������$��fe�����1�����9.�9Recall�from�Chapter�1�that��x��and��y��can�b�Ge�of�t���yp�e��t_INT�,��t_REAL�,��t_INTMOD�,����t_FRAC�/�t_FRACN�,�UUor��t_PADIC�.�������25���i9�����Kf�������2.3.6���p�-adic�n��9um�b�Q�ers����(t���yp�Ge��t_PADIC�):�to�en�ter�a��p�-adic�n�um�b�Ger,�ŕsimply�write�a�rational�or�in�teger���expression���and�add�to�it��O(�p�^�k�P��)�,��)where��p��and��k�ꖫare�in���tegers.�?�This�last�expression�indicates�three���things��to�GP:�rst�that�it�is�dealing�with�a��t_PADIC����t���yp�Ge�(the�fact�that��p��is�an�in�teger,��and�not���a��p�Golynomial,��whic���h�w�ould�b�Ge�used�to�en�ter�a�series,��see�Section�2.3.10),�secondly�the�\prime"��p����(note�z�that�it�is�not�c���hec�k�ed�z�whether��p��is�indeed�prime;��iy���ou�can�w�ork�on�10-adics�if�y�ou�w�an�t,��but���b�Gew���are�uAof�disasters�as�so�on�as�y���ou�do�something�non-trivial�lik�e�taking�a�square�ro�Got),�}=and�nally���the���n���um�b�Ger�of�signican�t��p�-adic�digits��k�P��.�Q�Note�that��O(25)��is�not�the�same�as��O(5^2)�;�y�ou�probably���w���an�t�UUthe�latter!��Ig��F��*�or�UUexample,�y���ou�can�t�yp�Ge�in�the�7-adic�n�um�b�Ger�����2*7^(-1)�?�+�3�+�4*7�+�2*7^2�+�O(7^3)����exactly�UUas�sho���wn,�or�equiv��q�alen�tly�as��905/7�?�+�O(7^3)�.���5��2.3.7�g�Quadratic�n��9um�b�Q�ers��ի(t���yp�Ge��t_QUAD�):�rst,��y�ou�m�ust�dene�the�default�quadratic�order�or���eld���in�whic���h�y�ou�w�an�t�to�w�ork.�&bThis�is�done�using�the��quadgen��function,�@in�the�follo�wing�w�a�y��*�.���W��*�rite�UUsomething�lik���e��Ig���w�?�=�quadgen(d)����where��&�d��is�the��discriminant����of�the�quadratic�order�in�whic���h�y�ou�w�an�t�to�w�ork�(hence��d��is�congruen�t���to���0�or�1�mo�Gdulo�4).�4�The�name��w��is�of�course�just�a�suggestion,��but�corresp�onds�to�traditional�usage.���Y��*�ou�
�can�use�an���y�v��q�ariable�name�that�y�ou�lik�e.�X�Ho�w�ev�er,��quadratic�n�um�b�Gers�are�alw�a�ys�prin�ted�with���a��.�w�,��$regardless�of�the�discriminan���t.�aSSo�b�Gew�are,��$t�w�o�n�um�b�Gers�can�b�e�prin���ted�in�the�same�w�a�y�and���not�UUb�Ge�equal.�q�Ho���w�ev�er�UUGP�will�refuse�to�add�or�m���ultiply�them�for�example.��Ig��No���w��w(1�;���w�D�)�will�b�Ge�the�\canonical"�in�tegral�basis�of�the�quadratic�order�(i.e.��w���=����zP�p���
���zP�fe4r�����d����Ml=�2�if����d�����0����mo�Gd���4,�5�and�.�w���=�(1��n+�����zP�p���
?ş�zP�fe4r�����d����t7�)�=�2�if��d�����1����mo�Gd���4,�5�where��d��is�the�discriminan���t),�and�to�en���ter��x��n�+��y�[�w����y���ou�UUjust�t�yp�Ge��x�?�+�y*w�.����2.3.8��P��9olmo�Q�ds�]7�(t���yp�Ge��t_POLMOD�):�exactly�as�for�in�tegermo�Gds,��/to�en�ter��x�����mo�Gd����y���(where��x��and��y����are��$p�Golynomials),��t���yp�e��Mod(x,y)�,��not��x%y��(see�Section�3.2.3).�U3Note�that�when��y����is�an�irreducible���p�Golynomial���in�one�v��q�ariable,�:�p�olmo�ds�whose�mo�dulus�is��y�5��are�simply�algebraic�n���um�b�ers���in�the���nite�a;extension�dened�b���y�the�p�Golynomial��y�[٫.��yThis�allo�ws�us�to�w�ork�easily�in�n�um�b�Ger�fields,�d4nite���extensions�UUof�the��p�-adic�eld��Q����p���R�,�or�finite�fields.���΍�Imp�Q�ortan��9t�remark.�7'�Since��tthe�v��q�ariables�o�Gccurring�in�a�p�olmo�d�are�not�free�v��q�ariables,�ȡit�is�essen���tial���in��order�to�a���v�oid��inconsistencies�that�p�Golmo�ds��use�the�same�v��q�ariable�in�in���ternal�op�Gerations�(i.e.�b�e-���t���w�een���p�Golmo�ds)�and�v��q�ariables�of�lo���w�er�priorit�y�(whic�h�ha�v�e�b�Geen�in�tro�Gduced�later�in�the�GP��}session)���for���external�op�Gerations�(t���ypically�b�et���w�een���a�p�olynomial�and�a�p�olmo�d).��F��*�or�example,�P�ARI���will���not���recognize�that��Mod(y,�?�y^2�+�1)����is�the�same�as��Mod(x,�?�x^2�+�1)�.�4�Hop�Gefully��*�,��3this���problem�will���pass�DWa���w�a�y�when�t�yp�Ge�\elemen�t�of�a�n�um�b�Ger�eld"�is�ev�en�tually�in�tro�Gduced.�l*�See�Section�2.6.2�for���a�UUdenition�of�\priorit���y"�and�a�discussion�of�(P��*�ARI's�idea�of��)�m�ultiv��q�ariate�p�Golynomial�arithmetic.��Ig��On��Ithe�other�hand,����Mod(x,�?�x^2�+�1)�+�Mod(x,�x^2�+�1)��I�(whic���h�giv�es��Mod(2*x,�?�x^2�+�1)�)���and�/%�x�?�+�Mod(y,�y^2�+�1)��(whic���h�giv�es�a�result�mathematically�equiv��q�alen�t�to��x�쁫+��i��with��i���^��2��C��=����1)���are��completely�correct,���while��y�?�+�Mod(x,�x^2�+�1)���giv���es��Mod(x�?�+�y,�x^2�+�1)�,�whic���h��ma�y�not���b�Ge�UUwhat�y���ou�w�an�t�(�y��is�treated�here�as�a�n�umerical�parameter,�not�as�a�p�Golynomial�v��q�ariable).��	�y�ff��ߟ����	��*��On��&the�other�hand,��one�can�argue�that�there�is�no�reason�to�consider�these�quan���tities�equal.���E.g.,�]�one�(�can�b�Ge�the�opp�osite�of�another.���Compare�with�n���umerous�discussions�on�whether�\the���algebraic�cMclosure�of��Q��is�canonically�dened",���or�one�needs�to�consider�a�group�Goid�of�algebraic���closures.�������26���wō����Kf�������Note�sj(added�in�v��9ersion�2.0.16)�0�As�long�as�the�main�v��q�ariables�are�the�same,�8it�is�allo���w�ed�0to�mix����t_POL��and����t_POLMOD�s.�D#The�result�will�b�Ge�the�exp�ected��t_POLMOD�.�F��*�or�instance��x�?�+�Mod(x,�x^2���+�?�1)���is�equal�to��Mod(2*x,�x^2�+�1)�.���This�w���asn't�the�case�prior�to�v�ersion�2.0.16:�Oit�returned�a���p�Golynomial�UUin��x��equiv��q�alen���t�to��x�8�+��i�,�UUwhic�h�w�as�in�fact�an�in�v��q�alid�ob��8ject�(y�ou�couldn't��lift��it).�����2.3.9�Y�P��9olynomials�ȃ�(t���yp�Ge��t_POL�):�t�yp�Ge�the�p�olynomial�in�a�natural�w���a�y��*�,��Nnot�ȃforgetting�to�put�a���\��"�<�b�Get���w�een�a�co�Gecien�t�and�a�formal�v��q�ariable�(this����do�Ges�not�app�ear�in�b�eautied�output).�i�An���y���v��q�ariable��6name�can�b�Ge�used�except�for�the�reserv���ed�names��I���(used�exclusiv�ely�for�the�square�ro�Got���of����1),���Pi��(3�:�14�����:�:�:��
UO�),��Euler��(Euler's�constan���t),�and�all�the�function�names:�^�predened�functions,���as�E�describ�Ged�in�Chapter�3�(use��\c��to�get�the�complete�list�of�them)�and�user-dened�functions,���whic���h��y�ou�ough�t�to�kno�w�ab�Gout�(use��\u��if�y�ou�are�sub��8ject�to�memory�lapses).�[5The�total�n�um�b�Ger�of���dieren���t�uOv��q�ariable�names�is�limited�to�16384�and�65536�on�32-bit�and�64-bit�mac�hines�resp�Gectiv�ely��*�,���whic���h�<*should�b�Ge�enough.�&GIf�y�ou�ev�er�need�h�undreds�of�v��q�ariables,�u�y�ou�should�probably�b�Ge�using���v���ectors�UUinstead.�q�See�Section�2.6.2�for�a�discussion�of�m�ultiv��q�ariate�p�Golynomial�rings.����2.3.10���P��9o�w�er�series�[�(t���yp�Ge��t_SER�):�t�yp�Ge�a�rational�function�or�p�olynomial�expression�and�add�to���it��n��O(��expr����^�k�P��)��6�ϫ,�uYwhere��n��expr���z�is�n�an�expression�whic���h�has�non-zero�v��q�aluation�(it�can�b�Ge�a�p�olynomial,���p�Go���w�er��Pseries,��or�a�rational�function;��the�most�common�case�b�eing�simply�a�v��q�ariable�name).��This���indicates�aPto�GP�athat�it�is�dealing�with�a�p�Go���w�er�aPseries,��Oand�the�desired�precision�is��k���times�the���v��q�aluation�<�of���expr����with�resp�Gect�to�the�main�v�ariable�of���expr����(to�c���hec�k�<�the�ordering�of�the�v�ariables,���or�UUto�mo�Gdify�it,�use�the�function��reorder�;�see�Section�3.11.2.22).����2.3.11�Rational�functions�o��(t���yp�Ges��t_RFRAC�o_�and��t_RFRACN�):�as�for�fractions,��<all�rational�func-���tions�8�are�automatically�reduced�to�lo���w�est�8�terms�under�GP��*�.�All�that�w���as�said�ab�Gout�fractions�in���Section�UU2.3.4�remains�v��q�alid�here.����2.3.12�΍Binary�quadratic�forms�of�p�Q�ositiv��9e�or�negativ�e�discriminan�t���(t���yp�Ge��t_QFR�6�and����t_QFI�):��Zthese�are�input�using�the�function��Qfb��(see�Chapter�3).�0�F��*�or�example��Qfb(1,2,3)��will�create���the��binary�form��x���^��2��E��+�Ʌ2�xy�%^�+�3�y��[ٟ�^��2���L�.�_8It��will�b�Ge�imaginary�(of�in���ternal�t�yp�Ge��t_QFI�)��since�2���^��2��E���Ʌ�4����3��=���8���is�UUnegativ���e.���w��In�J�the�case�of�forms�with�p�Gositiv���e�discriminan�t�(t�yp�Ge��t_QFR�),�y�ou�ma�y�add�an�optional�fourth���comp�Gonen���t� (related�to�the�regulator,�PRmore�precisely�to�Shanks�and�Lenstra's�\distance"),�whic���h���m���ust��5b�Ge�a�real�n�um�b�Ger.��fSee�also�the�function��qfbprimeform��whic�h�directly�creates�a�prime�form���of�UUgiv���en�discriminan�t�(see�Chapter�3).����2.3.13�)yRo��9w�and�column�v�ectors�}�(t���yp�Ges��t_VEC�|Ыand��t_COL�):�to�en�ter�a�ro�w�v�ector,��
t�yp�Ge�the���comp�Gonen���ts�)Lseparated�b�y�commas�\�,�",�2and�enclosed�b�Get�w�een�brac�k�ets�\�[����"�and�\��]�",�2e.g.��[1,2,3]�.���T��*�o���en���ter�a�column�v�ector,���t�yp�Ge�the�v�ector�horizon�tally��*�,���and�add�a�tilde�\��~��"�to�transp�Gose.�K��[�?�]��yields���the���empt���y�(ro�w)�v�ector.��The�function��Vec��can�b�Ge�used�to�transform�an�y�ob��8ject�in�to�a�v�ector�(see���Chapter�UU3).�������27����ύ����Kf�������2.3.14���Matrices�m��(t���yp�Ge��t_MAT�):�to�en�ter�a�matrix,���t�yp�Ge�the�comp�onen���ts�line�b�y�line,���the�comp�Gonen�ts���b�Geing���separated�b���y�commas�\�,�",���the�lines�b�y�semicolons�\�;�",���and�ev�erything�enclosed�in�brac�k�ets���\�[����"�:and�\��]�",�?�e.g.�h��[x,y;�?�z,t;�u,v]�.��[�;�]�C%�yields�:the�empt���y�(0x0)�matrix.�The�function��Mat��can���b�Ge�UUused�to�transform�an���y�ob��8ject�in�to�a�matrix�(see�Chapter�3).���ލ�Note��zthat�although�the�in���ternal�represen�tation�is�essen�tially�the�same�(only�the�t�yp�Ge�n�um�b�Ger���is��edieren���t),���a�ro�w�v�ector�of�column�v�ectors�is��not��=�a�matrix;�mfor�example,���m�ultiplication�will�not���w���ork�UUin�the�same�w�a�y��*�.����Note��also�that�it�is�p�Gossible�to�create�matrices�(b���y�con�v�ersion�of�empt�y�column�v�ectors�and���concatenation,��Oor�UQusing�the��matrix��function)�with�a�giv���en�p�Gositiv�e�n�um�b�Ger�of�columns,��Oeac�h�of���whic���h��has�zero�ro�ws.���It�is�not�p�Gossible�to�create�or�represen�t�matrices�with�zero�columns�and�a���nonzero�UUn���um�b�Ger�of�ro�ws.��?���2.3.15���Lists��(t���yp�Ge��t_LIST�):�lists�cannot�b�e�input�directly;��y���ou�ha�v�e�to�use�the�function��listcreate����rst,�0�then�'��listput��eac���h�time�y�ou�w�an�t�to�app�Gend�a�new�elemen�t�(but�y�ou�can�access�the�elemen�ts���directly���as�with�the�v���ector�t�yp�Ges�describ�ed�ab�o���v�e).�,�The���function��List��can�b�e�used�to�transform���(ro���w�UUor�column)�v�ectors�in�to�lists�(see�Chapter�3).����2.3.16�Strings�}��(t���yp�Ge��t_STR�):�to�en�ter�a�string,��&just�enclose�it�b�Get�w�een�double�quotes��"�,��&lik�e�this:����"this�?�is�a�string"�.��The�function��Str��can�b�Ge�used�to�transform�an���y�ob��8ject�in�to�a�string�(see���Chapter�UU3).����2.3.17�SfSmall�v��9ectors��Y�(t���yp�Ge��t_VECSMALL�):�this�is�an�in�ternal�t�yp�Ge,���used�to�co�de�in�an�ecien���t�w�a�y���v���ectors��con�taining�only�small�in�tegers�(suc�h�as�p�Germ�utations).���Most�GP�lfunctions�will�refuse�to���op�Gerate�UUon�these�ob��8jects.��"4��2.4��GP�op�`erators�.����Lo�Gosely��8sp�eaking,��an�op�erator�is�a�function�(usually�asso�ciated�to�basic�arithmetic�op�erations)���whose��name�con���tains�only�non-alphan�umeric�c�haracters.��%In�practice,�Qmost�of�these�are�simple���functions,��1whic���h��ltak�e�argumen�ts,��1and�return�a�v��q�alue;���assignmen�t�op�Gerators�also�ha�v�e�side�eects.���Eac���h�k�of�these�has�some�xed�and�unc�hangeable�priorit�y��*�,��ewhic�h�means�that,��ein�a�giv�en�expression,��ethe���op�Gerations��lwith�the�highest�priorit���y�will�b�e�p�erformed�rst.�Op�erations�at�the�same�priorit���y�lev�el���will�Y�alw���a�ys�b�Ge�p�erformed�in�the�order�they�w���ere�written,�[(i.e.�from�left�to�righ�t.��An�ything�enclosed���b�Get���w�een�E�paren�thesis�is�considered�a�complete�sub�Gexpression,�H�and�will�b�e�resolv���ed�indep�enden���tly�of���the�J�surrounding�con���text.�n3F��*�or�instance,�L�assuming�that���op���%���1�����,���op���'6���2�����,���op���'6���3���B�are�standard�binary�op�Gerators���with�UUincreasing�priorities�(think�of��+�,��*�,��^��for�instance),��4����"�x��UU�op���/͟qƮ1����y���.�op������qƮ2��]n�z�����op����d�qƮ2��r,�x��UU�op���/͟qƮ3���y����is�UUequiv��q�alen���t�to�������x��UU�op���/͟qƮ1����((�y���.�op������qƮ2��]n�z�p��)��UU�op���/͟qƮ2���(�x��UU�op���/͟qƮ3���y�[٫))�:��ٍ��GP�I�kno���ws�I�quite�a�lot�of�dieren�t�op�Gerators,�K�some�of�them�unary�(ha�ving�only�one�argumen�t),���some��binary��*�,�=plus�sp�Gecial�selection�op�erators.�@�Unary�op�erators�are�dened�for�either�prex�(pre-���ceding�6ktheir�single�argumen���t:��bR�op��s5�x�)�or�p�Gostx�(follo�wing�the�argumen�t:�bR�x���op���)�p�Gosition,�<�nev�er�b�Goth���(some��zare�syn���tactically�correct�in�b�Goth�p�ositions,�Ȧbut�with�dieren���t�meanings).�7)Binary�op�erators�all���use�!�the�syn���tax��x���op��F�y�[٫.�`�Most�of�them�are�w�ell�kno�wn,�,0some�are�b�Gorro�w�ed�from�C�syn�tax,�,0and�a�few���are��sp�Gecic�to�GP��*�.�Bew���are�that�some�GP��op�erators�ma���y�dier�sligh�tly�from�their�C��coun�terparts.�������28����������Kf�����卫F��*�or�|�instance,���GP's�p�Gostx��++��returns�the��new��J�v��q�alue,�lik���e�the�prex��++��of�C,�and�the�binary�shifts����<<�,�\��>>�[;�ha���v�e�a�priorit�y�whic�h�is�dieren�t�from�(higher�than)�that�of�their�C�[9coun�terparts.��xWhen�in���doubt,�.�just�%Usurround�ev���erything�b�y�paren�theses�(b�Gesides,�.�y�our�co�Gde�will�probably�b�e�more�legible).����Here�UUis�the�complete�list�(in�order�of�decreasing�priorit���y,�binary�unless�men�tioned�otherwise):�����UU�Priorit���y�10�����9�++��9�and��--��(unary��*�,���p�Gostx):�7��x�++��assigns�the�v��q�alue��x�zͫ+�1��9to��x�,�then�returns�the�new�v��q�alue�of����x�.�}This��<corresp�Gonds�to�the�C��.statemen���t��++�x��(there�is�no�prex��++��op�erator�in�GP).��x�--��do�es�the���same�UUwith��x�8���1.������UU�Priorit���y�9��������op��!yb�=�,��fwhere�����op��L�is���an���y�simple�binary�op�Gerator�(i.e.�a�binary�op�erator�with�no�side�eects,��fi.e.�one���of��]those�dened�b�Gelo���w)�whic�h�is�not�a�b�Go�olean��]op�erator�(comparison�or�logical).�.��x��?��op��u�=�?��y��6�assigns���(�x���2�op��*ܱy�[٫)��2to��x�,���and�returns�the�new�v��q�alue�of��x�,��not��
�a�reference�to�the�v��q�ariable��x�.�8(Th���us�an�assignmen�t���cannot�UUo�Gccur�on�the�left�hand�side�of�another�assignmen���t.)�����UU�Priorit���y�8�����8�=��8�is�the�assignmen���t�op�Gerator.��oThe�result�of��x�?�=��y��is��8the�v��q�alue�of�the�expression��y�[٫,�԰whic�h�is���also���assigned�to�the�v��q�ariable��x�.�)This�is��not�ڙ�the�equalit���y�test�op�Gerator.�Bew���are�that�a�statemen�t���lik���e��`�x�?�=�1��is�alw���a�ys�true�(i.e.�non-zero),�cand�sets��x��to�1.�9�The�righ�t�hand�side�of�the�assignmen�t���op�Gerator��is�ev��q�aluated�b�efore�the�left�hand�side.�r�If�the�left�hand�side�cannot�b�e�mo�died,��praise�an���error.�����UU�Priorit���y�7�������[�?�]����is�the�selection�op�Gerator.�wb�x�[�i�]��returns�the��i�-th�comp�onen���t�of�v�ector��x�;��#�x�[�i�;�j�],��V�x�[�;�j�]�and����x�[�i�,]���resp�Gectiv���ely���return�the�en�try�of�co�Gordinates�(�i;���j����),��the��j��-th�column,��and�the��i�-th�ro���w�of���matrix��x�.�W�If�the�assignmen���t�op�Gerator�(�=�)�immediately�follo�ws�a�sequence�of�selections,�nit�assigns�its���righ���t�b�hand�side�to�the�selected�comp�Gonen�t.���E.g��x[1][1]�?�=�0�b��is�v��q�alid;�i^but�b�Gew�are�that��(x[1])[1]���=�?�0���is�not�(b�Gecause�the�paren���theses�force�the�complete�ev��q�aluation�of��x[1]�,�-�and�the�result�is�not���mo�Gdiable).�����UU�Priorit���y�6����UU�'�UU�(unary��*�,�prex):�q�quote�its�argumen���t�(a�v��q�ariable�name)�without�ev�aluating�it.��F����?�?�a�=�x�+�1;�x�=�1;��Q���?�?�subst(a,x,1)�����***���variable�?�name�expected:�subst(a,x,1)�������^---����?�?�subst(a,'x,1)����%1�?�=�2����^�:�q�p�Go���w�ering.�����'���(unary��*�,��Up�Gostx):�(�deriv��q�ativ���e�with�resp�ect�to�the�main�v��q�ariable.�AIf��f�֣�is�a�(GP���or�user)�function,����f�����^��0���ȫ(�x�)�vis�allo���w�ed.��)If�v�x��is�a�scalar,�N=the�op�Gerator�p�erforms�n���umerical�deriv��q�ation,�N=dened�as�(�f���(�x����+����"�)��>���f���(�x����"�))�=�2�"�!��for�a�suitably�small�epsilon�dep�Gending�on�curren���t�precision.�`�It�b�eha���v�es�!�as�(�f���(�x�))���^��0�����otherwise.������&f�~���R�(unary��*�,�UUp�Gostx):�q�v���ector/matrix�transp�ose.�����!�qǫ(unary��*�,�UUp�Gostx):�factorial.��x��!���5=���x�(�x�8���1)������������1.�����.��memb��}'er��&EC�(unary��*�,�UUp�Gostx):�qDZx�.��memb��}'er���extracts���memb��}'er��)���from�structure��x��(see�Section�2.6.5).�������29����������Kf�����卷�UU�Priorit���y�5������!�P^�(unary��*�,�%prex):�?�logical����not���$�.��!�x���return�1�if��x��is�equal�to�0�(sp�Gecically�,�%if��gcmp0(�x�)==1�),�and���0�UUotherwise.���܍��#�UU�(unary��*�,�prex):�q�cardinalit���y;��#�x��returns��length(�x�)�.�����UU�Priorit���y�4����UU�+�,�UU�-��(unary��*�,�prex):�q��-��toggles�the�sign�of�its�argumen���t,��+��has�no�eect�whatso�Gev�er.�����UU�Priorit���y�3����UU�*�:�q�m���ultiplication.�����/�:�q�exact�UUdivision�(�3/2�=3�=�2,�not�1�:�5).�����\�,�E��%�:��Euclidean��quotien���t�and�remainder,�i.e.�if��x���=��q�[�y���+��!�r�G�,�with��0����r�N�<�y�q��(if��x��and��y��are���p�Golynomials,�E�assume��instead�that��deg����r�N�<��ݫdeg����y�q��and�that�the�leading�terms�of��r�\�and��x��ha���v�e��the���same�UUsign),�then���x�n�y���h�=���q�[٫,���x�%�y���=��r�G�.�����\/�:��^rounded��Euclidean�quotien���t�for�in�tegers�(rounded�to�w�ards�+�1��when�the�exact�quotien�t���w���ould�UUb�Ge�a�half-in�teger).�����<<�,�Cg�>>�:�f�left�>�and�righ���t�binary�shift:��x<<n��=��x�
���2���^��n���i�if�>�n��>��0,�Cgand��x��n�=��
�2���^���n���j�otherwise.�jORigh���t�shift���is�UUdened�b���y��x>>n��=��x<<(-n)�.�����UU�Priorit���y�2����UU�+�,�UU�-�:�q�addition/subtraction.�����UU�Priorit���y�1����d:�<�,����>�,��<=�,��>=�:���the�d:usual�comparison�op�Gerators,���returning�1�for��true��and�0�for��false�.��vF��*�or���instance,�UU�x<=1��returns�1�if��x�����1�UUand�0�otherwise.�����<>�,�UU�!=�:�q�test�for�(exact)�inequalit���y��*�.�����==�:�q�test�UUfor�(exact)�equalit���y��*�.�����UU�Priorit���y�0����UU�&�,�UU�&&�:�q�logical���and��6�.�����|�,�ZV�||�:�y�logical�YV(inclusiv���e)���or��
�ȫ.�}�An�y�sequence�of�logical���or���and���and���]�op�Gerations�is�ev��q�aluated�from���left��vto�righ���t,�oand�ab�Gorted�as�so�on�as�the�nal�truth�v��q�alue�is�kno���wn.�N�Th�us,�ofor��vinstance,��(x�?�&&�1/x)����or�8��(type(p)�?�==�"t���E�ff&f��ǫINT"�&&�isprime(p))��will�nev���er�pro�Gduce�an�error�since�the�second�argumen�t���need�UUnot�(and�will�not)�b�Ge�pro�cessed�when�the�rst�is�already�zero�(false).�������30����c�����Kf�������Remark:�qǫF��*�or�UUoptimal�eciency�,�y���ou�should�use�the��++�,��--��and���op��/��=��op�Gerators�whenev�er�p�Gossible:������?�?�a�=�200000;����?�?�i�=�0;�while(i<a,�i=i+1)����time�?�=�4,919�ms.����?�?�i�=�0;�while(i<a,�i+=1)����time�?�=�4,478�ms.����?�?�i�=�0;�while(i<a,�i++)����time�?�=�3,639�ms.����F��*�or�UUthe�same�reason,�the�shift�op�Gerators�should�b�e�preferred�to�m���ultiplication:�����?�?�a�=�1<<20000;����?�?�i�=�1;�while(i<a,�i=i*2);����time�?�=�5,255�ms.����?�?�i�=�1;�while(i<a,�i<<=1);����time�?�=�988�ms.�����2.5��The�general�GP�input�line�.������2.5.1�~7Generalities�.�X�User�	�in���teraction�with�a�GP�	�session�pro�Gceeds�as�follo�ws:�K�a�sequence�of�c�harac-���ters���is�t���yp�Ged�b�y�the�user�at�the�GP�Ɲprompt.�BAThis�can�b�Ge�either�a��\�?��command,��Ea�function�denition,���an�r expression,�ySor�a�sequence�of�expressions�(i.e.�a�program).��)In�the�latter�t���w�o�r cases,�after�the�last���expression�yhas�b�Geen�computed�its�result�is�put�in���to�an�in�ternal�(\history")�arra�y��*�,�*?and�prin�ted.�_�The���successiv���e�̇elemen�ts�of�this�arra�y�are�called��%1�,����%2�,���:���:�:��=3�As�a�shortcut,�the�latest�computed�expression���can�UUalso�b�Ge�called��%�,�the�previous�one��%`�,�the�one�b�efore�that��%``��and�so�on.����If�݆y���ou�w�an�t�to�suppress�the�prin�ting�of�the�result,��|for�example�b�Gecause�it�is�a�long�unimp�ortan���t���in���termediate�<Iresult,�vend�the�expression�with�a��;��ësign.�&�This�same�sign�is�used�as�an�instruction���separator�}"when�sev���eral�instructions�are�written�on�the�same�line�(note�that�for�the�pleasure�of���BASIC�Y�addicts,�Z�the�Y��:�zūsign�can�also�b�Ge�used,�but�w���e�will�try�to�stic�k�to�C-st�yle�con�v�en�tions�in�this���man���ual).���The�Ÿnal�expression�computed,���ev�en�if�not�prin�ted,���will�still�b�Ge�assigned�to�the�history���arra���y��*�,�Gso�C�y�ou�ma�y�ha�v�e�to�pa�y�close�atten�tion�when�y�ou�in�tend�to�refer�bac�k�to�it�b�y�n�um�b�Ger�since���this��7n���um�b�Ger�do�es�not�app�ear�explicitly��*�.�lOf�course,��/if�y���ou�just�w�an�t�to�use�it�on�the�next�line,��/use����%�UU�as�usual.����An���y���legal�expression�can�b�Ge�t�yp�Ged�in,���and�is�ev��q�aluated�using�the�con�v�en�tions�ab�Gout�op�erator���priorities��3and�left�to�righ���t�asso�Gciativit�y�(see�the�previous�section),���using�the�a�v��q�ailable�op�Gerator���sym���b�Gols,�Бfunction��`names�(including�user-dened�functions�and�mem�b�Ger�functions�see�Section�2.6.4),���and��sp�Gecial�v��q�ariables.���Please�note�that,�#sfrom�v���ersion�1�:�900�on,�there��is��(�a�distinction�b�Get���w�een���lo���w�ercase��/and�upp�Gercase.�1�Also,���note�that,�outside�of�constan���t�strings,�blanks�are�completely�ignored���in�UUthe�input�to�GP��*�.����The��sp�Gecial�v��q�ariable�names�kno���wn�to�GP���are��Euler��(Euler's�constan�t��
�]ث=�Ϡ0�:�577�����:�:�:��
UO�),���I���(the���square�
Yro�Got�of���1),�X�Pi��(3.14��:���:�:��
UO�)�|�whic���h�could�b�e�though���t�of�as�functions�with�no�argumen�ts,�Xand���whic���h�UUma�y�therefore�b�Ge�in�v�ok�ed�without�paren�theses�|,�and��O��whic�h�ob�Geys�the�follo�wing�syn�tax:�����O(��expr�����^k)����When���$�expr��"ޫis��$an�in���teger�or�a�rational�n�um�b�Ger,�٘this�creates�an���expr��c��-adic�n�um�b�Ger�(zero�in�fact)�of���precision�Q|�k�.�pWhen���expr��G��is�a�p�Golynomial,�RAa�p�o���w�er�Q|series�or�a�rational�function�whose�main�v��q�ariable���is��{�X���,���sa���y��*�,�this�creates�a�p�Go���w�er�series�(also�zero)�of�precision��v��(��VO�k��where��v��T�is�the��X���-adic�v��q�aluation���of��UU�expr��[email protected]�(see�UU2.3.6�and�2.3.9).�������31��� �`�����Kf�������2.5.2���Sp�Q�ecial�editing�c��9haracters�.���A�_DGP�program�_Gcan�of�course�ha���v�e�_Gmore�than�one�line.�Since���GP��executes��y���our�commands�as�so�Gon�as�y�ou�ha�v�e�nished�t�yping�them,��there�m�ust�b�Ge�a�w�a�y�to�tell���it��wto�w���ait�for�the�next�line�or�lines�of�input�b�Gefore�doing�an�ything.�-There�are�three�w�a�ys�of�doing���this.�����The��rst�one�is�simply�to�use�the�bac���kslash�c�haracter��\��at�the�end�of�the�line�that�y�ou�are���t���yping,��just���b�Gefore�hitting��<Return>�.�SKThis�tells�GP���that�what�y�ou�will�write�on�the�next�line�is���the�u�ph���ysical�con�tin�uation�of�what�y�ou�ha�v�e�just�written.��VIn�other�w�ords,�}�it�mak�es�GP�u�forget�y�our���newline�mc���haracter.��F��*�or�example�if�y�ou�use�this�while�dening�a�function,�N3and�if�y�ou�ask�for�the���denition���of�the�function�using��?name�,���y���ou�will�see�that�y�our�bac�kslash�has�disapp�Geared�and�that���ev���erything�`$is�on�the�same�line.��4Y��*�ou�can�t�yp�Ge�a��\��an�ywhere.��4It�will�b�Ge�in�terpreted�as�ab�Go�v�e�only�if���(apart��Lfrom�ignored�whitespace�c���haracters)�it�is�immediately�follo�w�ed�b�y�a�newline.���F��*�or�example,���y���ou�UUcan�t�yp�Ge��wt���?�?�3�+�\��
]ݍ�4����instead�UUof�t���yping��3�?�+�4�.����The�5�second�one�is�a�sligh���t�v��q�ariation�on�the�rst,�n%and�is�mostly�useful�when�dening�a�user���function��(see�Section�2.6.4):�:since�an�equal�sign�can�nev���er�end�a�v��q�alid�expression,��EGP���will�disregard���a�UUnewline�immediately�follo���wing�an��=�.��wt���?�?�a�=��
]ݍ�123����%1�?�=�123�����The�ݡthird�one�cannot�b�Ge�used�ev���erywhere,���but�is�in�general�m�uc�h�more�useful.�
�It�is�the�use���of��sbraces��{��and��}�.�#!When�GP��dsees�an�op�Gening�brace�(�{�)��at��Jthe�b��}'e�ginning��Jof�a�line�PΫ(mo�dulo��sspaces���as��<usual),���it�understands�that�y���ou�are�t�yping�a�m�ulti-line�command,���and�newlines�will�b�Ge�ignored���un���til���y�ou�t�yp�Ge�a�closing�brace��}�.�Ho�w�ev�er,���there�is�an�imp�Gortan�t�(but�easily�ob�Gey�ed)�restriction:���inside�an�op�Gen�brace-close�brace�pair,�B�all�y���our�input�lines�will�b�e�concatenated,�B�suppressing�an���y���newlines.�lTh���us,���all���newlines�should�o�Gccur�after�a�semicolon�(�;�),�a�comma�(�,�)�or�an�op�Gerator�(for���clarit���y's�8!sak�e,�=�w�e�don't�recommend�splitting�an�iden�tier�o�v�er�t�w�o�lines�in�this�w�a�y).�hF��*�or�instance,���the�UUfollo���wing�program��wt���{��
]ݍ��a�?�=�b�����b�?�=�c����}����w���ould�0silen�tly�pro�Gduce�garbage,��since�what�GP�will�really�see�is��a=bb=c��whic�h�will�assign�the�v��q�alue���of�UU�c��to�b�Goth��bb��and��a��(if�this�really�is�what�y���ou�in�tended,�y�ou're�a�hop�Geless�case).�������32���!�`�����Kf�������2.6��The�GP/P���ARI�programming�language�.���#��The��GP��calculator�uses�a�purely�in���terpreted�language.�	G�The�structure�of�this�language�is���reminiscen���t�\Qof�LISP�\
with�a�functional�notation,���f(x,y)��rather�than��(f�?�x�y)�:��all�\Qprogramming���constructs,�O�suc���h�Ntas��if�,��while,��etc...�o|are�functions�*�(see�Section�3.11�for�a�complete�list),�and�the���main�88lo�Gop�do�es�not�really�execute,�>
but�rather�ev��q�aluates�(sequences�of��)�expressions.�hOf�course,�it�is���b���y�UUno�means�a�true�LISP��*�.��峍�2.6.1��TV��
�ariables�and�sym��9b�Q�olic�expressions�.��rڍ�In��LGP���y���ou�can�use�up�to�16383�v��q�ariable�names�(up�to�65535�on�64-bit�mac�hines).�:�These���names�|can�b�Ge�an���y�standard�iden�tier�names,�@�i.e.�they�m�ust�start�with�a�letter�and�con�tain�only���v��q�alid��k���eyw�ord�c�haracters:��K��ff&f��
c�or�alphan�umeric�c�haracters�([���E�ff&f��ǫ�A-Za-z0-9�]).�F�T��*�o�a�v�oid�confusion�with���other�K�sym���b�Gols,�M�y�ou�m�ust�not�use�other�non-alphan�umeric�sym�b�Gols�lik�e��$�,�M�or�'�.�'.�n�In�addition�to�the���function�y5names�whic���h�y�ou�m�ust�not�use�(see�the�list�with��\c�),��<there�are�exactly�three�sp�Gecial�v��q�ariable���names���whic���h�y�ou�are�not�allo�w�ed�to�use:�F��Pi��and��Euler�,��whic�h�represen�t�w�ell�kno�wn�constan�ts,��and����I���=�����$��p���o��$��fe�����1�����.����Note���that�GP���names�are�case�sensitiv���e�since�v�ersion�1.900.�M�This�means�for�instance�that�the���sym���b�Gol�2$�i��is�p�erfectly�safe�to�use,�9.and�will�not�b�e�mistak���en�for�����$��p����{��$��fe�����1����N�,�9.and�that��o��is�not�synon�ymous���an���ymore�D#to��O�.�If�y�ou�grew�addicted�to�the�previous�b�Geha�viour,�G�y�ou�can�ha�v�e�it�bac�k�b�y�setting�the���default�UU�compatible��to�3.����No���w�5}the�main�thing�to�understand�is�that�P��*�ARI/GP�5uis��not�(U�a�sym�b�Golic�manipulation�pac�k��q�age,���although��4it�shares�some�of�the�functionalities.�<dOne�of�the�main�consequences�of�this�fact�is�that���all���expressions�are�ev��q�aluated�as�so�Gon�as�they�are�written,�߳they�nev���er�sta�y�in�a�purely�abstract���form**.�_As���an�imp�Gortan���t�example,�"�consider�what�happ�ens�when�y���ou�use�a�v��q�ariable�name��b��}'efor�e����assigning��a�v��q�alue�in���to�it.�jThis�is�p�Gerfectly�acceptable�to�GP��*�,�whic�h�considers�this�v��q�ariable�in�fact���as�
�a�p�Golynomial�of�degree�1,�;�with�co�ecien���ts�1�in�degree�1,�;�0�in�degree�0,�whose�v��q�ariable�is�the���v��q�ariable�UUname�y���ou�used.����If�T�later�y���ou�assign�a�v��q�alue�to�that�v�ariable,���the�ob��8jects�whic���h�y�ou�ha�v�e�created�b�Gefore�will���still��b�Ge�considered�as�p�olynomials.�I�If�y���ou�w�an�t�to�obtain�their�v��q�alue,�use�the�function��eval��(see���Section�UU3.7.3).����Finally��*�,��note���that�if�the�v��q�ariable��x��con���tains�a�v�ector�or�list,��y�ou�can�assign�a�result�to��x�[�m�]���(i.e.�L�write�something�lik���e��x�[�k�P��]��=���expr��k��).�n�If�Lʱx��is�a�matrix,�Ny�ou�can�assign�a�result�to��x�[�m;���n�],�Nbut��not����to��[�x�[�m�].���If�y���ou�w�an�t�to�assign�an�expression�to�the��m�-th�column�of�a�matrix��x�,���use��x�[�;���m�]�"=���expr�����instead.��USimilarly��*�,�oeuse�j/�x�[�m;����]���=���expr�����to�assign�an�expression�to�the��m�-th�ro���w�of��x�.��UThis�pro�Gcess�is���recursiv���e,��so���if��x��is�a�matrix�of�matrices�of���:���:�:��7�,�an�expression�suc���h�as��x�[1�;����1][�;��3][4]��,=�1���w�ould�b�Ge���p�Gerfectly�UUv��q�alid�(assuming�of�course�that�all�matrices�along�the�w���a�y�UUha�v�e�the�correct�dimensions).���k��Note:���W��*�e'll���see�in�Section�2.6.4�that�it�is�p�Gossible�to�restrict�the�use�of�a�giv���en�v��q�ariable�b�y�declaring���it�>�to�b�Ge��global��or��local�.�jSThis�can�b�e�useful�to�enforce�clean�programming�st���yle,�Cqbut�is�in�no�w�a�y���mandatory��*�.����ff��ߟ����	��*��Not�m9exactly��*�,�s2since�not�all�their�argumen���ts�need�b�Ge�ev��q�aluated.��tF�or�instance�it�w���ould�b�Ge�stupid���to���ev��q�aluate�b�Goth�branc���hes�of�an��if��statemen�t:�Cksince�only�one�will�apply��*�,�(GP���only�expands�this�one.�������**��An��Xob���vious�but�imp�Gortan�t�exception�are�c�haracter�strings�whic�h�are�ev��q�aluated�essen�tially�to���themselv���es�m�(t�yp�Ge��t_STR�).�Not�exactly�so�though,�s�since�w�e�do�some�w�ork�to�treat�the�quoted�c�har-���acters�UUcorrectly�(those�preceded�b���y�a��\)�.�������33���"ݬ�����Kf�������(T��
�ec��9hnical)�f�Note:�A��Eac���h��=v��q�ariable�has�a�stac�k�of�v��q�alues,�uimplemen�ted�as�a�link�ed�list.�Q�When�a�new���scop�Ge�9Nis�en���tered�(during�a�function�call�whic�h�uses�it�as�a�parameter,�>�or�if�the�v��q�ariable�is�used�as�a���lo�Gop�Bvindex,�F=see�Section�2.6.4�and�Section�3.11),�the�v��q�alue�of�the�actual�parameter�is�pushed�on�the���stac���k.���If��Qthe�parameter�is�not�supplied,�ؐa�sp�Gecial�0�v��q�alue�called��gnil��is�pushed�on�the�stac�k�(this���v��q�alue��is�not�prin���ted�if�it�is�returned�as�the�result�of�a�GP�aexpression�sequence).��{Up�Gon�exit,�<�the���stac���k���decreases.�R�Y��*�ou�can��kill��a�v��q�ariable,��decreasing�the�stac�k�y�ourself.�R�Ho�w�ev�er,��the�stac�k�has���a��Zb�Gottom:�-�the�v��q�alue�of�a�v�ariable�is�the�monomial�of�degree�1�in�this�v�ariable,���as�is�natural�for�a���mathematician.��݃��2.6.2���V��
�ariable�priorities�.�o�P��*�ARI��"has��Nno�in���telligen�t��N\sparse"�represen���tation�of�p�Golynomials.�So���a�-gm���ultiv��q�ariate�p�Golynomial�in�P��*�ARI�-/is�just�a�p�olynomial�(in�one�v��q�ariable),�ckwhose�co�ecien���ts�are���themselv���es�g	p�Golynomials,�kwarbitrary�but�for�the�fact�that�they�do�not�in�v�olv�e�the�main�v��q�ariable.���All���computations�UUare�then�just�done�formally�on�the�co�Gecien���ts�as�if�the�p�olynomial�w���as�univ��q�ariate.��n���This��is�not�symmetrical.���So�if�I���en���ter��x�?�+�y���in�a�clean�session,��what�happ�Gens�?�This�is���understo�Go�d�UUas��n����FƱx������1���S�+�8�y������x������0��C��2���(�Z�[�y�[٫])[�x�]��n��but���ho���w�can�GP�Ӻdecide�that��x��is�\more�imp�Gortan�t"�than��y�/��?��WWh�y�not��y��[ٟ�^��1��e��+��8�x����y��[ٟ�^��0���L�,��{whic�h���is�the���same�UUmathematical�en���tit�y�UUafter�all�?����The��.answ���er�is�that�v��q�ariables�are�ordered�implicitly�b�y�the�GP���in�terpreter:��when�a�new�iden�tier���(e.g���x�,��or��y�)ȫas�ab�Go���v�e)���is�input,�the�corresp�Gonding�v��q�ariable�is�registered�as�ha���ving�a�strictly�lo�w�er���priorit���y��than�an�y�v��q�ariable�in�use�at�this�p�Goin�t*�.�O�T��*�o�see�the�ordering�used�b�y�GP��at�an�y�giv�en�time,���t���yp�Ge��UU�reorder��(@�().����Giv���en��suc�h�an�ordering,��Dm�ultiv��q�ariate�p�Golynomials�are�stored�so�that�the�v�ariable�with�the���highest��?priorit���y�is�the�main�v��q�ariable.���And�so�on,��:recursiv�ely��*�,�un�til��?all�v��q�ariables�are�exhausted.���A���dieren���t� {storage�pattern�(whic�h�could�only�b�Ge�obtained�via�library�mo�de)�w���ould�pro�duce�an�illegal���ob��8ject,�UUand�ev���en�tually�UUa�disaster.����In���an���y�case,���if�y�ou�are�w�orking�with�expressions�in�v�olving�sev�eral�v��q�ariables�and�w�an�t�to�ha�v�e���them��ordered�in�a�sp�Gecic�manner�in�the�in���ternal�represen�tation�just�describ�Ged,�3the�simplest�is�just���to��write�do���wn�the�v��q�ariables�one�after�the�other�under�GP���b�Gefore�starting�an�y�real�computations.���Y��*�ou��could�also�dene�v��q�ariables�from�y���our�GPR�C��to�ha�v�e�a�consistan�t�ordering�of�common�v��q�ariable���names�UUin�all�y���our�GP�sessions,�e.g�read�in�a�le��variables.gp��con�taining��>W���x;y;z;t;a;b;c;d�����If���y���ou�already�ha�v�e�started�w�orking�and�w�an�t�to�c�hange�the�names�of�the�v��q�ariables�in�an�ob��8ject,���use��the�function��changevar�.�S\If�y���ou�only�w�an�t�to�ha�v�e�them�ordered�when�the�result�is�prin�ted,�Uy�ou���can��8also�use�the�function��reorder�,���but�this�w���on't�c�hange�an�ything�to�the�in�ternal�represen�tation,���and�UUis�not�recommended.��B)]�ff��ߟ����	��*��This�=�is�not�strictly�true:���if�an�iden���tier�is�in�terpreted�as�a�user�function,�u�no�v��q�ariable�is�registered.���Also,�UUthe�v��q�ariable��x��is�predened�and�alw���a�ys�UUhas�the�highest�p�Gossible�priorit���y��*�.�������34���#�̍����Kf�������Imp�Q�ortan��9t� note:���P��*�ARI�~�allo���ws�~�Euclidean�division�of�m�ultiv��q�ariate�p�Golynomials,��Ibut�assumes�that���the���computation�tak���es�place�in�the�fraction�eld�of�the�co�Gecien�t�ring�(if�it�is�not�an�in�tegral���domain,��the��result�will�a�priori�not�mak���e�sense).��This�can�b�Ge�v�ery�tric�ky;�,ffor�instance�assume��x����has�UUhighest�priorit���y�(whic�h�is�alw�a�ys�the�case),�then��y�[٫:���]���?�?�x�%�y��*��%1�?�=�0����?�?�y�%�x����%2�?�=�y�D?�\\����these�two�take�plac��}'e�in��Q�(�y�[٫)[�x�]�����?�?�x�*�Mod(1,y)����%3�?�=�Mod(1,�y)*x���\\����in��(�Q�(�y�[٫)�=y��Q�(�y��))[�x�]�Z����Q�[�x�]�����?�?�Mod(x,y)����%4�?�=�0��~F��In��Wthe�last�exemple,��the�division�b���y��y�0�tak�es�place�in��Q�(�y�[٫)[�x�],��hence�the��Mod��ob��8ject�is�a�coset���in�_(�Q�(�y�[٫)[�x�])�=�(�y��Q�(�y��)[�x�]),�1bwhic���h�is�the�n�ull�ring�since��y�a8�is�in�v�ertible!���So�b�Ge�v�ery�w�ary�of�v��q�ariable���ordering���when�y���our�computations�in�v�olv�e�implicit�divisions�and�man�y�v��q�ariables.�n�This�also�aects���functions�UUlik���e��numerator�/�denominator��or��content�:�����?�?�denominator(x�/�y)��*��%1�?�=�1����?�?�denominator(y�/�x)����%2�?�=�x����?�?�content(x�/�y)����%3�?�=�1/y����?�?�content(y�/�x)����%4�?�=�1����?�?�content(2�/�x)����%5�?�=�2��~F��Can���y���ou�see�wh�y�?�5�Hin�t:��v�x=y��ث=�3�(1�=y�[٫)�dp���x����is�in��Q�(�y��)[�x�]�and�denominator�is�tak���en�with�resp�Gect�to����Q�(�y�[٫)(�x�);��y�=x���=�(�y��b��\��x���^��0��|s�)�=x��)�is�in��Q�(�y�[٫)(�x�)�so��y�C�is�in���v�ertible��)in�the�co�Gecien���t�ring.�MOn�the�other�hand,���2�=x�UU�in���v�olv�es�a�single�v��q�ariable�and�the�co�Gecien�t�ring�is�simply��Z�.����These���problems�arise�b�Gecause�the�v��q�ariable�ordering�denes�an��implicit�䢫v�ariable�with�resp�Gect���to��:whic���h�division�tak�es�place.�=wThis�is�the�price�to�pa�y�to�allo�w��%��and��/��op�Gerators�on�p�olynomials���instead��of�requiring�a�more�cum���b�Gersome��divrem(�x�,�?��y�[��,���var��A�)���(whic�h�also�exists).��Unfortunately��*�,���in�D:some�functions�lik���e��content��and��denominator�,�G�there�is�no�w�a�y�to�set�explicitly�a�main�v��q�ariable���lik���e�yQin��divrem��and�remo�v�e�the�dep�Gendance�on�implicit�orderings.�ݻThis�will�hop�efully�b�e�corrected���in�UUfuture�v���ersions.������2.6.3��TExpressions�and�expression�sequences�.����An��expression�is�formed�b���y�com�bining�the�GP���op�Gerators,���functions�(including�user-dened���functions,�_'see�]0b�Gelo���w)�and�con�trol�statemen�ts.��YIt�ma�y�b�Ge�preceded�b�y�an�assignmen�t�statemen�t�'='���in���to�UUa�v��q�ariable.�q�It�alw�a�ys�has�a�v��q�alue,�whic�h�can�b�Ge�an�y�P��*�ARI�ob��8ject.����Sev���eral�]�expressions�can�b�Ge�com�bined�on�a�single�line�b�y�separating�them�with�semicolons�(';')���and�Ĺalso�with�colons�(':')�P�for�those�who�are�used�to�BASIC.�Suc���h�an�expression�sequence�will�b�Ge���called��7simply�a���se��}'q���ɫ.�QlA����se��}'q���׫also�has�a�v��q�alue,�/whic���h�is�the�v�alue�of�the�last�non-empt���y�expression���in��the�sequence.���Under�GP��*�,�the�v��q�alue�of�the���se��}'q���=�,�J�and�only�this�last�v�alue,�J�is�alw���a�ys��put�on�the���stac���k���(i.e.�6�it�will�b�Gecome�the�next�ob��8ject�%�n�).�The�v��q�alues�of�the�other�expressions�in�the���se��}'q���|�are�������35���$�X�����Kf�����卫discarded�*�after�the�execution�of�the���se��}'q���p�is�complete,�`Uexcept�of�course�if�they�w���ere�assigned�in�to���v��q�ariables.�D�In���addition,��the�v�alue�of�the���se��}'q�����(or�of�course�of�an�expression�if�there�is�only�one)�is���prin���ted�UUif�the�line�do�Ges�not�end�with�a�semicolon�(';').��2��2.6.4��TUser�dened�functions�.����It�x�is�v���ery�easy�to�dene�a�new�function�under�GP��*�,�whic�h�can�then�b�Ge�used�lik�e�an�y�other���function.�q�The�UUsyn���tax�is�as�follo�ws:�����name(��list���of�formal�variables��b��)�?�=�local(��list���of�lo��}'c�al���variables��Y�0�);��UU�se��}'q�����whic���h�UUlo�Goks�b�etter�written�on�consecutiv���e�lines:��!_���name(�x����0��|s�,�?��x����1���,���:���:�:���L�)�=��
X��{�����local(�t����0��|s�,�?��t����1���,���:���:�:���L�);�����local(��:���:�:��
UO�);��������:���:�:������}����(note��nthat�the�rst�newline�is�disregarded�due�to�the�preceding��=��sign,���and�the�others�b�Gecause�of���the���enclosing�braces).�'Both�lists�of�v��q�ariables�are�comma-separated�and�allo���w�ed���to�b�Ge�empt���y��*�.�The����local�UU�statemen���ts�can�b�Ge�omitted;�as�usual���se��}'q��T<�is�an�y�expression�sequence.�����name�{b�is�the�name�giv���en�to�the�function�and�is�sub��8ject�to�the�same�restrictions�as�v��q�ariable�names.���In��+addition,���v��q�ariable�names�are�not�v�alid�function�names,���y���ou�ha�v�e�to��kill��the�v��q�ariable�rst�(the���con���v�erse�Tis�true:�T�function�names�can't�b�Ge�used�as�v��q�ariables,�&�see�Section�3.11.2.14).�^rPreviously�used���function��names�can�b�Ge�recycled:��ky���ou�are�just�redening�the�function.�v�The�previous�denition�is���lost�UUof�course.�����list�?�of�formal�variables���is�the�list�of�v��q�ariables�corresp�Gonding�to�those�whic���h�y�ou�will���actually���use�when�calling�y���our�function.��The�n�um�b�Ger�of�actual�parameters�supplied�when�calling���the�UUfunction�has�to�b�Ge�less�than�the�n���um�b�er�UUof�formal�v��q�ariables.����Uninitialized��lformal�v��q�ariables�will�b�Ge�giv���en�a�default�v�alue.�#
An�equal�(�=�)�sign�follo���wing�a���v��q�ariable���name�in�the�function�denition,�"�follo���w�ed���b�y�an�y�expression,�"�giv�es�the�v��q�ariable�a�default���v��q�alue.�OThe��(said�expression�gets�ev�aluated�the�momen���t�the�function�is�called,��hence�ma�y�in�v�olv�e�the���function�UUparameters.�q�A�v��q�ariable�for�whic���h�y�ou�supply�no�default�v��q�alue�will�b�Ge�initialized�to�zero.�����list�?�of�local�variables�с�is�the�list�of�the�additional�lo�Gcal�v��q�ariables�whic���h�are�used�in�the���function�k�b�Go�dy��*�.���Note�that�if�y���ou�omit�some�or�all�of�these�lo�cal�v��q�ariable�declarations,���the�non-���declared�t�v��q�ariables�will�b�Gecome�global,���hence�kno���wn�outside�of�the�function,�and�this�ma���y�ha�v�e���undesirable��Sside-eects.��On�the�other�hand,��in�some�cases�it�ma���y�also�b�Ge�what�y�ou�w�an�t.��Lo�Gcal���v��q�ariables�UUcan�b�Ge�giv���en�a�default�v�alue�as�the�formal�v�ariables.�������36���%
E�����Kf�������Example:�qǫF��*�or�UUinstance���K����foo(x=1,�?�y=2,�z=3)�=�print(x�":"�y�":"�z)��ex��denes���a�function�whic���h�prin�ts�its�argumen�ts�(at�most�three�of�them),���separated�b�y�colons.��This���then��ffollo���ws�the�rules�of�default�argumen�ts�generation�as�explained�at�the�b�Geginning�of�Section�3.0.2.�����?�?�foo(6,7)��!Ӎ�6:7:3����?�?�foo(,5)����1:5:3����?�?�foo����1:2:3�����Once��Ithe�function�is�dened�using�the�ab�Go���v�e��Isyn�tax,�y�ou�can�use�it�lik�e�an�y�other�function.���In�]�addition,�_�y���ou�can�also�recall�its�denition�exactly�as�y�ou�do�for�predened�functions,�_�that�is�b�y���writing��I�?��name��C*�.�RThis�will�prin���t�the�list�of�argumen�ts,�	Kas�w�ell�as�their�default�v��q�alues,�	Kthe�text�of���se��}'q���۫,���and���a�short�help�text�if�one�w���as�pro�vided�using�the��addhelp��function�(see�Section�3.11.2.1).�TOne���small�VOdierence�to�predened�functions�is�that�y���ou�can�nev�er�redene�the�built-in�functions,�V�while���y���ou�UUcan�redene�a�user-dened�function�as�man�y�times�as�y�ou�w�an�t.����T���yping�UU�\u��will�output�the�list�of�user-dened�functions.����An���am���using�example�of�a�user-dened�function�is�the�follo�wing.�4�It�is�in�tended�to�illustrate�b�Goth���the��use�of�user-dened�functions�and�the�p�Go���w�er��of�the��sumalt��function.���Although�the�Riemann���zeta-function��$is�included�in�the�standard�functions,��Wlet�us�assume�that�this�is�not�the�case�(or���that�hGw���e�w�an�t�another�implemen�tation).���One�w�a�y�to�dene�it,�mwhic�h�is�probably�the�simplest�(but���certainly�UUnot�the�most�ecien���t),�is�as�follo�ws:���K���zet(s)�?�=��!Ӎ�{�����local(n);�?�/*�not�needed,�and�possibly�confusing�(see�below)�*/�����sumalt(n=1,�?�(-1)^(n-1)*n^(-s))�/�(1�-�2^(1-s))����}����This�s�giv���es�reasonably�go�Go�d�s�accuracy�and�sp�Geed�as�long�as�y�ou�are�not�to�Go�far�from�the�domain�of���con���v�ergence.�n�T��*�ry�L�it�for��s��in���tegral�b�Get�w�een���5�and�5,�Nrsa�y��*�,�or�L�for��s���=�0�:�5�'�+��i����t�L��where��t���=�14�:�134�����:�:�:������The���iterativ���e�constructs�whic�h�use�a�v��q�ariable�name�(�for�xxx�,���prod�xxx�,��sum�xxx�,��vector�,��ma-���trix�,��E�plot�,�etc.)�h�also���consider�the�giv���en�v��q�ariable�to�b�Ge�lo�cal�to�the�construct.�h�A���v��q�alue�is�pushed���on�%en���try�and�pulled�on�exit.�a�So,�.�it�is�not�necessary�for�a�function�using�suc�h�a�construct�to�declare���the�UUv��q�ariable�as�a�dumm���y�formal�parameter.����In���particular,���since�lo�Gop�v��q�ariables�are�not�visible�outside�their�lo�ops,���the�v��q�ariable��n��need�not���b�Ge�UUdeclared�in�the�proto���yp�e�of�our��zet��function�ab�o���v�e.���K���zet(s)�?�=�sumalt(n=1,�(-1)^(n-1)*n^(-s))�/�(1�-�2^(1-s))����w���ould��b�Ge�a�p�erfectly�sensible�(and�in�fact�b�etter)�denition.�7VSince�lo�cal/global�scop�e�is�a�v���ery�tric�ky���p�Goin���t,�UUhere's�one�more�example.�q�What's�wrong�with�the�follo�wing�denition?���K���?�?�first_prime_div(x)�=��!Ӎ�{�����local(p);�����forprime(p=2,�?�x,�if�(x%p�==�0,�break));�������37���&������Kf�����卑��p�����}����?�?�first_prime_div(10)����%1�?�=�0�����Answ��9er:���the���index��p��in�the��forprime��lo�Gop�is�lo�cal�to�the�lo�op�and�is�not�visible�to�the�outside���w���orld.�oHence,�N�it�MFdo�Gesn't�surviv�e�the��break��statemen�t.�oMore�precisely��*�,�N�at�this�p�Goin�t�the�lo�Gop�index���is��restored�to�its�preceding�v��q�alue,��whic���h�is�0�(lo�Gcal�v�ariables�are�initialized�to�0�b���y�default).�Q�T��*�o�sum���up,�$�the��routine�returns�the��p��declared�lo�Gcal�to�it,�not�the�one�whic���h�w�as�lo�Gcal�to��forprime��and�ran���through�UUconsecutiv���e�prime�n�um�b�Gers.�q�Here's�a�corrected�v�ersion:�����?�?�first_prime_div(x)�=�forprime(p=2,�x,�if�(x%p�==�0,�return(p)))������Again,�}it��Bis�strongly�recommended�to�declare�all�other�lo�Gcal�v��q�ariables�that�are�used�inside�a���function:�X�if�#�a�function�accesses�a�v��q�ariable�whic���h�is�not�one�of�its�formal�parameters,�-�the�v�alue�used���will��[b�Ge�the�one�whic���h�happ�ens�to�b�e�on�top�of�the�stac���k�at�the�time�of�the�call.���This�could�b�e�a���\global"�UUv��q�alue,�or�a�lo�Gcal�v�alue�b�Gelonging�to�an���y�function�higher�in�the�call�c�hain.�q�So,�b�Ge�w�arned.����Recursiv���e��?functions�can�easily�b�Ge�written�as�long�as�one�pa�ys�prop�Ger�atten�tion�to�v��q�ariable���scop�Ge.���Here's�a�a�last�example,�d�used�to�retriev���e�the�co�ecien���t�arra�y�of�a�m�ultiv��q�ariate�p�Golynomial�(a���non-trivial�UUtask�due�to�P��*�ARI's�unsophisticated�represen���tation�for�those�ob��8jects):�����coeffs(P,�?�nbvar)�=�����{�����local(v);��
���if�?�(type(P)�!=�"t_POL",����(��for�?�(i=0,�nbvar-1,�P�=�[P]);����(��return�?�(P)�����);�����v�?�=�vector(poldegree(P)+1,�i,�polcoeff(P,i-1));�����vector(length(v),�?�i,�coeffs(v[i],�nbvar-1))����}����If����P�!�is�a�p�Golynomial�in��k��v��q�ariables,�דsho���w�that�after�the�assignmen�t��v�?�=�coeffs(P,k)�,�דthe���co�Ge-���cien���t��gof��x����:��n�����Zcmr5�1���l��1����F�:���:�:��X�x���~���n����O
�\cmmi5�k�������k���
��in�P��Pis�giv�en�b�y��v[�n����1��|s�+1][��:���:�:��
UO�][�n����k����+1]�.���What�w�ould�happ�Gen�if�the�declaration����local(v)�UU�had�b�Geen�omitted�?����The�UUop�Gerating�system�will�automatically�limit�the�recursion�depth:�����?�?�dive(n)�=�if�(n,�dive(n-1))�����?�?�dive(5000);�����***���deep�?�recursion:�if(n,dive(n-1))�������^---------------�����There's�/�no�w���a�y�/�to�increase�the�recursion�limit�(whic���h�ma�y�b�Ge�dieren�t�on�y�our�mac�hine)�from���within,��Isince���it�w���ould�simply�crash�the�GP���pro�Gcess.���T��*�o�increase�it�b�efore�launc���hing�GP��*�,�y�ou�can���use�{��ulimit��or��limit�,��~dep�Gending�on�y���our�shell,�to�raise�the�pro�Gcess�a���v��q�ailable�stac�k�space�(increase����stacksize�).�������38���'&j�����Kf�������F��
�unction���whic��9h�tak�e�functions�as�parameters�?�p��This�Q�is�easy�in�GP�Q�using�the�follo���wing�tric�k���(neat�UUexample�due�to�Bill�Daly):��O���calc(f,�?�x)�=�eval(�Str(f,�"(x)")�)��;E��If�UUy���ou�call�this�with��calc("sin",�?�1)�,�it�will�return��sin���s(1)�(ev��q�aluated!).��bȍ�Restrictions�M�on�v��\rariable�use:���it���is�not�allo���w�ed���to�use�the�same�v��q�ariable�name�for�dieren���t���parameters��@of�y���our�function.�T�Or�to�use�a�giv�en�v��q�ariable�b�Goth�as�a�formal�parameter�and�a�lo�cal���v��q�ariable�UUin�a�giv���en�function.�q�Hence�����?�?�f(x,x)�=�1����***���user�?�function�f:�variable�x�declared�twice.��;E���Also,��the��Pstatemen���t��global(x,�?�y,�z,�t)��P�(see�Section�3.11.2.11)�declares�the�corresp�Gonding���v��q�ariables���to�b�Ge�global.�,It�is�then�forbidden�to�use�them�as�formal�parameters�or�lo�op�indexes�as���describ�Ged�UUab�o���v�e,�since�the�parameter�w�ould�\shado�w"�the�v��q�ariable.��bȍ�Implemen��9tation�,Enote.�T��F��*�or���the�curious�reader,���here�is�ho���w�these�stac�ks�are�handled:��a�hashing���function���is�computed�from�the�iden���tier,��]and�used�as�an�index�in��hashtable�,�a�table�of�p�Goin���ters.���Eac���h�vof�these�p�Goin�ters�b�Gegins�a�link�ed�list�of�structures�(t�yp�Ge��entree�).��The�link�ed�list�is�searc�hed���linearly�$for�the�iden���tier�(eac�h�list�will�t�ypically�ha�v�e�less�than�7�comp�Gonen�ts�or�so).�{5When�the���correct��R�entree��is�found,��Sit�p�Goin���ts�to�the�top�of�the�stac�k�of�v��q�alues�for�that�iden�tier�if�it�is�a�v��q�ariable,���to�j�the�function�itself�if�it�is�a�predened�function,�pand�to�a�cop���y�of�the�text�of�the�function�if�it�is���a�{�user-dened�function.��When�an�error�o�Gccurs,��-all�of�this�maze�(rather�a�tree,�in�fact)�is�searc���hed���and�UU(hop�Gefully)�restored�to�the�state�preceding�the�last�call�of�the�main�ev��q�aluator.����Note:�w�The�+-ab�Go���v�e�syn�tax�(using�the��local��k�eyw�ord)�w�as�in�tro�Gduced�in�v�ersion�2.0.13.��OThe�old���syn���tax��;E���name(��list���of�true�formal�variables,�list�of�lo��}'c�al���variables���|h�)�?�=���se��}'q�����is���still�recognized�but�is�deprecated�since�gen���uine�argumen�ts�and�lo�Gcal�v��q�ariables�b�ecome�undistin-���guishable.��v���2.6.5��TMem��9b�Q�er�functions�.����Mem���b�Ger���functions�use�the�`dot'�notation�to�retriev�e�information�from�complicated�structures���(b���y�6+default:�b2t�yp�Ges��ell�,�<g�nf�,��bnf�,��bnr��and�prime�ideals).�gdThe�syn���tax��structure.member��is�tak�en�to���mean:�T$retriev���e��member��from��structure�,�%�e.g.��ell.j��returns�the��j����-in�v��q�arian�t�of�the�elliptic�curv�e��ell����(or�UUoutputs�an�error�message�if��ell��do�Gesn't�ha���v�e�UUthe�correct�t���yp�e).����T��*�o���dene�y���our�o�wn�mem�b�Ger�functions,��Juse�the�syn�tax���structur��}'e.memb�er���=�function�text���C�,��Jwhere�����function���text��;+��is���written�as�the���se��}'q����in�a�standard�user�function�(without�lo�Gcal�v��q�ariables),�
�whose�only���argumen���t��fw�ould�b�Ge��structure�.�QxF��*�or�instance,��the�curren�t�implemen�tation�of�the��ell��t�yp�Ge�is�simply���an���horizon���tal�v�ector,��bthe��j����-in�v��q�arian�t�b�Geing�the�thirteen�th�comp�Gonen�t.�This�could�b�Ge�implemen�ted���as��O���x.j�?�=���{�����if�?�(type(x)�!=�"t_VEC"�||�length(x)�<�14,����(��error("this�?�is�not�a�proper�elliptic�curve:�"�x)�����);�����x[13]�������39���(2�����Kf�����卑�}��5���Y��*�ou��lcan�redene�one�of�y���our�o�wn�mem�b�Ger�functions�simply�b�y�t�yping�a�new�denition�for�it.���On��fthe�other�hand,��0as�a�safet���y�measure,�y���ou�can't�redene�the�built-in�mem�b�Ger�functions,��0so�t�yping���the���ab�Go���v�e�text�w�ould�in�fact�pro�Gduce�an�error�(y�ou'd�ha�v�e�to�call�it�e.g.��x.j2��in�order�for�GP���to���accept�UUit).��Y��W��
�arning:�4�con���trary���to�user�functions�argumen�ts,��Ythe�structure�accessed�b�y�a�mem�b�Ger�function�is����not�H-�copied�UUb�Gefore�b�eing�used.�q�An���y�mo�dication�to�the�structure's�comp�onen���ts�will�b�e�p�ermanen���t.����Note:�ʢ�Mem���b�Ger��functions�w�ere�not�mean�t�to�b�Ge�to�o�complicated�or�to�dep�end�on�an���y�data�that���w���ouldn't���b�Ge�global.��Hence�they�do�no�ha�v�e�parameters�(b�Gesides�the�implicit��structure�)�or�lo�cal���v��q�ariables.���Of�[course,�\lif�y���ou�need�some�prepro�Gcessing�w�ork�in�there,�\lthere's�nothing�to�prev�en�t�y�ou���from��Ocalling�y���our�o�wn�functions�(using�freely�their�lo�Gcal�v��q�ariables)�from�a�mem�b�Ger�function.��F��*�or���instance,�UUone�could�implemen���t�(a�dreadful�idea�as�far�as�eciency�go�Ges):��G���correct_ell_if_needed(x)�?�=����{�����local(tmp);�����if�?�(type(x)�!=�"t_VEC",�tmp�=�ellinit(x))����(��\\����some���further�che��}'cks������tmp����}����x.j�?�=�correct_ell_if_needed(x)[13];��5���T���yping�UU�\um��will�output�the�list�of�user-dened�mem�b�Ger�functions.��$k��2.6.6��TStrings�and�Keyw��9ords�.���GP���v��q�ariables��Gcan�no���w�hold�v�alues�of�t���yp�Ge�c�haracter�string�(in�ternal�t�yp�Ge��t_STR�).�This�section���describ�Ges���ho���w�they�are�actually�used,���as�w�ell�as�some�con�v�enien�t�tric�ks�(automatic�concatenation���and�UUexpansion,�k���eyw�ords)�UUv��q�alid�in�string�con���text.��5��As���explained�ab�Go���v�e,���the���general�w���a�y���to�input�a�string�is�to�enclose�c���haracters�b�et���w�een���quotes��"�.���This��is�the�only�input�construct�where�whitespace�c���haracters�are�signican�t:�>%the�string�will�con�tain���the�&'exact�n���um�b�Ger�&'of�spaces�y���ou�t�yp�Ged�in.�b
Besides,�/�y�ou�can�\escap�Ge"�c�haracters�b�y�putting�a��\��just���b�Gefore�UUthem;�the�translation�is�as�follo���ws����#���\e:�?�<Escape>����#��\n:�?�<Newline>����#��\t:�?�<Tab>��5���F��*�or�s�an���y�other�c�haracter��x�,�{%�\�x��is�expanded�to��x�.�̇In�particular,�the�only�w���a�y�s�to�put�a��"��in���to�a���string�p�is�to�escap�Ge�it.�ÞTh���us,�wofor�instance,��"\"a\""��w���ould�pro�Gduce�the�string�whose�con�ten�t�is�\a".���This��is�denitely��not��q�the�same�thing�as�t���yping��"a"�,��whose�con�ten�t�is�merely�the�one-letter�string�a.����Y��*�ou��can�concatenate�t���w�o��strings�using�the��concat��function.�Y�If�either�argumen���t�is�a�string,�he���other�UUis�automatically�con���v�erted�UUto�a�string�if�necessary�(it�will�b�Ge�ev��q�aluated�rst).��G���?�?�concat("ex",�1+1)����%1�?�=�"ex2"����?�?�a�=�2;�b�=�"ex";�concat(b,�a)����%2�?�=�"ex2"����?�?�concat(a,�b)�������40���)@+�����Kf�����卑�%3�?�=�"2ex"������Some�[email protected]�exp�Gect�strings�for�some�of�their�argumen���ts:��=�print��w�ould�b�Ge�an�ob�vious�example,����Str��
�is�a�less�ob���vious�but�useful�one�(see�the�end�of�this�section�for�a�complete�list).���While�t�yping���in�suc���h�an�argumen�t,�)�y�ou�will�b�Ge�said�to�b�e�in��string�a�c��}'ontext��ث.�_�The�rest�of�this�section�is�dev���oted�to���sp�Gecial���syn���tactical�tric�ks�whic�h�can�b�Ge�used�with�suc�h�argumen�ts�(and�only�here;��Fy�ou�will�get�an���error�UUmessage�if�y���ou�try�these�outside�of�string�con�text):������k�W��*�riting�t���w�o�kstrings�alongside�one�another�will�just�concatenate�them,�N1pro�Gducing�a�longer���string.��ZTh���us�ˆit�is�equiv��q�alen�t�to�t�yp�Ge�in��"a�?�"�"b"�ˆ�or��"a�?�b"�.��ZA��&little�tric�ky�p�Goin�t�in�the�rst���expression:��Ethe���rst�whitespace�is�enclosed�b�Get���w�een���quotes,�'�and�so�is�part�of�a�string;�Q�while�the���second� �(b�Gefore�the��"b"�)�is�completely�optional�and�GP� �actually�suppresses�it,�+`as�it�w���ould�with�an�y���n���um�b�Ger�UUof�whitespace�c���haracters�at�this�p�oin���t�(i.e.�outside�of�an�y�string).�������,�If�y���ou�insert�an�y�expression�when�GP��exp�Gects�a�string,���it�gets�\expanded":�?vit�is�ev��q�aluated���as��a�standard�GP��expression,�3(and�the�nal�result�(as�w���ould�ha�v�e�b�Geen�prin�ted�if�y�ou�had�t�yp�Ged���it��b���y�itself��)�is�then�con�v�erted�to�a�string,�H�as�if�y�ou�had�t�yp�Ged�it�directly��*�.��bF�or��instance��"a"�?�1+1���"b"��L�is�equiv��q�alen���t�to��"a2b"�:��three�strings�get�created,��Jthe�middle�one�b�Geing�the�expansion�of��1+1�,���and�,>these�are�then�concatenated�according�to�the�rule�describ�Ged�ab�o���v�e.�dAnother�,>tric�ky�p�Goin�t�here:���assume�vy���ou�did�not�assign�a�v��q�alue�to��aaa��in�a�GP�u�expression�b�Gefore.���Then�t�yping��aaa��b�y�itself�in���a�-Astring�con���text�will�actually�pro�Gduce�the�correct�output�(i.e.�the�string�whose�con�ten�t�is�aaa),�5Ebut���in��ga�fortuitous�w���a�y��*�.�3�This��g�aaa��gets�expanded�to�the�monomial�of�degree�one�in�the�v��q�ariable��aaa�,���whic���h�UUis�of�course�prin�ted�as��aaa�,�and�th�us�will�expand�to�the�three�letters�y�ou�w�ere�exp�Gecting.���_��W��
�arning:��ѫexpression��Zin���v�olving�strings�are�not�handled�in�a�sp�Gecial�w�a�y;�<]ev�en�in�string�con�text,���the��9largest�p�Gossible�expression�is�ev��q�aluated,���hence��print("a"[1])��is�incorrect�since��"a"��is�not�an���ob��8ject��whose�rst�comp�Gonen���t�can�b�e�extracted.�}#On�the�other�hand��print("a",�?�[1])��is�correct���(t���w�o�8mdistinct�argumen���t,�q2eac�h�8mcon�v�erted�to�a�string),�q2and�so�is��print("a"�?�1)��(since��"a"1��is�not���a�/�v��q�alid�expression,�fxonly��"a"��gets�expanded,�then��1�,�and�the�result�is�concatenated�as�explained���ab�Go���v�e).�h_In���case�of�doubt,�&�y���ou�can�surround�part�of�y�our�text�b�y�paren�thesis�to�force�immediate���in���terpretation�UUof�a�sub�Gexpression:�q��print("a"([1]))��is�another�solution.������r�Since�there�are�cases�where�expansion�is�not�really�desirable,�?:w���e�no�w�distinguish�b�Get�w�een���\Keyw���ords"���and�\Strings".�9AString�is�what�has�b�Geen�describ�ed�so�far.�9AKeyw���ords�are�sp�ecial�relativ���es���of�>�Strings�whic���h�are�automatically�assumed�to�b�Ge�quoted,�C?whether�y�ou�actually�t�yp�Ge�in�the�quotes���or��not.�L4Th���us�expansion�is�nev�er�p�Gerformed�on�them.�L4They�get�concatenated,��(though.�The�analyzer���supplies���automatically�the�quotes�y���ou�ha�v�e�\forgotten"�and�treats�Keyw�ords�just�as�normal�strings���otherwise.�]F��*�or�Niinstance,���if�y���ou�t�yp�Ge��"a"b+b��in�Keyw�ord�con�text,���y�ou�will�get�the�string�whose���con���ten�ts�UUare�ab+b.�q�In�String�con���text,�on�the�other�hand,�y�ou�w�ould�get�a2�*�b.����All���GP���functions�ha���v�e���protot�yp�Ges�(describ�ed�in�Chapter�3�b�elo���w)�whic�h�sp�Gecify�the�t�yp�Ges�of���argumen���ts��Athey�exp�Gect:�=either�generic�P��*�ARI��ob��8jects�(GEN),�or�strings,���or�k�eyw�ords,���or�unev��q�aluated���expression�b�sequences.� �In�the�k���eyw�ord�b�case,��Xonly�a�v���ery�small�set�of�w�ords�will�actually�b�Ge�meaningful���(the�UU�default��function�is�a�prominen���t�example).���Here�UUis�a�useful�example,�used�to�create�generic�matrices:��W����?�?�genmat(u,v,s="x")�=�matrix(u,v,i,j,�eval(Str(s�""�i�""�j)))��U�?�?�genmat(2,3)�+�genmat(2,3,"m")����%1�?�=����[x11�?�+�m11�x12�+�m12�x13�+�m13]����[x21�?�+�m21�x22�+�m22�x23�+�m23]�������41���*L������Kf�����卫Note���that�the�argumen���t�of��Str��is�ev��q�aluated�in�string�con�text,�M�and�really�consists�of�5�pieces.���(Exercise:�h�wh���y�зare�the�empt�y�strings�necessary?).���This�part�could�also�ha�v�e�b�Geen�written�as����concat(concat(Str(s),�?�i),�j)�+�(but��not�W�as��concat(Str(s),�?�concat(i,j))�!).�c�More�simply��*�,�3�w���e���could���ha���v�e�written��concat([Str(s),�?�i,j])�,��or�ev�en��concat([s,i,j])�,��silen�tly�assuming�that��s����will�UUindeed�b�Ge�a�string.���捑In��Rv���ersion�2.2.5,���the�protot�yp�Ge�of��Str��w�as�extended�to�allo�w�more�than�one�argumen�t,���whic�h���are��concatenated�in���to�a�single�string.���So,�O�nally��*�,��Str(s,�?�i,�j)���should�no�w�b�Ge�preferred�to�the���ab�Go���v�e�UUsolution,�since�it�is�less�cryptic�and�more�ecien���t.���A��Glast��lexample:���the�function��hist��returns�all�history�en���tries�from��%�a��to��%�b��neatly�pac�k�ed�in�to�a���single�UUv���ector�����?�
�hist(a,b)�?�=�vector(b-a+1,�i,�eval(Str("%",�a-1+i)))���̍�Reference:�qǫThe�UUargumen���ts�of�the�follo�wing�functions�are�pro�Gcessed�in�string�con�text:�������Str��������addhelp�UU�(second�argumen���t)���������default�UU�(second�argumen���t)���������error��������extern��������plotstring�UU�(second�argumen���t)���������plotterm�UU�(rst�argumen���t)���������read��������system���������all�UUthe��print��xxx��[email protected]�functions��������all�UUthe��write��xxx��[email protected]�functions�����The�UUargumen���ts�of�the�follo�wing�functions�are�pro�Gcessed�as�k�eyw�ords:�������alias��������default�UU�(rst�argumen���t)���������install�UU�(all�argumen���ts�but�the�last)���������trap�UU�(rst�argumen���t)���������type�UU�(second�argumen���t)���������whatnow����"�d��2.7��Errors�and�error�reco��v�ery�.�����2.7.1��TErrors.�����There�#�are�t���w�o�#�kind�of�errors:��syn���tax�errors,�Wand�errors�pro�Gduced�b�y�functions�in�the�P��*�ARI���library��*�.�f�Both�Q�kinds�will�b�Ge�fatal�to�y���our�computation:�j]GP�Q_will�rep�ort�the�error,���p�erform�some���clean���up��S(restore�v��q�ariables�mo�Gdied�while�ev�aluating�the�erroneous�command,��Rclose�op�Gen�les,�re-���claim�UUun���used�memory��*�,�etc.),�and�will�output�its�usual�prompt.����When��rep�Gorting�a�syn���tax�error,�TGP��{tries�to�giv�e�meaningful�con�text�b�y�cop�ying�the�sen�tence�it���w���as�Fjtrying�to�read�(whitespace�and�commen�ts�stripp�Ged�out),�Ifindicating�an�error�with�a�little�caret���lik���e�UUin�����?�?�factor(x^2�-�1�����***���expected�?�character:�','�instead�of:�factor(x^2-1����9�X^�������42���+_�����Kf�����卫p�Gossibly�UUenlarged�to�a�full�arro���w�giv�en�enough�trailing�con�text���]���?�?�if�(siN(x)�<�eps,�do_something())��*���***���expected�?�character:�'='�instead�of:�if(siN(x)<eps,do_something())����*?a^--------------------��~F��GP�S�error�messages�will�often�b�Ge�m���ysterious,�T=b�ecause�GP�cannot�guess�what�y���ou�w�ere�trying�to�do���and�L�the�error�usually�o�Gccurs�once�GP�L�has�b�een�sidetrac���k�ed.�n�Let's�L�ha�v�e�a�lo�Gok�at�the�t�w�o�messages���ab�Go���v�e.����The��)rst�error�is�a�missing�paren���thesis,���but�from�GP's�p�Goin�t�of�view,���y�ou�migh�t�as�w�ell�ha�v�e���in���tended���to�giv�e�further�argumen�ts�to��factor��(this�is�p�Gossible,�Iand�often�useful,�see�the�description���of�V=the�function).�t�Since�GP�did�not�see�the�closing�paren���thesis,�Vwit�tried�to�read�a�second�argumen�t,���rst�,clo�Goking�for�the�comma�that�w���ould�separate�it�form�the�rst.�d!The�error�o�ccurred�at�this�p�oin���t.���So�UUGP�tells�y���ou�that�it�w�as�exp�Gecting�a�comma�and�sa�w�a�blank.����The�Ȫsecond�error�is�ev���en�w�eirder.�B�It�is�a�simple�t�yp�Go,����siN�Ȇ�instead�of��sin��and�GP�tells�us�that�is���w���as�Geexp�Gecting�an�equal�sign�a�few�c�haracters�later?�m"What�happ�Gens�is�this:�j��siN�Ga�is�not�a�recognized���iden���tier,���but��from�the�con�text,���it�lo�Goks�lik�e�a�function�(it�is�follo�w�ed�b�y�an�op�Gen�paren�thesis),���then���w���e��ha�v�e�an�argumen�t,�4gthen�a�closing�paren�thesis.��%Then�if��siN���w�ere�a�kno�wn�function�w�e�w�ould���ev��q�aluate�UUit;�but�it�is�not,�so�GP�assumes�that�y���ou�w�ere�trying�to��dene���it,�as�in���]���?�?�if�(siN(x)=sin(x),�...)�����This��`is�actually�allo���w�ed��`(!)�P�and�denes�the�function��siN��F�as�an�alias�for��sin�.�As�an���y�expression���a��function�denition�has�a�v��q�alue,�CUwhic���h�is�0,�hence�the�test�is�meaningful,�and�false,�so�nothing���happ�Gens.�7�(Admittedly��gthis�do�esn't�lo�ok�lik���e�a�useful�syn�tax�but�it�can�b�Ge�in�teresting�in�other���con���texts�ito�let�functions�dene�other�functions.���An�yw�a�y��*�,�m�it�is�allo�w�ed�b�y�the�language�denition.)���So���GP���tells�y���ou�in�go�Go�d���faith�that�to�correctly�dene�a�function,��}y�ou�need�an�equal�sign�b�Get�w�een���its�UUname�and�its�b�Go�dy��*�.����Error�mWmessages�from�the�library�will�usually�b�Ge�m���uc�h�mWclearer�since,��Xb���y�denition,�they�an-���sw���er�)�a�correctly�w�orded�query�(otherwise�GP�)Vw�ould�ha�v�e�protested�rst).��nAlso�they�ha�v�e�more���mathematical�UUcon���ten�t,�whic�h�should�b�Ge�easier�to�grasp�than�a�parser's�logic.�q�F��*�or�instance:���]���?�?�1/0��*���***���division�?�by�zero�in�gdiv,�gdivgs�or�ginv�����The��rst�half�of�the�sen���tence�is�crystal�clear,��and�the�second�one�only�giv�es�more�con�text�as�to���where���exactly�the�problem�o�Gccured�in�the�library��*�.�Q�Unfortunately�library�errors�do�not�giv���e�con�text,���so�UUit�can�b�Ge�hard�to�trac���k�do�wn�exactly�where�in�y�our�program�the�error�o�Gccured.������2.7.2��TError�reco��9v�ery�����It���is�quite�anno���ying�to�w�ait�for�some�program�to�nish�and�nd�out�the�hard�w�a�y�that�there���w���as�[a�mistak�e�in�it�(lik�e�the�division�b�y�0�ab�Go�v�e),�\lsending�y�ou�bac�k�to�the�prompt.���First�y�ou�ma�y���lose��|some�v��q�aluable�in���termediate�data.�F�Also,��Acorrecting�the�error�ma�y�not�b�Ge�o�vious;��oy�ou�migh�t�ha�v�e���to���c���hange�y�our�program,��%adding�a�n�um�b�Ger�of�extra�statemen�ts�and�tests�to�try�and�narro�w�do�wn���the�UUproblem.����A���sligh���tly���dieren�t�situation,��still�related�to�error�reco�v�ery��*�,��is�when�y�ou�y�ou�actually�foresee���that�@�some�error�ma���y�o�Gccur,�Eare�unable�to�prev�en�t�it,�Ebut�quite�capable�of�reco�v�ering�from�it,�Egiv�en���the���c���hance.�1NExamples�include�lazy�factorization�(cf.��addprimes�),���where�y�ou�kno�wingly�use�a�pseudo���prime���N�,�as�if�it�w���ere�prime;�t�y�ou�ma�y�then�encoun�ter�an�\imp�Gossible"�situation,�D�but�this�w�ould�������43���,i������Kf�����卫usually�oexhibit�a�factor�of��N��,�#enabling�y���ou�to�rene�the�factorization�and�go�on.�\�Or�y�ou�migh�t�run���an���exp�Gensiv���e�computation�at�lo�w�precision�to�guess�the�size�of�the�output,���hence�the�righ�t�precision���to��vuse.�B(Y��*�ou�can�then�encoun���ter�errors�lik�e�\precision�loss�in�truncation",��	e.g�when�trying�to�con�v�ert����1E1000�,���kno���wn��ato�28�digits�of�accuracy��*�,�to�an�in���teger;��]or�\division�b�y�0",���e.g�in�v�erting��0E1000��when���all�y�accuracy�has�b�Geen�lost,��and�no�signican���t�digit�remains.��pIt�w�ould�b�Ge�enough�to�restart�part�of���the�UUcomputation�at�a�sligh���tly�higher�precision.���؍�W��*�e�\
no���w�describ�Ge��err��}'or��tr�apping��}�,�]�a�\
useful�mec�hanism�whic�h�alleviates�m�uc�h�of�the�pain�in�the���rst���situation,�and�pro���vides�a�satisfactory�w�a�y�out�of�the�second�one.�pEv�erything�is�handled�via���the�UU�trap��function�whose�dieren���t�mo�Gdes�w�e�no�w�describ�Ge.��ه��2.7.3��TBreak�lo�Q�op�����A�޺�br��}'e�ak�&�lo�op��p�is���a�sp�Gecial�debugging�mo�de�that�y���ou�en�ter�whenev�er�an�error�o�Gccurs,���freezing�the���GP��,state,���and��Kprev���en�ting�clean�up�un�til�y�ou�get�out�of�the�lo�Gop.�ӨAn�y�error:�]�syn�tax�error,���library���error,��Vuser���error�(from��error�),�ev���en�user�in�terrupts�lik�e��C-c��(Con�trol-C).�When�a�break�lo�Gop�starts,���a���prompt�is�issued�(�break>�).��Y��*�ou�can�t���yp�Ge�in�a�GP���command,�iwhic�h�is�ev��q�aluated�when�y�ou�hit���the�[email protected]�<Return>��k���ey��*�,�O�and�the�result�is�prin�ted�as�during�the�main�GP�N>lo�Gop,�O�except�that�no�history�of���results�8lis�k���ept�Then�the�break�lo�Gop�prompt�reapp�ears�and�y���ou�can�t�yp�Ge�further�commands�as�long���as���y���ou�do�not�exit�the�lo�Gop.��*If�y�ou�are�using�readline,��)the�history�of�commands�is�k�ept,��)and�line���editing�rnis�a���v��q�ailable�as�usual.��If�y�ou�t�yp�Ge�in�a�command�that�results�in�an�error,�y�y�ou�are�sen�t�bac�k���to�UUthe�break�lo�Gop�prompt�(errors�do�es���not�����terminate�the�lo�op).����T��*�o�_pget�out�of�a�break�lo�Gop,���y���ou�can�use��next�,��break�,��return�,�or��C-d��(�EOF�),�an���y�of�whic�h���will���let�GP���p�Gerform�its�usual�clean���up,��and�send�y�ou�bac�k�to�the�GP���prompt.�D�If�the�error�is�not���fatal,��inputing��an�empt���y�line,�i.e�hitting�the��<Return>��k���ey�at�the��break>��prompt,�will�con���tin�ue��the���temp�Gorarily��#in���terrupted�computation.�IAn�empt�y�line�has�no�eect�in�case�of�a�fatal�error,��to�ensure���y���ou�ͧdo�not�get�out�of�the�lo�Gop�prematurely��*�,��th�us�losing�most�debugging�data�during�the�clean�up���(since�UUuser�v��q�ariables�will�b�Ge�restored�to�their�former�v�alues).����In�e�curren���t�v�ersion�2.2.7,�jan�error�is�non-fatal�if�and�only�if�it�w�as�initiated�b�y�a��C-c��t�yp�Ged�b�y���the�UUuser.����Break���lo�Gops�are�useful�as�a�debugging�to�ol�to�insp�ect�the�v��q�alues�of�GP���v�ariables�to�understand���wh���y�SIan�error�o�Gccurred,�S�or�to�c�hange�GP�state�in�the�middle�of�a�computation�(increase�debugging���lev���el,�+&start�cstoring�results�in�a�logle,�set�v��q�ariables�to�dieren���t�v�alues��:���:�:��
UO�):���hit��C-c�,�+&t���yp�Ge�in�y�our���mo�Gdications,�UUthen�let�the�computation�go�on�as�explained�ab�o���v�e.����A�UUbreak�lo�Gop�lo�oks�lik���e�this:�����?�?�for(v�=�-2,�2,�print(1/v))����-1/2����-1�����***���division�?�by�zero�in�gdiv,�gdivgs�or�ginv�����***���Starting�?�break�loop�(type�'break'�to�go�back�to�GP):�����***���for(v=-2,2,print(1/v))�������^--����break>����So�!ythe�standard�error�message�is�prin���ted�rst,�T�except�no�w�w�e�alw�a�ys�ha�v�e�con�text,�T�whether�the���error��Icomes�from�the�library�or�the�parser.�4�The��break>��at�the�b�Gotto���w�is�a�prompt,���and�hitting��v����then�UU�<Return>�,�w���e�see:�����break>�?�v�������44���-z�����Kf�����卑�0��g��explaining�Z�the�problem.���W��*�e�could�ha���v�e�Z�t�yp�Ged�an�y�GP�Z�command,�\_not�only�the�name�of�a�v��q�ariable,���of��0course.�ZXThere�is�no�sp�Gecial�set�of�commands�b�ecoming�a���v��q�ailable�during�a�break�lo�op,� �as�they���w���ould�UUin�most�debuggers.��� ��Imp�Q�ortan��9t�C�Note:�1ūup�Gon��Tstartup,��Tthis�mec���hanism�is��o���.���T�yp�Ge��trap()��(or�include�it�in�a�script)���to�UUstart�trapping�errors�in�this�w���a�y��*�.�q�By�UUdefault,�y���ou�will�b�Ge�sen�t�bac�k�to�the�prompt.����T��
�ec��9hnical��Note:��7�When��y���ou�en�ter�a�break�lo�Gop�due�to�a�P��*�ARI��stac�k�o�v�er
o�w,��the�P��*�ARI��stac�k�is���reset���so�that�y���ou�can�run�commands�(otherwise�the�stac�k�w�ould�immediately�o�v�er
o�w�again).�O�Still,���as�UUexplained�ab�Go���v�e,�UUy�ou�do�not�lose�the�v��q�alue�of�an�y�GP�v��q�ariable�in�the�pro�Gcess.��50��2.7.4��TError�handlers��g���The���break�lo�Gop�describ�ed�ab�o���v�e���is�a�(sophisticated)�example�of�an��err��}'or���hand���ler���:�a�function���that�[)is�executed�whenev���er�an�error�o�Gccurs,�\�supp�osedly�[)to�try�and�reco�v�er.��CThe�break�lo�Gop�is�quite���a�Xsatisfactory�error�handler,�X�but�it�ma���y�not�b�Ge�adequate�for�some�purp�oses,�X�for�instance�when�GP���runs�UUin�non-in���teractiv�e�UUmo�Gde,�detac���hed�from�a�terminal.����So,�ZFy���ou�YIcan�dene�a�dieren�t�error�handler,�ZFto�b�Ge�used�in�place�of�the�break�lo�op.�}�This�is�the���purp�Gose� of�the��se��}'c�ond���argumen���t� of��trap�:��]to�sp�ecify�an�error�handler.��((W��*�e�will�discuss�the�rst���argumen���t�UUat�the�v�ery�end.)�q�F��*�or�instance:�����?�?�{�trap(�,�S��\\�note�the�comma:�arg1�is�omitted����3�print(reorder);����3�writebin("crash"))�?�}����After�%that,�.�whenev���er�an�error�o�Gccurs,�the�list�of�all�user�v��q�ariables�is�prin���ted,�and�they�are�all�sa���v�ed���in�NDbinary�format�in�le��crash�,�O�ready�for�insp�Gection.�olOf�course�break�lo�ops�are�no�longer�a���v��q�ailable:���the��new�handler�has�replaced�the�default�one.��*Besides�user-dened�handlers�as�ab�Go���v�e,�0�there��are���t���w�o�UUsp�Gecial�handlers�y���ou�can�use�in��trap�,�whic�h�are������f��trap(,�?�"")��(do-nothing�handler):���to�disable�the�trapping�mec���hanism�and�let�errors�propa-���gate,�UUwhic���h�is�the�default�situation�on�startup.������UU�trap(,�?�)��(omitted�argumen���t,�default�handler):�q�to�trap�errors�b�y�a�break�lo�Gop.��50��2.7.5�4�Protecting�co�Q�de��J�Finally��trap��can�dene�a�temp�Gorary�handler�used�within�the�scop�e�of�a���co�Gde���framen���t,���protecting�it�from�errors,�b���y�pro�viding�replacemen�t�co�Gde�should�the�trap�b�e�activ��q�ated.���The�UUexpression�����trap�(�UU,���r��}'e�c�overy��'|�,���statements��2hͫ)���ev��q�aluates��sand�returns�the�v�alue�of���statements��1��,��unless�an�error�o�Gccurs�during�the�ev�aluation�in�whic���h���case���the�v��q�alue�of���r��}'e�c�overy��+2��is�returned.��As�in�an�if/else�clause,��with�the�dierence�that���statements�����has�~�b�Geen�partially�ev��q�aluated,���with�p�ossible�side�eects.�*SF��*�or�instance�one�could�dene�a�fault�toleran���t���in���v�ersion�UUfunction�as�follo���ws:�����?�?�inv(x)�=�trap�(,�"oo",�1/x)����?�?�for�(i=-1,1,�print(inv(i)))����-1����oo����1����Protected�UUco�Gdes�can�b�e�nested�without�adv���erse�eect,�the�last�trap�seen�b�eing�the�rst�to�spring.�������45���.�������Kf�������2.7.6���T��
�rapping�sp�Q�ecic�exceptions�B��W��*�e�ha���v�e�B�not�y���et�seen�the�use�of�the�rst�argumen�t�of�trap,���whic���h�kphas�b�Geen�omitted�in�all�previous�examples.��It�simply�indicates�that�only�errors�of�a�sp�ecic���t���yp�Ge�UUshould�b�e�in���tercepted,�to�b�e�c���hosen�among���;���accurer�:�q�accuracy�UUproblem�����gdiver�:�q�division�UUb���y�0�����invmoder�:�q�imp�Gossible�UUin���v�erse�mo�Gdulo�����archer�:�q�not�UUa���v��q�ailable�on�this�arc�hitecture�or�op�Gerating�system�����typeer�:�q�wrong�UUt���yp�Ge�����errpile�:�q�the�UUP��*�ARI�stac���k�o�v�er
o�ws���Omitting�0�the�error�name�means�w���e�are�trapping�all�errors.�e�F��*�or�instance,�7�the�follo�wing�can�b�Ge�used���to�UUc���hec�k�in�a�safe�w�a�y�whether��install��w�orks�correctly�in�y�our�GP:�����broken_install()�?�=����{�����trap(archer,�?�return�("OS"),����(��install(addii,GG)�����);�����trap(,�?�"USE",����(��if�?�(addii(1,1)�!=�2,�"BROKEN")�����)����}����The�e�function�returns�0�if�ev���erything�w�orks�(the�omitted���else��c��clause�of�the��if�),�i��OS�e��if�the�op�Gerating���system�Ptdo�Ges�not�supp�ort��install�,�Qn�USE�Ps�if�using�an�installed�function�triggers�an�error,�and��BROKEN����if�UUthe�installed�function�did�not�b�Geha���v�e�UUas�exp�ected.���_��2.8��In��terfacing�GP�with�other�languages�.���b�The���P��*�ARI��library�w���as�mean�t�to�b�Ge�in�terfaced�with�C��programs.�PAThis�sp�Gecic�use�will�b�e�dealt�with���extensiv���ely�n�in�Chapter�4.���GP�n\itself�pro�vides�a�con�v�enien�t,���if�simple-minded,�in���terpreter,�whic�h���enables�UUy���ou�to�execute�rather�in�tricate�scripts�(see�Section�3.11).����Scripts,�when��prop�Gerly�written,�tend�to�b�Ge�shorter�and�m���uc�h��clearer�than�C���programs,�and�are���certainly��easier�to�write,��main���tain�or�debug.��Y��*�ou�don't�need�to�deal�with�memory�managemen�t,���garbage�m�collection,��p�Goin���ters,�declarations,�and�so�on.���Because�of�their�in���trinsic�simplicit�y��*�,��they���are�W�more�robust�as�w���ell.�x�They�are�unfortunately�somewhat�slo�w�er.�x�Th�us�their�use�will�remain���complemen���tary:�k>it��is�suggested�that�y�ou�test�and�debug�y�our�algorithms�using�scripts,�1?b�Gefore���actually�UUco�Gding�them�in�C�for�the�sak���e�of�sp�eed.������q�UNIX:�Note��fthat�the��install��command�enables�y���ou�to�concen�trate�on�critical�parts�of�y�our�programs�only���(whic���h�8can�of�course�b�Ge�written�with�the�help�of�other�mathematical�libraries�than�P��*�ARI!),�=�and�to���easily�UUand�ecien���tly�imp�Gort�foreign�functions�for�use�under�GP�(see�Section�3.11.2.13).����W��*�e�y�are�a���w�are�y�of�three�P�ARI-related�public�domain�libraries.�ߟW�e��neither���endorse�nor�supp��}'ort����an���y���of�them.��Y��*�ou�migh�t�w�an�t�to�giv�e�them�a�try�if�y�ou�are�familiar�with�the�languages�they�are���based�?on.�jZFirst,�C�there�are��PariPerl�*,�written�b���y�Ily�a�Zakharevic�h�(�[email protected]�),���and�ԫ�PariPython�**,�4�b���y�St���Gefane�F��*�ermigier�(�[email protected]�).���Finaly�,�4�Mic���hael�Stoll��?�ff��ߟ����	��*��UUsee�UU�http://nswt.tuwien.ac.at:8000/htdocs/internet/unix/perl/math-pari.html��������**��UUsee�UU�http://www.math.jussieu.fr/��&f~��?�fermigie/PariPython/readme.html�������46���/�������Kf�����卫(�Michael���E�ff&f��ǫ[email protected]�)�mhas�in���tegrated�P��*�ARI�9in�to��CLISP�,�whic�h�is�a�Common�Lisp���implemen���tation��eb�y�Bruno�Haible,��iMarcus�Daniels�and�others.�m�These�pro�vide�in�terfaces�to�GP���functions�$Ifor�use�in��perl�,�.�python��or��Lisp��programs.�anT��*�o�our�kno���wledge,�only�the��python��and��perl����in���terfaces��oha�v�e�b�Geen�upgraded�to�v�ersion�2.0�of�P��*�ARI,�the��CLISP��X�one�b�Geing�still�based�on�v�ersion���1.39.�xx�.��,7��2.9��The�preferences�le�.������This���le,��Ccalled��gprc��in�the�sequel,�is�used�to�mo�Gdify�or�extend�GP���default�b�eha���viour,��Cin�all�GP���sessions:��we.g���customize��default��v��q�alues�or�load�common�user�functions�and�aliases.� �GP���op�Gens�the����gprc�c�le�and�pro�Gcesses�the�commands�in�there,�g��b��}'efor�e�$>�doing�c�an���ything�else,�e.g.�creating�the�P��*�ARI���stac���k.���If�խthe�le�do�Ges�not�exist�or�cannot�b�e�read,���GP�Ջwill�pro�ceed�to�the�initialization�phase�at���once,�'�ev���en�tually� emitting�a�prompt.�^�If�an���y�explicit�command�line�switc�hes�are�giv�en,�'�they�o�v�erride���the�UUv��q�alues�read�from�the�preferences�le.��z��2.9.1�zdWhere�is�it?�Wk�When�AGP�-is�started,�it�lo�Goks�for�a�customization�le,�or��gprc��in�the�follo���wing���places�UU(in�this�order,�only�the�rst�one�found�will�b�Ge�loaded):������{ӫOn�the�Macin���tosh�(only),��sGP�{�lo�Goks�in�the�directory�whic�h�con�tains�the�GP�{�executable�itself�for���a�UUle�called��gprc�.�q�No�other�places�are�examined.�����º�If�the�op�Gerating�system�supp�orts�en���vironmen�t�ºv��q�ariables�(essen���tially��*�,��an�ything�ºbut�MacOS),�GP���c���hec�ks�gwhether�the�en���vironmen�t�gv��q�ariable��GPRC�T�is�set.�YxUnder�DOS,�y���ou�can�set�it�in��AUTOEXEC.BAT�.���On�UUUnix,�this�can�b�Ge�done�with�something�lik���e:��魍����GPRC=/my/dir/anyname;�?�export�GPRC������?��in�UU�sh��syn���tax�(for�instance�in�y�our��.profile�),���������setenv�?�GPRC�/my/dir/anyname������?��in�UU�csh��syn���tax�(in�y�our��.login��or��.cshrc��le).�����If�UUso,�the�le�named�b���y��$GPRC��is�the��gprc�.�����UU�If��GPRC��is�not�set,�and�if�the�en���vironmen�t�UUv��q�ariable��HOME��is�dened,�GP�then�tries�����$HOME/.gprc�UU�on�a�Unix�system�����$HOME\���E�ff&f��rSgprc�UU�on�a�DOS,�OS/2,�or�Windo���ws�system.�����UU�If��HOME��also�lea���v�es�UUus�clueless,�w���e�try������&f�~��?�/.gprc�UU�on�a�Unix�system�(where�as�usual���&f�~��ꧫstands�for�y���our�home�directory),�or�����\���E�ff&f��rSgprc�UU�on�a�DOS,�OS/2,�or�Windo���ws�system.������{�Finally��*�,�Lif�no�gprc�w���as�found�among�the�user�les�men�tioned�ab�Go�v�e�w�e�lo�Gok�for��/etc/gprc����(�\etc\gprc�)�Ρfor�a�system-wide�gprc�le�(y���ou�will�need�ro�Got�privileges�to�set�up�suc�h�a�le�y�ourself��).����Note��%that�on�Unix�systems,�the��gprc�'s�default�name�starts�with�a�'.'�98and�th���us�is�hidden�to���regular�UU�ls��commands;�y���ou�need�to�t�yp�Ge��ls�?�-a��to�list�it.�������47���0�9�����Kf�������2.9.2��TSyn��9tax���捑�The�j�syn���tax�in�the��gprc��le�(and�v��q�alid�in�this�le�only)�is�simple-minded,���but�should�b�Ge�sucien�t���for�bGmost�purp�Goses.���The�le�is�read�line�b���y�line;�h�as�usual,�e�white�space�is�ignored�unless�surrounded���b���y�_quotes�and�the�standard�m�ultiline�constructions�using�braces,�1b�\�,�or�_�=��are�a�v��q�ailable�(m�ultiline���commen���ts�UUb�Get�w�een��/*��?��:���:�:���I�*/��are�also�recognized).���̍�2.9.2.1��TPrepro�Q�cessor:�qǫTw���o�UUt�yp�Ges�of�lines�are�rst�dealt�with�b�y�a�prepro�Gcessor:�������t�commen���ts�are�remo�v�ed.�V#This�applies�to�all�text�surrounded�b�y��/*��?��:���:�:���I�*/��as�w�ell�as�to���ev���erything�UUfollo�wing��\\��on�a�giv�en�line.��������lines�starting�with��#if���b��}'o�ole�an��':�are�treated�as�commen���ts�if���b��}'o�ole�an���ev��q�aluates�to��false�,���and���read��6normally�otherwise.�<kThe�condition�can�b�Ge�negated�using�either��#if�?�not��(or��#if�!�).�<kIf�the���rest�7?of�the�curren���t�line�is�empt�y��*�,�=Cthe�test�applies�to�the�next�line�(same�b�Geha�viour�as��=��under�GP).���Only�UUthree�tests�can�b�Ge�p�erformed:�����EMACS�:�UU�true��if�GP�is�running�in�an�Emacs�or�T��*�eXmacs�shell�(see�Section�2.10).�����READL�:�UU�true��if�GP�is�compiled�with��readline��supp�Gort�(see�Section�2.11.1).�����VERSION����op���|�numb��}'er��3���:�i^where���!�op��|��is��!in�the�set��f��>���;����<��	q�;����<�=��8�;����>�=���g�,��and���!�numb��}'er��(�=�is��!a�P��*�ARI��v���ersion���n���um�b�Ger��of�the�form���Major��Km�.��Minor��>�.��p��}'atch����,��swhere�the�last�t���w�o��comp�onen�ts��can�b�e�omitted�(i.e.�1�is���understo�Go�d�UUas�v���ersio�1�:�0�:�0).�q�This�is��true��if�GP's�v�ersion�n�um�b�Ger�satises�the�required�inequalit�y��*�.���̍�2.9.2.2�K�Commands:��U�After��the�prepro�Gcessing�the�remaining�lines�are�executed�as�sequence�of���expressions�UU(as�usual,�separated�b���y��;��if�necessary).�q�Only�t�w�o�kinds�of�expressions�are�recognized:��������default��$C�=���value���,�#�where���default���is�one�of�the�a���v��q�ailable�defaults�(see�Section�2.1),�whic���h�will�b�Ge���set�UUto���value�����on�actual�startup.�q�Don't�forget�the�quotes�around�strings�(e.g.�for��prompt��or��help�).������G��read�?�"��some����ff���GP����ff��le��9b��"��where���some����ff���GP����ff��le��A�\�is�a�regular�GP�G�script�this�time,��_whic���h�will�b�Ge���read��]just�b�Gefore�GP��Jprompts�y���ou�for�commands,��but�after�initializing�the�defaults.�R�In�particular,���le�TAinput�is�dela���y�ed�TAun�til�the��gprc��has�b�Geen�fully�loaded.�n�This�is�the�righ�t�place�to�input�les���con���taining�UU�alias��commands,�or�y�our�fa�v�orite�macros.���F��*�or�UUinstance�y���ou�could�set�y�our�prompt�in�the�follo�wing�p�Gortable�w�a�y:�����\\�?�self�modifying�prompt�looking�like���(18:03)�UU�gp��>�����prompt���=�?�"(%H:%M)�\e[1mgp\e[m�>�"����\\�?�readline�wants�non-printing�characters�to�be�braced�between�^A/^B�pairs����#if�?�READL�prompt�=�"(%H:%M)�^A\e[1m^Bgp^A\e[m^B�>�"����\\�?�escape�sequences�not�supported�under�emacs����#if�?�EMACS�prompt�=�"(%H:%M)�gp�>�"���捫Note�UUthat�an���y�of�the�last�t�w�o�lines�could�b�Ge�brok�en�in�the�follo�wing�w�a�y�����#if�?�EMACS�����prompt�?�=�"(%H:%M)�gp�>�"����since�UUthe�prepro�Gcessor�directiv���e�applies�to�the�next�line�if�the�curren�t�one�is�empt�y��*�.����A��sample��2�gprc��le�called��misc/gprc.dft��is�pro���vided�in�the�standard�distribution.�MIt�is�a�go�Go�d���idea�P�to�ha���v�e�P�a�lo�Gok�at�it�and�customize�it�to�y���our�needs.�d�Since�this�le�do�es�not�use�m���ultiline���constructs,�UUhere�is�one�(note�the�terminating��;��to�separate�the�expressions):�����#if�?�VERSION�>�2.2.3�������48���1�������Kf�����卑�{��&����read�?�"my_scripts";�?�\\�syntax�errors�in�older�versions�����new_galois_format�?�=�1;�\\�default�introduced�in�2.2.4����}����#if�?�!�EMACS����{�����colors�?�=�"9,�5,�no,�no,�4,�1,�2";�����help���=�?�"gphelp�-detex�-ch�4�-cb�0�-cu�2";����}��%[��2.10��Using�GP�under�GNU�Emacs�.������If���GNU���Emacs�is�installed�on�y���our�mac�hine,�.it�is�p�Gossible�to�use�GP���as�a�subpro�cess�in�Emacs.���T��*�o�UUuse�this,�y���ou�should�include�in�y�our��.emacs��le�the�follo�wing�lines:�������(autoload�?�'gp-mode�"pari"�nil�t)����(autoload�?�'gp-script-mode�"pari"�nil�t)����(autoload�?�'gp�"pari"�nil�t)����(autoload�?�'gpman�"pari"�nil�t)����(setq�?�auto-mode-alist�����(cons�?�'("\\.gp$"�.�gp-script-mode)�auto-mode-alist))��s���whic���h�V+autoloads�functions�from��pari.el�.�tHSee�also��pariemacs.txt�.�These�les�are�included�in�the���P��*�ARI�UUdistribution�and�are�installed�at�the�same�time�as�GP�.����Once��this�is�done,�խunder�GNU���Emacs�if�y���ou�t�yp�Ge��M-x�?�gp��(where�as�usual��M���is�the��Meta��k�ey��*�,���i.e.�(�Escap�Ge,�1�or�on�SUN�(�k���eyb�oards,�1�the�Left�k���ey),�a�sp�Gecial�shell�will�b�e�started,�1�whic���h�in�particular���launc���hes�9�GP�9�with�the�default�stac�k�size,�?Hprime�limit�and�input�buer�size.�h�If�y�ou�t�yp�Ge�instead��C-u���M-x�?�gp�,��7y���ou���will�b�Ge�ask�ed�for�the�name�of�the�GP���executable,��7the�stac�k�size�and�the�prime�limit���b�Gefore���the�execution�of�GP���b�egins.�MRIf�for�an���y�of�these�y�ou�simply�t�yp�Ge�return,���the�default�v��q�alue�will���b�Ge���used.�DFOn�UNIX�̭mac���hines�it�will�b�e�the�place�y���ou�told��Configure��(usually��/usr/local/bin/gp�)���for�UUthe�executable,��10M��for�the�stac���k�and��500k��for�the�prime�limit.������Y��*�ou���can�then�w���ork�as�usual�under�GP�,�but�with�t���w�o���notable�adv��q�an���tages�(whic�h�don't�really���matter�if�readline�is�a���v��q�ailable�to�y�ou,�.|see�b�Gelo�w).�z�First�and�foremost,�.|y�ou�ha�v�e�at�y�our�disp�Gosal���all�Snthe�facilities�of�a�text�editor�lik���e�Emacs,�S�in�particular�for�correcting�or�cop�ying�blo�Gc�ks.�q%Second,���y���ou��can�ha�v�e�an�on-line�help�whic�h�is�m�uc�h�more�complete�than�what�y�ou�obtain�b�y�t�yping��?name�.���This���is�done�b���y�t�yping��M-?�.�LHIn�the�minibuer,��XEmacs�asks�what�function�y�ou�w�an�t�to�describ�Ge,��Xand���after�O�y���our�reply�y�ou�obtain�the�description�whic�h�is�in�the�users�man�ual,�P�including�the�description���of�UUfunctions�(suc���h�as��\�,��%�)�whic�h�use�sp�Gecial�sym�b�Gols.����This��help�system�can�also�b�Ge�men���u-driv�en,�b�y��using�the�command��M-\c��whic���h�op�ens�a�help���men���u���windo�w�whic�h�enables�y�ou�to�c�ho�Gose�the�category�of�commands�for�whic�h�y�ou�w�an�t�an���explanation.����Nev���ertheless,��if��extended�help�is�a�v��q�ailable�on�y�our�system�(see�Section�2.2.1),��y�ou�should�use�it���instead�UUof�the�ab�Go���v�e,�UUsince�it's�nicer�(it�ran�through�T���U>�'E���xX)�and�understands�man���y�more�k�eyw�ords.����Finally��y���ou�can�use�command�completion�in�the�follo�wing�w�a�y��*�.��hAfter�the�prompt,�2�t�yp�Ge�the���rst�>few�letters�of�the�command,�Cthen��<TAB>��where��<TAB>��is�the�T��*�AB�>yk���ey�.�j*If�>there�exists�a�unique���command�qXstarting�with�the�letters�y���ou�ha�v�e�t�yp�Ged,�xYthe�command�name�will�b�e�completed.���If�not,�������49���2������Kf�����卫either�~4the�list�of�commands�starting�with�the�letters�y���ou�t�yp�Ged�will�b�e�displa���y�ed�~4in�a�separate���windo���w���(whic�h�y�ou�can�then�kill�b�y�t�yping�as�usual��C-x�?�1��or�b�y�t�yping�in�more�letters),��or�\no���matc���h���found"�will�b�Ge�displa�y�ed�in�the�Emacs�command�line.�+,If�y�our�GP��Nw�as�link�ed�with�the�readline���library��*�,��read���the�section�on�completion�in�the�section�b�Gelo���w�(the�paragraph�on�online�help�is�not���relev��q�an���t).��܍�Note�Tthat�if�for�some�reason�the�session�crashes�(due�to�a�bug�in�y���our�program�or�in�the�P��*�ARI���system),�/�y���ou�&will�usually�sta�y�under�Emacs,�/�but�the�GP�&	buer�will�b�Ge�killed.�bT��*�o�reco�v�er�it,�/�simply���t���yp�Ge�l3again��M-x�?�gp��(or��C-u�M-x�gp�),�q�and�a�new�session�of�GP�l-will�b�Ge�started�after�the�old�one,�so���y���ou��+can�reco�v�er�what�y�ou�ha�v�e�t�yp�Ged.�R�Note�that�this�will�of�course��not���w�ork�if�for�some�reason�y�ou���kill�UUEmacs�and�start�a�new�session.��#Ѝ�Y��*�ou��Qalso�ha���v�e��Qat�y���our�disp�Gosal�a�few�other�commands�and�man�y�p�Gossible�customizations���(colours,�UUprompt).�q�Read�the�le��emacs/pariemacs.txt��in�standard�distribution�for�details.��$P���2.11��Using�GP�with�readline�.����Thanks�q�to�the�initial�help�of�Ily���a�Zakharevic�h,�� there�is�a�p�Gossibilit�y�of�line�editing�and�command���name�o�completion�outside�of�an�Emacs�buer��if��n�y���ou�ha�v�e�compiled�GP�o�with�the�GNU�readline���library��*�.��YIf���y���ou�don't�ha�v�e�Emacs�a�v��q�ailable,��|or�can't�stand�using�it,�w���e�really�advise�y�ou�to�mak�e���sure���y���ou�get�this�v�ery�useful�library�b�Gefore�conguring�or�compiling�GP��*�.�In�fact,��with��readline�,���ev���en�UUline�editing�b�Gecomes��mor��}'e���p�o���w�erful�UUoutside�an�Emacs�buer!��5���2.11.1�
�A�
�(to�Q�o)�short�in��9tro�duction�to�readline�:�	��The���basics�are�as�follo���ws�(read�the�readline���user��man���ual�!),�dassume�that��C-��stands�for�\the��Control��k�ey�com�bined�with�another"�and�the�same���for��&�M-��with�the��Meta��k���ey�(generally��C-��com�binations�act�on�c�haracters,���while�the��M-��ones�op�Gerate���on�6�w���ords).�g�The��Meta��k�ey�migh�t�b�Ge�called��Alt��on�some�k�eyb�Goards,�<�will�displa�y�a�blac�k�diamond�on���most���others,���and�can�safely�b�Ge�replaced�b���y��Esc��in�an�y�case.���T�yping�an�y�ordinary�k�ey�inserts�text���where��fthe�cursor�stands,���the�arro���w�k�eys�enabling�y�ou�to�mo�v�e�in�the�line.���There�are�man�y�more���mo���v�emen�t�vcommands,��whic�h�will�b�Ge�familiar�to�the�Emacs�user,��for�instance��C-a�/�C-e��will�tak�e�y�ou���to��the�start/end�of�the�line,�j�M-b�/�M-f��mo���v�e��the�cursor�bac���kw�ard/forw�ard��b�y�a�w�ord,�jetc.�VPJust�press���the�UU�<Return>��k���ey�at�an�y�p�Goin�t�to�send�y�our�command�to�GP��*�.��܍�All��the�commands�y���ou�t�yp�Ge�in�are�stored�in�a�history�(with�m�ultiline�commands�b�Geing�sa�v�ed�as���single�w�concatenated�lines).�'�The�Up�and�Do���wn�arro�ws�(or��C-p�/�C-n�)�will�mo�v�e�y�ou�through�it,��7�M-<�/�M-���>��٫sending�y���ou�to�the�start/end�of�the�history��*�.�T��C-r�/�C-s��will�start�an�incremen�tal�bac�kw�ard/forw�ard���searc���h.��"Y��*�ou�ycan�kill�text�(�C-k��kills�till�the�end�of�line,���M-d��to�the�end�of�curren�t�w�ord)�whic�h�y�ou���can��then�y���ank�bac�k�using�the��C-y��k�ey�(�M-y��will�rotate�the�kill-ring).�<�C-���E�ff&f��{��will�undo�y�our�last�c�hanges���incremen���tally���(�M-r��undo�Ges�all�c�hanges�made�to�the�curren�t�line).����C-t��and��M-t��will�transp�Gose�the���c���haracter�UU(w�ord)�preceding�the�cursor�and�the�one�under�the�cursor.����Keeping���the��M-��k���ey�do�wn�while�y�ou�en�ter�an�in�teger�(a�min�us�sign�meaning�rev�erse�b�Geha�viour)���giv���es�_�an�argumen�t�to�y�our�next�readline�command�(for�instance��M--�?�C-k��will�kill�text�bac�k�to�the���start�UUof�line).�q�If�y���ou�prefer�Vi{st�yle�editing,��M-C-j��will�toggle�y�ou�to�Vi�mo�Gde.����Of�UPcourse�y���ou�can�c�hange�all�these�default�bindings.�q�F��*�or�that�y�ou�need�to�create�a�le�named����.inputrc��s�in�y���our�home�directory��*�.�/�F�or��sinstance�(notice�the�em�b�Gedding�conditional�in�case�y�ou�w�ould���w���an�t�UUsp�Gecic�bindings�for�GP):��#Ѝ��$if�?�Pari-GP����set�?�show-all-if-ambiguous�������50���3������Kf�����卑��"\C-h":�?�backward-delete-char�����"\e\C-h":�?�backward-kill-word�����"\C-xd":�?�dump-functions�����(:�?�"\C-v()\C-b"�$��#����c��}'an�b�e�annoying�when�c�opy-p�asting�!������[:�?�"\C-v[]\C-b"����$endif���C-x�?�C-r�ǫwill�re-read�this�init�le,�$�incorp�Gorating�an���y�c�hanges�made�to�it�during�the�curren�t�session.����Note:���By��default,�Ra�(��and��[��are�b�Gound�to�the�function��pari-matched-insert��whic���h,�if�\electric���paren���theses"�are�enabled�(default:�S�o��)�will�automatically�insert�the�matc�hing�closure�(resp�Gectiv�ely����)��@�and��]�).���This�b�Geha���viour�can�b�e�toggled�on�and�o�b���y�giving�the�n�umeric�argumen�t���2�to��(����(�M--2(�),��"whic���h��`is�useful�if�y�ou�w�an�t,��"e.g�to�cop�y-paste�some�text�in�to�the�calculator.�
�If�y�ou�don't���w���an�t�UUa�toggle,�y���ou�can�use��M--0��/��M--1��to�sp�Gecically�switc�h�it�on�or�o��).����Note:�N�In�C�recen���t�v�ersions�of�readline�(2.1�for�instance),��the��Alt��or��Meta��k�ey�can�giv�e�funn�y�re-���sults�L�(output�8-bit�accen���ted�c�haracters�for�instance).�W�If�y�ou�don't�w�an�t�to�fall�bac�k�to�the��Esc����com���bination,�UUput�the�follo�wing�t�w�o�lines�in�y�our��.inputrc�:������set�?�convert-meta�on�����set�?�output-meta�off����2.11.2��TCommand�completion�and�online�help�����As��,in�the�Emacs�shell,���<TAB>��will�complete�w���ords�for�y�ou.�;But,��under�readline,�this�mec���hanism���will�`�b�Ge�con���text-dep�enden�t:���GP�`�will�`�striv�e�to�only�giv�e�y�ou�meaningful�completions�in�a�giv�en�con�text���(it�UUwill�fail�sometimes,�but�only�under�rare�and�restricted�conditions).����F��*�or�~instance,�)vshortly�after�a���&f�~��^{�,�w���e�exp�Gect�a�user�name,�then�a�path�to�some�le.�_�Directly�after����default(���has�b�Geen�t���yp�ed,�:jw�e��w�ould�exp�Gect�one�of�the��default��k�eyw�ords.���After��whatnow(��,�:jw�e���exp�Gect���the�name�of�an�old�function,��`whic���h�ma�y�w�ell�ha�v�e�disapp�Geared�from�this�v�ersion.��After�a���'.',��yw���e��>exp�Gect�a�mem�b�Ger�k�eyw�ord.�(�And�generally�of�course,��yw�e�exp�Gect�an�y�GP��/sym�b�Gol�whic�h�ma�y���b�Ge�UUfound�in�the�hashing�lists:�q�functions�(b�oth�y���ours�and�GP's),�and�v��q�ariables.����If,�UUat�an���y�time,�only�one�completion�is�meaningful,�GP�will�pro�vide�it�together�with������UU�an�ending�comma�if�w���e're�completing�a�default,������i�a�pair�of�paren���theses�if�w�e're�completing�a�function�name.���In�that�case�hitting��<TAB>��again���will�UUpro���vide�the�argumen�t�list�as�giv�en�b�y�the�online�help*.����Otherwise,� �hitting���<TAB>��once�more�will�giv���e�y�ou�the�list�of�p�Gossible�completions.�[�Just�exp�eri-���men���t��with�this�mec�hanism�as�often�as�p�Gossible,��y�ou'll�probably�nd�it�v�ery�con�v�enien�t.�/F��*�or�instance,���y���ou�^Xcan�obtain��default(seriesprecision,10)�,�`�just�b�y�hitting��def<TAB>se<TAB>10�,�`�whic�h�sa�v�es���18�UUk���eystrok�es�(out�of�27).����Hitting�6�M-h��will�giv���e�y�ou�the�usual�short�online�help�concerning�the�w�ord�directly�b�Geneath�the���cursor,�7:�M-H�/��will�/�yield�the�extended�help�corresp�Gonding�to�the��help��default�program�(usually�op�ens���a�dvi�preview���er,�G�or�runs�a�primitiv�e�tex-to-ASCI�GI��program).��None�of�these�disturb�the�line�y�ou���w���ere�UUediting.��&L��ff��ߟ����	��*��recall�UUthat�y���ou�can�alw�a�ys�undo�the�eect�of�the�preceding�k�eys�b�y�hitting��C-���E�ff&f��������51���4�w�����Kf�����52���5����Kf�����卒����Chapter��/3:���_��1~�F���4unctions��/and�Op�dCerations�Av��7xailable�in�P�ARI�and�GP��-��The�gXfunctions�and�op�Gerators�a���v��q�ailable�in�P��*�ARI�gSand�in�the�GP/P�ARI�gScalculator�are�n���umerous�and���ev���erexpanding.�hHere�88is�a�description�of�the�ones�a�v��q�ailable�in�v�ersion�2.2.7.�hIt�should�b�Ge�noted�that���man���y�o�of�these�functions�accept�quite�dieren�t�t�yp�Ges�as�argumen�ts,�v]but�others�are�more�restricted.���The���list�of�acceptable�t���yp�Ges�will�b�e�giv���en�for�eac�h�function�or�class�of�functions.�6�Except�when�stated���otherwise,��Vit���is�understo�Go�d���that�a�function�or�op�Geration�whic���h�should�mak�e�natural�sense�is�legal.���In��\this�c���hapter,���w�e��\will�describ�Ge�the�functions�according�to�a�rough�classication.�?The�general�en���try���lo�Goks�UUsomething�lik���e:���/���fo�Q�o�(�x;����f��flag����=��0�g�):�q�short�UUdescription.����The�UUlibrary�syn���tax�is���f�o�Q�o�����(�x;�����flag���t�).���This��means�that�the�GP��function��foo��has�one�mandatory�argumen���t��x�,���and�an�optional�one,���flag���U�,���whose�`default�v��q�alue�is�0.���(The��fg��should�not�b�Ge�t���yp�ed,�b�it�is�just�a�con���v�enien�t�`notation�w���e�will�use���throughout��Lto�denote�optional�argumen���ts.)���That�is,�Ɋy�ou�can�t�yp�Ge��foo(x,2)�,�Ɋor��foo(x)�,�whic���h�is���then��4understo�Go�d�to�mean��foo(x,0)�.��cAs�w���ell,���a�comma�or�closing�paren�thesis,���where�an�optional���argumen���t�y�should�ha�v�e�b�Geen,��signals�to�GP�y�it�should�use�the�default.�ߋTh�us,��the�syn�tax��foo(x,)���is���also���accepted�as�a�synon���ym�for�our�last�expression.�*�When�a�function�has�more�than�one�optional���argumen���t,��$the���argumen�t�list�is�lled�with�user�supplied�v��q�alues,��$in�order.���When�none�are�left,�the���defaults�UUare�used�instead.�q�Th���us,�assuming�that��foo�'s�protot�yp�Ge�had�b�een��O�������fo�Q�o�(�f�x���=�1�g�;����f�y�"�=�2�g�;��f�z�7��=�3�g�),����t���yping��Gin��foo(6,4)��w�ould�giv�e�y�ou��foo(6,4,3)�.���In�the�rare�case�when�y�ou�w�an�t�to�set�some�far���a���w�a�y�Qargumen�t,���and�lea�v�e�the�defaults�in�b�Get�w�een�as�they�stand,���y�ou�can�use�the�\empt�y�arg"���tric���k�3alluded�to�ab�Go�v�e:�-Y�foo(6,,1)��w�ould�yield��foo(6,2,1)�.�"By�the�w�a�y��*�,�j��foo()��b�y�itself�yields����foo(1,2,3)�UU�as�w���as�to�b�Ge�exp�ected.���/��In�ݗthis�rather�sp�Gecial�case�of�a�function�ha���ving�no�mandatory�argumen�t,���y�ou�can�ev�en�omit�the���():�
Ea���standalone��foo��w���ould�b�Ge�enough�(though�w�e�don't�really�recommend�it�for�y�our�scripts,���for���the�a�sak���e�of�clarit�y).��!In�dening�GP�a�syn�tax,�d�w�e�stro�v�e�to�put�optional�argumen�ts�at�the�end�of�the���argumen���t��2list�(of�course,���since�they�w�ould�not�mak�e�sense�otherwise),���and�in�order�of�decreasing���usefulness�UUso�that,�most�of�the�time,�y���ou�will�b�Ge�able�to�ignore�them.����Finally��*�,�[email protected]�roptional�argumen���t�(b�Get�w�een�braces)�follo�w�ed�b�y�a�star,�[email protected]�e��f��x���ѷg�,�[email protected]�that�an�y���n���um�b�Ger�vof�suc���h�argumen�ts�(p�Gossibly�none)�can�b�e�giv���en.��This�is�in�particular�used�b�y�the�v��q�arious����print�UU�routines.��^��Flags�.���A�o��flag�R��is�pan�argumen���t�whic�h,���rather�than�con�v�eying�actual�information�to�the�routine,���in���tructs�r&it�to�c�hange�its�default�b�Geha�viour,�yZe.g.�return�more�or�less�information.��:All�suc�h�
ags�are���optional,�!and��will�b�Ge�called���flag��`ޫin�the�function�descriptions�to�follo���w.�\.There�are�t�w�o�dieren�t�kind���of�UU
ags������i̫generic:��all�v��q�alid�v�alues�for�the�
ag�are�individually�describ�Ged�(\If���flag��d�is�equal�to�1,���then��:���:�:��
UO�").�������binary:��use�customary�binary�notation�as�a�compact�w���a�y��to�represen���t�man�y�toggles�with���just�one�in���teger.�_�Let�(�p����0��|s�;����:�:�:����;���p����n��q~�)�b�Ge�a�list�of�switc�hes�(i.e.�of�prop�Gerties�whic�h�tak�e�either�the�v��q�alue���0�l#or�1),�q�the�n���um�b�Ger�l#2���^��3��ć�+�H2���^��5��i��=��40�means�that��p����3��薫and��p����5���are�set�(that�is,�q�set�to�1),�and�none�of�the���others�I�are�(that�is,�Lthey�are�set�to�0).�m�This�is�announced�as�\The�binary�digits�of���flag���,�mean�1:�k�p����0��|s�,���2:�qDZp����1��|s�,�UU4:��p����2���",�UUand�so�on,�using�the�a���v��q�ailable�consecutiv�e�p�Go�w�ers�of�2.�������53���6�፟���Kf�������Mnemonics���for�
ags�.���Numeric�

ags�as�men���tionned�ab�Go�v�e�are�obscure,�:�error-prone,�and�
quite���rigid:��Kshould�_the�authors�w���an�t�_to�adopt�a�new�
ag�n���um�b�Gering�_sc�heme�(for�instance�when�noticing���
ags�%�with�the�same�meaning�but�dieren���t�n�umeric�v��q�alues),�/it�w�ould�break�bac�kw�ard�compatibilit�y��*�.���The�'Vonly�adv��q�an���tage�of�explicit�n�umeric�v��q�alues�is�that�they�are�fast�to�t�yp�Ge,�[�so�their�use�is�only���advised�UUwhen�using�the�calculator�GP��*�.���⍑As��an�alternativ���e,�C�one�can�replace�a�n�umeric�
ag�b�y�a�c�haracter�string�con�taining�sym�b�Golic���iden���tiers.��.F��*�or�v"a�generic�
ag,�~Uthe�mnemonic�corresp�Gonding�to�the�n�umeric�iden�tier�is�giv�en�after���it�UUas�in�(tak���en�from�description�of���log��L�(�x;����f��flag����=��0�g�)):����i��If��UU�flag���v�is�UUequal�to�1��=���AGM����,�UUuse�an�agm�form���ula��:���:�:�����whic���h�UUmeans�that�one�can�use�indieren�tly��log(�x�,�?�1)��or��log(�x�,�AGM)�.����F��*�or��za�binary�
ag,���mnemonics�corresp�Gonding�to�the�v��q�arious�toggles�are�giv���en�after�eac�h�of�them.���They�hcan�b�Ge�negated�b���y�prep�ending��no���E�ff&f����to�the�mnemonic,�1mor�b���y�remo�ving�suc�h�a�prex.��These���toggles��are�group�Ged�together�using�an���y�punctuation�c�haracter�(suc�h�as�','��#or�';').�0�F��*�or�instance�(tak�en���from�UUdescription�of���ploth���F�(�X����=���a;���b;���expr��O>�;��f��flag����=�0�g�;��f�n��=�0�g�))����G�Binary�UUdigits�of�
ags�mean:�q�1��=���Parametric��7F��,�UU2�=���Recursive��2��,���:���:�:�����so���that,��~instead�of�1,�one�could�use�the�mnemonic��"Parametric;�?�no���E�ff&f��ǫRecursive"�,�or�simply��"Para-���metric"�UU�since��Recursive��is�unset�b���y�default�(default�v��q�alue�of���flag���v�is�0,�i.e.�ev�erything�unset).��R#��P��9oin�ters�.�q�If�UUa�parameter�in�the�function�protot���yp�Ge�is�prexed�with�a�&�sign,�as�in�����fo�Q�o�(�x;����&�e�)���it�i�means�that,���b�Gesides�the�normal�return�v��q�alue,�the�function�ma���y�assign�a�v��q�alue�to��e��as�a�side���eect.���When���passing�the�argumen���t,��Athe�&�sign�has�to�b�Ge�t�yp�Ged�in�explicitly��*�.���As�of�v�ersion�2.2.7,���this���pointer��argumen���t�is�optional�for�all�do�Gcumen�ted�functions,��hence�the�&�will�alw�a�ys�app�Gear���b�Get���w�een�UUbrac�k�ets�as�in��issquare�(�x;����f�&�e�g�).��R#��Ab�Q�out�[^library�programming�.�kEthe����libr��}'ary��&Oޫfunction���foo�,��Ias�dened�at�the�b�Geginning�of�this���section,��is��seen�to�ha���v�e��t�w�o�mandatory�argumen�ts,���x��and���flag��)u�:�?�no�P��*�ARI��mathematical�function�has���b�Geen��rimplemen���ted�so�as�to�accept�a�v��q�ariable�n�um�b�Ger�of�argumen�ts,��so�all�argumen�ts�are�mandatory���when���programming�with�the�library�(often,���v��q�arian���ts�are�pro�vided�corresp�Gonding�to�the�v��q�arious���
ag��v��q�alues).�4When�not�men���tioned�otherwise,��Cthe�result�and�argumen�ts�of�a�function�are�assumed���implicitly��-to�b�Ge�of�t���yp�e��GEN�.�Most�other�functions�return�an�ob��8ject�of�t���yp�e��long��in���teger�in�C��!(see���Chapter�UU4).�q�The�v��q�ariable�or�parameter�names���pr��}'e�c�����and���flag���v�alw���a�ys�UUdenote��long��in���tegers.����The�\�entree��t���yp�Ge�is�used�b�y�the�library�to�implemen�t�iterators�(lo�Gops,�.�sums,�in�tegrals,�etc.)���when��a�formal�v��q�ariable�has�to�successiv���ely�assume�a�n�um�b�Ger�of�v��q�alues�in�a�giv�en�set.�	TWhen���programming�Έwith�the�library��*�,�,�it�is�easier�and�m���uc�h�Έmore�ecien���t�to�co�Gde�lo�ops�and�the�lik���e���directly��*�.�unHence�V�this�t���yp�Ge�is�not�do�cumen���ted,���although�it�do�es�app�ear�in�a�few�library�function���protot���yp�Ges�UUb�elo�w.�q�See�UUSection�3.9�for�more�details.�������54���7ٍ����Kf�������3.1��Standard�monadic�or�dy��adic�op�`erators�.��(��3.1.1����+�=�-�:��The��uexpressions��+�x��and��-�x��refer�to�monadic�op�Gerators�(the�rst�do�es�nothing,��othe�second���negates�UU�x�).��3��The�UUlibrary�syn���tax�is���gneg����(�x�)�for��-�x�.���~��3.1.2��(�+�,��-�:���The���expression��x��+��y�E��is�the�sum�and��x��-��y��is�the�difference�of��x��and��y�[٫.�/jAmong�the���prominen���t��imp�Gossibilities�are�addition/subtraction�b�et���w�een��a�scalar�t���yp�e�and�a�v���ector�or�a�matrix,���b�Get���w�een�UUv�ector/matrices�of�incompatible�sizes�and�b�Get�w�een�an�in�tegermo�Gd�and�a�real�n�um�b�Ger.����The�UUlibrary�syn���tax�is���gadd��s��(�x;���y�[٫)��x��+��y��,���gsub��e��(�x;���y��)�for��x��-��y��.���~��3.1.3����*�:�gqThe�@�expression��x��*��y����is�the�pro�Gduct�of��x��and��y�[٫.�j�Among�the�prominen���t�imp�ossibilities�are���m���ultiplication�(mb�Get�w�een�v�ector/matrices�of�incompatible�sizes,�]2b�Get�w�een�an�in�tegermo�Gd�and�a�real���n���um�b�Ger.�/9Note���that�b�ecause�of�v���ector�and�matrix�op�erations,����*��is�not�necessarily�comm���utativ�e.�/9Note���also�;�that�since�m���ultiplication�b�Get�w�een�t�w�o�column�or�t�w�o�ro�w�v�ectors�is�not�allo�w�ed,�@�to�obtain�the���scalar�q�pro�Gduct�of�t���w�o�q�v�ectors�of�the�same�length,��wy�ou�m�ust�m�ultiply�a�line�v�ector�b�y�a�column�v�ector,���if�8necessary�b���y�transp�Gosing�one�of�the�v�ectors�(using�the�op�Gerator���&f�~��nm�or�the�function��mattranspose�,���see�UUSection�3.8).����If�UU�x��and��y��.�are�binary�quadratic�forms,�comp�Gose�them.�q�See�also��qfbnucomp��and��qfbnupow�.����The��*library�syn���tax�is���gm��9ul��#�(�x;���y�[٫)�for��x��*��y��.�GAlso�a���v��q�ailable�is���gsqr�����(�x�)�for��x��*��x��(faster�of���course!).���~��3.1.4����/�:��The��expression��x��/��y�r��is�the�quotien���t�of��x��and��y�[٫.��1In�addition�to�the�imp�Gossibilities�for���m���ultiplication,���note���that�if�the�divisor�is�a�matrix,�it�m���ust�b�Ge�an�in�v�ertible�square�matrix,���and�in���that��Lcase�the�result�is��x��з��y��[ٟ�^���1��M�.�5F��*�urthermore��Lnote�that�the�result�is�as�exact�as�p�Gossible:��in�particular,���division��lof�t���w�o��lin�tegers�alw�a�ys�giv�es�a�rational�n�um�b�Ger�(whic�h�ma�y�b�Ge�an�in�teger�if�the�quotien�t���is��exact)�and��not�
��the�Euclidean�quotien���t�(see��x��\��y�v��for�that),�Land�similarly�the�quotien�t�of�t�w�o���p�Golynomials�+�is�a�rational�function�in�general.�c�T��*�o�obtain�the�appro���ximate�real�v��q�alue�of�the�quotien�t���of��t���w�o�in�tegers,�!�add��0.�\O�to�the�result;�*eto�obtain�the�appro�ximate��p�-adic�v��q�alue�of�the�quotien�t�of�t�w�o���in���tegers,�m^add�h��O(p^k)��to�the�result;�r,nally��*�,�to�obtain�the�T��*�a���ylor�series�expansion�of�the�quotien�t�of���t���w�o�UUp�Golynomials,�add��O(X^k)��to�the�result�or�use�the��taylor��function�(see�Section�3.7.32).����The�UUlibrary�syn���tax�is���gdiv���N�(�x;���y�[٫)�for��x��/��y��.���~��3.1.5�`&�\�:�c4The��expression��x�?��\��y�)�is��the�Euclidean�quotien���t�of��x��and��y�[٫.���If��y��is�a�real�scalar,��9this�is���dened���as��floor(�x�/�y�[��)��if��y�za>���0,���and��ceil(�x�/�y��)��if��y�za<���0�and�the�division�is�not�exact.�+Hence�the���remainder�UU�x�?��-�(�x�\�y�[��)*�y��.�is�in�[0�;����j�y��j�[.����Note�/�that�when��y����is�an�in���teger�and��x��a�p�Golynomial,�fD�y��is�rst�promoted�to�a�p�Golynomial�of���degree�UU0.�q�When��x��is�a�v���ector�or�matrix,�the�op�Gerator�is�applied�comp�onen���t�wise.����The�UUlibrary�syn���tax�is���gdiv��9en�t��(:��(�x;���y�[٫)�for��x��\��y��.���~��3.1.6���\/�:��xThe���expression��x��\/��y�燫ev��q�aluates�to�the�rounded�Euclidean�quotien���t�of��x��and��y�[٫.��This�is���the���same�as��x�?��\��y�#֫except���for�scalar�division:�+the�quotien���t�is�suc�h�that�the�corresp�Gonding�remainder���is���smallest�in�absolute�v��q�alue�and�in�case�of�a�tie�the�quotien���t�closest�to�+�1��is�c�hosen�(hence�the���remainder�UUw���ould�b�Gelong�to�]�8��j�y�[ٷj�=�2�;����j�y��j�=�2]).����When�UU�x��is�a�v���ector�or�matrix,�the�op�Gerator�is�applied�comp�onen���t�wise.����The�UUlibrary�syn���tax�is���gdivround��6c}�(�x;���y�[٫)�for��x��\/��y��.�������55���8H�����Kf�������3.1.7�b��%�:�g�The��Qexpression��x�?��%��y�,*�ev��q�aluates��Qto�the�mo�Gdular�Euclidean�remainder�of��x��and��y�[٫,��whic���h���w���e��Eno�w�dene.�4�If��y���is�an�in�teger,���this�is�the�smallest�non-negativ�e�in�teger�congruen�t�to��x��mo�Gdulo����y�[٫.��If��l�y��E�is�a�p�Golynomial,��qthis�is�the�p�olynomial�of�smallest�degree�congruen���t�to��x��mo�dulo��y�[٫.��When����y���is�C?a�non-in���tegral�real�n�um�b�Ger,�Fݱx�%�y���is�dened�as��x�?��-�(�x�\�y�[��)*�y��.�k�This�C?coincides�with�the�denition���for�UU�y��.�in���teger�if�and�only�if��x��is�an�in�teger,�but�still�b�Gelongs�to�[0�;����j�y�[ٷj�[.�q�F��*�or�instance:���y���?�?�(1/2)�%�3����%1�?�=�2����?�?�0.5�%�3�����***���forbidden�?�division�t_REAL�%�t_INT.����?�?�(1/2)�%�3.0����%2�?�=�1/2�����Note�/�that�when��y����is�an�in���teger�and��x��a�p�Golynomial,�fD�y��is�rst�promoted�to�a�p�Golynomial�of���degree�UU0.�q�When��x��is�a�v���ector�or�matrix,�the�op�Gerator�is�applied�comp�onen���t�wise.����The�UUlibrary�syn���tax�is���gmo�Q�d����(�x;���y�[٫)�for��x��%��y��.��l��3.1.8��divrem�(�x;���y�[�;��f�v��g�):�#�creates�.pa�column�v���ector�with�t�w�o�comp�Gonen�ts,�d�the�rst�b�Geing�the�Eu-���clidean�Kquotien���t�(�x�?��\��y�[٫),�Mthe�Ksecond�the�Euclidean�remainder�(�x�?��-�(�x�\�y��)*�y��),�Mof�Kthe�division�of��x����b���y�� �y�[٫.�'This�a�v�oids�the�need�to�do�t�w�o�divisions�if�one�needs�b�Goth�the�quotien�t�and�the�remainder.���If�UU�v��.�is�presen���t,�and��x�,��y��are�m���ultiv��q�ariate�p�Golynomials,�divide�with�resp�ect�to�the�v��q�ariable��v�[٫.����Bew���are�H�that��divrem(�x�,�y�[��)[2]��is�in�general�not�the�same�as��x�?��%��y��;�„there�H�is�no�op�Gerator�to���obtain�UUit�in�GP:�����?�?�divrem(1/2,�3)[2]����%1�?�=�1/2����?�?�(1/2)�%�3����%2�?�=�2����?�?�divrem(Mod(2,9),�3)[2]�����***���forbidden�?�division�t_INTMOD�\�t_INT.����?�?�Mod(2,9)�%�6����%3�?�=�Mod(2,3)�����The��Xlibrary�syn���tax�is���divrem��'+��(�x;���y�[�;�v��),where��X�v�I1�is�a��long�.�9�Also�a���v��q�ailable�as���gdiv��9en�tres��7]��(�x;���y��)���when�UU�v��.�is�not�needed.��l��3.1.9���^�:���The�r�expression��x��^��?��n��is�p�Go���w�ering.���If�r�the�exp�onen���t�is�an�in�teger,�zthen�exact�op�Gerations�are���p�Gerformed���using�binary�(left-shift)�p�o���w�ering���tec�hniques.��~In�particular,���in�this�case��x��cannot�b�Ge�a���v���ector�J�or�matrix�unless�it�is�a�square�matrix�(and�moreo�v�er�in�v�ertible�if�the�exp�Gonen�t�is�negativ�e).���If����x��is�a��p�-adic�n���um�b�Ger,�	�its���precision�will�increase�if��v����p���R�(�n�)�
F�>��0.���P���o�w�ering���a�binary�quadratic���form�n�(t���yp�Ges��t_QFI�n�and��t_QFR�)�returns�a�reduced�represen���tativ�e�n�of�the�class,�uapro���vided�the�input�is���reduced.�q�In�UUparticular,��x��^��?��1�is�iden���tical�to��x�.����P��*�ARI�
Ris�
dable�to�rewrite�the�m���ultiplication��x�����x�
d�of�t�w�o��identic��}'al��ob��8jects�as��x���^��2��|s�,��or���sqr���[�(�x�)�(here,���iden���tical��means�the�op�Gerands�are�t�w�o�dieren�t�lab�Gels�referencing�the�same�c�h�unk�of�memory;�Ojno���equalit���y�UUtest�is�p�Gerformed).�q�This�is�no�longer�true�when�more�than�t�w�o�argumen�ts�are�in�v�olv�ed.����If��the�exp�Gonen���t�is�not�of�t�yp�Ge�in�teger,�J�this�is�treated�as�a�transcenden�tal�function�(see�Sec-���tion�UU3.3),�and�in�particular�has�the�eect�of�comp�Gonen���t�wise�UUp�o�w�ering�UUon�v���ector�or�matrices.����As��an�exception,��4if�the�exp�Gonen���t�is�a�rational�n�um�b�Ger��p=q��and��x��an�in�teger�mo�Gdulo�a�prime,���return�UUa�solution��y��.�of��y��[ٟ�^��q�����=���x���^��p���if�it�exists.�q�Curren���tly��*�,��q��m���ust�not�ha�v�e�large�prime�factors.�������56���9!������Kf�����卑�Bew���are�UUthat���q���?�?�Mod(7,19)^(1/2)����%1�?�=�Mod(11,�19)�/*�is�any�square�root�*/����?�?�sqrt(Mod(7,19))����%2�?�=�Mod(8,�19)�
�/*�is�the�smallest�square�root�*/����?�?�Mod(7,19)^(3/5)����%3�?�=�Mod(1,�19)����?�?�%3^(5/3)����%4�?�=�Mod(1,�19)�
�/*�Mod(7,19)�is�just�another�cubic�root�*/��2⍑�The�UUlibrary�syn���tax�is���gp�Q�o��9w�����(�x;���n;���pr��}'e�c�����)�UUfor��x��^��?��n�.���R��3.1.10�s�shift�(�x;���n;��f��flag���c�=���0�g�)��or��x��<<��n��(=��x��>>��(��n�)):��.shifts��x��comp�Gonen���t�wise��left�b���y��n��bits�if����n�/���0�-�and�righ���t�b�y��j�n�j��bits�if��n�/�<��0.��;A�-�left�-�shift�b�y��n��corresp�Gonds�to�m�ultiplication�b�y�2���^��n��q~�.��;A���righ���t�Nshift�of�an�in�teger��x��b�y��j�n�j��corresp�Gonds�to�a�Euclidean�division�of��x��b�y�2���^��j�n�j��
~�with�a�remainder���of�j�the�same�sign�as��x�,��%hence�is�not�the�same�(when��x���<��0)�j�as��x�n�2���^��j�n�j��
1~�.��"If���flag��
^�is�non-zero,�this���b�Geha���viour��eis�mo�died�and�righ���t�shift�of�a�negativ�e��x��is�͆�the�same�as��x�n�2���^��j�n�j��
,�(whic�h�is�consisten�t�with���2-complemen���t�UUseman�tic�of�negativ�e�n�um�b�Gers).����The��!library�syn���tax�is���gshif�t3��&N5�(�x;���n;���flag���t�)��!where��n��is�a��long�.�F*Also�a�v��q�ailable�is���gshif�t�� �7�(�x;���n�)�for���the�UUcase���flag��T9�=��0.���R��3.1.11�POshiftm��9ul�(�x;���n�):�7�m���ultiplies�ᩱx��b�y�2���^��n��q~�.�K9The�dierence�with��shift��is�that�when��n��<��0,���ordinary���division��tak���es�place,�Hhence�for�example�if��x��is�an�in�teger�the�result�ma�y�b�Ge�a�fraction,�Hwhile�for����shift��y�Euclidean�division�tak���es�place�when��n��<��0��yhence�if��x��is�an�in�teger�the�result�is�still�an�in�teger.����The�UUlibrary�syn���tax�is���gm��9ul2n��(��(�x;���n�)�where��n��is�a��long�.���R��3.1.12�m
Comparison�and�b�Q�o�olean�m
op�erators�.�S�The���six�standard�comparison�op�Gerators��<=�,���<�,��>=�,����>�,����==�,��!=����are�a���v��q�ailable�in�GP��*�,�and�in�library�mo�Gde�under�the�names��gle�,����glt�,��gge�,��ggt�,��geq�,��gne����resp�Gectiv���ely��*�.���The���library�syn�tax�is���c��}'o��
�ī(�x;���y�[٫),���where���c��}'o��>«is�the�comparison�op�Gerator.���The�result�is�1���(as��Aa��GEN�)��#if�the�comparison�is�true,���0�(as�a��GEN�)�if�it�is�false.�JkF��*�or�the�purp�Gose�of�comparison,����t_STR����ob��8jects���are�strictly�larger�than�an���y�other�non-string�t�yp�Ge;���t�w�o��t_STR����ob��8jects�are�compared�using���the�UUstandard�lexicographic�order.����The�standard�b�Go�olean�functions��||��(inclusiv���e�or),�#��&&��(and)�and��!�]�(not)�are�also�a�v��q�ailable,�#�and���the�UUlibrary�syn���tax�is���gor���«(�x;���y�[٫),���gand��s��(�x;�y�[٫)�and���gnot�����(�x�)�resp�Gectiv���ely��*�.����In��library�mo�Gde,�\kit�is�in�fact�usually�preferable�to�use�the�t���w�o��basic�functions�whic���h�are�����gcmp���L�(�x;���y�[٫)���whic���h�giv�es�the�sign�(1,��0,�or���-1)�of��x�s����y�[٫,��where���x��and��y�N��m�ust�b�Ge�in��R�,��and���gegal����(�x;���y�[٫)���whic���h�can�b�Ge�applied�to�an�y�t�w�o�P��*�ARI��ob��8jects��x��and��y�`ܫand�giv�es�1�(i.e.�true)�if�they�are�equal�(but���not��necessarily�iden���tical),���0�(i.e.�false)�otherwise.�i�P�articular�cases�of��gegal��whic�h�should�b�Ge�used���are��UU�gcmp0��#꟫(�x�)�UU(�x���==�0�?),���gcmp1��#꟫(�x�)�(�x��==�1�?),�and���gcmp�����ffs4��#�1��(t�(�x�)�(�x��==���1�?).����Note�that���gcmp0��#�e�(�x�)�tests�whether��x��is�equal�to�zero,�)�ev���en�if��x��is�not�an�exact�ob��8ject.�_�T��*�o�test���whether�UU�x��is�an�exact�ob��8ject�whic���h�is�equal�to�zero,�one�m�ust�use���isexactzero��=4�.����Also�UUnote�that�the��gcmp��and��gegal��functions�return�a�C-in���teger,�and��not�H-�a��GEN��lik�e��gle��etc.���g��GP���accepts��the�follo���wing�synon�yms�for�some�of�the�ab�Go�v�e�functions:�?"since�w�e�though�t�it�migh�t���easily�!�lead�to�confusion,�,w���e�don't�use�the�customary�C�!�op�Gerators�for�bit�wise��and��or�bit�wise��or��(use����bitand�~C�or��bitor�),��hence��|��and��&��are�accepted�as�synon���yms�of��||��and��&&��resp�Gectiv�ely��*�.��Also,���<>��is���accepted�y�as�a�synon���ym�for��!=�.���On�the�other�hand,����=��is�denitely��not�l��a�synon�ym�for��==��since�it�is���the�UUassignmen���t�statemen�t.�������57���:0������Kf�������3.1.13�*�lex�(�x;���y�[٫):�{giv���es���the�result�of�a�lexicographic�comparison�b�Get�w�een��x��and��y����(as���1,��F0�or�1).���This��is�to�b�Ge�in���terpreted�in�quite�a�wide�sense:�/!It�is�admissible�to�compare�ob��8jects�of�dieren�t�t�yp�Ges���(scalars,��v���ectors,�matrices),�pro�vided��Cthe�scalars�can�b�Ge�compared,��as�w�ell�as�v�ectors/matrices�of���dieren���t�UUlengths.�q�The�comparison�is�recursiv�e.��,���In�:�case�all�comp�Gonen���ts�are�equal�up�to�the�smallest�length�of�the�op�erands,�@the�more�complex���is��considered�to�b�Ge�larger.�L�More�precisely��*�,�5the�longest�is�the�largest;�B�when�lengths�are�equal,�w���e���ha���v�e�UUmatrix��>��v���ector��>��scalar.�q�F��*�or�example:�������?�?�lex([1,3],�[1,2,5])��
d>��%1�?�=�1����?�?�lex([1,3],�[1,3,-1])����%2�?�=�-1����?�?�lex([1],�[[1]])����%3�?�=�-1����?�?�lex([1],�[1]��&f~��)����%4�?�=�0�����The�UUlibrary�syn���tax�is���lexcmp��&�(�x;���y�[٫).�� Yw��3.1.14��Tsign�(�x�):�q�sign�UU(0,�1�or���1)�of��x�,�whic���h�m�ust�b�Ge�of�t�yp�Ge�in�teger,�real�or�fraction.����The�UUlibrary�syn���tax�is���gsigne��"93�(�x�).�q�The�result�is�a��long�.����3.1.15�7�max�(�x;���y�[٫)��and��min�(�x;�y�[٫):�Bcreates�the�maxim���um�and�minim�um�of��x��and��y��when�they�can���b�Ge�UUcompared.����The�UUlibrary�syn���tax�is���gmax��S��(�x;���y�[٫)�and���gmin��?��(�x;�y�[٫).����3.1.16���v��9ecmax�(�x�):�j�if�Ѷ�x��is�a�v���ector�or�a�matrix,�0�returns�the�maxim�um�of�the�elemen�ts�of��x�,���otherwise��returns�a�cop���y�of��x�.��Returns��1��in�the�form�of���(2���^��31��+f�����1)�(or���(2���^��63�������1)�for�64-bit���mac���hines)�UUif��x��is�empt�y��*�.����The�UUlibrary�syn���tax�is���v��9ecmax��(�G�(�x�).�� Yw��3.1.17��v��9ecmin�(�x�):�if���x��is�a�v���ector�or�a�matrix,��returns�the�minim�um�of�the�elemen�ts�of��x�,��otherwise���returns���a�cop���y�of��x�.�[�Returns�+�1��in�the�form�of�2���^��31��������1�(or�2���^��63�������1�for�64-bit�mac���hines)�if��x��is���empt���y��*�.����The�UUlibrary�syn���tax�is���v��9ecmin��&���(�x�).�������58���;Bɍ����Kf�������3.2��Con��v�ersions�and�similar�elemen�tary�functions�or�commands�.��>��Man���y�}Mof�the�con�v�ersion�functions�are�rounding�or�truncating�op�Gerations.��In�this�case,��Kif�the�argu-���men���t��Dis�a�rational�function,���the�result�is�the�Euclidean�quotien�t�of�the�n�umerator�b�y�the�denomi-���nator,�1�and�(�if�the�argumen���t�is�a�v�ector�or�a�matrix,�1�the�op�Geration�is�done�comp�onen���t�wise.�b�This�(�will���not�UUb�Ge�restated�for�ev���ery�function.��]��3.2.1�V�List�(��x���=�[���]��EL):�:�transforms��a�(ro���w�or�column)�v�ector��x��in�to�a�list.�MThe�only�other�w�a�y�to�create���a�UU�t_LIST��is�to�use�the�function��listcreate�.������This�UUis�useless�in�library�mo�Gde.����3.2.2�e�Mat�(��x���=�[���]��EL):�mOtransforms��the�ob��8ject��x��in���to�a�matrix.��If��x��is�not�a�v�ector�or�a�matrix,��this���creates��Ya�1�d���1��Ymatrix.�7�If��x��is�a�ro���w�(resp.�column)�v���ector,���this�creates�a�1-ro�w�(resp.�7�1-column)���matrix.�q�If�UU�x��is�already�a�matrix,�a�cop���y�of��x��is�created.������This�UUfunction�can�b�Ge�useful�in�connection�with�the�function��concat��(see�there).����The�UUlibrary�syn���tax�is���gtomat��&�(�x�).����3.2.3� �Mo�Q�d�(�x;���y�[�;��f��flag��l.�=�4b0�g�):���creates���the�P��*�ARI���ob��8ject�(�x�����mo�Gd����y��),��Mi.e.�an�in���tegermo�Gd�or�a�p�olmo�d.����y��y�m���ust�j�b�Ge�an�in�teger�or�a�p�Golynomial.���If��y��y�is�an�in�teger,�o�x��m�ust�b�Ge�an�in�teger,�o�a�rational�n�um�b�Ger,���or���a��p�-adic�n���um�b�Ger���compatible�with�the�mo�dulus��y�[٫.�T�If��y�Yӫis�a�p�olynomial,�s�x��m���ust�b�e�a�scalar�(whic���h���is�UUnot�a�p�Golmo�d),�UUa�p�Golynomial,�a�rational�function,�or�a�p�o���w�er�UUseries.������This�UUfunction�is�not�the�same�as��x��%��y�[٫,�the�result�of�whic���h�is�an�in�teger�or�a�p�Golynomial.����If��nN�flag��h�is�nNequal�to�1,���the�mo�Gdulus�of�the�created�result�is�put�on�the�heap�and�not�on�the���stac���k,�D�and��hence�b�Gecomes�a�p�ermanen���t�cop�y�whic�h�cannot�b�Ge�erased�later�b�y�garbage�collecting���(see��Section�4.4).�g
F��*�unctions�will�op�Gerate�faster�on�suc���h�ob��8jects�and�memory�consumption�will�b�e���lo���w�er.�q�On�UUthe�other�hand,�care�should�b�Ge�tak���en�to�a�v�oid�creating�to�Go�man�y�suc�h�ob��8jects.������Under��*GP��*�,�the�same�eect�can�b�Ge�obtained�b���y�assigning�the�ob��8ject�to�a�GP��v��q�ariable�(the�v�alue���of�,Awhic���h�is�a�p�Germanen�t�ob��8ject�for�the�duration�of�the�relev��q�an�t�library�function�call,�4xand�is�treated���as���suc���h).�8SThis�v��q�alue�is�sub��8ject�to�garbage�collection,��rsince�it�will�b�Ge�deleted�when�the�v�alue�c���hanges.���This��vis�preferable�and�the�ab�Go���v�e��v
ag�is�only�retained�for�compatibilit���y�reasons�(it�can�still�b�e�useful���in�UUlibrary�mo�Gde).����The�UUlibrary�syn���tax�is���Mo�Q�d0�� uK�(�x;���y�[�;���flag���t�).�q�Also�UUa�v��q�ailable�are������UU�for���flag��T9�=��1:��q��gmo�Q�dulo��/���(�x;���y�[٫).������UU�for���flag��T9�=��0:��q��gmo�Q�dulcp��5Q��(�x;���y�[٫).��]��3.2.4�1�P��9ol�(�x;����f�v��+�=�MR�x�g�):��transforms���the�ob��8ject��x��in���to�a�p�Golynomial�with�main�v��q�ariable��v�[٫.�ceIf��x��is�a���scalar,���this���giv���es�a�constan�t�p�Golynomial.�>�If��x��is�a�p�o���w�er���series,���the�eect�is�iden���tical�to��truncate����(see�-nthere),�5ii.e.�it�c���hops�o�the��O�G�(�X�����^��k���r�).�dzIf��x��is�a�v�ector,�5ithis�function�creates�the�p�Golynomial�whose���co�Gecien���ts�UUare�giv�en�in��x�,�with��x�[1]�b�Geing�the�leading�co�ecien���t�(whic�h�can�b�Ge�zero).�������59���<K������Kf�������W��
�arning:�x�this���is��not����a�substitution�function.�k�It�is�in���tended�to�b�Ge�quic�k�and�dirt�y��*�.�k�So�if�y�ou�try����Pol(a,y)�UU�on�the�p�Golynomial��a�?�=�x+y�,�UUy���ou�will�get��y+y�,�whic�h�is�not�a�v��q�alid�P��*�ARI�ob��8ject.���O��The�UUlibrary�syn���tax�is���gtop�Q�oly��)/�(�x;���v�[٫),�where��v��.�is�a�v��q�ariable�n�um�b�Ger.��v���3.2.5�4P��9olrev�(�x;����f�v�c��=�"�x�g�):���transform�|[the�ob��8ject��x��in���to�a�p�Golynomial�with�main�v��q�ariable��v�[٫.���If��x��is���a�%�scalar,�/rthis�giv���es�a�constan�t�p�Golynomial.�a�If��x��is�a�p�o���w�er�%�series,�/rthe�eect�is�iden���tical�to��truncate����(see�-nthere),�5ii.e.�it�c���hops�o�the��O�G�(�X�����^��k���r�).�dzIf��x��is�a�v�ector,�5ithis�function�creates�the�p�Golynomial�whose���co�Gecien���ts���are�giv�en�in��x�,���with��x�[1]�b�Geing�the�constan�t�term.�XNote�that�this�is�the�rev�erse�of��Pol����if�UU�x��is�a�v���ector,�otherwise�it�is�iden�tical�to��Pol�.����The�UUlibrary�syn���tax�is���gtop�Q�olyrev��9C}�(�x;���v�[٫),�where��v��.�is�a�v��q�ariable�n�um�b�Ger.��v���3.2.6�4�Qfb�(�a;���b;�c;��f�D��ҫ=�Q�0�:�g�):�creates���the�binary�quadratic�form��ax���^��2���ū+�pR�bxy��+�+��cy��[ٟ�^��2���L�.�kJIf����b���^��2�����4�ac�Q�>��0,���initialize�UUShanks'�distance�function�to��D�G�.����The�library�syn���tax�is���Qf�b0��qЫ(�a;���b;�c;�D�G;���pr��}'e�c�����).�Z�Also�a�v��q�ailable�are���qf�i���F�(�a;���b;�c�)�(when��b���^��2��*з��]�4�ac��<��0),���and��UU�qf�r���3�(�a;���b;�c;�d�)�UU(when��b���^��2���S��8�4�ac��>��0).��v���3.2.7��2Ser�(�x;����f�v��t�=�B��x�g�):�94transforms�9the�ob��8ject��x��in���to�a�p�Go�w�er�series�with�main�v��q�ariable��v���(�x��b�y���default).�K8If�H{�x��is�a�scalar,��Dthis�giv���es�a�constan�t�p�Go�w�er�series�with�precision�giv�en�b�y�the�default����serieslength�"��(corresp�Gonding�to�the�C�"�global�v��q�ariable��precdl�).�`�If��x��is�a�p�olynomial,�,�the�precision���is��athe�greatest�of��precdl��and�the�degree�of�the�p�Golynomial.�=!If��x��is�a�v���ector,���the�precision�is�similarly���giv���en,�(and���the�co�Gecien�ts�of�the�v�ector�are�understo�Go�d���to�b�Ge�the�co�ecien���ts�of�the�p�o���w�er���series���starting�UUfrom�the�constan���t�term�(i.e.�the�rev�erse�of�the�function��Pol�).����The�UUw���arning�giv�en�for��Pol��applies�here:�q�this�is�not�a�substitution�function.����The�UUlibrary�syn���tax�is���gtoser��!�4�(�x;���v�[٫),�where��v��.�is�a�v��q�ariable�n�um�b�Ger�(i.e.�a�C�in�teger).��v���3.2.8���Set�(�f�x���=�[���]�g�):�m4con���v�erts�L.�x��in���to�a�set,�Ni.e.�in�to�a�ro�w�v�ector�with�strictly�increasing�en�tries.�n��x����can���b�Ge�of�an���y�t�yp�Ge,���but�is�most�useful�when��x��is�already�a�v�ector.��@The�comp�Gonen�ts�of��x��are�put���in�F�canonical�form�(t���yp�Ge��t_STR�)�F�so�as�to�b�e�easily�sorted.�l�T��*�o�reco���v�er�F�an�ordinary��GEN�F�from�suc���h�an���elemen���t,�UUy�ou�can�apply��eval��to�it.����The�UUlibrary�syn���tax�is���gtoset��!���(�x�).��v���3.2.9��Str�(�f�x�g�):��con���v�erts���its�argumen���t�list�in�to�a�single�c�haracter�string�(t�yp�Ge��t_STR�,�the�empt�y���string�6�if��x��is�omitted).�g�T��*�o�reco���v�er�6�an�ordinary��GEN�6��from�a�string,�<�apply��eval��to�it.�The�argumen���ts���of�UU�Str��are�ev��q�aluated�in�string�con���text,�see�Section�2.6.6.��O���?�?�x2�=�0;�i�=�2;�Str(x,�i)���ō�%1�?�=�"x2"����?�?�eval(%)����%2�?�=�0����This��function�is�mostly�useless�in�library�mo�Gde.�	EUse�the�pair��strtoGEN�/�GENtostr��to�con���v�ert���b�Get���w�een�UU�GEN��and��char*�.�q�The�latter�returns�a�mallo�ced�string,�whic���h�should�b�e�freed�after�usage.�������60���=Ze�����Kf�������3.2.10��TStrc��9hr�(�x�):�q�con���v�erts�UU�x��to�a�string,�translating�eac���h�in�teger�in�to�a�c�haracter.��l���?�?�Strchr(97)����%1�?�=�"a"����?�?�Vecsmall("hello�world")����%2�?�=�Vecsmall([104,�101,�108,�108,�111,�32,�119,�111,�114,�108,�100])����?�?�Strchr(%)����%3�?�=�"hello�world"��D��3.2.11���Strexpand�(�f�x�g�):��con���v�erts�Eits�argumen���t�list�in�to�a�single�c�haracter�string�(t�yp�Ge��t_STR�,���the��empt���y�string�if��x��is�omitted).��zThen�p�Gerforme�en�vironmen�t�expansion,�F
see�Section�2.1.��zThis���feature�UUcan�b�Ge�used�to�read�en���vironmen�t�UUv��q�ariable�v�alues.�����?�?�Strexpand("$HOME/doc")����%1�?�=�"/home/pari/doc"�����The�UUindividual�argumen���ts�are�read�in�string�con�text,�see�Section�2.6.6.��D��3.2.12��3Strtex�(�f�x�g�):�a�translates�5its�argumen���ts�to�T��*�eX�5format,�;�and�concatenates�the�results�in�to�a���single�UUc���haracter�string�(t�yp�Ge��t_STR�,�the�empt�y�string�if��x��is�omitted).����The�UUindividual�argumen���ts�are�read�in�string�con�text,�see�Section�2.6.6.��D��3.2.13��=V��
�ec�(��x���=�[���]��EL):�u�transforms��Wthe�ob��8ject��x��in���to�a�ro�w�v�ector.���The�v�ector�will�b�Ge�with�one���comp�Gonen���t��only��*�,�[except�when��x��is�a�v�ector/matrix�or�a�quadratic�form�(in�whic�h�case�the�resulting���v���ector�Ԩis�simply�the�initial�ob��8ject�considered�as�a�ro�w�v�ector),�4}a�c�haracter�string�(a�v�ector�of���individual�$�c���haracters�is�returned),�.�but�more�imp�Gortan�tly�when��x��is�a�p�Golynomial�or�a�p�o���w�er�$�series.���In���the�case�of�a�p�Golynomial,��:the�co�ecien���ts�of�the�v�ector�start�with�the�leading�co�Gecien�t�of�the���p�Golynomial,�s�while�m�for�p�o���w�er�m�series�only�the�signican���t�co�ecien���ts�are�tak�en�in�to�accoun�t,�s�but�this���time�UUb���y�increasing�order�of�degree.����The�UUlibrary�syn���tax�is���gto��9v�ec��#.�(�x�).��D��3.2.14�G*V��
�ecsmall�(��x���=�[���]��EL):�3�transforms�ٶthe�ob��8ject��x��in���to�a�ro�w�v�ector�of�t�yp�Ge��t_VECSMALL�.�This�acts���as����Vec�,��2but�only�on�a�limited�set�of�ob��8jects�(the�result�m���ust�b�Ge�represen�table�as�a�v�ector�of�small���in���tegers).�֧In��Jparticular,��p�Golynomials�and�p�o���w�er��Jseries�are�forbidden.�֧If��x��is�a�c���haracter�string,��a���v���ector��of�individual�c�haracters�in�ASCI�GI�jenco�ding��is�returned�(�Strchr��yields�bac�k�the�c�haracter���string).����The�UUlibrary�syn���tax�is���gto��9v�ecsmall��=7a�(�x�).��D��3.2.15�binary�(�x�):���outputs�kRthe�v���ector�of�the�binary�digits�of��j�x�j�.���Here��x��can�b�Ge�an�in�teger,���a���real��n���um�b�Ger�(in�whic�h�case�the�result�has�t�w�o�comp�Gonen�ts,�4Kone�for�the�in�teger�part,�4Kone�for�the���fractional�UUpart)�or�a�v���ector/matrix.����The�UUlibrary�syn���tax�is���binaire��&׫(�x�).��D��3.2.16��Tbitand�(�x;���y�[٫):�q�bit���wise�UU�and��of�t�w�o�in�tegers��x��and��y�[٫,�that�is�the�in�teger���������`�������u

cmex10�X������d�(�x����i������and����y����i��TL�)2������i���eٍ��Negativ���e�UUn�um�b�Gers�b�eha���v�e�as�if�mo�Gdulo�a�h�uge�p�Go�w�er�of�2.����The�UUlibrary�syn���tax�is���gbitand��)���(�x;���y�[٫).�������61���>i������Kf�������3.2.17��Bbitneg�(�x;����f�n�R��=���1�g�):�Lpbit���wise�B�negation�of�an�in�teger��x�,�}�truncated�to��n��bits,�that�is�the���in���teger��䉍��������w�n��������Q����X����t�����i�=0�������not���ڹ�(�x����i��TL�)2������i���-l��The�
.sp�Gecial�case��n���=���1�
.means�no�truncation:�M�an�innite�sequence�of�leading�1�is�then�represen���ted���as�UUa�negativ���e�n�um�b�Ger.��o1��Negativ���e�UUn�um�b�Gers�b�eha���v�e�as�if�mo�Gdulo�a�h�uge�p�Go�w�er�of�2.����The�UUlibrary�syn���tax�is���gbitneg��(�I�(�x�).���b��3.2.18�9bitnegimply�(�x;���y�[٫):��bit���wise���negated�imply�of�t�w�o�in�tegers��x��and��y��Z�(or��not��(�x�(�)��y�[٫)),��that���is�UUthe�in���teger��
��������G�����X��������(�x����i������andnot��&)��(�y����i��TL�))2������i���P-���Negativ���e�UUn�um�b�Gers�b�eha���v�e�as�if�mo�Gdulo�a�h�uge�p�Go�w�er�of�2.����The�UUlibrary�syn���tax�is���gbitnegimply��E#x�(�x;���y�[٫).����3.2.19��Tbitor�(�x;���y�[٫):�q�bit���wise�UU(inclusiv�e)��or��of�t�w�o�in�tegers��x��and��y�[٫,�that�is�the�in�teger��o5�����������X�����rb�(�x����i������or��~�y����i��TL�)2������i��� P-���Negativ���e�UUn�um�b�Gers�b�eha���v�e�as�if�mo�Gdulo�a�h�uge�p�Go�w�er�of�2.����The�UUlibrary�syn���tax�is���gbitor��!���(�x;���y�[٫).����3.2.20��:bittest�(�x;���n;��f�c�Në=�1�g�):�z�extracts���j�c�j��bits�starting�from�n���um�b�Ger���n��from�the�righ���t�in�the���dev���elopmen�t�@[of��j�x�j��(i.e.�the�co�Gecien���t�of�2���^��n���٫in�the�binary�expansion�of��x�),�D�returning�the�bits�as�an���in���teger�UUbitmap.�q�That�is,�if��x���=������P�����x����i��TL�2���^��i�����with�UUthe��x����i���in��f�0�;����1�g�,�this�routine�returns�the�in���teger��o9������7U����X���j�����h�0��i<�j�c�j����첱x����n�+�i��iZ�2������i���#����Bits���at�negativ���e�osets�are�0.�A-A��negativ�e�v��q�alue�of��c��means�that�negativ�e�v��q�alues�of��x��are�treated���in�e	the�spirit�of�2-complemen���t�arithmetic�(i.e�mo�Gdulo�a�big�p�o���w�er�e	of�2).���T��*�o�extract�sev���eral�bits�(or���groups�UUof�bits�if��j�c�j���>��1)�UUseparately�at�once�as�a�v���ector,�pass�a�v�ector�for��n�.��o1��The�(Ylibrary�syn���tax�is���gbittest3��/vݫ(�x;���n;�c�).�b�Also�(Ya�v��q�ailable�are���gbittest��)�߫(�x;���n�)�(default�case��c���=�1)���and�UUfor�simple�cases���bittest��$#ݫ(�x;���n�),�where��n��and�the�result�are��long�s.����3.2.21��Tbitxor�(�x;���y�[٫):�q�bit���wise�UU(exclusiv�e)��or��of�t�w�o�in�tegers��x��and��y�[٫,�that�is�the�in�teger��o5������`�����X������d�(�x����i������xor����y����i��TL�)2������i�������Negativ���e�UUn�um�b�Gers�b�eha���v�e�as�if�mo�Gdulo�a�h�uge�p�Go�w�er�of�2.��o1��The�UUlibrary�syn���tax�is���gbitxor��'���(�x;���y�[٫).�������62���?v������Kf�������3.2.22�L
ceil�(�x�):�6ceiling���of��x�.�I�When��x��is�in��R�,���the�result�is�the�smallest�in���teger�greater�than�or�equal���to��j�x�.��Applied�to�a�rational�function,���/�ceil���#�(�x�)�returns�the�euclidian�quotien���t�of�the�n�umerator�b�y���the�UUdenominator.�����The�UUlibrary�syn���tax�is���gceil��ڣ�(�x�).��OQ��3.2.23�r�cen��9terlift�(�x;����f�v�[ٷg�):��*lifts��an�elemen���t��x���=��a����mo�Gd���߱n���of��Z�=n�Z��to��a��in��Z�,�3and�similarly�lifts�a���p�Golmo�d���to�a�p�Golynomial.���This�is�the�same�as��lift��except�that�in�the�particular�case�of�elemen���ts���of�9��Z�=n�Z�,�sthe�lift��y��̫is�suc���h�that���n=�2�D�<�y������n=�2.��If�9�x��is�of�t�yp�Ge�fraction,�scomplex,�quadratic,���p�Golynomial,��p�o���w�er��Dseries,�rational�function,�v���ector�or�matrix,�the�lift�is�done�for�eac���h�co�Gecien�t.���Reals�UUare�forbidden.����The��)library�syn���tax�is���cen��9terlif�t0��7�m�(�x;���v�[٫),���where��v��is�a��long��and�an�omitted��v��is�co�Gded�as���1.���Also�UUa���v��q�ailable�is��cen��9terlift�(�x�)�=��centerlift0(�x�,-1)�.��OQ��3.2.24��[c��9hangev��\rar�(�x;���y�[٫):�f�creates�?�a�cop���y�of�the�ob��8ject��x��where�its�v��q�ariables�are�mo�Gdied�according���to���the�p�Germ���utation�sp�ecied�b���y�the�v�ector��y�[٫.�8QF��*�or�example,��assume�that�the�v��q�ariables�ha�v�e�b�Geen���in���tro�Gduced��=in�the�order��x�,��w�a�,��b�,��c�.�(Then,�if��=�y���is�the�v�ector��[x,c,a,b]�,��wthe�v��q�ariable��a��will�b�Ge���replaced��Wb���y��c�,�M�b��b�y��a�,�Mand��c��b�y��b�,�M�x��b�Geing�unc�hanged.�	*�Note�that�the�p�Germ�utation�m�ust�b�Ge���completely��sp�Gecied,��e.g.��[c,a,b]��w���ould�not�w�ork,��since�this�w�ould�replace��x��b�y��c�,��and�lea�v�e��a��and����b��6�unc���hanged�(as�w�ell�as��c��whic�h�is�the�fourth�v��q�ariable�of�the�initial�list).�0kIn�particular,�othe�new���v��q�ariable�UUnames�m���ust�b�Ge�distinct.����The�UUlibrary�syn���tax�is���c��9hangev��\rar��5EB�(�x;���y�[٫).��OQ��3.2.25��Tcomp�Q�onen��9ts�of�a�P��
�ARI�ob���ject�:����There�UUare�essen���tially�three�w�a�ys�to�extract�the�comp�Gonen�ts�from�a�P��*�ARI�ob��8ject.����The�_Vrst�and�most�general,���is�the�function���comp�Q�onen��9t��9y�(�x;���n�)�whic���h�extracts�the��n���^��th��
��-comp�Gonen�t���of�Dٱx�.�lIThis�is�to�b�Ge�understo�o�d�as�follo���ws:�i�ev�ery�D�P��*�ARI�D�t�yp�e�D�has�one�or�t���w�o�D�initial�co�de�w���ords.�lIThe���comp�Gonen���ts���are�coun�ted,���starting�at�1,�after�these�co�Gde�w���ords.���In�particular�if��x��is�a�v�ector,���this���is��indeed�the��n���^��th��
��-comp�Gonen���t�of��x�,�\if��x��is�a�matrix,�the��n���^��th���;�column,�if��x��is�a�p�Golynomial,�the��n���^��th�����co�Gecien���t�/�(i.e.�of�degree��n������1),�7`and�/�for�p�o���w�er�/�series,�7`the��n���^��th��:��signican���t�co�ecien���t.�eKThe�use�of�the���function�M�component��implies�the�kno���wledge�of�the�structure�of�the�dieren�t�P��*�ARI�Mt�yp�Ges,�N�whic�h�can���b�Ge�UUrecalled�b���y�t�yping��\t��under�GP��*�.����The�UUlibrary�syn���tax�is���comp�Q�o��$<f�(�x;���n�),�where��n��is�a��long�.����The�t���w�o�other�metho�Gds�are�more�natural�but�more�restricted.�}�The�function���p�Q�olco�ef�f��-S�(�x;���n�)���giv���es�\�the�co�Gecien�t�of�degree��n��of�the�p�Golynomial�or�p�o���w�er�\�series��x�,���with�resp�ect�to�the�main�v��q�ariable���of�~��x��(to�c���hec�k�~�v��q�ariable�ordering,���or�to�c���hange�it,�use�the�function��reorder�,�see�Section�3.11.2.22).���In��}particular�if��n��is�less�than�the�v��q�aluation�of��x��or�in�the�case�of�a�p�Golynomial,��greater�than�the���degree,���the��Lresult�is�zero�(con���trary�to��compo��whic�h�w�ould�send�an�error�message).��If��x��is�a�p�Go�w�er���series�UUand��n��is�greater�than�the�largest�signican���t�degree,�then�an�error�message�is�issued.����F��*�or�>.greater�
exibilit���y�,�B�v�ector�>.or�matrix�t���yp�Ges�are�also�accepted�for��x�,�and�the�meaning�is�then���iden���tical�UUwith�that�of��compo�.����Finally�UUnote�that�a�scalar�t���yp�Ge�is�considered�b�y��polcoeff��as�a�p�Golynomial�of�degree�zero.����The�UUlibrary�syn���tax�is���trueco�Q�ef�f��1�a�(�x;���n�).����The�pthird�metho�Gd�is�sp�ecic�to�v���ectors�or�matrices�under�GP��*�.�If��x��is�a�(ro�w�or�column)�v�ector,���then����x[n]��represen���ts�the��n���^��th�����comp�Gonen�t�of��x�,�˄i.e.��compo(x,n)�.��lIt�is�more�natural�and�shorter�to�������63���@������Kf�����卫write.�#If�;�x��is�a�matrix,�t��x[m,n]��represen���ts�the�co�Gecien�t�of�ro�w��m��and�column��n��of�the�matrix,����x[m,]�UU�represen���ts�the��m���^��th��`�r��}'ow�h�of��x�,�and��x[,n]��represen�ts�the��n���^��th��`�c��}'olumn���of��x�.�����Finally���note�that�in�library�mo�Gde,���the�macros��co�Q�eff��and��mael��are�a���v��q�ailable�to�deal�with�the���non-recursivit���y�i�of�the��GEN�i˫t�yp�Ge�from�the�compiler's�p�oin���t�of�view.��9See�the�discussion�on�t�yp�Gecasts���in�UUChapter�4.��$��3.2.26��Qconj�(�x�):�hconjugate��sof��x�.��"The�meaning�of�this�is�clear,�/;except�that�for�real�quadratic���n���um�b�Gers,�yait�r+means�conjugation�in�the�real�quadratic�eld.��JThis�function�has�no�eect�on�in���tegers,���reals,�Hin���tegermo�Gds,�fractions�D�or��p�-adics.�[email protected]�only�forbidden�t�yp�Ge�is�p�olmo�d�(see��conjvec��for�this).����The�UUlibrary�syn���tax�is���gconj���ګ(�x�).��$��3.2.27���conjv��9ec�(�x�):�]�conjugate�,�v���ector�represen�tation�of��x�.�dDIf��x��is�a�p�Golmo�d,�4�equal�,�to��Mod�(�a;���q�[٫),�this���giv���es��3a�v�ector�of�length��degree��cn(�q�[٫)�con�taining�the�complex�em�b�Geddings�of�the�p�olmo�d�if��q���has�in���tegral���or��rational�co�Gecien���ts,��zand�the�conjugates�of�the�p�olmo�d�if��q�ܫhas�some�in���tegermo�d�co�ecien���ts.�=WThe���order��%is�the�same�as�that�of�the��polroots��functions.��7If��x��is�an�in���teger�or�a�rational�n�um�b�Ger,��the���result���is��x�.�T:If��x��is�a�(ro���w�or�column)�v�ector,�hthe�result�is�a�matrix�whose�columns�are�the�conjugate���v���ectors�UUof�the�individual�elemen�ts�of��x�.����The�UUlibrary�syn���tax�is���conjv��9ec��(:��(�x;�����pr��}'e�c�����).��$��3.2.28�M5denominator�(�x�):��zlo���w�est��/denominator�of��x�.�FTThe�meaning�of�this�is�clear�when��x��is�a���rational�5vn���um�b�Ger�or�function.�g(When��x��is�an�in�teger�or�a�p�Golynomial,�;�the�result�is�equal�to�1.�g(When����x�霫is�a�v���ector�or�a�matrix,��'the�lo�w�est�common�denominator�of�the�comp�Gonen�ts�of��x��is�computed.�M�All���other�UUt���yp�Ges�are�forbidden.����W��
�arning:�^�m���ultiv��q�ariate���ob��8jects�are�created�according�to�v�ariable�priorities,��with�p�Gossibly�surprising���side�UUeects�(�x=y��.�is�a�p�Golynomial,�but��y�[�=x��is�a�rational�function).�q�See�Section�2.6.2.����The�UUlibrary�syn���tax�is���denom��$��(�x�).��$��3.2.29��mflo�Q�or�(�x�):�i 
o�Gor�Dof��x�.�lWhen��x��is�in��R�,�G}the�result�is�the�largest�in���teger�smaller�than�or�equal���to�v��x�.��IApplied�to�a�rational�function,��~��floor�����(�x�)�returns�the�euclidian�quotien���t�of�the�n�umerator�b�y���the�UUdenominator.����The�UUlibrary�syn���tax�is���gf�lo�Q�or��!o��(�x�).��$��3.2.30��Tfrac�(�x�):�q�fractional�UUpart�of��x�.�Iden���tical�to��x�8����
o�Gor����(�x�).�If�UU�x��is�real,�the�result�is�in�[0�;����1[.����The�UUlibrary�syn���tax�is���gf�rac����(�x�).����3.2.31�+�imag�(�x�):��imaginary��qpart�of��x�.�SWhen��x��is�a�quadratic�n���um�b�Ger,��8this��qis�the�co�ecien���t�of��!����in�UUthe�\canonical"�in���tegral�basis�(1�;���!�[٫).����The�^�library�syn���tax�is���gimag��"e��(�x�).��zThis�returns�a�cop�y�of�the�imaginary�part.��zThe�in�ternal���routine�UU�imag_i��is�faster,�since�it�returns�the�p�Goin���ter�and�skips�the�cop�y��*�.��$��3.2.32��?length�(�x�):�^-n���um�b�Ger�.!of�non-co�de�w���ords�in��x��really�used�(i.e.�the�eectiv�e�length�min�us�2�for���in���tegers�/�and�p�Golynomials).�e=In�particular,�7=the�degree�of�a�p�olynomial�is�equal�to�its�length�min���us�1.���If�UU�x��has�t���yp�Ge��t_STR�,�output�n�um�b�Ger�of�letters.����The�UUlibrary�syn���tax�is���glength��(�e�(�x�)�and�the�result�is�a�C�long.�������64���A�3�����Kf�������3.2.33�!alift�(�x;����f�v�[ٷg�):��
lifts��wan�elemen���t��x�5O�=��a����mo�Gd���߱n��w�of��Z�=n�Z��to��a��in��Z�,���and�similarly�lifts�a�p�Golmo�d���to�ݗa�p�Golynomial�if��v�9p�is�omitted.�
�Otherwise,���lifts�only�p�olmo�ds�whose�mo�dulus�has�main�v��q�ariable����v��7�(if��^�v��do�Ges�not�o�ccur�in��x�,��alifts�only�in���tmo�ds).�1�If��x��is�of�recursiv���e�(non�mo�dular)�t���yp�e,��athe�lift�is���done�%�co�Gecien���t�wise.�a�F��*�or��p�-adics,�/this�routine�acts�as��truncate�.�It�is�not�allo���w�ed�to�ha�v�e��x��of�t�yp�Ge����t_REAL�.��d����?�?�lift(Mod(5,3))��Y.��%1�?�=�2����?�?�lift(3�+�O(3^9))����%2�?�=�3����?�?�lift(Mod(x,x^2+1))����%3�?�=�x����?�?�lift(x�*�Mod(1,3)�+�Mod(2,3))����%4�?�=�x�+�2����?�?�lift(x�*�Mod(y,y^2+1)�+�Mod(2,3))����%5�?�=�y*x�+�Mod(2,�3)���\\����do�you�understand�this�one�?�����?�?�lift(x�*�Mod(y,y^2+1)�+�Mod(2,3),�x)����%6�?�=�Mod(y,�y^2+1)�*�x�+�Mod(2,�y^2+1)������The�Xlibrary�syn���tax�is���lif�t0��<l�(�x;���v�[٫),�1Ywhere��v�a1�is�a��long��and�an�omitted��v��is�co�Gded�as���1.���Also���a���v��q�ailable�UUis��lift�(�x�)�=��lift0(�x�,-1)�.����3.2.34���norm�(�x�):�P�algebraic��norm�of��x�,� 'i.e.�the�pro�Gduct�of��x��with�its�conjugate�(no�square�ro�ots�are���tak���en),��aor��dconjugates�for�p�Golmo�ds.�KwF��*�or��dv�ectors�and�matrices,��athe�norm�is�tak�en�comp�Gonen�t�wise�and���hence�[email protected]�not�the��L���^��2��|s�-norm�(see��norml2�).�kNote�that�the�norm�of�an�elemen���t�of��R��is�its�square,�EEso�as���to�UUb�Ge�compatible�with�the�complex�norm.����The�UUlibrary�syn���tax�is���gnorm��#���(�x�).����3.2.35���norml2�(�x�):�square���of�the��L���^��2��|s�-norm�of��x�.�2�More�precisely��*�,���if��x��is�a�scalar,���norml2��"=«(�x�)�is�dened���to�/�b�Ge��x�?��*�conj(�x�)�.�eJIf�/ݱx��is�a�(ro���w�or�column)�v�ector�or�a�matrix,�7[�norml2(�x�)��is�dened�recursiv�ely���as��֟���P���
���i�����norml2��2�(�x����i��TL�),�Vwhere��(�x����i���)�run�through�the�comp�Gonen���ts�of��x�.�W�In�particular,�Vthis�yields�the�usual��������P��8�j�x����i��TL�j���^��2���ȫ(resp.��UU����P���8�j�x����i;j��	j��j���^��2��|s�)�UUif��x��is�a�v���ector�(resp.�matrix)�with�complex�comp�Gonen�ts.��d����?�?�norml2(�[�1,�2,�3�]�)��\\�vector��Y.��%1�?�=�14����?�?�norml2(�[�1,�2;�3,�4]�)���\\�matrix����%1�?�=�30����?�?�norml2(�I�+�x�)����%3�?�=�x^2�+�1����?�?�norml2(�[�[1,2],�[3,4],�5,�6�]�)���\\�recursively�defined����%4�?�=�91�����The�UUlibrary�syn���tax�is���gnorml2��,|d�(�x�).����3.2.36��Qn��9umerator�(�x�):��Sn���umerator�dof��x�.��When��x��is�a�rational�n�um�b�Ger�or�function,�g�the�meaning�is���clear.�oNWhen�M�x��is�an�in���teger�or�a�p�Golynomial,�Ogthe�result�is��x��itself.�When��x��is�a�v���ector�or�a�matrix,���then�UU�numerator(x)��is�dened�to�b�Ge��denominator(x)*x�.�q�All�other�t���yp�es�are�forbidden.�������65���B�`�����Kf�������W��
�arning:�^�m���ultiv��q�ariate���ob��8jects�are�created�according�to�v�ariable�priorities,��with�p�Gossibly�surprising���side�UUeects�(�x=y��.�is�a�p�Golynomial,�but��y�[�=x��is�a�rational�function).�q�See�Section�2.6.2.��k���The�UUlibrary�syn���tax�is���n��9umer��#a��(�x�).��B��3.2.37���n��9um�top�Q�erm�(�n;���k�P��):�-generates�%�the��k��-th�p�Germ���utation�(as�a�ro�w�v�ector�of�length��n�)�of�the���n���um�b�Gers�UU1�to��n�.�q�The�n���um�b�er�UU�k���is�tak���en�mo�dulo��n�!���,�i.e.�in���v�erse�UUfunction�of��permtonum�.����The�UUlibrary�syn���tax�is���n��9um�top�Q�erm��=�{�(�n;���k�P��),�where��n��is�a��long�.��B��3.2.38��padicprec�(�x;���p�):���absolute�n��p�-adic�precision�of�the�ob��8ject��x�.��	This�is�the�minim���um�precision���of�<the�comp�Gonen���ts�of��x�.�]The�result�is��VERYBIGINT�,�(2���^��31��
5������1�for�32-bit�mac�hines�or�2���^��63��
5������1�for�64-bit���mac���hines)�UUif��x��is�an�exact�ob��8ject.����The�UUlibrary�syn���tax�is���padicprec��3�}�(�x;���p�)�and�the�result�is�a��long��in�teger.��B��3.2.39�l�p�Q�erm��9ton�um�(�x�):�6giv���en��ta�p�Germ�utation��x��on��n��elemen�ts,��giv�es�the�n�um�b�Ger��k��suc�h�that����x���=���numtoperm�(�n�;����k�)��H��,�UUi.e.�in���v�erse�UUfunction�of��numtoperm�.����The�UUlibrary�syn���tax�is���p�Q�erm��9ton�um��=�{�(�x�).��B��3.2.40��)precision�(�x;����f�n�g�):���giv���es��the�precision�in�decimal�digits�of�the�P��*�ARI��ob��8ject��x�.�F�If��x��is�an���exact�;�ob��8ject,�u�the�largest�single�precision�in���teger�is�returned.�%�If��n��is�not�omitted,�creates�a�new���ob��8ject�UUequal�to��x��with�a�new�precision��n�.�q�This�is�to�b�Ge�understo�o�d�as�follo���ws:����F��*�or�@zexact�t���yp�Ges,�D�no�c�hange.�j�F��*�or��x��a�v�ector�or�a�matrix,�D�the�op�Geration�is�done�comp�onen���t�wise.����F��*�or��#real��x�,��V�n��is�the�n���um�b�Ger��#of�desired�signican���t��de��}'cimal����digits.�@0If��n��is�smaller�than�the���precision�UUof��x�,��x��is�truncated,�otherwise��x��is�extended�with�zeros.����F��*�or�)$�x��a��p�-adic�or�a�p�Go���w�er�)$series,�1��n��is�the�desired�n���um�b�er�)$of�signican���t��p�-adic�or��X���-adic�digits,���where�UU�X�7�is�the�main�v��q�ariable�of��x�.����Note�H�that�the�function��precision��nev���er�c�hanges�the�t�yp�Ge�of�the�result.�m�In�particular�it�is�not���p�Gossible�UUto�use�it�to�obtain�a�p�olynomial�from�a�p�o���w�er�UUseries.�q�F��*�or�that,�see��truncate�.����The�9Ulibrary�syn���tax�is���precision0��5�f�(�x;���n�),�>�where��n��is�a��long�.�hrAlso�a�v��q�ailable�are���ggprecision��;Kd�(�x�)���(result�UUis�a��GEN�)�and���gprec����(�x;���n�),�where��n��is�a��long�.��B��3.2.41�efrandom�(�f�N����=���2���^��31��x�g�):�lVgiv���es�ҝa�random�in�teger�b�Get�w�een�0�and��N������e�1.�鞱N�鸫can�b�Ge�arbitrary���large.�YThis�20is�an�in���ternal�P��*�ARI�1�function�and�do�Ges�not�dep�end�on�the�system's�random�n���um�b�er���generator.�q�Note�UOthat�the�resulting�in���teger�is�obtained�b�y�means�of�linear�congruences�and�will�not���b�Ge�UUw���ell�distributed�in�arithmetic�progressions.����The�UUlibrary�syn���tax�is���genrand��+�ի(�N��).��B��3.2.42���real�(�x�):�dreal�9�part�of��x�.�h�In�the�case�where��x��is�a�quadratic�n���um�b�Ger,�?Uthis�9�is�the�co�ecien���t�of���1�UUin�the�\canonical"�in���tegral�basis�(1�;���!�[٫).����The�<�library�syn���tax�is���greal��Lj�(�x�).�(yThis�returns�a�cop�y�of�the�real�part.�(yThe�in�ternal�routine����real_i�UU�is�faster,�since�it�returns�the�p�Goin���ter�and�skips�the�cop�y��*�.��B��3.2.43��round�(�x;����f�&�e�g�):���If�|�x��is�in��R�,���rounds��x��to�the�nearest�in���teger�and�sets��e��to�the�n�um�b�Ger�of���error�
&bits,�0that�is�the�binary�exp�Gonen���t�of�the�dierence�b�et���w�een�
&the�original�and�the�rounded�v��q�alue���(the�[�\fractional�part").��GIf�the�exp�Gonen���t�of��x��is�to�o�large�compared�to�its�precision�(i.e.��e��_>��0),�]
the���result�UUis�undened�and�an�error�o�Gccurs�if��e��w���as�not�giv�en.�������66���C�t�����Kf�������Imp�Q�ortan��9t��)remark:�U�note��that,�(�con���trary�to�the�other�truncation�functions,�this�function�op�Gerates���on�UUev���ery�co�Gecien�t�at�ev�ery�lev�el�of�a�P��*�ARI�ob��8ject.�q�F�or�example��č����truncate�����N����^�������<$����2�2�:�4�8���X�����^��2��~5���1�:�7����2�w�fe<��	(֍�ڨ�X��������{���^�������=��2�:�4�8���X�:�;�����whereas��������round�����N���^�������<$���ޏ�2�:�4�8���X�����^��2��~5���1�:�7���ޏ�w�fe<��	(֍�ڨ�X��������؟��^������d�=�����<$���K2�8���X�����^��2��~5���2���K�w�fe-8ڟ	(֍���X�����2fX:�����An�Kimp�Gortan���t�use�of��round��is�to�get�exact�results�after�a�long�appro�ximate�computation,��|when���theory�UUtells�y���ou�that�the�co�Gecien�ts�m�ust�b�Ge�in�tegers.��8H��The�;xlibrary�syn���tax�is���grndtoi��'饫(�x;����&�e�),�@�where��e��is�a��long��in�teger.�i(Also�a�v��q�ailable�is���ground��&���(�x�).��p���3.2.44�[�simplify�(�x�):�[�this��^function�tries�to�simplify�the�ob��8ject��x��as�m���uc�h��^as�it�can.���The�simpli-���cations��]do�not�concern�rational�functions�(whic���h�P��*�ARI��=automatically�tries�to�simplify),��but�t�yp�Ge���c���hanges.���Sp�Gecically��*�,��;a���complex�or�quadratic�n�um�b�Ger�whose�imaginary�part�is�exactly�equal�to�0���(i.e.���not�a�real�zero)�is�con���v�erted���to�its�real�part,���and�a�p�Golynomial�of�degree�zero�is�con���v�erted���to�its���constan���t�u�term.�ӵF��*�or�all�t�yp�Ges,�~#this�of�course�o�ccurs�recursiv���ely��*�.�ӵThis�function�is�useful�in�an�y�case,���but��in�particular�b�Gefore�the�use�of�arithmetic�functions�whic���h�exp�ect�in���teger�argumen�ts,��Band�not���for�lexample�a�complex�n���um�b�Ger�lof�0�imaginary�part�and�in���teger�real�part�(whic�h�is�ho�w�ev�er�prin�ted���as�UUan�in���teger).����The�UUlibrary�syn���tax�is���simplif�y��,B�(�x�).��p���3.2.45�5sizeb��9yte�(�x�):�,outputs���the�total�n���um�b�Ger���of�b���ytes�o�ccupied�b���y�the�tree�represen�ting�the�P��*�ARI���ob��8ject�UU�x�.����The���library�syn���tax�is���taille2��!���(�x�)�whic�h�returns�a��long�.�I�The�function��taille��returns�the�n�um�b�Ger���of�UU�wor��}'ds�'v�instead.��p���3.2.46��sizedigit�(�x�):���outputs���a�quic���k�b�Gound�for�the�n�um�b�Ger�of�decimal�digits�of�(the�comp�onen���ts���of��)�r.�x�,�ydo�b���y�at�most�1.��RIf�y�ou�w�an�t�the�exact�v��q�alue,�ydy�ou�can�use��length(Str(x))�,�ydwhic�h�is�m�uc�h���slo���w�er.����The�UUlibrary�syn���tax�is���sizedigit��,r�(�x�)�whic�h�returns�a��long�.��p���3.2.47�\Dtruncate�(�x;����f�&�e�g�):�\struncates�ʫ�x��and�sets��e��to�the�n���um�b�Ger�ʫof�error�bits.���When��x��is�in��R�,���this��Emeans�that�the�part�after�the�decimal�p�Goin���t�is�c�hopp�Ged�a�w�a�y��*�,����e��is�the�binary�exp�Gonen�t�of�the���dierence�]�b�Get���w�een�the�original�and�the�truncated�v��q�alue�(the�\fractional�part").��If�the�exp�Gonen�t�of����x���is�to�Go�large�compared�to�its�precision�(i.e.��e�@8>��0),��.the��result�is�undened�and�an�error�o�ccurs�if����e�cq�w���as�not�giv�en.��The�function�applies�comp�Gonen�t�wise�on�v�ector�/�matrices;�j�e��is�then�the�maximal���n���um�b�Ger��Pof�error�bits.�NIf��x��is�a�rational�function,���the�result�is�the�\in���teger�part"�(Euclidean�quotien�t���of�UUn���umerator�b�y�denominator)�and��e��is�not�set.����Note��*a�v���ery�sp�Gecial�use�of��truncate�:�_rwhen�applied�to�a�p�o���w�er��*series,���it�transforms�it�in���to�a���p�Golynomial��
or�a�rational�function�with�denominator�a�p�o���w�er��
of��X���,���b���y�c�hopping�a�w�a�y�the��O�G�(�X�����^��k���r�).���Similarly��*�,��Lwhen���applied�to�a��p�-adic�n���um�b�Ger,�it���transforms�it�in���to�an�in�teger�or�a�rational�n�um�b�Ger���b���y�UUc�hopping�a�w�a�y�the��O�G�(�p���^��k��됫).����The�UUlibrary�syn���tax�is���gcvtoi��!�.�(�x;����&�e�),�where��e��is�a��long��in�teger.�q�Also�a�v��q�ailable�is��gtrunc�(�x�).�������67���D�����Kf�������3.2.48�#
v��\raluation�(�x;���p�):���computes���the�highest�exp�Gonen���t�of��p��dividing��x�.�<�If��p��is�of�t�yp�Ge�in�teger,��ͱx����m���ust�	�b�Ge�an�in�teger,�6�an�in�tegermo�Gd�whose�mo�dulus�is�divisible�b���y��p�,�6�a�fraction,�a��q�[٫-adic�n���um�b�Ger���with�'�q����=�$��p�,�[�or�a�p�Golynomial�or�p�o���w�er�'series�in�whic���h�case�the�v��q�aluation�is�the�minim�um�of�the���v��q�aluation�UUof�the�co�Gecien���ts.��}��If����p��is�of�t���yp�Ge�p�olynomial,�ձx��m���ust�b�e�of�t���yp�e�p�olynomial�or�rational�function,��and�also�a�p�o���w�er���series��if��x��is�a�monomial.���Finally��*�,���the�v��q�aluation�of�a�v���ector,�complex�or�quadratic�n���um�b�Ger��is�the���minim���um�UUof�the�comp�Gonen�t�v��q�aluations.����If�C̱x���=�0,�GNthe�result�is��VERYBIGINT�Cǫ(2���^��31��
����ͫ1�for�32-bit�mac���hines�or�2���^��63����ͫ1�for�64-bit�mac���hines)���if����x��is�an�exact�ob��8ject.�b}If��x��is�a��p�-adic�n���um�b�Gers���or�p�o���w�er���series,���the�result�is�the�exp�onen���t�of�the���zero.�q�An���y�UUother�t�yp�Ge�com�binations�giv�es�an�error.����The�UUlibrary�syn���tax�is���ggv��\ral��g�(�x;���p�),�and�the�result�is�a��long�.��*���3.2.49���v��\rariable�(�x�):��igiv���es�s&the�main�v��q�ariable�of�the�ob��8ject��x�,�z�and��p��if��x��is�a��p�-adic�n�um�b�Ger.��:Giv�es���an�R�error�if��x��has�no�v��q�ariable�asso�Gciated�to�it.�p�Note�that�this�function�is�useful�only�in�GP��*�,�since�in���library�UUmo�Gde�the�function��gvar��is�more�appropriate.����The���library�syn���tax�is���gp�Q�olv��\rar��(��(�x�).�O�Ho�w�ev�er,�)in�library�mo�Gde,�this�function�should�not�b�Ge�used.���Instead,��Stest���whether��x��is�a��p�-adic�(t���yp�Ge��t_PADIC�),�in�whic�h�case��p��is�in��x�[2],��Sor�call�the�function�����gv��\rar�����(�x�)�UUwhic���h�returns�the�v��q�ariable��numb��}'er�h�of��x��if�it�exists,��BIGINT��otherwise.��[email protected]��3.3��T���ranscenden��tal�functions�.�����As�ԯa�general�rule,��jwhic���h�of�course�in�some�cases�ma�y�ha�v�e�exceptions,��jtranscenden�tal�functions���op�Gerate�UUin�the�follo���wing�w�a�y:������|=�If�the�argumen���t�is�either�an�in�teger,���a�real,�a�rational,�a�complex�or�a�quadratic�n���um�b�Ger,�it���is,���if��^necessary��*�,�rst�con���v�erted�to�a�real�(or�complex)�n�um�b�Ger�using�the�curren�t�precision�held�in�the���default����realprecision�.��YNote�that�only�exact�argumen���ts�are�con�v�erted,��<while�inexact�argumen�ts���suc���h�UUas�reals�are�not.����Under�kGP�kthis�is�transparen���t�to�the�user,�p�but�when�programming�in�library�mo�Gde,�care�m���ust���b�Ge��tak���en�to�supply�a�meaningful�parameter���pr��}'e�c���y�as�the�last�argumen�t�of�the�function�if�the�rst���argumen���t�UUis�an�exact�ob��8ject.�q�This�parameter�is�ignored�if�the�argumen�t�is�inexact.����Note��zthat�in�library�mo�Gde�the�precision�argumen���t���pr��}'e�c��u�is�a�w�ord�coun�t�including�co�Gdew�ords,���i.e.���represen���ts�the�length�in�w�ords�of�a�real�n�um�b�Ger,��@while�under�GP���the�precision�(whic�h�is�c�hanged���b���y�n�the�metacommand��\p��or�using��default(realprecision,...)�)��His�the�n�um�b�Ger�of�signican�t���decimal�UUdigits.����Note���that�some�accuracies�attainable�on�32-bit�mac���hines�cannot�b�Ge�attained�on�64-bit�mac�hines���for��Uparit���y�reasons.�[�F��*�or�example�the�default�GP��@accuracy�is�28�decimal�digits�on�32-bit�mac�hines,���corresp�Gonding�UUto���pr��}'e�c�����ha���ving�the�v��q�alue�5,�but�this�cannot�b�e�attained�on�64-bit�mac���hines.�����After���p�Gossible�con���v�ersion,���the���function�is�computed.��Note�that�ev���en�if�the�argumen�t�is�real,���the��result�ma���y�b�Ge�complex�(e.g.��acos��u(2�:�0)�or��acosh��V(0�:�0)).��mNote�also�that�the�principal�branc�h�is���alw���a�ys�UUc�hosen.���������If�the�argumen���t�is�an�in�tegermo�Gd�or�a��p�-adic,���at�presen�t�only�a�few�functions�lik�e��sqrt����(square�i�ro�Got),����sqr��(square),��log�,��exp�,�p�Go���w�ering,��teichmuller�i��(T��*�eic�hm�G����uller�c�haracter)�and��agm����(arithmetic-geometric�UUmean)�are�implemen���ted.�������68���E�덟���Kf�����卑�Note�?�that�in�the�case�of�a�2-adic�n���um�b�Ger,��D*�sqr��!�(�x�)�?�ma�y�not�b�Ge�iden�tical�to��x�
���x�:�gfor�example�if����x���=�1�A�+��O�G�(2���^��5��|s�)���and��y�"�=��1�A�+��O��(2���^��5��|s�)���then��x�A���y�"�=��1�+��O��(2���^��5��|s�)���while���sqr���Ы(�x�)��=�1�A�+��O��(2���^��6��|s�).�H�Here,��x����x��٫yields���the��Zsame�result�as���sqr��AQ�(�x�)�since�the�t���w�o��Zop�Gerands�are�kno���wn�to�b�e��identic��}'al���.���The�same�statemen���t���holds�UUtrue�for��p�-adics�raised�to�the�p�Go���w�er�UU�n�,�where��v����p���R�(�n�)���>��0.������Remark:��H�note��that�if�w���e�w�an�ted�to�b�Ge�strictly�consisten�t�with�the�P��*�ARI��nphilosoph�y�,�&w�e��should���ha���v�e��:�x�Vη��y�mī=��(4����mo�Gd���8)�and���sqr��B1�(�x�)�=�(4����mo�Gd���32)�when�b�Goth��x��and��y���are�congruen���t�to�2�mo�dulo�4.���Ho���w�ev�er,�Ȑsince���in�tegermo�Gd�is�an�exact�ob��8ject,�ȐP��*�ARI��lassumes�that�the�mo�dulus�m���ust�not�c�hange,���and�O�the�result�is�hence�(0��UPmo�Gd���O4)�in�b�Goth�cases.�o�On�the�other�hand,�Q�p�-adics�are�not�exact�ob��8jects,���hence�UUare�treated�dieren���tly��*�.��9������If�the�argumen���t�is�a�p�Golynomial,�Gfp�o�w�er��series�or�rational�function,�Gfit�is,�if�necessary��*�,�rst���con���v�erted��to�a�p�Go���w�er��series�using�the�curren���t�precision�held�in�the�v��q�ariable��precdl�.�[HUnder�GP��this���again��is�transparen���t�to�the�user.�_BWhen�programming�in�library�mo�Gde,�(�ho�w�ev�er,�the��global�v��q�ariable����precdl�>�m���ust�b�Ge�set�b�efore�calling�the�function�if�the�argumen���t�has�an�exact�t�yp�Ge�(i.e.�not�a�p�o���w�er���series).�q�Here�UU�precdl��is�not�an�argumen���t�of�the�function,�but�a�global�v��q�ariable.����Then���the�T��*�a���ylor�series�expansion�of�the�function�around��X����=��0�(where��X����is�the�main�v��q�ariable)���is�8scomputed�to�a�n���um�b�Ger�8sof�terms�dep�ending�on�the�n���um�b�er�8sof�terms�of�the�argumen���t�and�the���function�UUb�Geing�computed.��������If�the�argumen���t�is�a�v�ector�or�a�matrix,�the�result�is�the�comp�Gonen�t�wise�ev��q�aluation�of�the���function.��In��Cparticular,�~transcenden���tal�functions�on�square�matrices,�whic���h�are�not�implemen�ted���in���the�presen���t�v�ersion�2.2.7�(see�App�Gendix�B���ho�w�ev�er),��|will�ha�v�e�a�sligh�tly�dieren�t�name�if�they���are�UUimplemen���ted�some�da�y��*�.��r<��3.3.1����^�:�eIf�;ϱy����is�not�of�t���yp�Ge�in�teger,�@��x^y��has�the�same�eect�as��exp(y*ln(x))�.�iEIt�can�b�Ge�applied�to����p�-adic�UUn���um�b�Gers�as�w�ell�as�to�the�more�usual�t�yp�Ges.����The�UUlibrary�syn���tax�is���gp�Q�o��9w�����(�x;���y�[�;���pr��}'e�c�����).��r<��3.3.2�Euler�:�Euler's���constan���t�0�:�57721���������
UO�.�8�Note�that��Euler��is�one�of�the�few�sp�Gecial�reserv�ed�names���whic���h�UUcannot�b�Ge�used�for�v��q�ariables�(the�others�are��I��and��Pi�,�as�w�ell�as�all�function�names).����The��
library�syn���tax�is���mp�Q�euler��,��(��pr��}'e�c���)�where���pr��}'e�c��p+must���b�Ge�giv�en.�~�Note�that�this�creates��
�=B�on���the�(�P��*�ARI�(�stac���k,�]�but�a�cop�y�is�also�created�on�the�heap�for�quic�k�er�computations�next�time�the���function�UUis�called.��r<��3.3.3��TI�:�UUthe�complex�n���um�b�Ger���UU��$��p�������$��fe�����1����q�.����The�UUlibrary�syn���tax�is�the�global�v��q�ariable��gi��(of�t�yp�Ge��GEN�).����3.3.4��TPi�:�q�the�UUconstan���t����.�(3�:�14159���������
UO�).����The��Nlibrary�syn���tax�is���mppi��~�(��pr��}'e�c���)�where���pr��}'e�c��.�must��&�b�Ge�giv�en.��Note�that�this�creates����'�on�the���P��*�ARI���stac���k,���but��a�cop�y�is�also�created�on�the�heap�for�quic�k�er�computations�next�time�the�function���is�UUcalled.�������69���F�����Kf�������3.3.5�5`abs�(�x�):��absolute���v��q�alue�of��x��(mo�Gdulus�if��x��is�complex).�lUP���o�w�er���series�and�rational�functions���are��{not�allo���w�ed.��:Con�trary��{to�most�transcenden���tal�functions,���an�exact�argumen�t�is��not��S�con�v�erted���to�UUa�real�n���um�b�Ger�UUb�efore�applying��abs��and�an�exact�result�is�returned�if�p�ossible.��&���?�?�abs(-1)��	���%1�?�=�1����?�?�abs(3/7�+�4/7*I)����%2�?�=�5/7����?�?�abs(1�+�I)����%3�?�=�1.414213562373095048801688724�����If�Z��x��is�a�p�Golynomial,�[�returns���x��if�the�leading�co�ecien���t�is�real�and�negativ�e�else�returns��x�.���F��*�or�a���p�Go���w�er�UUseries,�the�constan���t�co�ecien���t�is�considered�instead.����The�UUlibrary�syn���tax�is���gabs���4�(�x;�����pr��}'e�c�����).��9��3.3.6���acos�(�x�):�giprincipal�P&branc���h�of��cos�������^���1��p)�(�x�),���i.e.�suc�h�that��Re(acos��&e~(�x�))�i�2��[0�;����[٫].�b:If�P&�x��2��R��and����j�x�j���>��1,�UUthen��acos����(�x�)�is�complex.����The�UUlibrary�syn���tax�is���gacos���(�x;�����pr��}'e�c�����).��9��3.3.7�
pacosh�(�x�):��$principal���branc���h�of��cosh���uM�����1��!1��(�x�),��i.e.�suc�h�that��Im(acosh��+J�(�x�))��2��[0�;����[٫].��SIf����x��2��R��and����x��<��1,�UUthen��acosh��G(�x�)�is�complex.����The�UUlibrary�syn���tax�is���gac��9h��ڡ�(�x;�����pr��}'e�c�����).��9��3.3.8���agm�(�x;���y�[٫):���arithmetic-geometric��Tmean�of��x��and��y��.�	<�In�the�case�of�complex�or�negativ���e���n���um�b�Gers,���the�U�principal�square�ro�ot�is�alw���a�ys�U�c�hosen.�r�p�-adic�or�p�Go�w�er�series�argumen�ts�are�also���allo���w�ed.�p7Note�T�that�a��p�-adic�agm�exists�only�if��x=y����is�congruen���t�to�1�mo�Gdulo��p��(mo�dulo�16�for����p���=�2).�qDZx�UU�and��y��.�cannot�b�Goth�b�e�v���ectors�or�matrices.����The�UUlibrary�syn���tax�is���agm��A��(�x;���y�[�;���pr��}'e�c�����).��9��3.3.9��Targ�(�x�):�q�argumen���t�UUof�the�complex�n�um�b�Ger��x�,�suc�h�that����"�<����arg���R(�x�)������[٫.����The�UUlibrary�syn���tax�is���garg��Q��(�x;�����pr��}'e�c�����).����3.3.10�`�asin�(�x�):�dDprincipal�Γbranc���h�of��sin�������*��1���%�(�x�),���i.e.�suc�h�that��Re(asin��$�z(�x�))��*�2��[���[�=�2�;����=�2].�݂If�Γ�x��*�2��R����and�UU�j�x�j���>��1�then��asin���t(�x�)�is�complex.����The�UUlibrary�syn���tax�is���gasin�����(�x;�����pr��}'e�c�����).����3.3.11��Tasinh�(�x�):�q�principal�UUbranc���h�of��sinh���*������1���!�(�x�),�i.e.�suc�h�that��Im(asinh��*(�x�))���2��[���[�=�2�;����=�2].����The�UUlibrary�syn���tax�is���gash���4�(�x;�����pr��}'e�c�����).����3.3.12��Tatan�(�x�):�q�principal�UUbranc���h�of��tan������RH��1�����(�x�),�i.e.�suc�h�that��Re(atan��&x�(�x�))���2��]�8����[�=�2�;����=�2[.����The�UUlibrary�syn���tax�is���gatan���(�x;�����pr��}'e�c�����).����3.3.13���atanh�(�x�):��
principal���branc���h�of��tanh����������1��"�n�(�x�),�_i.e.�suc�h�that��Im(atanh��,�S(�x�))��η2��]�������[�=�2�;����=�2].�J�If����x���2��R�UU�and��j�x�j���>��1�UUthen��atanh��UZ(�x�)�is�complex.����The�UUlibrary�syn���tax�is���gath���ګ(�x;�����pr��}'e�c�����).�������70���G������Kf�������3.3.14���b�Q�ernfrac�(�x�):�[�Bernoulli�)Un���um�b�Ger��B����x���,�2"where��B����0��C��=��1,��B����1���=����1�=�2,��B����2���=��1�=�6,��:���:�:��
UO�,�expressed�)Uas���a�UUrational�n���um�b�Ger.�q�The�UUargumen�t��x��should�b�Ge�of�t�yp�Ge�in�teger.��zB��The�UUlibrary�syn���tax�is���b�Q�ernf�rac��.z��(�x�).����3.3.15��b�Q�ernreal�(�x�):���Bernoulli�_�n���um�b�Ger��B����x���,��`as��bernfrac�,�but��B����x��	h��is�returned�as�a�real�n���um�b�Ger���(with�UUthe�curren���t�precision).����The�UUlibrary�syn���tax�is���b�Q�ernreal��-:��(�x;�����pr��}'e�c�����).����3.3.16�9�b�Q�ern��9v�ec�(�x�):� wcreates���a�v���ector�con�taining,�ƒas�rational�n�um�b�Gers,�ƒthe�Bernoulli�n�um�b�Gers��B����0��|s�,����B����2��|s�,��:���:�:��
UO�,���B����2�x��	W�.�2�This��routine�is�obsolete.�Use��bernfrac��instead�eac���h�time�y�ou�need�a�Bernoulli�n�um�b�Ger���in�UUexact�form.���Í�Note:����this��Oroutine�is�implemen���ted�using�rep�Geated�indep�endan���t�calls�to��bernfrac�,���whic�h�is�faster���than��!the�standard�recursion�in�exact�arithmetic.��*It�is�only�k���ept�for�bac�kw�ard�compatibilit�y:�/^it�is���not�faster�than�individual�calls�to��bernfrac�,�AFits�output�uses�a�lot�of�memory�space,�and�coping���with�UUthe�index�shift�is�a���wkw�ard.����The�UUlibrary�syn���tax�is���b�Q�ern��9v�ec��*?�(�x�).����3.3.17��Tb�Q�esselh1�(��nu�����;���x�):�qDZH������^��1��Lq�-Bessel�UUfunction�of�index���nu��l1�and�argumen���t��x�.����The�UUlibrary�syn���tax�is���h��9b�Q�essel1��,�Q�(��nu�����;���x;���pr��}'e�c�����).����3.3.18��Tb�Q�esselh2�(��nu�����;���x�):�qDZH������^��2��Lq�-Bessel�UUfunction�of�index���nu��l1�and�argumen���t��x�.����The�UUlibrary�syn���tax�is���h��9b�Q�essel2��,�Q�(��nu�����;���x;���pr��}'e�c�����).����3.3.19���b�Q�esseli�(��nu�����;���x�):���I���-Bessel��function�of�index���nu���W�and�argumen���t��x�.��If��x��con�v�erts�to�a�p�Go�w�er���series,��the��[initial�factor�(�x=�2)���^�����ɱ=�(��/�+�`91)�is�omitted�(since�it�cannot�b�Ge�represen���ted�in�P��*�ARI��Lwhen������K�is�UUnot�in���tegral).����The�UUlibrary�syn���tax�is���ib�Q�essel��$T�(��nu�����;���x;���pr��}'e�c�����).����3.3.20��1b�Q�esselj�(��nu�����;���x�):���J��9�-Bessel���function�of�index���nu����and�argumen���t��x�.�[�If��x��con�v�erts�to�a�p�Go�w�er���series,��the��[initial�factor�(�x=�2)���^�����ɱ=�(��/�+�`91)�is�omitted�(since�it�cannot�b�Ge�represen���ted�in�P��*�ARI��Lwhen������K�is�UUnot�in���tegral).����The�UUlibrary�syn���tax�is���ib�Q�essel��$T�(��nu�����;���x;���pr��}'e�c�����).����3.3.21��2b�Q�esseljh�(�n;���x�):�i�J��9�-Bessel�Qdfunction�of�half�in���tegral�index.�e�More�precisely��*�,���h�besseljh��.�P�(�n;�x�)���computes�Ζ�J���:�n�+1�=�2���ث(�x�)�where��n��m���ust�b�Ge�of�t�yp�Ge�in�teger,���and��x��is�an�y�elemen�t�of��C�.�݋In�the�presen�t���v���ersion�UU2.2.7,�this�function�is�not�v�ery�accurate�when��x��is�small.����The�UUlibrary�syn���tax�is���jb�Q�esselh��*���(�n;���x;���pr��}'e�c�����).����3.3.22��Kb�Q�esselk�(��nu�����;���x;��f��flag���ѫ=�t0�g�):�t�K���-Bessel�V�function�of�index���nu��n�(whic���h�can�b�Ge�complex)�and���argumen���t�D\�x�.�lOnly�real�and�p�Gositiv�e�argumen�ts��x��are�allo�w�ed�in�the�presen�t�v�ersion�2.2.7.�lIf���flag�����is���equal�UUto�1,�uses�another�implemen���tation�of�this�function�whic�h�is�often�faster.����The�UUlibrary�syn���tax�is���kb�Q�essel��&�S�(��nu�����;���x;���pr��}'e�c�����)�UUand���kb�Q�essel2��,�Q�(��nu���;���x;���pr��}'e�c�����)�UUresp�Gectiv���ely��*�.�������71���H������Kf�������3.3.23��Tb�Q�esseln�(��nu�����;���x�):�qDZN��-Bessel�UUfunction�of�index���nu��l1�and�argumen���t��x�.��	J��The�UUlibrary�syn���tax�is���n��9b�Q�essel��&�S�(��nu�����;���x;���pr��}'e�c�����).�����3.3.24��Tcos�(�x�):�q�cosine�UUof��x�.����The�UUlibrary�syn���tax�is���gcos��z��(�x;�����pr��}'e�c�����).����3.3.25��Tcosh�(�x�):�q�h���yp�Gerb�olic�UUcosine�of��x�.����The�UUlibrary�syn���tax�is���gc��9h��C��(�x;�����pr��}'e�c�����).����3.3.26��Tcotan�(�x�):�q�cotangen���t�UUof��x�.����The�UUlibrary�syn���tax�is���gcotan��$eH�(�x;�����pr��}'e�c�����).����3.3.27��dilog�(�x�):��principal��Ebranc���h�of�the�dilogarithm�of��x�,��Ai.e.�analytic�con�tin�uation�of�the�p�Go�w�er���series��UUlog���@�qƮ2���t�(�x�)��=������P���
US��n��1����x���^��n��q~�=n���^��2��|s�.����The�UUlibrary�syn���tax�is���dilog���M�(�x;�����pr��}'e�c�����).���m��3.3.28��Tein��9t1�(�x;����f�n�g�):�q�exp�Gonen���tial�UUin�tegral�����ĽR����j���
�1��	#���9�x���������V�e����r���0ncmsy5��t���V���&�fe�w�������t�����$��dt��(�x���2��R�)����If���n��is�presen���t,���outputs�the��n�-dimensional�v�ector�[��eint1��?�(�x�)�;����:�:�:����;�����eint1��ꙫ(�nx�)]�(�x������0).��{This���is���faster�UUthan�rep�Geatedly�calling��eint1(�i�?��*�x)�.����The�UUlibrary�syn���tax�is���v��9ecein�t1��,8֫(�x;���n;���pr��}'e�c�����).�q�Also�UUa�v��q�ailable�is���ein��9t1���(�x;�����pr��}'e�c�����).��q��3.3.29��Terfc�(�x�):�q�complemen���tary�UUerror�function�(2�=������p���UW����fe�3荱����du�)�������ĽR����j���US�1��	#���c��x���x�e���^���t����r�2���W�dt��(�x���2��R�).����The�UUlibrary�syn���tax�is���erf�c��2�(�x;�����pr��}'e�c�����).�����3.3.30��eta�(�x;����f��flag��Ci�=��0�g�):��Dedekind's�~r���K�function,���without�the��q��[ٟ�^��1�=�24����.��This�means�the�follo���wing:�if����x�oG�is�a�complex�n���um�b�Ger�oGwith�p�ositiv���e�imaginary�part,�u�the�result�is������Q�����ލ���1��%����n�=1���r��(1�J,���q��[ٟ�^��n���W�),�where�oG�q�N.�=��U�e���^��2�i�@Lx����.���If��H�x��is�a�p�Go���w�er��Hseries�(or�can�b�e�con���v�erted��Hto�a�p�o���w�er��Hseries)�with�p�ositiv���e�v��q�aluation,���the�result�is��������Q�����ލ�	qɺ1��%��	qɴn�=1���J�(1�8���x���^��n��q~�).����If��I��flag��H��=��1�I�and��x��can�b�Ge�con���v�erted�I�to�a�complex�n���um�b�er�I�(i.e.�is�not�a�p�o���w�er�I�series),�K�computes���the�UUtrue����.�function,�including�the�leading��q��[ٟ�^��1�=�24����.����The�UUlibrary�syn���tax�is���eta�����(�x;�����pr��}'e�c�����).�����3.3.31��Texp�(�x�):�q�exp�Gonen���tial�UUof��x�.��p�-adic�argumen���ts�with�p�Gositiv�e�v��q�aluation�are�accepted.����The�UUlibrary�syn���tax�is���gexp�����(�x;�����pr��}'e�c�����).����3.3.32�#�gammah�(�x�):���gamma��Zfunction�ev��q�aluated�at�the�argumen���t��x�f8�+�1�=�2.�=�When��Z�x��is�an�in�teger,���this�UUis�m���uc�h�UUfaster�than�using���gamma���F�(�x�8�+�1�=�2).����The�UUlibrary�syn���tax�is���ggamd��$eH�(�x;�����pr��}'e�c�����).����3.3.33���gamma�(�x�):��<gamma�]�function�of��x�.��wIn�the�presen���t�v�ersion�2.2.7�the��p�-adic�gamma�function���is�UUnot�implemen���ted.����The�UUlibrary�syn���tax�is���ggamma��-.'�(�x;�����pr��}'e�c�����).�������72���Iꍟ���Kf�������3.3.34���h��9yp�Q�eru�(�a;���b;�x�):��E�U��-con
uen���t���h�yp�Gergeometric�function�with�parameters��a��and��b�.�X�The�pa-���rameters�UU�a��and��b��can�b�Ge�complex�but�the�presen���t�implemen�tation�requires��x��to�b�Ge�p�ositiv���e.��{	��The�UUlibrary�syn���tax�is���h��9yp�Q�eru��&���(�a;���b;�x;���pr��}'e�c�����).��q��3.3.35��Tincgam�(�s;���x;�y�[٫):�q�incomplete�UUgamma�function.�����x�Oe�m���ust�b�Ge�p�ositiv���e�and��s��real.�o�The�result�returned�is�����ĽR����j���	��1��	#���I�x�����e���^���t��	�W�t���^��s��1��-V�dt�.�When��y��>�is�giv���en,�P�assume���(of�:�course�without�c���hec�king!)�"�that�:��y����=�E�(�s�).�F��*�or�small��x�,�tgthis�will�tremendously�sp�Geed�up�the���computation.����The���library�syn���tax�is���incgam��'$��(�s;���x;���pr��}'e�c�����)���and���incgam0��,䮫(�s;���x;�y�[�;���pr��}'e�c���),���resp�Gectiv���ely���(an�omitted����y����is�]�co�Gded�as��NULL�).�There�exist�also�the�functions��incgam1��and��incgam2��whic���h�are�used�for���in���ternal�UUpurp�Goses.��q��3.3.36��Tincgamc�(�s;���x�):�q�complemen���tary�UUincomplete�gamma�function.����The�{Bargumen���ts��s��and��x��m�ust�b�Ge�p�ositiv���e.��The�result�returned�is�����ĽR����j���
%�x��	#���4&�0����y�e���^���t��	�W�t���^��s��1��-V�dt�,���when��x��is�not���to�Go�UUlarge.����The�UUlibrary�syn���tax�is���incgamc��,�(�s;���x;���pr��}'e�c�����).��q��3.3.37�+�log�(�x;����f��flag����=��0�g�):�(principal���branc���h�of�the�natural�logarithm�of��x�,��ci.e.�suc�h�that��Im(ln���(�x�))���2����]�8����[�;�����].�q�The�UUresult�is�complex�(with�imaginary�part�equal�to���[٫)�if��x���2��R�UU�and��x��<��0.�����p�-adic��argumen���ts�are�also�accepted�for��x�,�O�with�the�con�v�en�tion�that��ln��
?�(�p�)�ju=�0.�	1tHence��in���particular��D�exp����(�ln��UW(�x�))�=x�D��will�not�in�general�b�Ge�equal�to�1�but�to�a�(�p�����1)-th�D�ro�ot�of�unit���y�(or���1�if����p���=�2)�UUtimes�a�p�Go���w�er�UUof��p�.����If��.	�flag���ޫis�.	equal�to�1��=���AGM����,�5�use�.	an�agm�form���ula�suggested�b�y�Mestre,�5�when��x��is�real,�otherwise���iden���tical�UUto��log�.����The�UUlibrary�syn���tax�is���glog�����(�x;�����pr��}'e�c�����)�or���glogagm��,�~�(�x;�����pr��}'e�c���).��q��3.3.38��jlngamma�(�x�):��principal�branc���h�of�the�logarithm�of�the�gamma�function�of��x�.��DCan�ha�v�e���m���uc�h��larger�argumen���ts�than��gamma��itself.�Z�In�the�presen�t�v�ersion�2.2.7,��the��p�-adic��lngamma��function���is�UUnot�implemen���ted.����The�UUlibrary�syn���tax�is���glngamma��6�y�(�x;�����pr��}'e�c�����).��q��3.3.39��Tp�Q�olylog�(�m;���x;����flag�����=��0��$7�):�q�one�UUof�the�dieren���t�p�Golylogarithms,�dep�ending�on���flag���!�:����If��
�flag���=��0�
or�is�omitted:�S��m���^��th��#��p�Golylogarithm�of��x�,�%i.e.�analytic�con���tin�uation�
of�the�p�o���w�er�
series����Li���	���m�����(�x�)��=������P���
US��n��1����x���^��n��q~�=n���^��m�����.�q�The�T�program�uses�the�p�Go���w�er�T�series�when��j�x�j���^��2��C�����1�=�2,�T�and�the�p�o���w�er�T�series���expansion�Z3in��log��D�(�x�)�otherwise.��aIt�is�v��q�alid�in�a�large�domain�(at�least��j�x�j��5�<��230),�[kbut�Z3should�not�b�Ge���used�FMto�Go�far�a���w�a�y�FMfrom�the�unit�circle�since�it�is�then�b�etter�to�use�the�functional�equation�linking���the���v��q�alue�at��x��to�the�v�alue�at�1�=x�,���whic���h�tak�es�a�trivial�form�for�the�v��q�arian�t�b�Gelo�w.��P�o�w�er�series,���p�Golynomial,�UUrational�and�v���ector/matrix�argumen�ts�are�allo�w�ed.����F��*�or�,vthe�v��q�arian���ts�to�follo�w�w�e�need�a�notation:�]Wlet��<����m��
��denotes��<��or��=��dep�Gending�whether��m��is���o�Gdd�UUor�ev���en.����If��UU�flag��T9�=��1:�q�mo�Gdied�UU�m���^��th��`�p�olylogarithm�of��x�,�called���x䍑��~������D����m����5g�(�x�)�in�Zagier,�dened�for��j�x�j����1�b���y��e��P��<����m����	CC���\� �������-�m��1������������X��������k�+B�=0�������<$��%`٫(������log��?��j�x�j�)���^��k���%`ٟw�fe/��	(֍��V�k�P��!������V�*Li���_�H���m��k��q�t�(�x�)�8�+�����<$��l(������log��?��j�x�j�)���^��m��1���l�w�fe<蝟	(֍���m�!������C2�log��Q�߷j�1����x�j����\�!���8�:�������73���Jf�����Kf�����卑�If��UU�flag��T9�=��2:�q�mo�Gdied�UU�m���^��th��`�p�olylogarithm�of��x�,�called��D����m�����(�x�)�in�Zagier,�dened�for��j�x�j����1�b���y��##���h��<����m����	CC���\� �������-�m��1������������X��������k�+B�=0�������<$��%`٫(������log��?��j�x�j�)���^��k���%`ٟw�fe/��	(֍��V�k�P��!������V�*Li���_�H���m��k��q�t�(�x�)�8������<$��l�1��l�w�fe�	(֍2���������<$��
�z(������log��?��j�x�j�)���^��m���
�z�w�fe2�)�	(֍����m�!������>�֟��\�!���ѣֱ:��+�덑�If���)�flag����=��!3:��nanother��)mo�Gdied��m���^��th���֫p�olylogarithm�of��x�,��]called��P����m�����(�x�)�in�Zagier,�dened�for����j�x�j����1�UUb���y��#���W�Ϸ<����m����	CC���\� �������-�m��1������������X��������k�+B�=0�������<$��%`٫2���^��k��됱B����k���%`ٟw�fel�	(֍�;�k�P��!�����=�(�log���T�j�x�j�)������k���됫Li���
���m��k�� 6ګ(�x�)�8������<$��l�2���^��m��1����B����m���l�w�fe&s�	(֍�
:P�m�!�����*��(�log���j�x�j�)������m��������\�!�����?�:��&lR���These�UUthree�functions�satisfy�the�functional�equation��f����m�����(1�=x�)��=�(��1)���^��m��1����f����m���(�x�).������The�UUlibrary�syn���tax�is���p�Q�olylog0��-�(�m;���x;���flag���t�;���pr��}'e�c�����).��AZ��3.3.40��Tpsi�(�x�):�q�the�UU� �[٫-function�of��x�,�i.e.�the�logarithmic�deriv��q�ativ���e����^��0���9�(�x�)�=�(�x�).����The�UUlibrary�syn���tax�is���gpsi��3�(�x;�����pr��}'e�c�����).����3.3.41��Tsin�(�x�):�q�sine�UUof��x�.����The�UUlibrary�syn���tax�is���gsin��3�(�x;�����pr��}'e�c�����).����3.3.42��Tsinh�(�x�):�q�h���yp�Gerb�olic�UUsine�of��x�.����The�UUlibrary�syn���tax�is���gsh���(�x;�����pr��}'e�c�����).����3.3.43�V{sqr�(�x�):�:�square��of��x�.�MThis�op�Geration�is�not�completely�straigh���tforw�ard,��i.e.��iden�tical�to��x�\G���x�,���since���it�can�usually�b�Ge�computed�more�ecien���tly�(roughly�one-half�of�the�elemen�tary�m�ultiplications���can�UUb�Ge�sa���v�ed).�q�Also,�UUsquaring�a�2-adic�n���um�b�er�UUincreases�its�precision.�q�F��*�or�example,��+����?�?�(1�+�O(2^4))^2���䍑%1�?�=�1�+�O(2^5)����?�?�(1�+�O(2^4))�*�(1�+�O(2^4))����%2�?�=�1�+�O(2^4)������Note���that�this�function�is�also�called�whenev���er�one�m�ultiplies�t�w�o�ob��8jects�whic�h�are�kno�wn�to�b�Ge����identic��}'al���,�UUe.g.�they�are�the�v��q�alue�of�the�same�v�ariable,�or�w���e�are�computing�a�p�Go�w�er.�����?�?�x�=�(1�+�O(2^4));�x�*�x����%3�?�=�1�+�O(2^5)����?�?�(1�+�O(2^4))^4����%4�?�=�1�+�O(2^6)������(note�UUthe�dierence�b�Get���w�een�UU�%2��and��%3��ab�o���v�e).����The�UUlibrary�syn���tax�is���gsqr��lū(�x�).�������74���K*������Kf�������3.3.44�8Ssqrt�(�x�):�-�principal���branc���h�of�the�square�ro�Got�of��x�,��i.e.�suc�h�that��Arg��[(�sqrt��(�x�))���2��]�'Է���[�=�2�;����=�2],���or�ɨin�other�w���ords�suc�h�that��<�(�sqrt��(�x�))����>��0�ɨor��<�(�sqrt��(�x�))���=�0�ɨand��=�(�sqrt��(�x�))������0.���If�ɨ�x��2��R��and����x��<��0,�UUthen�the�result�is�complex�with�p�Gositiv���e�imaginary�part.���Ӎ�In���tegermo�Gd�g�a�prime�and��p�-adics�are�allo�w�ed�as�argumen�ts.���In�that�case,�l$the�square�ro�Got�(if�it���exists)���whic���h�is�returned�is�the�one�whose�rst��p�-adic�digit�(or�its�unique��p�-adic�digit�in�the�case���of�]�in���tegermo�Gds)�is�in�the�in�terv��q�al�[0�;���p=�2].��wWhen�the�argumen�t�is�an�in�tegermo�Gd�a�non-prime�(or�a���non-prime-adic),�UUthe�result�is�undened.����The�UUlibrary�syn���tax�is���gsqrt��姫(�x;�����pr��}'e�c�����).�����3.3.45�=�sqrtn�(�x;���n;��f�&�z�p��g�):��principal���branc���h�of�the��n�th�ro�Got�of��x�,��	i.e.�suc�h�that��Arg���(�sqrt��(�x�))��\�2����]�8����[�=n;����=n�].����In���tegermo�Gd�UUa�prime�and��p�-adics�are�allo�w�ed�as�argumen�ts.����If�h��z���is�presen���t,�mNit�is�set�to�a�suitable�ro�Got�of�unit�y�allo�wing�to�reco�v�er�all�the�other�ro�Gots.��QIf�it���w���as�UUnot�p�Gossible,�z�is�set�to�zero.����The�UUfollo���wing�script�computes�all�ro�Gots�in�all�p�ossible�cases:������sqrtnall(x,n)=��/F��{�����local(V,r,z,r2);�����r�?�=�sqrtn(x,n,�&z);�����if�?�(!z,�error("Impossible�case�in�sqrtn"));�����if�?�(type(x)�==�"t_INTMOD"�||�type(x)=="t_PADIC"�,����(��r2�?�=�r*z;�n�=�1;����(��while�?�(r2!=r,�r2*=z;n++));�����V�?�=�vector(n);�V[1]�=�r;�����for(i=2,�?�n,�V[i]�=�V[i-1]*z);�����V����}����addhelp(sqrtnall,"sqrtnall(x,n):compute�?�the�vector�of�nth-roots�of�x");������The�UUlibrary�syn���tax�is���gsqrtn��#I3�(�x;���n;��&�z�p�;���pr��}'e�c�����).�����3.3.46��Ttan�(�x�):�q�tangen���t�UUof��x�.����The�UUlibrary�syn���tax�is���gtan���ګ(�x;�����pr��}'e�c�����).����3.3.47��Ttanh�(�x�):�q�h���yp�Gerb�olic�UUtangen�t�of��x�.����The�UUlibrary�syn���tax�is���gth�����(�x;�����pr��}'e�c�����).����3.3.48��Tteic��9hm�uller�(�x�):�q�T��*�eic���hm�G����uller�UUc�haracter�of�the��p�-adic�n�um�b�Ger��x�.����The�UUlibrary�syn���tax�is���teic��9h��s��(�x�).����3.3.49��Ttheta�(�q�[�;���z�p��):�q�Jacobi�UUsine�theta-function.����The�UUlibrary�syn���tax�is���theta����(�q�[�;���z�p�;���pr��}'e�c�����).�������75���L5������Kf�������3.3.50��Tthetan��9ullk�(�q�[�;���k�P��):�qDZk��-th�UUderiv��q�ativ���e�at��z�7��=��0�of���theta���F�(�q�;���z�p��).���u��The�UUlibrary�syn���tax�is���thetan��9ullk��6q��(�q�[�;���k�P�;���pr��}'e�c�����),�UUwhere��k���is�a��long�.��V_��3.3.51��Tw��9eb�Q�er�(�x;����f��flag����=��0�g�):�q�one�UUof�W��*�eb�Ger's�three��f�h�functions.�If���flag��T9�=��0,�returns������2x}�f���(�x�)��=��exp��7(��i�[�=�24)�8�����((�x��+�1)�=�2)����=���(�x�)��
suc���h�UUthat��<㕱j�Y��=��(�f��������24���U��8�16)������3��|s�=f��������24��7�;����where�UU�j���is�the�elliptic��j����-in���v��q�arian�t�UU(see�the�function��ellj�).�q�If���flag��T9�=��1,�returns����\���f����1��|s�(�x�)��=���[٫(�x=�2)����=���(�x�)��
suc���h�UUthat��<㕱j�Y��=��(�f���������24����1����U�+�8�16)������3��|s�=f���������24����1���7�:����Finally��*�,�UUif���flag��T9�=��2,�returns����Y6Y�f����2��|s�(�x�)��=�����=V�p���o��=V�fe�ª��2����p��[٫(2�x�)����=���(�x�)��
suc���h�UUthat��<㕱j�Y��=��(�f���������24����2����U�+�8�16)������3��|s�=f���������24����2���	�u�:����Note�UUthe�iden���tities��f�����^��8��W�=���f���^�����8��l�1�����+�8�f���^�����8��l�2����W�and��f��f����1��|s�f����2��C��=������P�p���o���P�fe�E���2����p.����The�UUlibrary�syn���tax�is���w��9eb�Q�er0��'.�(�x;�����flag���t�;�����pr��}'e�c�����),�or���wf��>3�(�x;�����pr��}'e�c���),���wf�1���1�(�x;�����pr��}'e�c���)�or���wf�2���1�(�x;�����pr��}'e�c���).��V_��3.3.52�1�zeta�(�s�):�IRiemann's���zeta�function�����(�s�)�L�=������P���
���n��1��3��n���^���s��
�;�,���computed���using�the�Euler-Maclaurin���summation�A�form���ula,�E�except�when��s��is�of�t�yp�Ge�in�teger,�E�in�whic�h�case�it�is�computed�using�Bernoulli���n���um�b�Gers�UUfor��s�����0�UUor��s��>��0�UUand�ev���en,�and�using�mo�dular�forms�for��s��>��0�UUand�o�dd.����The�UUlibrary�syn���tax�is���gzeta����(�s;�����pr��}'e�c�����).������3.4��Arithmetic�functions�.�����These�m/functions�are�b���y�denition�functions�whose�natural�domain�of�denition�is�either��Z��(or����Z����>�0��
�t�),��or��Jsometimes�p�Golynomials�o���v�er��Ja�base�ring.�K�F��*�unctions�whic���h�concern�p�olynomials�exclusiv���ely���will�]�b�Ge�explained�in�the�next�section.���The�w���a�y�]�these�functions�are�used�is�completely�dieren���t���from��Gtranscenden���tal�functions:���in�general�only�the�t�yp�Ges�in�teger�and�p�Golynomial�are�accepted�as���argumen���ts.�p�If�T�a�v�ector�or�matrix�t�yp�Ge�is�giv�en,���the�function�will�b�Ge�applied�on�eac�h�co�Gecien�t���indep�Genden���tly��*�.����In��Lthe�presen���t�v�ersion�2.2.7,���all�arithmetic�functions�in�the�narro�w�sense�of�the�w�ord�|�Euler's���totien���t��6function,�ۣthe�Mo�Gebius�function,�the�sums�o���v�er��6divisors�or�p�Go���w�ers��6of�divisors�etc.|�call,�after���trial�]qdivision�b���y�small�primes,�_xthe�same�v�ersatile�factoring�mac�hinery�describ�Ged�under��factorint�.���It��;includes�Shanks�SQUF���OF,�P�ollard�Rho,���ECM��'and�MPQS�stages,���and�has�an�early�exit�option���for�%the�functions��mo�Q�ebius��and�(the�in���teger�function�underlying)��issquarefree�.�a�Note�that�it�relies���on�UUa�(fairly�strong)�probabilistic�primalit���y�test,�see��ispseudoprime�.����3.4.1���addprimes�(�f�x��[�=�[���]�g�):��adds��~the�\primes"�con���tained�in�the�v�ector��x��(or�the�single�in�teger����x�)�Oto�the�table�computed�up�Gon�GP�#initialization�(b���y��pari���E�ff&f��ǫinit��in�library�mo�de),�+
and�returns�a���ro���w���v�ector�en�tries�con�tain�all�suc�h�user�primes.�]Whenev�er��factor��or��smallfact��is�subsequen�tly���called,�ʸrst��the�primes�in�the�table�computed�b���y��pari���E�ff&f��ǫinit��will�b�Ge�c�hec�k�ed,�ʸand�then�the�additional���primes�UUin�this�table.�q�If��x��is�empt���y�or�omitted,�just�returns�the�curren�t�list�of�extra�primes.����The��nen���tries�in��x��are�not�c�hec�k�ed�for�primalit�y��*�.�<zThey�need�only�b�Ge�p�ositiv���e�in�tegers�not�divisible���b���y���an�y�of�the�pre-computed�primes.�$'It's�in�fact�a�nice�tric�k�to�add�comp�Gosite�n�um�b�Gers,���whic�h�for���example�Tbthe�function���factor��"�P�(�x;����0)�w���as�not�able�to�factor.�qvIn�case�the�message�\imp�Gossible�in�v�erse���mo�Gdulo�l۷h��some���INTMOD��E��i�"�sho���ws�up�afterw�ards,�r�y�ou�ha�v�e�just�stum�bled�o�v�er�a�non-trivial�factor.���Note�Cthat�the�arithmetic�functions�in�the�narro���w�sense,�F�lik�e��eulerphi�,�F�do��not�5ܫuse�this�extra�table.����T��*�o�UUremo���v�e�primes�from�the�list�use��removeprimes�.����The�UUlibrary�syn���tax�is���addprimes��7i+�(�x�).�������76���M?������Kf�������3.4.2�}cb�Q�estappr�(�x;���A;��f�B��q�g�):��if��x�B�g�is�omitted,�nds�the�b�Gest�rational�appro���ximation�to��x����2��R��x�(or����R�[�X���],�UUor��R���^��n��q~�,���:���:�:�����)�with�denominator�at�most�equal�to��A��using�con���tin�ued�UUfractions.��R��If���B���is�presen���t,���x��is�assumed�to�b�Ge�of�t�yp�Ge��t_INTMOD���mo�dulo��M�ȫ(or�a�recursiv���e�com�bination�of���those),� and��the�routine�returns�the�unique�fraction��a=b��in�coprime�in���tegers��a�����A���and��b�����B���whic�h���is���congruen���t�to��x��mo�Gdulo��M��.�k�If��M��<���!�2�AB��q�,�(uniqueness�is�not�guaran�teed�and�the�function�fails���with�Can�error�message.�YlIf�rational�reconstruction�is�not�p�Gossible�(no�suc���h��a=b��exists�for�at�least�one���comp�Gonen���t�UUof��x�),�returns���1.����The�;>library�syn���tax�is���b�Q�estappr0��5��(�x;���A;�B��q�).�iAlso�;>a�v��q�ailable�is���b�Q�estappr��/R��(�x;���A�)�corresp�Gonding�to���an�UUomitted��B��q�.�����3.4.3��b�Q�ezout�(�x;���y�[٫):��nds��M�u��and��v��&�minimal�in�a�natural�sense�suc���h�that��x�b۷��u��+��y������v���=��0gcd��0
(�x;�y�[٫).���The�?�argumen���ts�m�ust�b�Ge�b�oth�in���tegers�or�b�oth�p�olynomials,�z�and�the�result�is�a�ro���w�v�ector�with���three�UUcomp�Gonen���ts��u�,��v�[٫,�and��gcd��UW(�x;���y��).����The��jlibrary�syn���tax�is���v��9ecb�Q�ezout��4���(�x;���y�[٫)�to�get�the�v�ector,�for���gb�Q�ezout��*_�(�x;���y�[�;��&�u;��&�v��)��jwhic���h�giv�es���as���result�the�address�of�the�created�gcd,��kand�puts�the�addresses�of�the�corresp�Gonding�created�ob��8jects���in���to�UU�u��and��v�[٫.�����3.4.4��Tb�Q�ezoutres�(�x;���y�[٫):�q�as�UU�bezout�,�with�the�resultan���t�of��x��and��y��.�replacing�the�gcd.����The��library�syn���tax�is���v��9ecb�Q�ezoutres��Cl1�(�x;���y�[٫)�to�get�the�v�ector,��or���subresext��2�;�(�x;���y�[�;��&�u;��&�v��)��whic���h���giv���es�Fvas�result�the�address�of�the�created�gcd,�Ioand�puts�the�addresses�of�the�corresp�Gonding�created���ob��8jects�UUin���to��u��and��v�[٫.�����3.4.5�+bigomega�(�x�):��%n���um�b�Ger�~�of�prime�divisors�of��j�x�j��coun���ted�with�m�ultiplicit�y��*�.��U�x��m�ust�b�Ge�an���in���teger.����The�UUlibrary�syn���tax�is���bigomega��2�`�(�x�),�the�result�is�a��long�.�� ���3.4.6��,binomial�(�x;���y�[٫):��3binomial�
�co�Gefficien���t������^��������
��x������
N�y������vk���^�����߫.��iHere��y�id�m�ust�b�Ge�an�in�teger,�;�but��x��can�b�Ge�an�y��qύP��*�ARI�UUob��8ject.����The�UUlibrary�syn���tax�is���binome��'�׫(�x;���y�[٫),�where��y��.�m�ust�b�Ge�a��long�.�����3.4.7�+Cc��9hinese�(�x;����f�y�[ٷg�):�;if���x��and��y���are�b�Goth�in���tegermo�ds�or�b�oth�p�olmo�ds,���creates�(with�the�same���t���yp�Ge)�UUa��z���in�the�same�residue�class�as��x��and�in�the�same�residue�class�as��y�[٫,�if�it�is�p�ossible.����This��&function�also�allo���ws�v�ector�and�matrix�argumen�ts,���in�whic�h�case�the�op�Geration�is�recur-���siv���ely�\�applied�to�eac�h�comp�Gonen�t�of�the�v�ector�or�matrix.���F��*�or�p�Golynomial�argumen�ts,�^�it�is�applied���to�UUeac���h�co�Gecien�t.����If���y��߫is�omitted,���and��x��is�a�v���ector,��chinese��is�applied�recursiv���ely�to�the�comp�Gonen�ts�of��x�,���yielding�UUa�residue�b�Gelonging�to�the�same�class�as�all�comp�onen���ts�of��x�.����Finally��I��chinese��(	s�(�x;���x�)��=��x�I��regardless�of�the�t���yp�Ge�of��x�;�Mwthis�allo�ws�v�ector�argumen�ts�to�con�tain���other�UUdata,�so�long�as�they�are�iden���tical�in�b�Goth�v�ectors.����The�UUlibrary�syn���tax�is���c��9hinois��%�ܫ(�x;���y�[٫).�������77���NR������Kf�������3.4.8�(icon��9ten�t�(�x�):�&�computes���the�gcd�of�all�the�co�Gecien���ts�of��x�,��when�this�gcd�mak�es�sense.�?�If��x��is�a���scalar,��this�Ӛsimply�returns�the�absolute�v��q�alue�of��x��if��x��is�rationnal�(�t_INT�,��t_FRAC��y�or��t_FRACN�),�and����x�&)�otherwise.�bIf��x��is�a�p�Golynomial�(and�b���y�extension�a�p�o���w�er�&)series),�/�it�giv���es�the�usual�con�ten�t�of��x�.���If�(E�x��is�a�rational�function,�1Hit�giv���es�the�ratio�of�the�con�ten�ts�of�the�n�umerator�and�the�denominator.���Finally��*�,�UUif��x��is�a�v���ector�or�a�matrix,�it�giv�es�the�gcd�of�the�con�ten�ts�of�all�en�tries.��$㍑The�UUlibrary�syn���tax�is���con��9ten�t��(�e�(�x�).��Iƍ�3.4.9�؆con��9tfrac�(�x;����f�b�g�;��f�nmax�g�):��creates�y�the�ro���w�v�ector�whose�comp�Gonen�ts�are�the�partial�quotien�ts���of�0�the�con���tin�ued�0�fraction�expansion�of��x�.�e�That�is�a�result�[�a����0��|s�;����:�:�:����;���a����n��q~�]�means�that��x�����a����0��lb�+���1�=�(�a����1���+�����:���:�:��
㇫+�8�1�=a����n��q~�)�����:�:�:��
UO�).�q�The�UUoutput�is�normalized�so�that��a����n��8��6�=��1�(unless�w���e�also�ha�v�e��n���=�0).����The��n���um�b�Ger�of�partial�quotien�ts��n��is�limited�to��nmax�.��If��x��is�a�real�n�um�b�Ger,��sthe�expansion���stops��;at�the�last�signican���t�partial�quotien�t�if��nmax��is�omitted.�
y�x��can�also�b�Ge�a�rational�function���or�UUa�p�Go���w�er�UUseries.����If�pa�v���ector��b��is�supplied,�1wthe�n�umerators�will�b�Ge�equal�to�the�co�ecien���ts�of��b��(instead�of�all���equal�'uto�1�as�ab�Go���v�e).��&The�'ulength�of�the�result�is�then�equal�to�the�length�of��b�,�[�unless�a�partial���remainder�b�is�encoun���tered�whic�h�is�equal�to�zero,�e�in�whic�h�case�the�expansion�stops.���In�the�case�of���real��n���um�b�Gers,�the�stopping�criterion�is�th�us�dieren�t�from�the�one�men�tioned�ab�Go�v�e�since,�if��b��is���to�Go�UUlong,�some�partial�quotien���ts�ma�y�not�b�Ge�signican�t.����If�UU�b��is�an�in���teger,�the�command�is�understo�Go�d�UUas��contfrac(�x;���nmax�)�.����The�zlibrary�syn���tax�is���con��9tf�rac0��2F/�(�x;���b;�nmax�).�\)Also�za�v��q�ailable�are���gb�Q�oundcf��2+��(�x;���nmax�),��!s�gcf�����(�x�),���or��UU�gcf�2���i�(�b;���x�),�UUwhere��nmax��is�a�C�in���teger.��Iƍ�3.4.10�ATcon��9tfracpnqn�(�x�):���when��ڱx��is�a�v���ector�or�a�one-ro�w�matrix,����x��is�considered�as�the�list���of�partial�quotien���ts�[�a����0��|s�;���a����1���;��:�:�:����;�a����n��q~�]�of�a�rational�n���um�b�Ger,���and�the�result�is�the�2�b���y�2�matrix���[�p����n��q~�;���p����n��1����;��q����n���;�q����n��1����]��Bin�the�standard�notation�of�con���tin�ued��Bfractions,��=so��p����n���=q����n���v�=�*��a����0���F�+�`�1�=�(�a����1���+���:���:�:��lM�+���1�=a����n��q~�)�����:�:�:��
UO�).�[kIf�A�x��is�a�matrix�with�t���w�o�Aro�ws�[�b����0��|s�;���b����1���;��:�:�:����;�b����n��q~�]�Aand�[�a����0��|s�;�a����1���;��:�:�:����;�a����n��q~�],��this�Ais�then�considered���as�^ra�generalized�con���tin�ued�^rfraction�and�w���e�ha�v�e�similarly��p����n��q~�=q����n��8��=��1�=b����0��|s�(�a����0��Ǒ�+�K�b����1���=�(�a����1���+��K�:���:�:��@�+�K�b����n��q~�=a����n���)�����:�:�:��
UO�).���Note�UUthat�in�this�case�one�usually�has��b����0��C��=��1.����The�UUlibrary�syn���tax�is���pnqn�����(�x�).��Iƍ�3.4.11���core�(�n;����f��flag����=��0�g�):�\4if�*.�n��is�a�non-zero�in���teger�written�as��n��=��d��UUf�����^��2���0�with��d��squarefree,�2�returns����d�.�q�If��UU�flag���v�is�UUnon-zero,�returns�the�t���w�o-elemen�t�UUro�w�v�ector�[�d;���f���].����The�h�library�syn���tax�is���core0����(�n;�����flag���t�).��_Also�a�v��q�ailable�are���core��F��(�n�)�(=��core�(�n;����0))�and���core2����(�n�)���(=�UU�core�(�n;����1)).��Iƍ�3.4.12�d�coredisc�(�n;����f��flag��7̷g�):�(�if����n��is�a�non-zero�in���teger�written�as��n�
�=��d��UUf�����^��2��
@��with����d��fundamen�tal���discriminan���t�6�(including�1),�<�returns��d�.�g�If���flag���H�is�non-zero,�returns�the�t���w�o-elemen�t�6�ro�w�v�ector�[�d;���f���].���Note�UUthat�if��n��is�not�congruen���t�to�0�or�1�mo�Gdulo�4,��f�h�will�b�e�a�half�in���teger�and�not�an�in�teger.����The��library�syn���tax�is���coredisc0��1��(�n;�����flag���t�).��Also�a�v��q�ailable�are���coredisc��+��(�n�)�(=��coredisc�(�n;����0))���and��UU�coredisc2��1.��(�n�)�UU(=��coredisc�(�n;����1)).��Iƍ�3.4.13��dirdiv�(�x;���y�[٫):��x����and��y��f�b�Geing�v���ectors�of�p�erhaps�dieren���t�lengths�but�with��y�[٫[1]���6�=�0���considered���as�UUDiric���hlet�series,�computes�the�quotien�t�of��x��b�y��y�[٫,�again�as�a�v�ector.����The�UUlibrary�syn���tax�is���dirdiv��!w�(�x;���y�[٫).�������78���Oax�����Kf�������3.4.14��direuler�(�p���=��a;���b;���expr��O>�;��f�c�g�):�h�computes�C�the�Diric���hlet�series�to��b��terms�of�the�Euler�pro�Gduct���of�rSexpression���expr���<�as��p��ranges�through�the�primes�from��a��to��b�.��&�expr��=�m���ust�b�Ge�a�p�olynomial�or�rational���function���in�another�v��q�ariable�than��p��(sa���y��X���)�and���expr��&9�(�X��)�is�understo�Go�d���as�the�Diric���hlet�series�(or���more�2,precisely�the�lo�Gcal�factor)���expr���«(�p���^���s��
�;�).�fIf��c��is�presen���t,�94output�only�the�rst��c��co�ecien���ts�in�the���series.�����The�UUlibrary�syn���tax�is��direuler�(�entree�?�*ep,�GEN�a,�GEN�b,�char�*expr�)��%��3.4.15���dirm��9ul�(�x;���y�[٫):�%��x�/B�and��y���b�Geing�v���ectors�of�p�erhaps�dieren���t�lengths�considered�as�Diric�hlet���series,�UUcomputes�the�pro�Gduct�of��x��b���y��y�[٫,�again�as�a�v�ector.����The�UUlibrary�syn���tax�is���dirm��9ul��$��(�x;���y�[٫).��%��3.4.16�pudivisors�(�x�):�E�creates���a�ro���w�v�ector�whose�comp�Gonen�ts�are�the�p�Gositiv�e�divisors�of�the�in�teger����x�UU�in�increasing�order.�q�The�factorization�of��x��(as�output�b���y��factor�)�can�b�Ge�used�instead.����The�UUlibrary�syn���tax�is���divisors��)��(�x�).��%��3.4.17��Qeulerphi�(�x�):���Euler's��ر��(totien���t)�function�of��j�x�j�,��in�other�w�ords��j�(�Z�=x�Z�)���^������j�.�GQ�x��m�ust�b�Ge�of���t���yp�Ge�UUin�teger.����The�UUlibrary�syn���tax�is���phi��N3�(�x�).��%��3.4.18��factor�(�x;����f��lim��/��=��Ϸ�1�g�):���general�p^factorization�function.���If��x��is�of�t���yp�Ge�in�teger,��rational,���p�Golynomial��or�rational�function,�Bthe�result�is�a�t���w�o-column��matrix,�the�rst�column�b�Geing�the���irreducibles��dividing��x��(prime�n���um�b�Gers��or�p�olynomials),�Xand�the�second�the�exp�onen���ts.�If��x��is�a���v���ector�}�or�a�matrix,���the�factoring�is�done�comp�Gonen�t�wise�(hence�the�result�is�a�v�ector�or�matrix�of���t���w�o-column�UUmatrices).�q�By�denition,�0�is�factored�as�0���^��1��|s�.����If��.�x��is�of�t���yp�Ge�in�teger�or�rational,���the�factors�are���pseudoprimes��B�̫(see��ispseudoprime�),�and�in���general���not�rigorously�pro���v�en���primes.�3�In�fact,��an���y�factor�whic�h�is�����10���^��13����is�a�gen�uine�prime�n�um�b�Ger.���Use�UU�isprime��to�pro���v�e�UUprimalit�y�of�other�factors,�as�in������fa�?�=�factor(2^2^7�+1)��-��isprime(�?�fa[,1]�)����An�ϧargumen���t���lim��0y�can�b�Ge�added,��dmeaning�that�w�e�lo�Gok�only�for�factors�up�to���lim��`ҫ,��dor�to��primelimit�,���whic���hev�er���is�lo���w�est���(except�when���lim����=��0�where�the�eect�is�iden���tical�to�setting���lim���=����primelimit��7F��).���In�Q�this�case,���the�remaining�part�ma���y�actually�b�Ge�a�pro�v�en�comp�Gosite!�f�See��factorint��for�more���information�UUab�Gout�the�algorithms�used.����The�~�p�Golynomials�or�rational�functions�to�b�e�factored�m���ust�ha�v�e�scalar�co�Gecien�ts.�*FIn�particular���P��*�ARI��do�Ges���not�ߑ�kno���w�ho�w�to�factor�m�ultiv��q�ariate�p�Golynomials.�N�See��factormod��and��factorff��for�the���algorithms�]used�o���v�er�]nite�elds,�?�factornf��for�the�algorithms�o���v�er�]n�um�b�Ger�elds.���Ov�er��Q�,�?v��q�an���Ho�Geij's�UUmetho�d�is�used,�whic���h�is�able�to�cop�e�with�h���undreds�of�mo�dular�factors.����Note�H�that�P��*�ARI�H\tries�to�guess�in�a�sensible�w���a�y�H�o�v�er�whic�h�ring�y�ou�w�an�t�to�factor.�K�Note���also�Pthat�factorization�of�p�Golynomials�is�done�up�to�m���ultiplication�b�y�a�constan�t.�WpIn�particular,�the���factors��of�rational�p�Golynomials�will�ha���v�e��in�teger�co�Gecien�ts,�QOand�the�con�ten�t�of�a�p�Golynomial�or���rational�Z�function�is�discarded�and�not�included�in�the�factorization.���If�needed,�\y���ou�can�alw�a�ys�ask���for�UUthe�con���ten�t�UUexplicitly:������?�?�factor(t^2�+�5/2*t�+�1)��-��%1�?�=�������79���Pt܍����Kf�����卑�[2*t�?�+�1�1]���H��[t�?�+�2�1]����?�?�content(t^2�+�5/2*t�+�1)��N$��%2�?�=�1/2���m��See�UUalso��factornf��and��nffactor�.����The�zalibrary�syn���tax�is���f�actor0��'}�(�x;�����lim��;ӫ),���where���lim����is�a�C�zWin�teger.���Also�a�v��q�ailable�are���f�actor��!��(�x�)���(=��UU�f�actor0��'Xի(�x;�����1)),��UU�smallf�act��15��(�x�)�UU(=���f�actor0���(�x;����0)).���ڍ�3.4.19���factorbac��9k�(�f��V;����f�e�g�;��f�nf���g�):��\giv���es�w�bac�k�the�factored�ob��8ject�corresp�Gonding�to�a�factorization.���If�ҥthe�last�argumen���t�is�of�n�um�b�Ger�eld�t�yp�Ge�(e.g.�created�b�y��nfinit��or��bnfinit�),���assume�w�e�are���dealing�؎with�an�ideal�factorization�in�the�n���um�b�Ger�؎eld.�H0The�resulting�ideal�pro�duct�is�giv���en�in�HNF���form.���m��If����e��is�presen���t,����e��and��f��)�m�ust�b�Ge�v�ectors�of�the�same�length�(�e��b�Geing�in�tegral),���and�the�corre-���sp�Gonding�UUfactorization�is�the�pro�duct�of�the��f���[�i�]���^��e�[�i�]�����.����If�Unot,��and��f�h��is�v���ector,�it�is�understo�Go�d�Uas�in�the�preceding�case�with��e��a�v���ector�of�1�(the���pro�Gduct��pof�the��f���[�i�]�is�returned).�OFinally��*�,�7�f���can�b�e�a�regular�factorization,�7as�pro�duced�with�an���y����factor�UU�command.�q�A�few�examples:��8����?�?�factorback([2,2;�3,1])��N$��%1�?�=�12����?�?�factorback([2,2],�[3,1])����%2�?�=�12����?�?�factorback([5,2,3])����%3�?�=�30����?�?�factorback([2,2],�[3,1],�nfinit(x^3+2))����%4�?�=����[16�?�0�0]���H��[0�?�16�0]����[0�?�0�16]��N$��?�?�nf�=�nfinit(x^2+1);�fa�=�idealfactor(nf,�10)����%5�?�=����[[2,�?�[1,�1]��&f~��,�2,�1,�[1,�1]��&f~��]�2]���H��[[5,�?�[-2,�1]��&f~��,�1,�1,�[2,�1]��&f~��]�1]����[[5,�?�[2,�1]��&f~��,�1,�1,�[-2,�1]��&f~��]�1]��N$��?�?�factorback(fa)�����***���forbidden�?�multiplication�t_VEC�*�t_VEC.����?�?�factorback(fa,�nf)����%6�?�=����[10�?�0]���H��[0�?�10]��8����In�h�the�fourth�example,�mt2�and�3�are�in���terpreted�as�principal�ideals�in�a�cubic�eld.���In�the�fth���one,��6�factorback(fa)��p�is�meaningless�since�w���e�forgot�to�indicate�the�n�um�b�Ger�eld,��6and�the�en�tries���in�UUthe�rst�column�of��fa��can't�b�Ge�m���ultiplied.�������80���Q�������Kf�����卑�The��0library�syn���tax�is���f�actorbac��9k0��=�ë(�f��V;���e;���nf��y��),��where��0an�omitted���nf���L�or��e��is�en�tered�as��NULL�.�Also���a���v��q�ailable�UUis��factorback�(�f��V;�����nf��y��)�(case��e���=���NULL����)�UUwhere�an�omitted���nf��y��is�en�tered�as��NULL�.��h&��3.4.20��6factorcan��9tor�(�x;���p�):�'�factors�0\the�p�Golynomial��x��mo�dulo�the�prime��p�,�gusing�distinct�degree���plus���Can���tor-Zassenhaus.��MThe�co�Gecien�ts�of��x��m�ust�b�Ge�op�eration-compatible�with��Z�=p�Z�.��MThe���result��Ais�a�t���w�o-column��Amatrix,���the�rst�column�b�Geing�the�irreducible�p�olynomials�dividing��x�,���and���the��second�the�exp�Gonen���ts.�X.If�y�ou�w�an�t�only�the��de��}'gr�e�es�ګ�of��the�irreducible�p�Golynomials�(for�example���for�p�computing�an��L�-function),��vuse���factormod��1���(�x;���p;��1).�%�Note�p�that�the��factormod��algorithm�is�usually���faster�UUthan��factorcantor�.��4��The�UUlibrary�syn���tax�is���f�actcan��9tor��6��(�x;���p�).����3.4.21�P	factorff�(�x;���p;�a�):�G.factors��the�p�Golynomial��x��in�the�eld��F����q��*��dened�b���y�the�irreducible�p�oly-���nomial����a��o���v�er����F����p���R�.���The�co�Gecien���ts�of��x��m�ust�b�Ge�op�eration-compatible�with��Z�=p�Z�.���The�result�is�a���t���w�o-column�s�matrix,�{�the�rst�column�b�Geing�the�irreducible�p�olynomials�dividing��x�,�{�and�the�second���the�zxexp�Gonen���ts.��/It�is�recommended�to�use�for�the�v��q�ariable�of��a��(whic�h�will�b�Ge�used�as�v��q�ariable�of�a���p�Golmo�d)���a�name�distinct�from�the�other�v��q�ariables�used,��so�that�a��lift()��of�the�result�will�b�Ge�legible.���If���all�the�co�Gecien���ts�of��x��are�in��F����p���R�,��)a�m�uc�h�faster�algorithm�is�applied,��)using�the�computation�of���isomorphisms�UUb�Get���w�een�nite�elds.��4��The�UUlibrary�syn���tax�is���f�actmo�Q�d9��2�	�(�x;���p;�a�).����3.4.22�b�factorial�(�x�)��or��x�!:�?�factorial�of��x�.�P�The�expression��x�!�giv���es�a�result�whic�h�is�an�in�teger,�}while�����factorial��/?�(�x�)�UUgiv���es�a�real�n�um�b�Ger.��4��The�D�library�syn���tax�is���mpf�act��'ګ(�x�)�for��x�!�and���mpf�actr��+�K�(�x;�����pr��}'e�c�����)�for���factorial��2�Ϋ(�x�).�lN�x��m�ust�b�Ge�a����long�UU�in���teger�and�not�a�P��*�ARI�in�teger.����3.4.23�<wfactorin��9t�(�n;����f��flag����=��0�g�):�/Pfactors��hthe�in���teger��n��in�to�a�pro�Gduct�of�pseudoprimes�(see��ispseu-���doprime�),�}Uusing�GUa�com���bination�of�the�Shanks�SQUF�OF�Gand�P�ollard�Rho�metho�Gd�(with�mo�dications���due��Yto�Bren���t),��%Lenstra's�ECM��*(with�mo�Gdications�b�y�Mon�tgomery),��%and�MPQS��*(the�latter�adapted���from���the�LiDIA��tco�Gde�with�the�kind�p�ermission�of�the�LiDIA��tmain���tainers),���as�w�ell�as�a�searc�h�for���pure�5Sp�Go���w�ers�with�exp�Gonen�ts����10.�gThe�output�is�a�t�w�o-column�matrix�as�for��factor�.�gUse��isprime����on�UUthe�result�if�y���ou�w�an�t�to�guaran�tee�primalit�y��*�.��4��This���giv���es�direct�access�to�the�in�teger�factoring�engine�called�b�y�most�arithmetical�functions.�����flag�����is�v�optional;��its�binary�digits�mean�1:���a���v�oid�v�MPQS,�2:�skip�rst�stage�ECM�v�(w���e�ma�y�still���fall�Ibac���k�to�it�later),��4:�YKa�v�oid�Rho�and�SQUF�OF,�8:�YKdon't�run�nal�ECM�H�(as�a�result,��a�h�uge���comp�Gosite�X=ma���y�b�e�declared�to�b�e�prime).�z�Note�that�a�(strong)�probabilistic�primalit���y�test�is�used;���th���us�UUcomp�Gosites�migh�t�(v�ery�rarely)�not�b�Ge�detected.����The�t�mac���hinery�underlying�this�function�is�still�in�a�somewhat�exp�Gerimen�tal�state,�|�but�should���b�Ge���m���uc�h�faster�on�a�v�erage�than�pure�ECM���as�used�b�y�all�P��*�ARI���v�ersions�up�to�2.0.8,�
�at�the�exp�Gense���of���hea���vier�memory�use.��\Y��*�ou�are�in�vited�to�pla�y�with�the�
ag�settings�and�w�atc�h�the�in�ternals�at���w���ork�1�b�y�using�GP's��debuglevel��default�parameter�(lev�el�3�sho�ws�just�the�outline,�8�4�turns�on�time���k���eeping,�Dh5��and�ab�Go�v�e�sho�w�an�increasing�amoun�t�of�in�ternal�details).���If�y�ou�see�an�ything�funn�y���happ�Gening,�UUplease�let�us�kno���w.����The�UUlibrary�syn���tax�is���f�actorin��9t��/UD�(�n;�����flag���t�).�������81���R�"�����Kf�������3.4.24�L�factormo�Q�d�(�x;���p;��f��flag���߫=�t0�g�):�A\factors�� the�p�Golynomial��x��mo�dulo�the�prime�in���teger��p�,��using���Berlek��q�amp.��The��co�Gecien���ts�of��x��m�ust�b�Ge�op�eration-compatible�with��Z�=p�Z�.��The�result�is�a�t���w�o-���column��Mmatrix,���the�rst�column�b�Geing�the�irreducible�p�olynomials�dividing��x�,���and�the�second�the���exp�Gonen���ts.�F+If��Ҁ�flag���̫is�Ҁnon-zero,��outputs�only�the��de��}'gr�e�es����of�Ҁthe�irreducible�p�olynomials�(for�example,���for��Wcomputing�an��L�-function).�d�A��dieren���t�algorithm�for�computing�the�mo�Gd��p��factorization�is����factorcantor�UU�whic���h�is�sometimes�faster.������The��&library�syn���tax�is���f�actormo�Q�d��6�K�(�x;���p;���flag���t�).�7�Also��&a�v��q�ailable�are���f�actmo�Q�d��,xܫ(�x;���p�)�(whic�h�is�equiv-���alen���t�UUto���f�actormo�Q�d��7�z�(�x;���p;��0))�UUand���simplef�actmo�Q�d��MR�(�x;���p�)�(=���f�actormo�Q�d���(�x;���p;��1)).��S
��3.4.25��Tfib�Q�onacci�(�x�):�qDZx���^��th��`�Fib�Gonacci�UUn���um�b�er.����The�UUlibrary�syn���tax�is���f�ib�Q�o����(�x�).�qDZx��m�ust�b�Ge�a��long�.����3.4.26���ffinit�(�p;���n;��f�v�,��=��ȱx�g�):���computes��a�monic�p�Golynomial�of�degree��n��whic���h�is�irreducible�o�v�er����F����p���R�.���F��*�or�[�instance�if��P�?�=�ffinit(3,2,y)�,�]Py���ou�[�can�represen�t�elemen�ts�in��F����3����2����J�as�p�Golmo�ds�[�mo�dulo��P�.���Starting��with�v���ersion�2.2.3�this�function�use�a�fast�v��q�arian�t�of�Adleman{Lenstra�algorithm,��Nand�is���m���uc�h�UUfaster�than�in�earlier�v���ersions.����The�UUlibrary�syn���tax�is���f�f�init��ʟ�(�p;���n;�v�[٫),�UUwhere��v��.�is�a�v��q�ariable�n�um�b�Ger.��S
��3.4.27��Jgcd�(�x;����f�y�[ٷg�;��f��flag����=��0�g�):�e�creates�<�the�greatest�common�divisor�of��x��and��y��.�i��x��and��y��ͫcan�b�Ge�of���quite�G�general�t���yp�Ges,�JXfor�instance�b�oth�rational�n���um�b�ers.�m3V��*�ector/matrix�G�t�yp�es�G�are�also�accepted,�JXin���whic���h�4
case�the�GCD�4is�tak�en�recursiv�ely�on�eac�h�comp�Gonen�t.�f�Note�that�for�these�t�yp�Ges,�:��gcd��is�not���comm���utativ�e.��q��flag����is�UUobsolete�and�should�not�b�Ge�used.����If�,�y���is�omitted�and��x��is�a�v���ector,�4Wreturn�the��gcd��X2of�all�comp�Gonen�ts�of��x�.�dThe�algorithm�used�is���a�UUnaiv���e�Euclid�except�for�the�follo�wing�inputs:������UU�in���tegers:�q�use�mo�Gdied�righ�t-shift�binary�(\plus-min�us"�v��q�arian�t).������Dϫuniv��q�ariate�p�Golynomials�with�co�een���ts�in�the�same�n�um�b�Ger�eld�(in�particular�rational):�i�use���mo�Gdular�UUgcd�algorithm.�������W�general�p�Golynomials:�	�use�the�subresultan���t�algorithm�if�co�ecien���t�explosion�is�lik�ely�(exact,���non�UUmo�Gdular,�co�ecien���ts).����The�CWlibrary�syn���tax�is���ggcd��CO�(�x;���y�[٫).�k�F��*�or�general�p�Golynomial�inputs,��F��srgcd��̘�(�x;�y�[٫)�is�also�a���v��q�ailable.���F��*�or�UUuniv��q�ariate��r��}'ational�]ޫp�Golynomials,�one�also�has���mo�Q�dulargcd��>�Ϋ(�x;���y�[٫).��S
��3.4.28��]hilb�Q�ert�(�x;���y�[�;��f�p�g�):�Z�Hilb�Gert�I�sym���b�ol�of��x��and��y����mo�dulo��p�.�N�If��x��and��y����are�of�t���yp�e�in���teger���or��cfraction,�gan�explicit�third�parameter��p��m���ust�b�Ge�supplied,��p�Ą�=�0��cmeaning�the�place�at�innit���y��*�.���Otherwise,���p��o�needs�not�b�Ge�giv���en,�and��x��and��y�NH�can�b�Ge�of�compatible�t���yp�es�in���teger,��fraction,�real,���in���tegermo�Gd�UUa�prime�(result�is�undened�if�the�mo�dulus�is�not�prime),�or��p�-adic.����The�UUlibrary�syn���tax�is���hil��m�(�x;���y�[�;�p�).��S
��3.4.29�O�isfundamen��9tal�(�x�):�F�true���(1)�if��x��is�equal�to�1�or�to�the�discriminan���t�of�a�quadratic�eld,���false�UU(0)�otherwise.����The��@library�syn���tax�is���gisf�undamen��9tal��O�ѫ(�x�),��wbut�the�simpler�function���isf�undamen��9tal��I�ӫ(�x�)�whic�h���returns�UUa��long��should�b�Ge�used�if��x��is�kno���wn�to�b�e�of�t���yp�e�in���teger.�������82���S�:�����Kf�������3.4.30��isprime�(�x;����f��flag����=���0�g�):��true�_�(1)�if��x��is�a�(pro���v�en)�_�prime�n���um�b�Ger,�b�false�_�(0)�otherwise.���This���can�b�b�Ge�v���ery�slo�w�when��x��is�indeed�prime�and�has�more�than�1000�digits,�fsa�y��*�.���Use��ispseudoprime����to�UUquic���kly�c�hec�k�for�pseudo�primalit�y��*�.�����If��r1�flag��K׫=���0,��huse�r1a�com���bination�of�Baillie-PSW�q�pseudo�primalit�y�test�(see��ispseudoprime�),���Selfridge�g�\�p�E>���1"�test�if��x����1�is�smo�Goth�enough,�l�and�Adleman-P���omerance-Rumely-Cohen-Lenstra���(APR���CL)�UUfor�general��x�.����If�����flag���r�=��1,��use���Selfridge-P���o�Gc�klington-Lehmer�\�p��T���1"�test�and�output�a�primalit���y�certicate�as���follo���ws:���return�n�0�if��x��is�comp�Gosite,��1�if��x��is�small�enough�that�passing�Baillie-PSW�n�test�guaran�tees�its���primalit���y��k(curren�tly��x��<��10���^��13��x�),��32�if��x��is�a�large�prime�whose�primalit���y�could�only�sensibly�b�Ge�pro�v�en���(giv���en�3�the�algorithms�implemen�ted�in�P��*�ARI)�3susing�the�APR�CL�3stest.��Otherwise�(�x��is�large�and����x�ym���1���is�smo�Goth)�output�a�three�column�matrix�as�a�primalit���y�certicate.�Q�The�rst�column�con�tains���the���prime�factors��p��of��x�{ط��1,���the���second�the�corresp�Gonding�elemen���ts��a����p��Y�as�in�Prop�osition�8.3.1�in���GTM�
�138,��and�the�third�the�output�of�isprime(p,1).�X�The�algorithm�fails�if�one�of�the�pseudo-prime���factors�UUis�not�prime,�whic���h�is�exceedingly�unlik�ely�(and�w�ell�w�orth�a�bug�rep�Gort).����If��UU�flag��T9�=��2,�UUuse�APR���CL.����The�D-library�syn���tax�is���gisprime��-떫(�x;�����flag���t�),�G�but�the�simpler�function���isprime��(+��(�x�)�whic�h�returns�a����long�UU�should�b�Ge�used�if��x��is�kno���wn�to�b�e�of�t���yp�e�in���teger.����3.4.31�	�ispseudoprime�(�x;����f��flag��7̷g�):��atrue�a�(1)�if��x��is�a�strong�pseudo�prime�(see�b�Gelo���w),���false�(0)���otherwise.�#If��tthis�function�returns�false,����x��is�not�prime;��if,�on�the�other�hand�it�returns�true,�it�is���only��highly�lik���ely�that��x��is�a�prime�n�um�b�Ger.�K�Use��isprime��(whic�h�is�of�course�m�uc�h�slo�w�er)�to�pro�v�e���that�UU�x��is�indeed�prime.����If�����flag��2��=�R%0,���c���hec�ks���whether��x��is�a�Baillie-P���omerance-Selfridge-W��*�agsta�pseudo�prime�(strong���Rabin-Miller��Mpseudo�prime�for�base�2,��follo���w�ed��Mb�y�strong�Lucas�test�for�the�sequence�(�P�G;�����1),���P����smallest�UUp�Gositiv���e�in�teger�suc�h�that��P��c���^��2����8�4�is�not�a�square�mo�Gd��x�).����There�-Oare�no�kno���wn�comp�Gosite�n�um�b�Gers�passing�this�test�(in�particular,�5Pall�comp�osites�����10���^��13�����are�UUcorrectly�detected),�although�it�is�exp�Gected�that�innitely�man���y�suc�h�n�um�b�Gers�exist.����If��u~�flag�����>����0,�}�c���hec�ks�u~whether��x��is�a�strong�Miller-Rabin�pseudo�prime�for���flag��"ȫrandomly�c���hosen���bases�UU(with�end-matc���hing�to�catc�h�square�ro�Gots�of���1).����The�xFlibrary�syn���tax�is���gispseudoprime��P��(�x;�����flag���t�),��but�the�simpler�function���ispseudoprime��K�(�x�)���whic���h�UUreturns�a��long��should�b�Ge�used�if��x��is�kno�wn�to�b�Ge�of�t�yp�Ge�in�teger.����3.4.32�rissquare�(�x;����f�&�n�g�):��qtrue�ݪ(1)�if��x��is�square,���false�(0)�if�not.�
Ʊx��can�b�Ge�of�an���y�t�yp�Ge.�
�If��n��is���giv���en�?�and�an�exact�square�ro�Got�had�to�b�e�computed�in�the�c���hec�king�?�pro�cess,�Dputs�that�square�ro�ot���in��a�n�.�
�This�is�in�particular�the�case�when��x��is�an�in���teger�or�a�p�Golynomial.�This�is��not�|9�the�case�for���in���tmo�Gds�UU(use�quadratic�recipro�cit���y)�or�series�(only�c�hec�k�the�leading�co�Gecien�t).����The�UUlibrary�syn���tax�is���gcarrecomplet��JLZ�(�x;����&�n�).�q�Also�a�v��q�ailable�is���gcarreparf�ait��E��(�x�).����3.4.33��issquarefree�(�x�):���true�k�(1)�if��x��is�squarefree,�q\false�(0)�if�not.��Here��x��can�b�Ge�an�in���teger�or�a���p�Golynomial.����The���library�syn���tax�is���gissquaref�ree��F�!�(�x�),�M�but�the�simpler�function���issquaref�ree��A#�(�x�)�whic�h���returns���a��long��should�b�Ge�used�if��x��is�kno���wn�to�b�e�of�t���yp�e�in���teger.��wThis��issquarefree��is�just�the���square�8sof�the�Mo�Gebius�function,�>:and�is�computed�as�a�m���ultiplicativ�e�8sarithmetic�function�m���uc�h�8slik�e���the�UUlatter.�������83���T�v�����Kf�������3.4.34� 0kronec��9k�er�(�x;���y�[٫):��0Kronec���k�er�u	sym�b�Gol�(�x�j�y�[٫),���where��x��and��y���m�ust�b�Ge�of�t�yp�Ge�in�teger.���By���denition,��Ithis���is�the�extension�of�Legendre�sym���b�Gol�to��Z����Z����b�y�total�m�ultiplicativit�y�in�b�Goth���argumen���ts�UUwith�the�follo�wing�sp�Gecial�rules�for��y�"�=��0�;�����1�or�2:�������UU�(�x�j�0)��=�1�if��j�x�j��=�1�and�0�otherwise.������UU�(�x�j�8���1)��=�1�if��x����0�and���1�otherwise.������UU�(�x�j�2)��=�0�if��x��is�ev���en�and�1�if��x��=�1�;�����1��mo�Gd���8�and���1�if��x���=�3�;�����3��mo�Gd���8.����The�UUlibrary�syn���tax�is���kronec��9k�er��4ի(�x;���y�[٫),�the�result�(0�or���1)�is�a��long�.��9��3.4.35���lcm�(�x;����f�y�[ٷg�):��least���common�m���ultiple�of��x��and��y��,�W�i.e.�suc���h�that��lcm��0(�x;���y��)�KJ����gcd��KL(�x;���y��)�u =����abs���(�x�8���y�[٫).����If�UU�y��.�is�omitted�and��x��is�a�v���ector,�return�the��lcm��8�of�all�comp�Gonen�ts�of��x�.����The�UUlibrary�syn���tax�is���glcm���۫(�x;���y�[٫).����3.4.36��Tmo�Q�ebius�(�x�):�q�Mo�Gebius�UU��-function�of��j�x�j�.��x��m���ust�b�Ge�of�t�yp�Ge�in�teger.����The�UUlibrary�syn���tax�is���m��9u���l�(�x�),�the�result�(0�or���1)�is�a��long�.����3.4.37���nextprime�(�x�):�TQnds�hthe�smallest�pseudoprime�(see��ispseudoprime�)�greater�than�or�equal���to��r�x�.�D�x��can�b�Ge�of�an���y�real�t�yp�Ge.�DNote�that�if��x��is�a�pseudoprime,���this�function�returns��x��and�not���the��9smallest�pseudoprime�strictly�larger�than��x�.�ytT��*�o�rigorously�pro���v�e��9that�the�result�is�prime,��2use����isprime�.�����The�UUlibrary�syn���tax�is���nextprime��6�E�(�x�).����3.4.38��Tn��9umdiv�(�x�):�q�n���um�b�Ger�UUof�divisors�of��j�x�j�.��x��m���ust�b�Ge�of�t�yp�Ge�in�teger.����The�UUlibrary�syn���tax�is���n��9um�b�Q�div��/��(�x�).����3.4.39��=n��9um�bpart�(�n�):��0giv���es�d
the�n�um�b�Ger�of�unrestricted�partitions�of��n�,�g�usually�called��p�(�n�)�in�the���litterature;�Q
in�N�other�w���ords�the�n�um�b�Ger�of�nonnegativ�e�in�teger�solutions�to��a�,�+�2�b��+�3�c��+����������ƫ=���n�.�o��n����m���ust�.b�Ge�of�t�yp�Ge�in�teger�and�1�����n�<��10���^��15��x�.�d�The�.algorithm�uses�the�Hardy-Raman�ujan-Rademac�her���form���ula.�����The�UUlibrary�syn���tax�is���n��9um�bpart��4���(�n�).����3.4.40��Tomega�(�x�):�q�n���um�b�Ger�UUof�distinct�prime�divisors�of��j�x�j�.��x��m���ust�b�Ge�of�t�yp�Ge�in�teger.����The�UUlibrary�syn���tax�is���omega��#G�(�x�),�the�result�is�a��long�.����3.4.41���precprime�(�x�):��nds��sthe�largest�pseudoprime�(see��ispseudoprime�)�less�than�or�equal�to����x�.�p?�x�P��can�b�Ge�of�an���y�real�t�yp�Ge.�p?Returns�0�if��x�����1.�Note�P�that�if��x��is�a�prime,�Q�this�function�returns��x����and�A�not�the�largest�prime�strictly�smaller�than��x�.�k2T��*�o�rigorously�pro���v�e�A�that�the�result�is�prime,�E�use����isprime�.�����The�UUlibrary�syn���tax�is���precprime��6�(�x�).����3.4.42��Tprime�(�x�):�q�the�UU�x���^��th��`�prime�n���um�b�Ger,�UUwhic�h�m�ust�b�Ge�among�the�precalculated�primes.����The�UUlibrary�syn���tax�is���prime�� ���(�x�).�qDZx��m�ust�b�Ge�a��long�.�������84���U�A�����Kf�������3.4.43�=_primes�(�x�):�&�creates���a�ro���w�v�ector�whose�comp�Gonen�ts�are�the�rst��x��prime�n�um�b�Gers,��lwhic�h���m���ust�UUb�Ge�among�the�precalculated�primes.���k��The�UUlibrary�syn���tax�is���primes��%
��(�x�).�qDZx��m�ust�b�Ge�a��long�.���A��3.4.44�X�qfb�Q�classno�(�D�G;����f��flag���W�=���0�g�):�VRordinary�ǚclass�n���um�b�er�ǚof�the�quadratic�order�of�discriminan���t����D�G�.�1bIn��%the�presen���t�v�ersion�2.2.7,���a��O�G�(�D����^��1�=�2����)��%algorithm�is�used�for��D�5>���0�(using�Euler�pro�Gduct�and�the���functional�8{equation)�so��D���should�not�b�Ge�to�o�large,�>@sa���y��D�5<���10���^��8��|s�,�for�the�time�to�b�Ge�reasonable.�h)On���the���other�hand,���for��D�qn<�*Q�0�one�can�reasonably�compute��qfbclassno(�D�G�)��for��j�D��j�*Q�<��10���^��25��x�,���since���the���routine�UUuses�Shanks's�metho�Gd�whic���h�is�in��O��(�j�D��j���^��1�=�4���ʫ).�q�F��*�or�larger�v��q�alues�of��j�D��j�,�see��quadclassunit�.����If���F�flag��&��=�*�1,� compute��Fthe�class�n���um�b�Ger��Fusing�Euler�pro�ducts�and�the�functional�equation.���Ho���w�ev�er,�UUit�is�in��O�G�(�j�D��j���^��1�=�2���ʫ).���֍�Imp�Q�ortan��9t�Hw�arning.�6X�F��*�or���D�5<���0,�Ʊthis�function�ma���y�giv�e�incorrect�results�when�the�class�group�has���a��jlo���w�exp�Gonen�t�(has�man�y�cyclic�factors),�3b�Gecause�implemen�ting�Shanks's�metho�Gd�in�full�generalit�y���slo���ws��it�do�wn�immensely��*�.�O�It�is�therefore�strongly�recommended�to�double-c�hec�k�results�using�either���the�UUv���ersion�with���flag��T9�=��1,�the�function���qfbhclassno��=4�(��D�G�)�or�the�function��quadclassunit�.����W��
�arning.�U�con���trary��to�what�its�name�implies,�gthis�routine�do�Ges�not�compute�the�n�um�b�Ger�of�classes���of�+binary�primitiv���e�forms�of�discriminan�t��D�G�,���whic�h�is�equal�to�the��narr��}'ow����class�n�um�b�Ger.��HThe�t�w�o���notions�}�are�the�same�when��D�Q8<�
�0�or�the�fundamen���tal�unit��"��has�negativ�e�norm;���when��D�Q8>�
�0�and����N�"�d�>��0,���the�M�n���um�b�Ger�of�classes�of�forms�is�t�wice�the�ordinary�class�n�um�b�Ger.�Z�This�is�a�problem���whic���h�s�w�e�cannot�x�for�bac�kw�ard�compatibilit�y�reasons.��SUse�the�follo�wing�routine�if�y�ou�are�only���in���terested�UUin�the�n�um�b�Ger�of�classes�of�forms:���k���QFBclassno(D)�?�=�����qfbclassno(D)�?�*�if�(D�<�0�||�norm(quadunit(D))�<�0,�1,�2)����Here�UUare�a�few�examples:�����?�?�qfbclassno(400000028)����time�?�=�3,140�ms.����%1�?�=�1����?�?�quadclassunit(400000028).no����time�?�=�20�ms.�\\����much�faster�����%2�?�=�1����?�?�qfbclassno(-400000028)����time�?�=�0�ms.����%3�?�=�7253�\\����c��}'orr�e�ct,�and�fast�enough�����?�?�quadclassunit(-400000028).no����time�?�=�0�ms.����%4�?�=�7253�����The�&library�syn���tax�is���qf�b�Q�classno0��=c%�(�D�G;�����flag���t�).�bAlso�a�v��q�ailable:��Z'�classno��'ux�(�D�G�)�(=���qf�b�Q�classno��7�'�(�D��)),�����classno2��(�O�(�D�G�)��,(=���qf�b�Q�classno��7\=�(�D�;����1)),���and�nally�there�exists�the�function���hclassno��,^	�(�D��)�whic���h�com-���putes���the�class�n���um�b�Ger���of�an�imaginary�quadratic�eld�b���y�coun�ting�reduced�forms,�!�an��O�G�(�j�D��j�)���algorithm.�q�See�UUalso��qfbhclassno�.���A��3.4.45���qfb�Q�compra��9w�(�x;���y�[٫)�p�comp�Gosition�of�the�binary�quadratic�forms��x��and��y��,�w�without�reduction���of�UUthe�result.�q�This�is�useful�e.g.�to�compute�a�generating�elemen���t�of�an�ideal.����The�UUlibrary�syn���tax�is���compra��9w��0�~�(�x;���y�[٫).�������85���V�h�����Kf�������3.4.46�E�qfbhclassno�(�x�):�5uHurwitz��,class�n���um�b�Ger��,of��x�,�ϡwhere��x��is�non-negativ���e�and�congruen�t�to�0���or�UU3�mo�Gdulo�4.�q�See�also��qfbclassno�.���ύ�The�UUlibrary�syn���tax�is���hclassno��,�2�(�x�).���n��3.4.47�!qfbn��9ucomp�(�x;���y�[�;�l�2`�):��Mcomp�Gosition���of�the�primitiv���e�p�ositiv���e�denite�binary�quadratic�forms����x�别and��y�Aa�(t���yp�Ge��t_QFI�)��cusing�the�NUCOMP�and�NUDUPL�algorithms�of�Shanks,�	�����a�la�A���tkin.�"a�l��is���an���y��Yp�Gositiv�e�constan�t,��Zbut�for�optimal�sp�Geed,�one�should�tak���e��l�I�=��j�D�G�j���^��1�=�4���ʫ,�where��D��v�is�the�common���discriminan���t�of��x��and��y�[٫.�ZXWhen��x��and��y�j�do�not�ha�v�e�the�same�discriminan�t,�the�result�is�undened.����The�-olibrary�syn���tax�is���n��9ucomp��+x�(�x;���y�[�;�l�2`�).��The�-oauxiliary�function���n��9udupl��&�*�(�x;���l��)�should�b�Ge�used���instead�UUfor�sp�Geed�when��x���=��y�[٫.���n��3.4.48�#�qfbn��9up�Q�o�w�(�x;���n�):��p�n�-th�x)p�Go���w�er�of�the�primitiv�e�p�Gositiv�e�denite�binary�quadratic�form��x����using�UUShanks's�NUCOMP�and�NUDUPL�algorithms�(see��qfbnucomp�).����The�UUlibrary�syn���tax�is���n��9up�Q�o�w��$eJ�(�x;���n�).���n��3.4.49��zqfbp�Q�o��9wra�w�(�x;���n�):�b�n�-th�)�p�Go���w�er�of�the�binary�quadratic�form��x�,�^�computed�without�doing���an���y�UUreduction�(i.e.�using��qfbcompraw�).�q�Here��n��m�ust�b�Ge�non-negativ�e�and��n��<��2���^��31��x�.����The�UUlibrary�syn���tax�is���p�Q�o��9wra�w��*?�(�x;���n�)�where��n��m�ust�b�Ge�a��long��in�teger.���n��3.4.50���qfbprimeform�(�x;���p�):�Pprime��binary�quadratic�form�of�discriminan���t��x��whose�rst�co�Gecien�t���is���the�prime�n���um�b�Ger����p�.��By�abuse�of�notation,��h�p�ą�=�1���is�a�v��q�alid�sp�ecial�case�whic���h�returns�the���unit�� form.��'Returns�an�error�if��x��is�not�a�quadratic�residue�mo�Gd��p�.�In�the�case�where��x��i>��0,��the���\distance"�UUcomp�Gonen���t�of�the�form�is�set�equal�to�zero�according�to�the�curren�t�precision.����The���library�syn���tax�is���primef�orm��9���(�x;���p;���pr��}'e�c�����),�where���the�third�v��q�ariable���pr��}'e�c����is�a��long�,�but�is���only�UUtak���en�in�to�accoun�t�when��x��>��0.���n��3.4.51���qfbred�(�x;����f��flag��;H�=�|0�g�;��f�D�G�g�;��f��isqrtD���շg�;��f��sqrtD���ŷg�):��treduces�,the�binary�quadratic�form��x��(up-���dating�UUShanks's�distance�function�if��x��is�indenite).�q�The�binary�digits�of���flag���v�are�toggles�meaning����1:�q�p�Gerform�UUa�single�reduction�step����2:�q�don't�UUup�Gdate�Shanks's�distance�����D�G�,���o�isqrtD���D�,���o�sqrtD���4�,��oif���presen���t,�supply�the�v��q�alues�of�the�discriminan���t,��b������p���UW�����fe���wv��D������c�,�and��������p���
L�����fe���wv��D����Sիresp�Gectiv���ely���(no���c���hec�king�is�done�of�these�facts).�GNIf��D�5<���0�these�v��q�alues�are�useless,��eand�all�references�to�Shanks's���distance�UUare�irrelev��q�an���t.����The��llibrary�syn���tax�is���qf�bred0��*ִ�(�x;�����flag���t�;���D�G;���isqrtD��s}�;���sqrtD��bm�).�VUse��l�NULL��X�to�omit�an�y�of��D�G�,���q�isqrtD��}F�,�����sqrtD���ū.���Also�UUa���v��q�ailable�are������redimag��<�d�(�x�)�UU(=���qf�bred��$ʟ�(�x�)�where��x��is�denite),���and�UUfor�indenite�forms:������redreal��7/��(�x�)�UU(=���qf�bred��$ʟ�(�x�)),������rhoreal��7���(�x�)�UU(=���qf�bred��$ʟ�(�x;����1)),������redrealno�Q�d��Jҫ(�x;���sq�[٫)�UU(=���qf�bred��$ʟ�(�x;��2�;�;�isq�[�r�GtD��)),������rhorealno�Q�d��J�|�(�x;���sq�[٫)�UU(=���qf�bred��$ʟ�(�x;��3�;�;�isq�[�r�GtD��)).�������86���W�썟���Kf�������3.4.52�-�qfbsolv��9e�(�Q;���p�):��Solv���e��6the�equation��Q�(�x;�y�[٫)�G9=��p��6�o���v�er�the�in�tegers,��nwhere��Q��is�a�imaginary���binary�UUquadratic�form�and��p��a�prime�n���um�b�Ger.��Ki��Return�L�[�x;���y�[٫]�as�a�t���w�o-comp�Gonen�ts�L�v�ector,���or�zero�if�there�is�no�solution.��Note�that�this�functions���return�UUonly�one�solution�and�not�all�the�solutions.����The�UUlibrary�syn���tax�is���qf�bsolv��9e��,堫(�Q;���n�).���ҍ�3.4.53���quadclassunit�(�D�G;����f��flag��!=�=��q0�g�;��f��te��}'ch����=�[]�g�):��3Buc���hmann-McCurley's��sub-exp�Gonen�tial�algo-���rithm�UUfor�computing�the�class�group�of�a�quadratic�order�of�discriminan���t��D�G�.����This��function�should�b�Ge�used�instead�of��qfbclassno��or��quadregula��when��D��}<��`��10���^��25��x�,���D�>����10���^��10��x�,�UUor�when�the��structur��}'e���is�w���an�ted.����If�����flag��Cz�is���non-zero��and��`�D�_>��0,���computes�the�narro���w�class�group�and�regulator,�instead�of�the���ordinary�Z(or�wide)�ones.��#In�the�curren���t�v�ersion�2.2.7,��Pthis�do�Gesn't�w�ork�at�all:�{Zuse�the�general���function�UU�bnfnarrow�.����Optional�u�parameter���te��}'ch���A�is�a�ro���w�v�ector�of�the�form�[�c����1��|s�;���c����2���],�}�where�uϱc����1���B�and��c����2���are�p�Gositiv���e�real���n���um�b�Gers�~gwhic�h�con�trol�the�execution�time�and�the�stac�k�size.���T��*�o�get�maxim�um�sp�Geed,���set��c����2�����=���c�.���T��*�o���get�a�rigorous�result�(under�GRH)���y���ou�m�ust�tak�e��c����2�����=�26.�*Reasonable�v��q�alues�for��c��are�b�Get�w�een���0�:�1�UUand�2.����The��Presult�of�this�function�is�a�v���ector��v�7)�with�3�comp�Gonen�ts�if��D��<��e�0,���and�4�otherwise.��The���corresp�Gond�UUresp�ectiv���ely�to������UU�v�[٫[1]:�q�the�class�n���um�b�Ger������UU�v�[٫[2]:�q�a�v���ector�giving�the�structure�of�the�class�group�as�a�pro�Gduct�of�cyclic�groups;������UU�v�[٫[3]:�q�a�v���ector�giving�generators�of�those�cyclic�groups�(as�binary�quadratic�forms).�������ѱv�[٫[4]:�1�(omitted�if��D�5<���0)�the�regulator,��computed�to�an�accuracy�whic���h�is�the�maxim�um�of�an���in���ternal��Waccuracy�determined�b�y�the�program�and�the�curren�t�default�(note�that�once�the�regulator���is�UUkno���wn�to�a�small�accuracy�it�is�trivial�to�compute�it�to�v�ery�high�accuracy��*�,�see�the�tutorial).����The���library�syn���tax�is���quadclassunit0��M��(�D�G;�����flag���t�;���tech�).��PAlso�a�v��q�ailable�are���buc��9himag��3��(�D�G;���c����1��|s�;�c����2���)���and��UU�buc��9hreal��.F�(�D�G;�����flag���t�;���c����1��|s�;�c����2���).���ҍ�3.4.54��Tquaddisc�(�x�):�q�discriminan���t�UUof�the�quadratic�eld��Q�(������p���UW����fe��3荱x����s�),�where��x���2��Q�.����The�UUlibrary�syn���tax�is���quaddisc��/I�(�x�).����3.4.55��quadhilb�Q�ert�(�D�G;����f��flag��?��=��0�g�):�Yrelativ���e�H�equation�dening�the�Hilb�ert�class�field�of�the���quadratic�]Deld�of�discriminan���t��D�G�.���If���flag���T�is�non-zero�and��D�n<��Q�0,�[email protected]�[��form��Vر;�����r��}'o�ot��Z��(��form���)]�]D(to�b�e���used���for�constructing�subelds).�0�If���flag��a��is�non-zero�and��D�x9>�1�0,���try�hard�to�get�the�b�Gest�mo�dulus.���Uses�UUcomplex�m���ultiplication�in�the�imaginary�case�and�Stark�units�in�the�real�case.����The�UUlibrary�syn���tax�is���quadhilb�Q�ert��=�]�(�D�G;�����flag���t�;�����pr��}'e�c�����).���ҍ�3.4.56��quadgen�(�D�G�):���creates��^the�quadratic�n���um�b�er��^�!�j��=��(�a�U��+��������p���
������fe���wv��D����9|�)�=�2�where��a�ѫ=�0�if��x����0����mo�Gd���4,����a���=�1�r�if��D�?����1����mo�Gd���4,�zso�that�(1�;���!�[٫)�is�an�in���tegral�basis�for�the�quadratic�order�of�discriminan�t��D�G�.����D��r�m���ust�UUb�Ge�an�in�teger�congruen�t�to�0�or�1�mo�Gdulo�4,�whic�h�is�not�a�square.����The�UUlibrary�syn���tax�is���quadgen��-.)�(�x�).�������87���X�č����Kf�������3.4.57�c�quadp�Q�oly�(�D�G;����f�v��=��˱x�g�):�i�creates��[the�\canonical"�quadratic�p�olynomial�(in�the�v��q�ariable��v�[٫)���corresp�Gonding��gto�the�discriminan���t��D��,��ki.e.�the�minimal�p�olynomial�of���quadgen��(}R�(�D��).����D���m���ust�b�e�an���in���teger�UUcongruen�t�to�0�or�1�mo�Gdulo�4,�whic�h�is�not�a�square.������The�UUlibrary�syn���tax�is���quadp�Q�oly0��7>%�(�x;���v�[٫).������3.4.58�(�quadra��9y�(�D�G;���f��V;��f��flag��w�=�@'0�g�):�
relativ���e���equation�for�the�ra�y�class�eld�of�conductor��f����for�the���quadratic�UUeld�of�discriminan���t��D��r�(whic�h�can�also�b�Ge�a��bnf�),�using�analytic�metho�ds.����F��*�or�,*�D�5<���0,�4fuses�the�����function.��d�flag����has�the�follo���wing�meaning:�]1if�it's�an�o�Gdd�in�teger,�4foutputs���instead��the�v���ector�of�[��ide��}'al���o�;�����c��}'orr�esp�onding���r�o�ot��Ryɫ].��]It�can�also�b�Ge�a�t�w�o-comp�Gonen�t�v�ector�[�;�����flag���t�],���where���-�flag���&�is��-as�ab�Go���v�e��-and����is�the�tec���hnical�elemen�t�of��bnf��necessary�for�Sc�hertz's�metho�Gd.�I�In�that���case,�UUreturns�0�if����is�not�suitable.����F��*�or�J�D�5>���0,�L�uses�Stark's�conjecture.�nMIf���flag��͘�is�non-zero,�try�hard�to�get�the�b�Gest�mo�dulus.�nMThe���function�UUma���y�fail�with�the�follo�wing�message��S���"Cannot�?�find�a�suitable�modulus�in�FindModulus"�����See�UU�bnrstark��for�more�details�ab�Gout�the�real�case.����The�UUlibrary�syn���tax�is���quadra��9y��,��(�D�G;���f��V;���flag���t�).������3.4.59��~quadregulator�(�x�):�j�regulator�G�of�the�quadratic�eld�of�p�Gositiv���e�discriminan�t��x�.�m0Returns�an���error�1�if��x��is�not�a�discriminan���t�(fundamen�tal�or�not)�or�if��x��is�a�square.�e�See�also��quadclassunit��if����x�UU�is�large.����The�UUlibrary�syn���tax�is���regula��"C��(�x;�����pr��}'e�c�����).������3.4.60�u�quadunit�(�D�G�):�Hfundamen���tal�unit�of�the�real�quadratic�eld��Q�(�������p���UW�����fe���wv��D������)�where��D�I"�is�the�p�ositiv���e���discriminan���t���of�the�eld.�&7If��D�-�is�not�a�fundamen�tal�discriminan�t,�.this�probably�giv�es�the�funda-���men���tal��unit�of�the�corresp�Gonding�order.�X,�D�O��m�ust�b�Ge�an�in�teger�congruen�t�to�0�or�1�mo�Gdulo�4,��whic�h���is�UUnot�a�square;�the�result�is�a�quadratic�n���um�b�Ger�UU(see�Section�3.4.56).����The�UUlibrary�syn���tax�is���f�undunit��/�a�(�x�).������3.4.61�q�remo��9v�eprimes�(�f�x���=�[���]�g�):�F�remo���v�es���the�primes�listed�in��x��from�the�prime�n���um�b�Ger���table.�T�In���particular��E�removeprimes(addprimes)��empties�the�extra�prime�table.�:�x��can�also�b�Ge�a�single�in���teger.���List�UUthe�curren���t�extra�primes�if��x��is�omitted.����The�UUlibrary�syn���tax�is���remo��9v�eprimes��I��(�x�).������3.4.62���sigma�(�x;����f�k���=��1�g�):�dsum�9�of�the��k��P���^��th����p�Go���w�ers�9�of�the�p�ositiv���e�divisors�of��j�x�j�.�h��x��m�ust�b�Ge�of�t�yp�Ge���in���teger.����The�$flibrary�syn���tax�is���sumdiv��'v{�(�x�)�(=���sigma���ѫ(�x�))�or���gsumdivk��3Z�(�x;���k�P��)�(=���sigma���(�x;���k�P��)),�./where��k����is�UUa�C�long�in���teger.������3.4.63�5/sqrtin��9t�(�x�):�|in���teger���square�ro�Got�of��x�,���whic�h�m�ust�b�Ge�a�non-negativ�e�in�teger.�k�The�result�is���non-negativ���e�UUand�rounded�to�w�ards�zero.����The�UUlibrary�syn���tax�is���racine��!���(�x�).�������88���Y�̍����Kf�������3.4.64���znlog�(�x;���g�[٫):�[DZg��/�m���ust�)Vb�Ge�a�primitiv�e�ro�Got�mo�d�a�prime��p�,�2"and�the�result�is�the�discrete�log�of����x�3��in�the�m���ultiplicativ�e�3�group�(�Z�=p�Z�)���^������.�f�This�function�uses�a�simple-minded�com���bination�of�P�ohlig-���Hellman�L[algorithm�and�Shanks�bab���y-step/gian�t-step�L[whic�h�requires��O�G�(�������p���UW�����feҪ�;��q����
(�)�storage,�N'where��q��4�is�the���largest���prime�factor�of��p������1.��-Hence���it�cannot�b�Ge�used�when�the�largest�prime�divisor�of��p������1���is���greater�UUthan�ab�Gout�10���^��13��x�.���C��The�UUlibrary�syn���tax�is���znlog�����(�x;���g�[٫).���ʍ�3.4.65��Xznorder�(�x�):��o�x�H��m���ust�b�Ge�an�in�teger�mo�Gd��n�,�~cand�the�result�is�the�order�of��x��in�the�m�ultiplicativ�e���group�UU(�Z�=n�Z�)���^������.�q�Returns�an�error�if��x��is�not�in���v�ertible.����The�UUlibrary�syn���tax�is���order��7�(�x�).���ʍ�3.4.66�a�znprimro�Q�ot�(�n�):�"�returns���a�primitiv���e�ro�Got�(generator)�of�(�Z�=n�Z�)���^������,�whenev�er�this�latter���group�UUis�cyclic�(�n���=�4�UUor��n���=�2�p���^��k��@�or�UU�n��=��p���^��k��됫,�where��p��is�an�o�Gdd�prime�and��k�����0).����The�UUlibrary�syn���tax�is���gener�����(�x�).���ʍ�3.4.67��znstar�(�n�):�Єgiv���es���the�structure�of�the�m�ultiplicativ�e�group�(�Z�=n�Z�)���^������as�a�3-comp�Gonen�t�ro�w���v���ector�� �v�[٫,��+where��v��[1]��=���(�n�)�� is�the�order�of�that�group,��+�v��[2]�is�a��k�P��-comp�Gonen���t�ro�w-v�ector��d��of�in�tegers��
c���d�[�i�]��suc���h�that��d�[�i�]���>��1��and��d�[�i�]���j��d�[�i��I���1]��for��i�����2��and�(�Z�=n�Z�)���^������'�������Q�����ލ�
o�k��%��
o�i�=1����5�(�Z�=d�[�i�]�Z�),�>�and��v�[٫[3]�is�a����k�P��-comp�Gonen���t�UUro�w�v�ector�giving�generators�of�the�image�of�the�cyclic�groups��Z�=d�[�i�]�Z�.����The�UUlibrary�syn���tax�is���znstar��"*��(�n�).��#w���3.5��F���unctions�related�to�elliptic�curv��es�.�����W��*�e�
ha���v�e�implemen�ted�a�n�um�b�Ger�of�functions�whic�h�are�useful�for�n�um�b�Ger�theorists�w�orking�on���elliptic�?curv���es.�jVW��*�e�alw�a�ys�use�T��*�ate's�notations.�jVThe�functions�assume�that�the�curv�e�is�giv�en�b�y�a���general�UUW��*�eierstrass�mo�Gdel��w���}h�y��[ٟ����2��,�+�8�a����1��|s�xy����+��a����3���y�"�=���x������3���S�+��a����2���x������2���S�+��a����4���x��+��a����6���;����where�c}a�priori�the��a����i���ɫcan�b�Ge�of�an���y�scalar�t�yp�Ge.��>This�curv�e�can�b�Ge�considered�as�a�v�e-comp�Gonen�t���v���ector�/�E=[a1,a2,a3,a4,a6]�.�\�P�oin�ts�on��E��are�represen�ted�as�t�w�o-comp�Gonen�t�v�ectors��[x,y]�,�"�except���for�u	the�p�Goin���t�at�innit�y��*�,���i.e.�the�iden�tit�y�elemen�t�of�the�group�la�w,���represen�ted�b�y�the�one-comp�Gonen�t���v���ector�UU�[0]�.����It�N\is�useful�to�ha���v�e�N\at�one's�disp�Gosal�more�information.�otThis�is�giv���en�b�y�the�function��ellinit����(see�(�there),�]�whic���h�usually�giv�es�a�19�comp�Gonen�t�v�ector�(whic�h�w�e�will�call�a�long�v�ector�in�this���section).�lIf�5�a�sp�Gecic�
ag�is�added,�m�a�v���ector�with�only�13�comp�onen���t�will�b�e�output�(whic���h�w�e���will�]�call�a�medium�v���ector).��nA�]�medium�v�ector�just�giv�es�the�rst�13�comp�Gonen�ts�of�the�long�v�ector���corresp�Gonding�H�to�the�same�curv���e,�~_but�is�of�course�faster�to�compute.�6The�follo�wing�mem�b�Ger�functions���are�UUa���v��q�ailable�to�deal�with�the�output�of��ellinit�:������a1�{�a6�,�UU�b2�{�b8�,��c4�{�c6�����_�:�����f9co�Gecien���ts�UUof�the�elliptic�curv�e.��������area�����_�:�����f9v���olume�UUof�the�complex�lattice�dening��E����.��������disc�����_�:�����f9discriminan���t�UUof�the�curv�e.��������j�����_�:�����f9�j����-in���v��q�arian�t�UUof�the�curv���e.��������omega�����_�:�����f9[�!����1��|s�;���!����2���],�UUp�Gerio�ds�forming�a�basis�of�the�complex�lattice�dening��E���(�!����1���ȫis�the��������f9real�UUp�Gerio�d,�and��!����2��|s�=!����1���ȫb�elongs�to�P���oincar���Ge's�half-plane).��������eta�����_�:�����f9quasi-p�Gerio�ds�UU[�����1��|s�;�������2���],�suc���h�that������1���!����2���S��8�����2���!����1��C��=���i�[٫.���������89���Z	������Kf�����卍��roots�����_�:�����f9ro�Gots�UUof�the�asso�ciated�W��*�eierstrass�equation.��������tate�����_�:�����f9[�u���^��2��|s�;���u;�v�[٫]�UUin�the�notation�of�T��*�ate.��������w�����_�:�����f9Mestre's�UU�w��8�(this�is�tec���hnical).�������Their���use�is�b�Gest�describ�ed�b���y�an�example:�'assume�that��E�Sq�w�as�output�b�y��ellinit�,���then�t�yping����E����.disc��>�will�retriev���e�the�curv�e's�discriminan�t.�<The�mem�b�Ger�functions��area�,��v�eta��and��omega��are�only���a���v��q�ailable�UUfor�curv�es�o�v�er��Q�.�q�Con�v�ersely��*�,��tate��and��w��are�only�a�v��q�ailable�for�curv�es�dened�o�v�er��Q����p���R�.��h��Some�>�functions,�v�in�particular�those�relativ���e�to�heigh�t�computations�(see��ellheight�)�require�also���that��Sthe�curv���e�b�Ge�in�minimal�W��*�eierstrass�form.�I�This�is�ac�hiev�ed�b�y�the�function��ellminimalmodel�.����All�Ԟfunctions�related�to�elliptic�curv���es�share�the�prex��ell�,�4pand�the�precise�curv�e�w�e�are���in���terested��in�is�alw�a�ys�the�rst�argumen�t,�in�either�one�of�the�three�formats�discussed�ab�Go�v�e,�unless���otherwise���sp�Gecied.�ESF��*�or�instance,��in�functions�whic���h�do�not�use�the�extra�information�giv�en�b�y�long���v���ectors,��Sthe���curv�e�can�b�Ge�giv�en�either�as�a�v�e-comp�Gonen�t�v�ector,��Sor�b�y�one�of�the�longer�v�ectors���computed�UUb���y��ellinit�.�����3.5.1���elladd�(�E���;���z�p��1�;�z��2):��sum�{of�the�p�Goin���ts��z��1�and��z��2�on�the�elliptic�curv���e�corresp�Gonding�to�the���v���ector�UU�E����.����The�UUlibrary�syn���tax�is���addell��!\f�(�E���;���z�p��1�;�z��2).�����3.5.2��ellak�(�E���;���n�):���computes�k�the�co�Gecien���t��a����n��	�B�of�the��L�-function�of�the�elliptic�curv�e��E����,��`i.e.�in���principle��xco�Gecien���ts�of�a�newform�of�w�eigh�t�2�assuming�T��*�aniy�ama-W�eil��xconjecture�(whic�h�is�no�w���kno���wn��<to�hold�in�full�generalit�y�thanks�to�the�w�ork�of�Breuil,��BConrad,�Diamond,�T��*�a�ylor��<and�Wiles).����E�N��m���ust��b�Ge�a�medium�or�long�v�ector�of�the�t�yp�Ge�giv�en�b�y��ellinit�.��F��*�or�this�function�to�w�ork�for���ev���ery�ik�n��and�not�just�those�prime�to�the�conductor,�np�E����m�ust�b�Ge�a�minimal�W��*�eierstrass�equation.��If���this�UUis�not�the�case,�use�the�function��ellminimalmodel��rst�b�Gefore�using��ellak�.����The�UUlibrary�syn���tax�is���ak��9ell��UL�(�E���;���n�).�����3.5.3��*ellan�(�E���;���n�):�j�computes�GGthe�v���ector�of�the�rst��n�a����k��2׫corresp�Gonding�to�the�elliptic�curv�e��E����.�mAll���commen���ts�UUin��ellak��description�remain�v��q�alid.����The�UUlibrary�syn���tax�is���anell���ګ(�E���;���n�),�where��n��is�a�C�in�teger.�����3.5.4�hGellap�(�E���;���p;��f��flag����=��0�g�):�B]computes���the��a����p���ӫcorresp�Gonding�to�the�elliptic�curv���e��E���and�the�prime���n���um�b�Ger�T��p�.�q�These�are�dened�b���y�the�equation�#�E����(�F����p���R�)��=��p�7��+�1����a����p���,�T�where�T�#�E����(�F����p���)�stands�for�the���n���um�b�Ger�ǯof�p�oin���ts�of�the�curv�e��E�[<�o�v�er�the�nite�eld��F����p���R�.���When���flag���*�is�0,��Ethis�uses�the�bab�y-step���gian���t-step���metho�Gd�and�a�tric�k�due�to�Mestre.�	This�runs�in�time��O�G�(�p���^��1�=�4���ʫ)�and�requires��O��(�p���^��1�=�4���ʫ)���storage,�UUhence�b�Gecomes�unreasonable�when��p��has�ab�out�30�digits.����If���r�flag��d��is��r1,���computes�the��a����p��5īas�a�sum�of�Legendre�sym���b�Gols.�5This�is�slo�w�er�than�the�previous���metho�Gd�UUas�so�on�as��p��is�greater�than�100,�sa���y��*�.����No��c���hec�king�is�done�that��p��is�indeed�prime.�m	�E�<��m�ust�b�Ge�a�medium�or�long�v�ector�of�the�t�yp�Ge���giv���en�W�b�y��ellinit�,�X�dened�o�v�er��Q�,�X��F����p���D�or��Q����p���R�.�y��E���m�ust�b�Ge�giv�en�b�y�a�W��*�eierstrass�equation�minimal���at�UU�p�.����The��!library�syn���tax�is���ellap0�����(�E���;���p;���flag���t�).�2Also��!a�v��q�ailable�are���ap�Q�ell���m�(�E���;���p�),��_corresp�Gonding�to���flag����=���0,�UUand���ap�Q�ell2��!
��(�E���;���p�)�(��flag����=��1).�������90���[؍����Kf�������3.5.5��ellbil�(�E���;���z�p��1�;�z��2):��xif�f.�z��1�and��z��2�are�p�Goin���ts�on�the�elliptic�curv�e��E����,�jdthis�function�computes�the���v��q�alue�UUof�the�canonical�bilinear�form�on��z�p��1,��z��2:��#����M�ellheight��|O��(�E���;���z�p��1�+����z��2)�8����ellheight��1xū(�E�;���z�p��1)�����ellheight��1xū(�E�;���z�p��2)���where��d�+��denotes�of�course�addition�on��E����.���In�addition,��h�z�p��1�or��z��2�(but�not�b�Goth)�can�b�e�v���ectors�or���matrices.�o�Note�O�that�this�is�equal�to�t���wice�some�normalizations.��E��5�is�assumed�to�b�Ge�in���tegral,�P�giv�en���b���y�UUa�minimal�mo�Gdel.���S��The�UUlibrary�syn���tax�is���bilhell��"(٫(�E���;���z�p��1�;�z��2�;���pr��}'e�c�����).������3.5.6�*�ellc��9hangecurv�e�(�E���;���v�[٫):�'�c���hanges���the�data�for�the�elliptic�curv�e��E�T��b�y�c�hanging�the�co�Gordinates���using���the�v���ector��v=[u,r,s,t]�,�&i.e.�if��x���^��0���6�and��y��[ٟ�^��0�� �are�the�new�co�Gordinates,�then��x��٫=��u���^��2��|s�x���^��0��r3�+����r�G�,��y�.��=����u���^��3��|s�y��[ٟ�^��0��b�+�8�su���^��2���x���^��0���+��t�.�q�The�UUv���ector��E���m�ust�b�Ge�a�medium�or�long�v�ector�of�the�t�yp�Ge�giv�en�b�y��ellinit�.����The�UUlibrary�syn���tax�is���co�Q�ordc��9h��*���(�E���;���v�[٫).������3.5.7�'Gellc��9hangep�Q�oin�t�(�x;���v�[٫):�Lc���hanges���the�co�Gordinates�of�the�p�oin���t�or�v�ector�of�p�Goin�ts��x��using�the���v���ector����v=[u,r,s,t]�,��i.e.�if��x���^��0���6�and��y��[ٟ�^��0����are�the�new�co�Gordinates,�then��x���=��u���^��2��|s�x���^��0���k�+��2�r�G�,��y�"�=��u���^��3��|s�y��[ٟ�^��0��"D�+��2�su���^��2���x���^��0���k�+��t����(see�UUalso��ellchangecurve�).����The�UUlibrary�syn���tax�is���p�Q�oin��9tc�h��(�H�(�x;���v�[٫).������3.5.8�{�elleisn��9um�(�E���;���k�P�;��f��flag���ƫ=���0�g�):��ױE�yj�b�Geing���an�elliptic�curv���e�as�output�b�y��ellinit��(or,�	�alterna-���tiv���ely��*�,��*giv�en��_b�y�a�2-comp�Gonen�t�v�ector�[�!����1��|s�;���!����2���]�represen���ting�its�p�Gerio�ds),��*and��k����b�eing�an�ev���en�p�ositiv���e���in���teger,�UUcomputes�the�n�umerical�v��q�alue�of�the�Eisenstein�series�of�w�eigh�t��k���at��E����,�namely������m'(2�i�[�=!����2��|s�)������k�����됟��`�����
�t�1�8�+�2�=���(1����k�P��)���������X����
�����n��0����B�n������k�+B��1��(�q�������n���W�=�(1����q�������n���W�)������`�������;��!�[��where�UU�q�"�=���e�(�!����1��|s�=!����2���).����When��UU�flag���v�is�UUnon-zero�and��k���=��4�or�6,�returns�the�elliptic�in���v��q�arian�ts�UU�g����2���ȫor��g����3��|s�,�suc���h�that��#�����y��[ٟ����2���d�=��4�x������3���S��8�g����2��|s�x����g����3�����is�UUa�W��*�eierstrass�equation�for��E����.���S��The�UUlibrary�syn���tax�is���elleisn��9um��2	.�(�E���;���k�P�;���flag���t�).������3.5.9�#�elleta�(�om�):���returns�xKthe�t���w�o-comp�Gonen�t�xKro�w�v�ector�[�����1��|s�;�������2���]�of�quasi-p�Gerio�ds�asso�ciated�to�����om��
G�=��[�!����1��|s�;���!����2���]����The�UUlibrary�syn���tax�is���elleta��S��(�om;�����pr��}'e�c�����)������3.5.10���ellglobalred�(�E����):�w�calculates�X_the�arithmetic�conductor,�Y!the�global�minimal�mo�Gdel�of��E���and���the���global�T��*�amaga���w�a���n�um�b�Ger��c�.���Here��E�J��is�an�elliptic�curv�e�giv�en�b�y�a�medium�or�long�v�ector�of���the���t���yp�Ge�giv�en�b�y��ellinit�,����and��is�supp��}'ose�d��to�have�al���l�its�c��}'o�ecients�옱a����i��@��in�z�Q�.���The���result�is�a�3���comp�Gonen���t�:�v�ector�[�N���;���v�[�;�c�].���N�R�is�the�arithmetic�conductor�of�the�curv���e.��v��ѫgiv�es�:�the�co�Gordinate�c�hange���for��O�E�xܫo���v�er��Q��to�the�minimal�in�tegral�mo�Gdel�(see��ellminimalmodel�).�LpFinally��c��is�the�pro�duct�of�the���lo�Gcal��T��*�amaga���w�a�n�um�b�Gers��c����p���R�,���a�quan�tit�y�whic�h�en�ters�in�the�Birc�h�and�Swinnerton-Dy�er�conjecture.����The�UUlibrary�syn���tax�is���globalreduction��P��(�E����).�������91���\+������Kf�������3.5.11��Iellheigh��9t�(�E���;���z�p�;��f��flag���=��S0�g�):��
global�axN\'eron-T��*�ate�heigh���t�of�the�p�Goin�t��z���on�the�elliptic�curv�e����E����.�7VThe��v���ector��E�9��m�ust�b�Ge�a�long�v�ector�of�the�t�yp�Ge�giv�en�b�y��ellinit�,��with���flag����=��1.�7VIf���flag���=��0,��this���computation�o�is�done�using�sigma�and�theta-functions�and�a�tric���k�due�to�J.�Silv�erman.���If���flag���E�=���1,���use��AT��*�ate's�4���^��n��	K��algorithm,��|whic���h�is�m�uc�h�slo�w�er.���E�mΫis�assumed�to�b�Ge�in�tegral,��|giv�en�b�y�a�minimal���mo�Gdel.��q���The��library�syn���tax�is���ellheigh��9t0��5�ϫ(�E���;���z�p�;���flag���t�;���pr��}'e�c�����).�	��The��Arc�himedean�con�tribution�alone�is���giv���en��7b�y�the�library�function���hell�����(�E���;���z�p�;���pr��}'e�c�����).�EmAlso�a���v��q�ailable�are���ghell�����(�E���;�z�p�;���pr��}'e�c�����)�(��flag����=���0)�and�����ghell2���h�(�E���;���z�p�;���pr��}'e�c�����)�UU(��flag����=��1).���K��3.5.12���ellheigh��9tmatrix�(�E���;���x�):�W�x�ƫb�Geing�a�v���ector�of�p�oin���ts,�*|this�function�outputs�the�Gram�matrix���of����x��with�resp�Gect�to�the�N�����Geron-T��*�ate�heigh�t,�փin�other�w�ords,�փthe�(�i;���j����)�comp�Gonen�t�of�the�matrix�is���equal��tto��ellbil(�E����,x[�i�],x[�j����])�.�F�The�rank�of�this�matrix,��;at�least�in�some�appro���ximate�sense,�giv���es���the�Y�rank�of�the�set�of�p�Goin���ts,�[and�if��x��is�a�basis�of�the�Mordell-W��*�eil�group�of��E����,�its�determinan���t�is���equal�Mto�the�regulator�of��E����.�ZoNote�that�this�matrix�should�b�Ge�divided�b���y�2�to�b�e�in�accordance�with���certain�UUnormalizations.�qDZE���is�assumed�to�b�Ge�in���tegral,�giv�en�b�y�a�minimal�mo�Gdel.����The�UUlibrary�syn���tax�is���mathell��)�(�E���;���x;���pr��}'e�c�����).���K��3.5.13���ellinit�(�E���;����f��flag����=��0�g�):�Y�computes�%
some�xed�data�concerning�the�elliptic�curv���e�giv�en�b�y�the���v���e-comp�Gonen�t�RUv�ector��E����,�R�whic�h�will�b�Ge�essen�tial�for�most�further�computations�on�the�curv�e.�p�The���result�Ϧis�a�19-comp�Gonen���t�v�ector�E�τ(called�a�long�v�ector�in�this�section),��cshortened�to�13�comp�Gonen�ts���(medium�UUv���ector)�if���flag��T9�=��1.�q�Both�con�tain�the�follo�wing�information�in�the�rst�13�comp�Gonen�ts:��q����i2�a����1��|s�;���a����2���;�a����3���;�a����4���;�a����6���;�b����2���;�b����4���;�b����6���;�b����8���;�c����4���;�c����6���;���;�j�R:����In�UUparticular,�the�discriminan���t�is��E����[12]�(or��E��.disc�),�and�the��j����-in���v��q�arian�t�UUis��E��[13]�(or��E��.j�).����The��other�six�comp�Gonen���ts�are�only�presen�t�if���flag��I��is�0�(or�omitted!).�XJTheir�con�ten�t�dep�Gends�on���whether�UUthe�curv���e�is�dened�o�v�er��R��or�not:���������۫When��E��h�is�dened�o���v�er����R�,��E����[14]�(�E��.roots�)�is�a�v���ector�whose�three�comp�Gonen�ts�con�tain�the���ro�Gots�UUof�the�righ���t�hand�side�of�the�asso�ciated�W��*�eierstrass�equation.��q�����d(�y����+�8�a����1��|s�x=�2�+��a����3���=�2)������2��C��=���g�[٫(�x�)���If�%(the�ro�Gots�are�all�real,�.�then�they�are�ordered�b���y�decreasing�v��q�alue.�a�If�only�one�is�real,�it�is�the�rst���comp�Gonen���t.�����E����[15]��(�E��.omega[1]�)�is�the�real�p�Gerio�d�of��E���(in���tegral�of��dx=�(2�y��+��:�a����1��|s�x��+��a����3���)��o���v�er�the�connected���comp�Gonen���t��:of�the�iden�tit�y�elemen�t�of�the�real�p�Goin�ts�of�the�curv�e),��3and��E����[16]�(�E��.omega[2]�)�is�a���complex�ڳp�Gerio�d.��In�other�w���ords,���!����1��!ҫ=��_�E����[15]�and��!����2���=��_�E����[16]�form�a�basis�of�the�complex�lattice���dening�UU�E���(�E����.omega�),�with����߫=������h���K�!���2����K��ʉfe�˟����!���1������s��ha���ving�p�Gositiv�e�imaginary�part.�����E����[17]�0pand��E��[18]�are�the�corresp�Gonding�v��q�alues������1����and������2���suc���h�that������1��|s�!����2��k���������2���!����1��C��=���i�[٫,�7�and�0pb�Goth���can�UUb�Ge�retriev���ed�b�y�t�yping��E����.eta��(as�a�ro�w�v�ector�whose�comp�Gonen�ts�are�the������i��TL�).����Finally��*�,�UU�E����[19]�(�E��.area�)�is�the�v���olume�of�the�complex�lattice�dening��E��.��������L�When��E�ߔ�is�dened�o���v�er�L�Q����p���R�,��the��p�-adic�v��q�aluation�of��j�ޒ�m���ust�b�Ge�negativ�e.�XThen��E����[14]�(�E��.roots�)���is��^the�v���ector�with�a�single�comp�Gonen�t�equal�to�the��p�-adic�ro�Got�of�the�asso�ciated�W��*�eierstrass�equation���corresp�Gonding�UUto���1�under�the�T��*�ate�parametrization.�������92���];Í����Kf�����卑�E����[15]�UUis�equal�to�the�square�of�the��u�-v��q�alue,�in�the�notation�of�T��*�ate.���I���E����[16]�UUis�the��u�-v��q�alue�itself,�if�it�b�Gelongs�to��Q����p���R�,�otherwise�zero.�����E����[17]�UUis�the�v��q�alue�of�T��*�ate's��q��.�for�the�curv���e��E��.�����E����.tate�UU�will�yield�the�three-comp�Gonen���t�v�ector�[�u���^��2��|s�;���u;�q�[٫].�����E����[18]�U�(�E��.w�)�is�the�v��q�alue�of�Mestre's��w����(this�is�tec���hnical),�U�and��E��[19]�is�arbitrarily�set�equal�to���zero.���a��F��*�or�=�all�other�base�elds�or�rings,�BGthe�last�six�comp�Gonen���ts�are�arbitrarily�set�equal�to�zero.�i�See���also�O�the�description�of�mem���b�Ger�functions�related�to�elliptic�curv�es�at�the�b�Geginning�of�this�section.���I��The�\'library�syn���tax�is���ellinit0��&��(�E���;�����flag���t�;�����pr��}'e�c�����).��<Also�a�v��q�ailable�are���initell�� E�(�E���;�����pr��}'e�c�����)�(��flag��
B�=��v0)�and�����smallinitell��7
�(�E���;�����pr��}'e�c�����)�UU(��flag����=��1).��D���3.5.14��ellisoncurv��9e�(�E���;���z�p��):�g�giv���es�A1�(i.e.�true)�if�the�p�Goin�t��z����is�on�the�elliptic�curv�e��E����,�E$0�otherwise.���If���E��q�or��z�i{�ha���v�e���imprecise�co�Gecien���ts,�aan�attempt�is�made�to�tak�e�this�in�to�accoun�t,�ai.e.�an�imprecise���equalit���y�UUis�c�hec�k�ed,�not�a�precise�one.����The�UUlibrary�syn���tax�is���oncurv��9e��*���(�E���;���z�p��),�and�the�result�is�a��long�.��D���3.5.15��ellj�(�x�):���elliptic�nѱj����-in���v��q�arian�t.��;�x��m�ust�b�Ge�a�complex�n�um�b�Ger�with�p�ositiv���e�imaginary�part,�u0or���con���v�ertible�UUin�to�a�p�Go�w�er�series�or�a��p�-adic�n�um�b�Ger�with�p�ositiv���e�v��q�aluation.����The�UUlibrary�syn���tax�is���jell���«(�x;�����pr��}'e�c�����).��D���3.5.16�(�elllo�Q�calred�(�E���;���p�):�,calculates��the�Ko�Gdaira�t���yp�e�of�the�lo�cal�b�er�of�the�elliptic�curv���e��E�1��at���the���prime��p�.��5�E�d\�m���ust�b�Ge�giv�en�b�y�a�medium�or�long�v�ector�of�the�t�yp�Ge�giv�en�b�y��ellinit�,��and�is���assumed���to�ha���v�e���all�its�co�Gecien���ts��a����i��TJ�in��Z�.�UUThe�result�is�a�4-comp�onen���t�v�ector�[�f��V;���k�P�od;�v�[�;�c�].�UUHere����f����is�D�the�exp�Gonen���t�of��p��in�the�arithmetic�conductor�of��E����,�H;and��k�P�od��is�the�Ko�daira�t���yp�e�whic���h�is�co�ded���as�UUfollo���ws:����1�;means�go�Go�d�;reduction�(t���yp�Ge�I����0��|s�),�M�2,�3�;and�4�mean�t�yp�Ges�I�I,�I�I�I�and�IV�resp�Gectiv���ely��*�,�M�4��y+������with���j>���0�means�t���yp�Ge�I�������ɫ;�%�nally�the�opp�osite�v��q�alues���1,�\��2,�etc.�refer�to�the�starred�t���yp�es�I���^�����l��0�����,�\I�I���^�����,���etc.�_RThe���third�comp�Gonen���t��v�\�is�itself�a�v�ector�[�u;���r���;�s;�t�]���giving�the�co�Gordinate�c�hanges�done�during���the��lo�Gcal�reduction.�i�Normally��*�,���this�has�no�use�if��u��is�1,�that�is,�if�the�giv���en�equation�w�as�already���minimal.�q�Finally��*�,�UUthe�last�comp�Gonen���t��c��is�the�lo�cal�T��*�amaga���w�a�UUn�um�b�er�UU�c����p���R�.����The�UUlibrary�syn���tax�is���lo�Q�calreduction��J1��(�E���;���p�).��D���3.5.17�Ȝelllseries�(�E���;���s;��f�A���=�1�g�):���E��6�b�Geing�k�a�medium�or�long�v���ector�giv�en�b�y��ellinit�,��fthis�computes���the��v��q�alue�of�the�L-series�of��E���at��s�.�soIn�the�presen���t�v�ersion�2.2.7,�+[�s��m�ust�b�Ge�a�real�n�um�b�Ger.�soIt�is���assumed��that��E��l�is�a�minimal�mo�Gdel�o���v�er���Z�.�tfThe�optional�parameter��A��is�a�cuto�p�oin���t�for�the���in���tegral,�`'whic�h�]�m�ust�b�Ge�c�hosen�close�to�1�for�b�Gest�sp�eed.���The�result�m���ust�b�e�indep�enden���t�of��A�,�`'so���this�UUallo���ws�some�in�ternal�c�hec�king�of�the�function.����Note�ythat�if�the�conductor�of�the�curv���e�is�large,��sa�y�greater�than�10���^��12��x�,��this�function�will�tak�e���an�UUunreasonable�amoun���t�of�time�since�it�uses�an��O�G�(�N����^��1�=�2��
��)�algorithm.����The�Dhlibrary�syn���tax�is���lseriesell��-�e�(�E���;���s;�A;���pr��}'e�c�����)�Dhwhere���pr��}'e�c����is�a��long��and�an�omitted��A��is�co�Gded���as�UU�NULL�.�������93���^N|�����Kf�������3.5.18�b�ellminimalmo�Q�del�(�E���;����f�&�v�[ٷg�):�g�return��Nthe�standard�minimal�in���tegral�mo�Gdel�of�the�rational���elliptic��xcurv���e��E����.�1If�presen�t,�ہsets��v��Q�to�the�corresp�Gonding�c�hange�of�v��q�ariables,�ہwhic�h�is�a�v�ector���[�u;���r���;�s;�t�]���with�rational�comp�Gonen���ts.�zThe�return�v��q�alue�is�iden�tical�to�that�of��ellchangecurve(E,���v)�.���The��resulting�mo�Gdel�has�in���tegral�co�ecien���ts,�+Xis�ev�erywhere�minimal,�+X�a����1��|��is�0�or�1,��a����2��|��is�0,�1���or��V��1�and��a����3��ɫis�0�or�1.��Suc���h�a�mo�Gdel�is�unique,���and�the�v�ector��v��/�is�unique�if�w�e�sp�Gecify�that��u��is���p�Gositiv���e,�UUwhic�h�w�e�do.����The�UUlibrary�syn���tax�is���ellminimalmo�Q�del��V:��(�E���;����&�v�[٫),�where�an�omitted��v��.�is�co�Gded�as��NULL�.���̍�3.5.19��7ellorder�(�E���;���z�p��):�Q�giv���es��the�order�of�the�p�Goin�t��z��y�on�the�elliptic�curv�e��E��o�if�it�is�a�torsion�p�Goin�t,���zero���otherwise.�C�In�the�presen���t�v�ersion�2.2.7,��this�is�implemen�ted�only�for�elliptic�curv�es�dened�o�v�er����Q�.����The�UUlibrary�syn���tax�is���orderell��)���(�E���;���z�p��).���̍�3.5.20��ellordinate�(�E���;���x�):���giv���es�Va�0,���1�or�2-comp�Gonen�t�v�ector�con�taining�the��y�[٫-co�Gordinates�of�the���p�Goin���ts�UUof�the�curv�e��E���ha�ving��x��as��x�-co�Gordinate.����The�UUlibrary�syn���tax�is���ordell���0�(�E���;���x�).���̍�3.5.21���ellp�Q�oin��9ttoz�(�E���;���z�p��):�beif�6��E���is�an�elliptic�curv���e�with�co�Gecien�ts�in��R�,�<�this�computes�a�complex���n���um�b�Ger�࠱t��(mo�dulo�the�lattice�dening��E����)�corresp�onding�to�the�p�oin���t��z�p��,�Csi.e.�suc�h�that,�Csin�the���standard��BW��*�eierstrass�mo�Gdel,��}�}�(�t�)�oM=��z�p��[1]�;���}���^��0���9�(�t�)�=��z��[2].���In��Bother�w���ords,��}this�is�the�in�v�erse�function���of�UU�ellztopoint�.����If�d�E����has�co�Gecien���ts�in��Q����p���R�,�g�then�either�T��*�ate's��u��is�in��Q����p���,�g�in�whic���h�case�the�output�is�a��p�-adic���n���um�b�Ger���t��corresp�onding�to�the�p�oin���t��z����under�the�T��*�ate�parametrization,�D�or�only�its�square�is,�in���whic���h�UUcase�the�output�is��t�8�+�1�=t�.�qDZE���m�ust�UUb�Ge�a�long�v�ector�output�b�y��ellinit�.����The�UUlibrary�syn���tax�is���zell����(�E���;���z�p�;���pr��}'e�c�����).���̍�3.5.22�jsellp�Q�o��9w�(�E���;���z�p�;�n�):�2Vcomputes����n��times�the�p�Goin���t��z�&3�for�the�group�la�w�on�the�elliptic�curv�e����E����.��Here,����n�k�can�b�Ge�in��Z�,�or��n��can�b�Ge�a�complex�quadratic�in���teger�if�the�curv�e��E����has�complex���m���ultiplication�UUb�y��n��(if�not,�an�error�message�is�issued).����The�UUlibrary�syn���tax�is���p�Q�o��9w�ell��#.�(�E���;���z�p�;�n�).���̍�3.5.23���ellro�Q�otno�(�E���;����f�p���=�1�g�):�[@�E��ԫb�Geing�(Ga�medium�or�long�v���ector�giv�en�b�y��ellinit�,�1Jthis�computes���the���lo�Gcal�(if��p��0�6�=�1)���or�global�(if��p��0�=�1)���ro�ot�n���um�b�er���of�the�L-series�of�the�elliptic�curv���e��E����.���Note���that��the�global�ro�Got�n���um�b�er��is�the�sign�of�the�functional�equation�and�conjecturally�is�the�parit���y�of���the�t2rank�of�the�Mordell-W��*�eil�group.��^The�equation�for��E���m���ust�ha�v�e�co�Gecien�ts�in��Q��but�need��not����b�Ge�UUminimal.����The�UUlibrary�syn���tax�is���ellro�Q�otno��0(ի(�E���;���p�)�and�the�result�(equal�to���1)�is�a��long�.���̍�3.5.24��=ellsigma�(�E���;���z�p�;��f��flag��:/�=�c0�g�):���v��q�alue�x�of�the�W��*�eierstrass������function�of�the�lattice�asso�Gciated�to����E���as�UUgiv���en�b�y��ellinit��(alternativ�ely��*�,��E���can�b�Ge�giv�en�as�a�lattice�[�!����1��|s�;���!����2���]).����If��UU�flag��T9�=��1,�UUcomputes�an�(arbitrary)�determination�of��log��@(��[٫(�z�p��)).����If��n��flag����=��2�;����3,�u(same�n�using�the�pro�Gduct�expansion�instead�of�theta�series.��)The�library�syn���tax�is�����ellsigma��(PK�(�E���;���z�p�;���flag���t�)�������94���__S�����Kf�������3.5.25���ellsub�(�E���;���z�p��1�;�z��2):��Kdierence�k�of�the�p�Goin���ts��z��1�and��z��2�on�the�elliptic�curv���e�corresp�Gonding�to���the�UUv���ector��E����.��tA��The�UUlibrary�syn���tax�is���sub�Q�ell�� �P�(�E���;���z�p��1�;�z��2).��\Í�3.5.26���elltaniy��9ama�(�E����):��qcomputes�u*the�mo�Gdular�parametrization�of�the�elliptic�curv���e��E��,�}where��E����is��agiv���en�in�the�(long�or�medium)�format�output�b�y��ellinit�,���in�the�form�of�a�t�w�o-comp�Gonen�t�v�ector���[�u;���v�[٫]�lJof�p�Go���w�er�lJseries,��giv�en�to�the�curren�t�default�series�precision.���This�v�ector�is�c�haracterized���b���y�q�the�follo�wing�t�w�o�prop�Gerties.��First�the�p�oin���t�(�x;���y�[٫)��z=�(�u;�v�[٫)�q�satises�the�equation�of�the�elliptic���curv���e.�8Second,���the��Sdieren�tial��du=�(2�v�:��+��ޱa����1��|s�u��+��a����3���)��Sis�equal�to��f���(�z�p��)�dz��,���a��Sdieren���tial�form�on��H�A�=�����0���(�N��)���where�#�N�;
�is�the�conductor�of�the�curv���e.�ݟThe�v��q�ariable�used�in�the�p�Go�w�er�series�for��u��and��v�˫is��x�,���whic���h��Eis�implicitly�understo�Go�d��Eto�b�Ge�equal�to��exp��d(2�i�[�z�p��).���It�is�assumed�that�the�curv�e�is�a��str��}'ong����W��*�eil��`curv���e,���and�the�Manin�constan�t�is�equal�to�1.�C�The�equation�of�the�curv�e��E�.�m�ust�b�Ge�minimal���(use�UU�ellminimalmodel��to�get�a�minimal�equation).����The���library�syn���tax�is���taniy��9ama��0銫(�E����),��sand�the�precision�of�the�result�is�determined�b�y�the�global���v��q�ariable�UU�precdl�.��\Í�3.5.27��elltors�(�E���;����f��flag����=��0�g�):��if��^�E�6�is�an�elliptic�curv���e��dene��}'d��.over��Q�,���outputs��^the�torsion�subgroup���of��ٱE�Cf�as�a�3-comp�Gonen���t�v�ector��[t,v1,v2]�,��zwhere��t��is�the�order�of�the�torsion�group,��v1��giv���es�the���structure���of�the�torsion�group�as�a�pro�Gduct�of�cyclic�groups�(sorted�b���y�decreasing�order),��and��v2����giv���es�UUgenerators�for�these�cyclic�groups.�qDZE���m�ust�b�Ge�a�long�v�ector�as�output�b�y��ellinit�.�����?�
�E�?�=�ellinit([0,0,0,-1,0]);����?�
�elltors(E)����%1�?�=�[4,�[2,�2],�[[0,�0],�[1,�0]]]�����Here,�UUthe�torsion�subgroup�is�isomorphic�to��Z�=�2�Z�8���Z�=�2�Z�,�UUwith�generators�[0�;����0]�and�[1�;��0].����If�����flag���ɫ=��Q0,���use���Doud's�algorithm:��ub�Gound�torsion�b���y�computing�#�E����(�F����p���R�)�for�small�primes���of�[�go�Go�d�reduction,��Gthen�lo�ok�for�torsion�p�oin���ts�using�W��*�eierstrass�parametrization�(and�Mazur's���classication).����If��UU�flag��T9�=��1,�UUuse�Lutz{Nagell�(�much���slo���w�er),�UU�E���is�allo���w�ed�UUto�b�Ge�a�medium�v���ector.����The�UUlibrary�syn���tax�is���elltors0��(<��(�E���;���f��l�2`ag�[٫).��\Í�3.5.28��Tellwp�(�E���;����f�z�7��=���x�g�;��f��flag����=�0�g�):����Computes�Ԉthe�v��q�alue�at��z�E�of�the�W��*�eierstrass��}��function�attac���hed�to�the�elliptic�curv�e��E�h�as�giv�en���b���y�UU�ellinit��(alternativ�ely��*�,��E���can�b�Ge�giv�en�as�a�lattice�[�!����1��|s�;���!����2���]).����If�jq�z���is�omitted�or�is�a�simple�v��q�ariable,���computes�the��p��}'ower���series�<��expansion�in��z��(starting����z��p���^���2��
~=�+�Q2�O�G�(�z��p���^��2���
�)).��7The�y�n���um�b�er�y�of�terms�to�an��even�>3�p�o���w�er�y�in�the�expansion�is�the�default�serieslength���in�UUGP��*�,�and�the�second�argumen���t�(C�long�in�teger)�in�library�mo�Gde.����Optional��y��flag��+��is�y�(for�no���w)�only�tak�en�in�to�accoun�t�when��z�ꎫis�n�umeric,��and�means�0:��
compute���only�UU�}�(�z�p��),�1:�q�compute�[�}�(�z��)�;���}���^��0���9�(�z��)].����The���library�syn���tax�is���ellwp0��#�f�(�E���;���z�p�;���flag���t�;���pr��}'e�c�����;���pr��}'e�c�d���l���9�).��Also���a�v��q�ailable�is��w��9eip�Q�ell�(�E���;�����pr��}'e�c�d���l���9�)�for���the�UUp�Go���w�er�series�(in��x���=���polx�[�0�]��"�C).��\Í�3.5.29���ellzeta�(�E���;���z�p��):�XPv��q�alue�"gof�the�W��*�eierstrass����J�function�of�the�lattice�asso�Gciated�to��E���as�giv���en�b�y����ellinit�UU�(alternativ���ely��*�,��E���can�b�Ge�giv�en�as�a�lattice�[�!����1��|s�;���!����2���]).����The�UUlibrary�syn���tax�is���ellzeta��#o�(�E���;���z�p��).�������95���`o������Kf�������3.5.30�$ellztop�Q�oin��9t�(�E���;���z�p��):����E�-_�b�Geing���a�long�v���ector,���computes�the�co�ordinates�[�x;���y�[٫]�on�the�curv���e��E����corresp�Gonding��to�the�complex�n���um�b�er��z�p��.��~Hence�this�is�the�in���v�erse��function�of��ellpointtoz�.�In���other���w���ords,��lif�the�curv�e�is�put�in�W��*�eierstrass�form,��l[�x;���y�[٫]�represen�ts�the�W��*�eierstrass�$\wp$-function���and�UUits�deriv��q�ativ���e.�q�If��z���is�in�the�lattice�dening��E���o�v�er��C�,�the�result�is�the�p�Goin�t�at�innit�y�[0].��C?��The�UUlibrary�syn���tax�is���p�Q�oin��9tell��)/�(�E���;���z�p�;���pr��}'e�c�����).��'ɼ��3.6��F���unctions�related�to�general�n��um�b�`er��elds�.������In���this�section�can�b�Ge�found�functions�whic���h�are�used�almost�exclusiv�ely�for�w�orking�in�general���n���um�b�Ger��elds.��
Other�less�sp�ecic�functions�can�b�e�found�in�the�next�section�on�p�olynomials.���F��*�unctions�Črelated�to�quadratic�n���um�b�Ger�Čelds�can�b�e�found�in�the�section�Section�3.4�(Arithmetic���functions).���W��*�e�UUshall�use�the�follo���wing�con�v�en�tions:���������nf����denotes��a�n���um�b�Ger��eld,�_�i.e.�a�9-comp�onen���t�v�ector�in�the�format�output�b�y��nfinit�.���This�v�con���tains�the�basic�arithmetic�data�asso�Gciated�to�the�n�um�b�Ger�eld:���signature,�maximal�order,���discriminan���t,�UUetc.����������bnf��<I�denotes���a�big�n���um�b�Ger���eld,��`i.e.�a�10-comp�onen���t�v�ector�in�the�format�output�b�y��bnfinit�.���This�o�con���tains���nf����and�the�deep�Ger�in�v��q�arian�ts�of�the�eld:��0units,��class�groups,�as�w���ell�as�a�lot�of���tec���hnical�UUdata�necessary�for�some�complex�functions�lik�e��bnfisprincipal�.�������i��bnr��WO�denotes�i�a�big�\ra���y�n�um�b�Ger�eld",���i.e.�some�data�structure�output�b�y��bnrinit�,���ev�en���more��^complicated�than���bnf��>�,���corresp�Gonding�to�the�ra���y�class�group�structure�of�the�eld,�for�some���mo�Gdulus.�������UU�rnf����denotes�UUa�relativ���e�n�um�b�Ger�eld�(see�b�elo���w).���������UU�ide��}'al����can�UUmean�an���y�of�the�follo�wing:����{�UUa��Z�-basis,�in�Hermite�normal�form�(HNF)�or�not.�q�In�this�case��x��is�a�square�matrix.����{�=0an��idele��[�,�Bi.e.�a�2-comp�Gonen���t�v�ector,�Bthe�rst�b�Geing�an�ideal�giv�en�as�a��Z�{basis,�Bthe�second���b�Geing�UUa��r����1���S�+�8�r����2��|s�-comp�onen���t�ro�w�v�ector�giving�the�complex�logarithmic�Arc�himedean�information.����{�UUa��Z����K�����-generating�system�for�an�ideal.����{�Ǵa��c��}'olumn���v���ector��x��expressing�an�elemen�t�of�the�n�um�b�Ger�eld�on�the�in�tegral�basis,��in�whic�h���case�UUthe�ideal�is�treated�as�b�Geing�the�principal�idele�(or�ideal)�generated�b���y��x�.����{�UUa�prime�ideal,�i.e.�a�5-comp�Gonen���t�v�ector�in�the�format�output�b�y��idealprimedec�.����{�rXa�p�Golmo�d�rX�x�,���i.e.�an�algebraic�in���teger,�in�whic���h�case�the�ideal�is�treated�as�b�Geing�the�principal���idele�UUgenerated�b���y��x�.����{�UUan�in���teger�or�a�rational�n�um�b�Ger,�also�treated�as�a�principal�idele.������׍�a��char��}'acter���on�the�Ab�Gelian�group������L��
��(�Z�=��q�N����i��TL�Z�)�g����i��+٫is�giv���en�b�y�a�ro�w�v�ector�����=�[�a����1��|s�;����:�:�:����;���a����n��q~�]�׍suc�h���that�UU��(�����Q��q�g����:��[ٴn���i���;Z��i����O�)��=��exp�(2�i�������P��?d�a����i��TL�n����i���=��q�N����i���).�������96���a�ύ����Kf�������W��
�arnings:������1)�
JAn�elemen���t�in���nf��〫can�b�Ge�expressed�either�as�a�p�olmo�d�or�as�a��c��}'olumn�έ�v���ector�of�comp�onen���ts���on�UUthe�in���tegral�basis���nf��$A�.zk�.�q�A�ro�w�v�ector�will�not�b�Ge�recognized.����2)�dWWhen�giving�an�ideal�b���y�a��Z����K��
�generating�system�to�a�function�exp�Gecting�an�ideal,�hit�m�ust���b�Ge��lensured�that�the�function�understands�that�it�is�a��Z����K�����-generating�system�and�not�a��Z�-generating���system.��When�$�the�n���um�b�Ger�$�of�generators�is�strictly�less�than�the�degree�of�the�eld,�X�there�is�no���am���biguit�y�i�and�the�program�assumes�that�one�is�giving�a��Z����K�����-generating�set.���When�the�n���um�b�Ger�i�of���generators�{is�greater�than�or�equal�to�the�degree�of�the�eld,�'
ho���w�ev�er,�the�{program�assumes�on�the���con���trary��Rthat�y�ou�are�giving�a��Z�-generating�set.���If�this�is�not�the�case,��y�ou��must�w*�c�hange�it�in�to�a����Z�-generating�UUset,�using��idealhnf(��nf��
���,�x�)�.����Concerning�d�relativ���e�extensions,���some�additional�denitions�are�necessary��*�.���When�dening�a���relativ���e��extension,��Pthe�base�eld���nf���\�m�ust�b�Ge�dened�b�y�a�v��q�ariable�ha�ving�a�lo�w�er�priorit�y�(see���Section��2.6.2)�than�the�v��q�ariable�dening�the�extension.�@�F��*�or�example,�Lunder�GP��y���ou�can�use�the���v��q�ariable���name��y��x�(or��t�)�to�dene�the�base�eld,��and�the�v�ariable�name��x��to�dene�the�relativ���e���extension.�������A��r��}'elative�_7matrix�PS�is�a�matrix�whose�en���tries�are�elemen�ts�of�a�(xed)�n�um�b�Ger�eld���nf��
���,�'�alw�a�ys���expressed�UUas�column�v���ectors�on�the�in�tegral�basis���nf��$A�.zk�.�q�Hence�it�is�a�matrix�of�v�ectors.������UU�An��ide��}'al���list�H-�is�a�ro���w�v�ector�of�(fractional)�ideals�of�the�n�um�b�Ger�eld���nf��$A�.�������.�A���pseudo-matrix�r�is�a�pair�(�A;���I���)�where��A��is�a�relativ���e�matrix�and��I���an�ideal�list�whose�length���is�-�the�same�as�the�n���um�b�Ger�-�of�columns�of��A�.�d�This�pair�is�represen���ted�b�y�a�2-comp�Gonen�t�ro�w�v�ector.���������The��mo��}'dule�d�generated�b���y�a�pseudo-matrix�(�A;���I���)�is�the�sum������P���2ğ�i��1��a����j��6��A����j���5�where�the��a����j���are�the���ideals�UUof��I�7�and��A����j����is�the��j����-th�column�of��A�.��������A��pseudo-matrix�(�A;���I���)�is�a��pseudo-b��}'asis�Qīof�the�mo�Gdule�it�generates�if��A��is�a�square�matrix���with��non-zero�determinan���t�and�all�the�ideals�of��I����are�non-zero.�DW��*�e�sa�y�that�it�is�in�Hermite�Normal���F��*�orm�UU(HNF)�if�it�is�upp�Ger�triangular�and�all�the�elemen���ts�of�the�diagonal�are�equal�to�1.�������;�The��determinant���of�a�pseudo-basis�(�A;���I���)�is�the�ideal�equal�to�the�pro�Gduct�of�the�determinan���t���of�W��A��b���y�all�the�ideals�of��I���.�x�The�determinan�t�of�a�pseudo-matrix�is�the�determinan�t�of�an�y�pseudo-���basis�UUof�the�mo�Gdule�it�generates.����No���w�{�a�last�set�of�denitions�concerning�the�w�a�y�big�ra�y�n�um�b�Ger�elds�(or���bnr�����)�are�input,���using�XJclass�eld�theory��*�.�z�These�are�dened�b���y�a�triple��a�1,�Y�a�2,��a�3,�where�XJthe�dening�set�[�a�1�;���a�2�;�a�3]���can��!ha���v�e�an�y�of�the�follo�wing�forms:�K`[��bnr����],��T[��bnr���;�����sub��}'gr�oup��'���],�[��bnf��h��;�����mo��}'dule�� �5�],�[��bnf���;�����mo��}'dule�� �5�;�����sub��}'gr�oup��'���],���where:��������N�bnf��k�is��Nas�output�b���y��bnfclassunit��or��bnfinit�,��Lwhere�units�are�mandatory�unless�the�ideal���is�UUtrivial;���bnr��.��b���y��bnrclass��(with���flag��T9�>���0)�or��bnrinit�.�q�This�is�the�ground�eld.������<
�mo��}'dule��h�is�either�an�ideal�in�an���y�form�(see�ab�Go�v�e)�or�a�t�w�o-comp�Gonen�t�ro�w�v�ector�con�taining���an���ideal�and�an��r����1��|s�-comp�Gonen���t�ro�w�v�ector�of�
ags�indicating�whic�h�real�Arc�himedean�em�b�Geddings���to�UUtak���e�in�the�mo�Gdule.������Z��sub��}'gr�oup��U�is�the�HNF�Z�matrix�of�a�subgroup�of�the�ra���y�class�group�of�the�ground�eld�for�the���mo�Gdulus����mo��}'dule��[�.�HThis�is�input�as�a�square�matrix�expressing�generators�of�a�subgroup�of�the�ra���y���class�UUgroup���bnr���6�.clgp��on�the�giv���en�generators.����The�*�corresp�Gonding���bnr��ُ�is�then�the�subeld�of�the�ra���y�class�eld�of�the�ground�eld�for�the���giv���en�UUmo�Gdulus,�asso�ciated�to�the�giv���en�subgroup.�������97���b�ٍ����Kf�����卑�All�lthe�functions�whic���h�are�sp�Gecic�to�relativ�e�extensions,�N1n�um�b�Ger�elds,�N1big�n�um�b�Ger�elds,���big��n���um�b�Ger�ra�ys,���share�the�prex��rnf�,��nf�,��bnf�,��bnr��resp�Gectiv���ely��*�.���They�are�mean�t�to�tak�e�as�rst���argumen���t���a�n�um�b�Ger�eld�of�that�precise�t�yp�Ge,��	resp�ectiv�ely���output�b�y��rnfinit�,��	�nfinit�,��bnfinit�,���and�UU�bnrinit�.���ߍ�Ho���w�ev�er,���and���ev�en�though�it�ma�y�not�b�Ge�sp�ecied�in�the�descriptions�of�the�functions�b�elo���w,���it�F�is�p�Germissible,��!if�the�function�exp�ects�a���nf����,��!to�use�a���bnf���
�instead�(whic���h�con�tains�m�uc�h�more���information).�TThe��program�will�mak���e�the�eort�of�con�v�erting�to�what�it�needs.�TOn�the�other�hand,���if�X�the�program�requires�a�big�n���um�b�Ger�X�eld,�Y�the�program�will��not�Këlaunc���h��bnfinit��for�y�ou,�Y�whic�h�is���a�UUcostly�op�Geration.�q�Instead,�it�will�giv���e�y�ou�a�sp�Gecic�error�message.����The���data�t���yp�Ges�corresp�onding�to�the�structures�describ�ed�ab�o���v�e���are�rather�complicated.�L�Th���us,���as�:�w���e�already�ha�v�e�seen�it�with�elliptic�curv�es,�?�GP�:�pro�vides�y�ou�with�some�\mem�b�Ger�functions"�to���retriev���e���the�data�y�ou�need�from�these�structures�(once�they�ha�v�e�b�Geen�initialized�of�course).�l�The���relev��q�an���t�UUt�yp�Ges�of�n�um�b�Ger�elds�are�indicated�b�et���w�een�paren�theses:��5�����bnf�����$�ҫ(��bnr����,������@g}�bnf������bz��)�����k�\:�����r�@big�UUn���um�b�Ger�eld.��������clgp�����$�ҫ(��bnr����,������@g}�bnf������bz��)�����k�\:�����r�@classgroup.�q�This�UUone�admits�the�follo���wing�three�sub�Gclasses:��������
�cyc�����k�\�:�����|�Acyclic�UUdecomp�Gosition�(SNF).��������
�gen�����k�\�:�����|�Agenerators.��������
�no�����k�\�:�����|�An���um�b�Ger�UUof�elemen���ts.��������diff�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@the�UUdieren���t�ideal.��������codiff�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@the�UUco�Gdieren���t�(in�v�erse�of�the�dieren�t�in�the�ideal�group).��������disc�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@discriminan���t.��������fu�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@fundamen���tal�UUunits.��������futu�����$�ҫ(��bnr����,������@g}�bnf������bz��)�����k�\:�����r�@[�u;���w�D�],�UU�u��is�a�v���ector�of�fundamen�tal�units,��w��8�generates�the�torsion.��������nf�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@n���um�b�Ger�UUeld.��������reg�����$�ҫ(��bnr����,������@g}�bnf��O��,�����bz�)�����k�\:�����r�@regulator.��������roots�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@ro�Gots�UUof�the�p�olynomial�generating�the�eld.��������sign�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@[�r����1��|s�;���r����2���]�UUthe�signature�of�the�eld.�q�This�means�that�the�eld�has��r����1���ȫreal��������r�@em���b�Geddings,�UU2�r����2���ȫcomplex�ones.��������t2�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@the�UUT2�matrix�(see��nfinit�).��������tu�����$�ҫ(��bnr����,������@g}�bnf��O��,�����bz�)�����k�\:�����r�@a�UUgenerator�for�the�torsion�units.��������tufu�����$�ҫ(��bnr����,������@g}�bnf��O��,�����bz�)�����k�\:�����r�@as�UU�futu�,�but�outputs�[�w�D�;���u�].��������zk�����$�ҫ(��bnr����,������@g}�bnf��O��,������W�;�nf������bz��)�����k�\:�����r�@in���tegral�UUbasis,�i.e.�a��Z�-basis�of�the�maximal�order.��������zkst�����$�ҫ(��bnr������bz��)�����k�\:�����r�@structure�UUof�(�Z����K�����=m�)���^�����9�(can�b�Ge�extracted�also�from�an���ide��}'alstar��)�).������F��*�or���instance,�&assume�that���bnf��$u�=����bnfinit��'��(��p��}'ol��
Lȫ),�for�some�p�Golynomial.�Q�Then���bnf��]]�.clgp��retriev���es���the�I class�group,�K�and���bnf�����.clgp.no��the�class�n���um�b�Ger.�m�If�I w�e�had�set���bnf��x��=����nfinit��"G�(��p��}'ol��
Lȫ),�K�b�Goth�w�ould���ha���v�e��output�an�error�message.��All�these�functions�are�completely�recursiv���e,�5th�us��for�instance�����bnr�����.bnf.nf.zk���will�yield�the�maximal�order�of���bnr�����,�?�whic���h�y�ou�could�get�directly�with�a�simple�����bnr�����.zk�.����Some���of�the�functions�starting�with��bnf��are�implemen���tations�of�the�sub-exp�Gonen�tial�algorithms���for�gInding�class�and�unit�groups�under�GRH,�due�to�Hafner-McCurley��*�,���Buc���hmann�and�Cohen-���Diaz-Olivier.���The�,general�call�to�the�functions�concerning�class�groups�of�general�n���um�b�Ger�,elds���(i.e.�UUexcluding��quadclassunit�)�in���v�olv�es�UUa�p�Golynomial��P���and�a�tec���hnical�v�ector���ߍ���^��te��}'ch���	J�=��[�c;���c�2�;���nrpid���ޫ]�;����where�UUthe�parameters�are�to�b�Ge�understo�o�d�as�follo���ws:�������98���c�΍����Kf�����卑�P��`�is�*�the�dening�p�Golynomial�for�the�n���um�b�er�*�eld,�`0whic�h�m�ust�b�Ge�in��Z�[�X���],�`0irreducible�and,���preferably��*�,�f�monic.��In�/�fact,�if�y���ou�supply�a�non-monic�p�Golynomial�at�this�p�oin���t,�f�GP�/�will�issue�a���w���arning,���then���tr��}'ansform��your�p�olynomial����so��that�it�b�Gecomes�monic.��Instead�of�the�normal�result,���sa���y���res�,�4y�ou�then�get�a�v�ector��[res,Mod(a,Q)]�,�where��Mod(a,Q)=Mod(X,P)�\�giv�es�the�c�hange�of���v��q�ariables.�����The�L�n���um�b�Gers��c��and��c�2�are�p�ositiv���e�real�n�um�b�Gers�whic�h�con�trol�the�execution�time�and�the���stac���k��*size.�3FT��*�o�get�maxim�um�sp�Geed,��set��c�2���=��c�.�3FT��*�o��*get�a�rigorous�result�(under�GRH)��y�ou�m�ust���tak���e�ȓ�c�2��)=�12�(or��c�2�=�6�in�the�quadratic�case,��bbut�then�y���ou�should�use�the�m�uc�h�faster�function����quadclassunit�).�q�Reasonable�UUv��q�alues�for��c��are�b�Get���w�een�UU0�:�1�and�2.�(The�defaults�are��c���=��c�2�=�0�:�3.)������nrpid��0O6�is�&the�maximal�n���um�b�Ger�&of�small�norm�relations�asso�ciated�to�eac���h�ideal�in�the�factor���base.��;Set��|it�to�0�to�disable�the�searc���h�for�small�norm�relations.�Otherwise,��Ereasonable�v��q�alues�are���b�Get���w�een�UU4�and�20.�q�(The�default�is�4).���6��Remarks.�����Apart���from�the�p�Golynomial��P�c��,��y���ou�don't�need�to�supply�an�y�of�the�tec�hnical�parameters�(under���the�$library�y���ou�still�need�to�send�at�least�an�empt�y�v�ector,�-��cgetg(1,t���E�ff&f��ǫVEC)�).�Ho�w�ev�er,�-�should�y�ou���c���ho�Gose��to�set�some�of�them,��they��must�؄�b�e�giv���en�in�the�requested�order.�L�F��*�or�example,��if�y�ou�w�an�t�to���sp�Gecify�T�a�giv���en�v��q�alue�of��nr�el�2`�,�T�y���ou�m�ust�giv�e�some�v��q�alues�as�w�ell�for��c��and��c�2,�T�and�pro�vide�a�v�ector���[�c;���c�2�;�nr�Gel�2`�].����Note��also�that�y���ou�can�use�an���nf���,�instead�of��P�c��,�	�whic�h�a�v�oids�recomputing�the�in�tegral�basis���and�UUanalogous�quan���tities.��$d��3.6.1�/obnfcertify�(��bnf��h��):��˴�bnf�����b�Geing��Ka�big�n���um�b�er��Keld�as�output�b���y��bnfinit��or��bnfclassunit�,���c���hec�ks�9�whether�the�result�is�correct,�r�i.e.�whether�it�is�p�Gossible�to�remo���v�e�9�the�assumption�of�the���Generalized�A�Riemann�Hyp�Gothesis.�k5If�it�is�correct,�E�the�answ���er�is�1.�If�not,�E�the�program�ma���y�output���some�"�error�message,�-but�more�probably�will�lo�Gop�indenitely��*�.�`�In��no�ć�o�ccasion�can�the�program�giv���e���a�UUwrong�answ���er�(barring�bugs�of�course):�q�if�the�program�answ�ers�1,�the�answ�er�is�certied.����The�UUlibrary�syn���tax�is���certif�ybuc��9hall��H���(��bnf��h��),�and�the�result�is�a�C�long.��LR��3.6.2�r�bnfclassunit�(�P�G;����f��flag���ū=���0�g�;��f��te��}'ch�����=�[�]�g�):��<Buc���hmann's��sub-exp�Gonen�tial�algorithm�for�com-���puting��the�class�group,��the�regulator�and�a�system�of�fundamen���tal�units�of�the�general�algebraic���n���um�b�Ger�UUeld��K�q�dened�b���y�the�irreducible�p�olynomial��P���with�in���teger�co�ecien���ts.����The�J�result�of�this�function�is�a�v���ector��v����with�man�y�comp�Gonen�ts�(it�is��not�=��a���bnf���5�,��	y�ou�need����bnfinit����for�that),��^whic���h�for�ease�of�presen�tation�is�in�fact�output�as�a�one�column�matrix.�f�First���w���e�UUdescrib�Ge�the�default�b�eha���viour�(��flag����=��0):�����v�[٫[1]�Ǥis�equal�to�the�p�Golynomial��P�c��.�ȴNote�that�for�optim���um�p�erformance,��7�P�+3�should�ha���v�e�Ǥgone���through�UU�polred��or���nfinit��"�C�(�x;����2).�����v�[٫[2]���is�the�2-comp�Gonen���t�v�ector�[�r�G�1�;���r��2],��/where��бr��1�and��r��2�are�as�usual�the�n���um�b�Ger�of�real�and���half�UUthe�n���um�b�Ger�UUof�complex�em���b�eddings�of�the�n���um�b�er�UUeld��K���.�����v�[٫[3]�UUis�the�2-comp�Gonen���t�v�ector�con�taining�the�eld�discriminan�t�and�the�index.�����v�[٫[4]�UUis�an�in���tegral�basis�in�Hermite�normal�form.�����v�[٫[5]���(�v��.clgp�)�is�a�3-comp�Gonen���t�v�ector�con�taining�the�class�n�um�b�Ger�(�v�[��.clgp.no�),�Vthe�structure���of��?the�class�group�as�a�pro�Gduct�of�cyclic�groups�of�order��n����i�����(�v�[��.clgp.cyc�),��:and�the�corresp�onding���generators�UUof�the�class�group�of�resp�Gectiv���e�orders��n����i�����(�v�[��.clgp.gen�).�������99���d�������Kf�����卑�v�[٫[6]�I�(�v��.reg�)�is�the�regulator�computed�to�an�accuracy�whic���h�is�the�maxim�um�of�an�in�ternally���determined�UUaccuracy�and�of�the�default.��c����v�[٫[7]�UUis�deprecated,�main���tained�for�bac�kw�ard�compatibilit�y�and�alw�a�ys�equal�to�1.�����v�[٫[8]��O(�v��.tu�)�a�v���ector�with�2�comp�Gonen�ts,��
the�rst�b�Geing�the�n�um�b�Ger��w��2�of�ro�ots�of�unit���y�in��K����and�UUthe�second�a�primitiv���e��w�D�-th�ro�Got�of�unit�y�expressed�as�a�p�Golynomial.�����v�[٫[9]�UU(�v��.fu�)�is�a�system�of�fundamen���tal�units�also�expressed�as�p�Golynomials.����If��Ѽ�flag�����=��n1,���and�Ѽthe�precision�happ�Gens�to�b�e�insucien���t�for�obtaining�the�fundamen�tal�units���exactly��*�,���the�ƙin���ternal�precision�is�doubled�and�the�computation�redone,�un���til�the�exact�results�are���obtained.��The���user�should�b�Ge�w���arned�that�this�can�tak�e�a�v�ery�long�time�when�the�co�Gecien�ts�of���the�+Dfundamen���tal�units�on�the�in�tegral�basis�are�v�ery�large,�`�for�example�in�the�case�of�large�real���quadratic��Felds.�:In�that�case,�ϯthere�are�alternate�metho�Gds�for�represen���ting�algebraic�n�um�b�Gers�whic�h���are�UUnot�implemen���ted�in�P��*�ARI.����If��p��flag����=��2,�wthe�p�fundamen���tal�units�and�ro�Gots�of�unit�y�are�not�computed.���Hence�the�result�has���only�UU7�comp�Gonen���ts,�the�rst�sev�en�ones.������te��}'ch��)���is���a�tec���hnical�v�ector�(empt�y�b�y�default)�con�taining��c�,��X�c�2,���nr��}'el�����,���b��}'orne��`5�,���nbpid�����,���minsfb��!=/�,�in���this��Zorder�(see�the�b�Geginning�of�the�section�or�the�k���eyw�ord��Z�bnf�).���Y��*�ou�can�supply�an���y�n�um�b�Ger�of���these��F�pr��}'ovide�d���you�give�an�actual�value�to�e��}'ach�of�them�W��(the�\empt���y�arg"�tric�k�w�on't�w�ork�here).���Careful�UUuse�of�these�parameters�ma���y�sp�Geed�up�y�our�computations�considerably��*�.����The�UUlibrary�syn���tax�is���bnf�classunit0��E�(�P�G;�����flag���t�;�����te��}'ch���K�;�����pr��}'e�c�����).���b��3.6.3��Tbnfclgp�(�P�G;����f��te��}'ch�����=��[�]�g�):�q�as�UU�bnfclassunit�,�but�only�outputs��v�[٫[5],�i.e.�the�class�group.����The���library�syn���tax�is���bnf�classgroup�Q�only��`ʫ(�P�G;�����te��}'ch���K�;�����pr��}'e�c�����),�6'where���te��}'ch�����is�as�describ�Ged�under����bnfclassunit�.���b��3.6.4��*bnfdeco�Q�demo�dule�(��nf��
��;���m�):��if����m��is�a�mo�Gdule�as�output�in�the�rst�comp�onen���t�of�an�extension���giv���en�UUb�y��bnrdisclist�,�outputs�the�true�mo�Gdule.����The�UUlibrary�syn���tax�is���deco�Q�demo�dule��J���(��nf��
��;���m�).���b��3.6.5��.bnfinit�(�P�G;����f��flag�� ��=��0�g�;��f��te��}'ch���]�=�[�]�g�):��Xessen���tially�iden�tical�to��bnfclassunit��except�that�the���output��con���tains�a�lot�of�tec�hnical�data,��and�should�not�b�Ge�prin�ted�out�explicitly�in�general.��#The���result�!of��bnfinit��is�used�in�programs�suc���h�as��bnfisprincipal�,�T�bnfisunit��or��bnfnarrow�.��&The���result�UUis�a�10-comp�Gonen���t�v�ector���bnf���ث.�����L��The�rst�6�and�last�2�comp�Gonen���ts�are�tec�hnical�and�in�principle�are�not�used�b�y�the�casual�user.���Ho���w�ev�er,���for�W&the�sak���e�of�completeness,�their�description�is�as�follo���ws.�
W��*�e�use�the�notations�explained���in�vXthe�b�Go�ok�vXb���y�H.�Cohen,�~��A��>Course��Fin�Computational�A���lgebr��}'aic�Numb�er�The�ory��}�,�~�Graduate�vXT��*�exts���in�UUMaths��138�,�Springer-V��*�erlag,�1993,�Section�6.5,�and�subsection�6.5.5�in�particular.������bnf��#h��[1]�]�con���tains�the�matrix��W�c��,�_�i.e.�the�matrix�in�Hermite�normal�form�giving�relations�for�the���class�UUgroup�on�prime�ideal�generators�(�}����i��TL�)����1��i��r���c�.������bnf��#h��[2]�e�con���tains�the�matrix��B��q�,��i.e.�the�matrix�con�taining�the�expressions�of�the�prime�ideal���factorbase�UUin�terms�of�the��}����i��TL�.�q�It�is�an��r����8�c��matrix.������bnf��#h��[3]��|con���tains�the�complex�logarithmic�em�b�Geddings�of�the�system�of�fundamen�tal�units�whic�h���has�UUb�Geen�found.�q�It�is�an�(�r����1���S�+�8�r����2��|s�)����(�r����1���+��r����2�����1)�UUmatrix.��������100���e������Kf�����卍��bnf��#h��[4]���con���tains�the�matrix��M���^����00��b��C���[��of�Arc�himedean�comp�Gonen�ts�of�the�relations�of�the�matrix���(�W�c��j�B��q�).�������bnf��#h��[5]�;�con���tains�the�prime�factor�base,�@�i.e.�the�list�of�prime�ideals�used�in�nding�the�relations.������bnf��#h��[6]�`�used�to�con���tain�a�p�Germ�utation�of�the�prime�factor�base,��abut�has�b�Geen�obsoleted.��}It���con���tains�UUa�dumm�y�0.������bnf��#h��[9]��is�a�3-elemen���t�ro�w�v�ector�used�in��bnfisprincipal��only�and�obtained�as�follo�ws.�4�Let����D���=�ŏ�U�W�c�V�&�obtained��b���y�applying�the�Smith�normal�form�algorithm�to�the�matrix��W�Q��(=���bnf��V��[1])���and�7Wlet��U����r�����b�Ge�the�reduction�of��U�Nr�mo�dulo��D��.��The�rst�elemen���ts�of�the�factorbase�are�giv�en�(in���terms��;of��bnf.gen�)�b���y�the�columns�of��U����r��m��,�4with�Arc�himedean�comp�Gonen�t��g����a���p�;�E.let�also��GD����a��˫�b�Ge�the���Arc���himedean��ncomp�Gonen�ts�of�the�generators�of�the�(principal)�ideals�dened�b�y�the��bnf.gen[i]^���bnf.cyc[i]�.�q�Then��UU�bnf���ث[9]��=�[�U����r��m��;���g����a���p�;�GD����a���].����Finally��*�,��r\�bnf���߫[10]�9Zis�b���y�default�un�used�and�set�equal�to�0.��This�eld�is�used�to�store�further���information� 'ab�Gout�the�eld�as�it�b�ecomes�a���v��q�ailable�(whic�h�is�rarely�needed,�R�hence�w�ould�b�Ge�to�o���exp�Gensiv���e��%to�compute�during�the�initial��bnfinit��call).�PbF��*�or�instance,�/the�generators�of�the�principal���ideals�g��bnf.gen[i]^bnf.cyc[i]��(during�a�call�to��bnrisprincipal�),�lDor�those�corresp�Gonding�to�the���relations�UUin��W���and��B��ƫ(when�the��bnf��in���ternal�precision�needs�to�b�Ge�increased).��W����UU�The�less�tec���hnical�comp�Gonen�ts�are�as�follo�ws:������bnf��#h��[7]�UUor���bnf�����.nf��is�equal�to�the�n���um�b�Ger�UUeld�data���nf��y��as�w���ould�b�e�giv���en�b�y��nfinit�.������bnf��#h��[8]��"is�a�v���ector�con�taining�the�last�6�comp�Gonen�ts�of��bnfclassunit[,1]�,��Vi.e.�the�classgroup�����bnf��h��.clgp�,���the���regulator���bnf��;D�.reg�,�the�general�\c���hec�k"���n�um�b�Ger�whic�h�should�b�Ge�close�to�1,���the�n�um-���b�Ger�Q�of�ro�ots�of�unit���y�and�a�generator���bnf���u�.tu�,�R�the�fundamen�tal�units���bnf���u�.fu�,�R�and�nally�the�c�hec�k���on��ltheir�computation.�\
If�the�precision�b�Gecomes�insucien���t,���GP��Xoutputs�a�w�arning�(�fundamental���units�?�too�large,�not�given�)�UUand�do�Ges�not�striv���e�to�compute�the�units�b�y�default�(��flag����=��0).����When��C��flag�����=�TL1,�=GP�Ckinsists�C�on�nding�the�fundamen���tal�units�exactly��*�,�the�in���ternal�precision���b�Geing���doubled�and�the�computation�redone,��
un���til�the�exact�results�are�obtained.��The�user�should���b�Ge��w���arned�that�this�can�tak�e�a�v�ery�long�time�when�the�co�Gecien�ts�of�the�fundamen�tal�units�on���the�UUin���tegral�basis�are�v�ery�large.����When�����flag���;�=��y2,���on���the�con���trary��*�,�it�is�initially�agreed�that�GP���will�not�compute�units.���Note���that�m�the�resulting���bnf��C��will�not�b�Ge�suitable�for��bnrinit�,�s�and�that�this�
ag�pro���vides�negligible�time���sa���vings.�q�In�UUshort,�do�not�use�it�without�a�v�ery�go�Go�d�UUreason.����When���<�flag��� �=��3,�ucomputes��<a�v���ery�small�v�ersion�of��bnfinit�,�ua�\small�big�n�um�b�Ger�eld"�(or���sbnf�����for��short)�whic���h�con�tains�enough�information�to�reco�v�er�the�full���bnf����v�ector�v�ery�rapidly��*�,�wbut�whic�h���is��5m���uc�h�smaller�and�hence�easy�to�store�and�prin�t.�LfIt�is�supp�Gosed�to�b�e�used�in�conjunction�with����bnfmake�.�/fThe��2output�is�a�12�comp�Gonen���t�v�ector��v�[٫,��as�follo�ws.�/fLet���bnf����b�Ge�the�result�of�a�full��bnfinit�,���complete�4�with�units.�f�Then��v�[٫[1]�is�the�p�Golynomial��P�c��,�;&�v��[2]�is�the�n���um�b�Ger�4�of�real�em���b�eddings��r����1��|s�,�;&�v�[٫[3]���is�Sthe�eld�discriminan���t,�)T�v�[٫[4]�is�the�in�tegral�basis,�)T�v�[٫[5]�is�the�list�of�ro�Gots�as�in�the�sixth�comp�onen���t���of�a�nfinit�,�2��v�[٫[6]�is�the�matrix��M�D�M~�of��nfinit��giving�a��Z�-basis�of�the�dieren���t,��v�[٫[7]�is�the�matrix����W���=���bnf��/��[1],� ��v�[٫[8]��is�the�matrix���matalpha��/ڜ�=����bnf���[2],� ��v�[٫[9]�is�the�prime�ideal�factor�base���bnf��|�[5]�co�Gded�in���a�p:compact�w���a�y��*�,�v�and�p:ordered�according�to�the�p�Germ���utation���bnf��ؽ�[6],��v�[٫[10]�is�the�2-comp�Gonen���t�v�ector���giving�ҵthe�n���um�b�Ger�ҵof�ro�ots�of�unit���y�and�a�generator,��
expressed�on�the�in�tegral�basis,��
�v�[٫[11]�is�the���list�7eof�fundamen���tal�units,�=bexpressed�on�the�in�tegral�basis,�=b�v�[٫[12]�is�a�v�ector�con�taining�the�algebraic���n���um�b�Gers�alpha�corresp�onding�to�the�columns�of�the�matrix��matalpha�,�Q�expressed�on�the�in���tegral���basis.��������101���f����Kf�����卑�Note��Tthat�all�the�comp�Gonen���ts�are�exact�(in�tegral�or�rational),���except�for�the�ro�Gots�in��v�[٫[5].�(�In���practice,���this��!is�the�only�comp�Gonen���t�whic�h�a�user�is�allo�w�ed�to�mo�Gdify��*�,���b�y�recomputing�the�ro�Gots���to���a�higher�accuracy�if�desired.��-Note�also�that�the�mem���b�Ger�functions�will��not����w�ork�on���sbnf��@�,�۪y�ou���ha���v�e�UUto�use��bnfmake��explicitly�rst.���썑The�UUlibrary�syn���tax�is���bnf�init0��+�
�(�P�G;�����flag���t�;�����te��}'ch���K�;�����pr��}'e�c�����).���č�3.6.6�[bnfisin��9tnorm�(��bnf��h��;���x�):�Zgcomputes�ɥa�complete�system�of�solutions�(mo�Gdulo�units�of�p�ositiv���e���norm)��jof�the�absolute�norm�equation��Norm���n(�a�)���=��x�,��where��j�a��is�an�in���teger�in���bnf��:�.��If���bnf��
W�has�not���b�Geen�UUcertied,�the�correctness�of�the�result�dep�ends�on�the�v��q�alidit���y�of�GRH.����See�UUalso��bnfisnorm�.����The�UUlibrary�syn���tax�is���bnf�isin��9tnorm��D�ѫ(��bnf��h��;���x�).���č�3.6.7�}bnfisnorm�(��bnf��h��;���x;��f��flag����=��61�g�):���tries��5to�tell�whether�the�rational�n���um�b�Ger��5�x��is�the�norm�of���some�Muelemen���t�y�in���bnf�����.�o'Returns�a�v�ector�[�a;���b�]�where��x���=��N�or�Gm�(�a�)�)!���b�.�o'Lo�oks�Mufor�a�solution�whic���h���is�jqan��S����-unit,�o�with��S����a�certain�set�of�prime�ideals�con���taining�(among�others)�all�primes�dividing��x�.���If�����bnf���߫is���kno���wn�to�b�Ge�Galois,�…set���flag��=&�=�X�0�(in�this�case,��x��is�a�norm�i��b�X��=�1).�w�If�����flag���(�is���non�zero���the���program�adds�to��S�H�the�follo���wing�prime�ideals,��^dep�Gending�on�the�sign�of���flag���[�.��vIf���flag��R)�>�eΫ0,�the���ideals�UUof�norm�less�than���flag���!�.�q�And�if���flag��T9�<���0�the�ideals�dividing���flag���.����Assuming�z3GRH,�the�answ���er�is�guaran�teed�(i.e.��x��is�a�norm�i��b���=�1),��kif�z3�S�
��con�tains�all�primes���less�UUthan�12����log���T(��disc��n��(��Bnf���ޫ))���^��2��|s�,�where���Bnf�����is�the�Galois�closure�of���bnf���ث.����See�UUalso��bnfisintnorm�.����The�UUlibrary�syn���tax�is���bnf�isnorm��6�d�(��bnf��h��;���x;���flag���t�;���pr��}'e�c�����),�UUwhere���flag���v�and���pr��}'e�c�����are��long�s.���č�3.6.8�lDbnfissunit�(��bnf��h��;�����sfu���;���x�):��xG�bnf���_�b�Geing�ؕoutput�b���y��bnfinit�,���e�sfu��	�b�y��bnfsunit�,��egiv�es�the�column���v���ector�.`of�exp�Gonen�ts�of��x��on�the�fundamen�tal��S����-units�and�the�ro�Gots�of�unit�y��*�.���If��x��is�not�a�unit,���outputs�UUan�empt���y�v�ector.����The�UUlibrary�syn���tax�is���bnf�issunit��5m�(��bnf��h��;�����sfu���;���x�).���č�3.6.9��bnfisprincipal�(��bnf��h��;���x;��f��flag���%�=�]Y1�g�):��YK�bnf��
�b�Geing�Ithe�n���um�b�er�Ield�data�output�b���y��bnfinit�,���and�ē�x��b�Geing�either�a��Z�-basis�of�an�ideal�in�the�n���um�b�er�ēeld�(not�necessarily�in�HNF)��vor�a�prime���ideal�2?in�the�format�output�b���y�the�function��idealprimedec�,�9Dthis�function�tests�whether�the�ideal�is���principal���or�not.�O�The�result�is�more�complete�than�a�simple�true/false�answ���er:�?it�giv�es�a�ro�w�v�ector���[�v����1��|s�;���v����2���],�UUwhere�����v����1��Jɫis��Vthe�v���ector�of�comp�Gonen�ts��c����i��"��of�the�class�of�the�ideal��x��in�the�class�group,��expressed�on���the���generators��g����i���8�giv���en�b�y��bnfinit��(sp�Gecically���bnf��o�.gen�).�]�The��c����i���8�are�c�hosen�so�that�0�J���c����i���_�<�n����i�����where�UU�n����i�����is�the�order�of��g����i���(the�v���ector�of��n����i���b�Geing���bnf�����.cyc�).�����v����2�����giv���es��*on�the�in�tegral�basis�the�comp�Gonen�ts�of������suc�h�that��x�&�=�����"����Q���%��i��$߱g����:��[ٴc���i���;Z��i������.��GIn��*particular,�� �x��is���principal�:[if�and�only�if��v����1���Ϋis�equal�to�the�zero�v���ector.�h�In�the�latter�case,�?��x���=���	z�Z����K��
��where�:[��Cիis�giv�en���b���y�=��v����2��|s�.�i�Note�that�if���G�is�to�Go�large�to�b�e�giv���en,�BOa�w�arning�message�will�b�Ge�prin�ted�and��v����2����will�b�Ge�set���equal�UUto�the�empt���y�v�ector.����If��UU�flag��T9�=��0,�UUoutputs�only��v����1��|s�,�whic���h�is�m�uc�h�easier�to�compute.����If��UU�flag��T9�=��2,�UUdo�Ges�as�if���flag���v�w���ere�0,�but�doubles�the�precision�un�til�a�result�is�obtained.����If�����flag��`8�=�n�3,���as���in�the�default�b�Geha���viour�(��flag���c�=�1),���but�doubles�the�precision�un���til�a�result�is���obtained.��������102���g꓍����Kf�����卑�The�UUuser�is�w���arned�that�these�t�w�o�last�setting�ma�y�induce��very�7ҫlength�y�computations.��5��The�UUlibrary�syn���tax�is���isprincipalall��C:�(��bnf��h��;���x;���flag���t�).��$k��3.6.10���bnfisunit�(��bnf��h��;���x�):��R��bnf���b�Geing�E�the�n���um�b�er�E�eld�data�output�b���y��bnfinit��and��x��b�eing�an���algebraic��n���um�b�Ger�(t�yp�Ge�in�teger,��rational�or�p�Golmo�d),��this�outputs�the�decomp�osition�of��x��on�the���fundamen���tal���units�and�the�ro�Gots�of�unit�y�if��x��is�a�unit,��the�empt�y�v�ector�otherwise.�T�More�precisely��*�,���if��u����1��|s�,��:���:�:��
UO�,�u����r��폫are�the�fundamen���tal�units,���and���<Ыis�the�generator�of�the�group�of�ro�Gots�of�unit�y�(found�b�y����bnfclassunit��ԫor��bnfinit�),��!the�output�is�a�v���ector�[�x����1��|s�;����:�:�:����;���x����r��m��;�x����r�7�+1�����]���suc�h�that��x���=��u����:��x���1���l��1����
������������u���^���x���r���፴r���	�{���������^��x���r�,r�+1���X2�.���The�UU�x����i�����are�in���tegers�for��i�����r��r�and�UUis�an�in�teger�mo�Gdulo�the�order�of���8�for��i���=��r���+�8�1.����The�UUlibrary�syn���tax�is���isunit����(��bnf��h��;���x�).��$k��3.6.11���bnfmak��9e�(��sbnf��C�):��_I�sbnf���b�Geing�0Za�\small���bnf���ݫ"�as�output�b���y��bnfinit�(�x;����3),�7�computes�the�com-���plete����bnfinit��information.�h�The�result�is��not����iden���tical�to�what��bnfinit��w�ould�yield,��Obut�is�func-���tionally��iden���tical.���The�execution�time�is�v�ery�small�compared�to�a�complete��bnfinit�.���Note�that���if���the�default�precision�in�GP���(or���pr��}'e�c���իin�library�mo�Gde)�is�greater�than�the�precision�of�the�ro�ots�����sbnf��C�[5],�UUthese�are�recomputed�so�as�to�get�a�result�with�greater�accuracy��*�.����Note�0that�the�mem���b�Ger�functions�are��not��a�v��q�ailable�for���sbnf���s�,�jy�ou�ha�v�e�to�use��bnfmake��explicitly���rst.����The�UUlibrary�syn���tax�is���mak��9ebigbnf��>>"�(��sbnf��C�;�����pr��}'e�c�����),�where���pr��}'e�c�����is�a�C�long�in�teger.��$k��3.6.12�bnfnarro��9w�(��bnf��h��):����bnf��6�b�Geing���a�big�n���um�b�er���eld�as�output�b���y��bnfinit�,��?computes�the�narro�w���class��Bgroup�of���bnf��]ū.�Q�The�output�is�a�3-comp�Gonen���t�ro�w�v�ector��v�Q�analogous�to�the�corresp�Gonding�class���group��comp�Gonen���t���bnf��q\�.clgp��(��bnf��h��[8][1]�):���the�rst�comp�onen���t�is�the�narro�w�class�n�um�b�Ger��v�[��.no�,���the��second�comp�Gonen���t�is�a�v�ector�con�taining�the�SNF��cyclic�comp�Gonen�ts��v�[��.cyc��of�the�narro�w�class���group,�5yand��the�third�is�a�v���ector�giving�the�generators�of�the�corresp�Gonding��v�[��.gen��cyclic�groups.���Note�UUthat�this�function�is�a�sp�Gecial�case�of��bnrclass�.����The�UUlibrary�syn���tax�is���buc��9hnarro�w��>�z�(��bnf��h��).��$k��3.6.13�!'bnfsign��9unit�(��bnf��h��):�����bnf���@�b�Geing�u�a�big�n���um�b�er�u�eld�output�b���y��bnfinit�,��this�computes�an����r����1��#ܷ��i�(�r����1���+��r����2�����1)��$matrix�ha���ving���1�comp�Gonen�ts,�$�giving�the�signs�of�the�real�em�b�Geddings�of�the���fundamen���tal�UUunits.�q�The�follo�wing�functions�compute�generators�for�the�totally�p�Gositiv�e�units:��G���/*�?�exponents�of�totally�positive�units�generators�on�bnf.tufu�*/����tpuexpo(bnf)=����{�?�local(S,d,K);��$���S�?�=�bnfsignunit(bnf);�d�=�matsize(S);�����S�?�=�matrix(d[1],d[2],�i,j,�if�(S[i,j]�<�0,�1,0));�����S�?�=�concat(S,�vectorv(d[1],i,1));���\\�sign(-1)�����K�?�=�lift(matker(S�*�Mod(1,2)));�����if�?�(K,�mathnfmodid(K,�2),�2*matid(d[1]))����}����/*�?�totally�positive�units�*/����tpu(bnf)=����{�?�local(vu,�ex�=�tpuexpo(bnf));�����vu�?�=�nfbasistoalg(bnf,�bnf.tufu);�����vector(length(ex)-1,�?�i,�factorback([vu,�ex[,i+1]]))�
�\\�ex[,1]�is�1��������103���h������Kf�����卑�}��Z2���The�UUlibrary�syn���tax�is���sign��9units��/��(��bnf��h��).���d��3.6.14��Tbnfreg�(��bnf��h��):��q��bnf��/��b�Geing�UUa�big�n���um�b�er�UUeld�output�b���y��bnfinit�,�computes�its�regulator.����The�UUlibrary�syn���tax�is���regulator��18ԫ(��bnf��h��;�����te��}'ch���K�;�����pr��}'e�c�����),�where���te��}'ch���M�is�as�in��bnfclassunit�.����3.6.15�T�bnfsunit�(��bnf��h��;���S����):�OBcomputes��the�fundamen���tal��S��-units�of�the�n���um�b�Ger��eld���bnf���(output�b���y����bnfinit�),��?where��ݱS�j�is�a�list�of�prime�ideals�(output�b���y��idealprimedec�).�_The�output�is�a�v�ector��v����with�UU6�comp�Gonen���ts.��Z2���v�[٫[1]���giv���es�a�minimal�system�of�(in�tegral)�generators�of�the��S����-unit�group�mo�Gdulo�the�unit�group.�����v�[٫[2]�UUcon���tains�tec�hnical�data�needed�b�y��bnfissunit�.�����v�[٫[3]��is�an�empt���y�v�ector�(used�to�giv�e�the�logarithmic�em�b�Geddings�of�the�generators�in��v�[٫[1]�in���v���ersion�UU2.0.16).�����v�[٫[4]���is�the��S����-regulator�(this�is�the�pro�Gduct�of�the�regulator,��the�determinan���t�of��v��[2]�and�the���natural�UUlogarithms�of�the�norms�of�the�ideals�in��S����).�����v�[٫[5]�Ogiv���es�the��S����-class�group�structure,��zin�the�usual�format�(a�ro�w�v�ector�whose�three�comp�Gonen�ts���giv���e�UUin�order�the��S����-class�n�um�b�Ger,�the�cyclic�comp�onen���ts�and�the�generators).�����v�[٫[6]�UUis�a�cop���y�of��S����.����The�UUlibrary�syn���tax�is���bnf�sunit��-��(��bnf��h��;���S�T;���pr��}'e�c�����).���d��3.6.16�A�bnfunit�(��bnf��h��):��.�bnf��J�b�Geing��wa�big�n���um�b�er��weld�as�output�b���y��bnfinit�,���outputs�the�v�ector�of���fundamen���tal�UUunits�of�the�n�um�b�Ger�eld.����This�ڞfunction�is�mostly�useless,���since�it�will�only�succeed�if���bnf����con���tains�the�units,�in�whic���h���case��S�bnf.fu��is�recommanded�instead,��Ror���bnf���)�w���as�pro�Gduced�with��bnfinit(,,2)�,�whic���h�is�itself���deprecated.����The�UUlibrary�syn���tax�is���buc��9hf�u��&H֫(��bnf��h��).���d��3.6.17�g�bnrL1�(��bnr����;����f��sub��}'gr�oup��&�g�;��f��flag����=��%0�g�):��p>�bnr��Ȱ�b�Geing�ԑthe�n���um�b�er�ԑeld�data�whic���h�is�output�b�y����bnrinit(,,1)�<�and���sub��}'gr�oup��,Y�b�Geing�a�square�matrix�dening�a�congruence�subgroup�of�the�ra���y�class���group�ԫcorresp�Gonding�to���bnr��-7�(the�trivial�congruence�subgroup�if�omitted),��greturns�for�eac���h�c�haracter�����W�of�the�ra���y�class�group�whic�h�is�trivial�on�this�subgroup,�Q�the�v��q�alue�at��s�ī=�1�W(or��s�ī=�0)�Wof�the���ab�Gelian�镱L�-function�asso�ciated�to���.�.�F��*�or�the�v��q�alue�at��s��,�=�0,��the��function�returns�in�fact�for�eac���h���c���haracter��E���a�v�ector�[�r�������;���c�������]��Ewhere��r������~b�is�the�order�of��L�(�s;��)�at��s���=�0��Eand��c������~b�the�rst�non-zero�term���in�UUthe�expansion�of��L�(�s;����)�at��s���=�0;�UUin�other�w���ords��Z2����бL�(�s;����)��=��c����������8�s������r������B�+��O�G�(�s������r�����Ү�+1��)7�)���near�	0.����flag�����is�optional,�6	default�v��q�alue�is�0;�b�its�binary�digits�mean�1:��Ncompute�at��s��=�1�	if�set�to���1�n}or��s����=�0�n}if�set�to�0,���2:��compute�the�primitiv���e��L�-functions�asso�Gciated�to����if�set�to�0�or�the����L�-function�0Fwith�Euler�factors�at�prime�ideals�dividing�the�mo�Gdulus�of���bnr���m�remo���v�ed�0Fif�set�to�1�(this���is��Tthe�so-called��L����S����(�s;����)�function�where��S��is�the�set�of�innite�places�of�the�n���um�b�Ger��Teld�together���with���the�nite�prime�ideals�dividing�the�mo�Gdulus�of���bnr��?ǫ,�Պsee�the�example�b�elo���w),�Պ3:�>�returns�also���the�UUc���haracter.��������104���i������Kf�����卑�Example:������bnf�?�=�bnfinit(x^2�-�229);��z���bnr�?�=�bnrinit(bnf,1,1);����bnrL1(bnr)��o���returns���the�order�and�the�rst�non-zero�term�of�the�ab�Gelian��L�-functions��L�(�s;����)�at��s�B�=�0���where������runs�UUthrough�the�c���haracters�of�the�class�group�of��Q�(�����P�p���UW���P�fe�E���229����UZ).�q�Then�����bnr2�?�=�bnrinit(bnf,2,1);����bnrL1(bnr2,,2)��o���returns���the�order�and�the�rst�non-zero�terms�of�the�ab�Gelian��L�-functions��L����S����(�s;����)�at��s�F:�=�0���where������,�runs�through�the�c���haracters�of�the�class�group�of��Q�(�����P�p���UW���P�fe�E���229����UZ)�and��S�#��is�the�set�of�innite�places�of����Q�(�����P�p���UW���P�fe�E���229����UZ)��together�with�the�nite�prime�2�(note�that�the�ra���y�class�group�mo�Gdulo�2�is�in�fact�the���class�UUgroup,�so��bnrL1(bnr2,0)��returns�exactly�the�same�answ���er�as��bnrL1(bnr,0)�!).����The�I�library�syn���tax�is���bnrL1��!x�(��bnr����;�����sub��}'gr�oup��'���;�����flag���t�;�����pr��}'e�c�����),�Lwhere�an�omitted���sub��}'gr�oup��,���is�co�Gded�as����NULL�.�����3.6.18�,�bnrclass�(��bnf��h��;�����ide��}'al����;����f��flag��}�=�F0�g�):��
*�bnf��3�b�Geing���a�big�n���um�b�er���eld�as�output�b���y��bnfinit��(the���units��3are�mandatory�unless�the�ideal�is�trivial),���and���ide��}'al��oիb�Geing�either�an�ideal�in�an���y�form�or�a�t�w�o-���comp�Gonen���t���ro�w�v�ector�con�taining�an�ideal�and�an��r����1��|s�-comp�Gonen�t�ro�w�v�ector�of�
ags�indicating�whic�h���real�hnArc���himedean�em�b�Geddings�to�tak�e�in�the�mo�Gdule,�m4computes�the�ra�y�class�group�of�the�n�um�b�Ger���eld�~qfor�the�mo�Gdule���ide��}'al��u�,���as�a�3-comp�onen���t�v�ector�as�all�other�nite�Ab�Gelian�groups�(cardinalit�y��*�,���v���ector�UUof�cyclic�comp�Gonen�ts,�corresp�Gonding�generators).����If���e�flag���I�=��2,�
bthe��eoutput�is�dieren���t.�S�It�is�a�6-comp�Gonen�t�v�ector��w�D�.�Sͱw��[1]��eis���bnf��c�.��w�D�[2]�is�the�result���of��Xapplying���idealstar��3=�(��bnf��h��;���I���;��2).��ѱw�D�[3],��Y�w��[4]��Xand��w�D�[6]�are�tec���hnical�comp�Gonen�ts�used�only�b�y�the���function�y��bnrisprincipal�.��i�w�D�[5]�is�the�structure�of�the�ra���y�class�group�as�w�ould�ha�v�e�b�Geen�output���with��UU�flag��T9�=��0.����If�����flag�����=��1,��Has���ab�Go���v�e,�except���that�the�generators�of�the�ra���y�class�group�are�not�computed,�whic���h���sa���v�es�UUtime.����The�UUlibrary�syn���tax�is���bnrclass0��1���(��bnf��h��;�����ide��}'al����;�����flag���t�).�����3.6.19���bnrclassno�(��bnf��h��;���I���):��T��bnf��د�b�Geing�`a�big�n���um�b�er�`eld�as�output�b���y��bnfinit��(units�are�manda-���tory���unless�the�ideal�is�trivial),���and��I�}��b�Geing�either�an�ideal�in�an���y�form�or�a�t�w�o-comp�Gonen�t�ro�w�v�ec-���tor��5con���taining�an�ideal�and�an��r����1��|s�-comp�Gonen�t�ro�w�v�ector�of�
ags�indicating�whic�h�real�Arc�himedean���em���b�Geddings�0to�tak�e�in�the�mo�Gdulus,�f�computes�the�ra�y�class�n�um�b�Ger�of�the�n�um�b�Ger�eld�for�the���mo�Gdulus��s�I���.�C|This�is�faster�than��bnrclass��and�should�b�e�used�if�only�the�ra���y�class�n�um�b�Ger�is�desired.����The�UUlibrary�syn���tax�is���ra��9yclassno��6�.�(��bnf��h��;���I���).�����3.6.20���bnrclassnolist�(��bnf��h��;�����list����):����bnf��w�b�Geing���a�big�n���um�b�er���eld�as�output�b���y��bnfinit��(units�are���mandatory��]unless�the�ideal�is�trivial),��_and���list���b�Geing�a�list�of�mo�dules�as�output�b���y��ideallist��of����ideallistarch�,�UUoutputs�the�list�of�the�class�n���um�b�Gers�UUof�the�corresp�onding�ra���y�class�groups.����The�UUlibrary�syn���tax�is���ra��9yclassnolist��E�ث(��bnf��h��;�����list����).��������105���j������Kf�������3.6.21�E-bnrconductor�(�a����1��|s�;����f�a����2���g�;��f�a����3���g�;��f��flag�����=�i00�g�):�4Kconductor����f��&�of�the�subeld�of�a�ra���y�class�eld���as�UUdened�b���y�[�a����1��|s�;���a����2���;�a����3���]�UU(see��bnr��at�the�b�Geginning�of�this�section).��卑If��UU�flag��T9�=��0,�UUreturns��f���.����If���)�flag����=��!1,��]returns��)[�f��V;���C��l����f��/ �;�H����],�where��)�C��l����f��	�I�is�the�ra���y�class�group�mo�Gdulo��f���,�as�output�b���y�����bnrclass��)��(�;���f��V;��1),��and��;�H��9�is�the�subgroup�of��C��l����f��,[�dening�the�extension.�TiIf��a����1��y��is�a��bnr�,�the�algorithm���requires�UUthat�it�has�b�Geen�computed�b���y���bnrinit��(@�(�;���;��1),�UUi.e.�with�generators.����If�����flag���z�=��2,�ļreturns���[�f��V;�����bnr��.��(�f���)�;���H����],�as�ab�Go���v�e�except��C��l����f��϶�is�replaced�b�y�a��bnr��structure,�ļas�output���b���y��UU�bnrinit��(@�(�;���f��V;��1).����The��library�syn���tax�is���conductor��4�_�(��bnr����;�����sub��}'gr�oup��'���;�����flag���t�),��where�an�omitted�subgroup�(trivial�sub-���group,�UUi.e.�ra���y�class�eld)�is�input�as��NULL�,�and���flag���v�is�a�C�long.��'ʍ�3.6.22���bnrconductorofc��9har�(��bnr����;�����chi��v��):��d�bnr��#%�b�Geing�:�a�big�ra���y�n�um�b�Ger�eld�as�output�b�y��bnrclass�,���and��$��chi����b�Geing�$�a�ro���w�v�ector�represen�ting�a�c�haracter�as�expressed�on�the�generators�of�the�ra�y�class���group,�UUgiv���es�the�conductor�of�this�c�haracter�as�a�mo�Gdulus.����The�UUlibrary�syn���tax�is���bnrconductorof�c��9har��f��(��bnr����;�����chi��v��).��'ʍ�3.6.23���bnrdisc�(�a�1�;����f�a�2�g�;��f�a�3�g�;��f��flag��P�=�?0�g�):�^�a�1,�R3�a�2,��a�3��dening�a�big�ra���y�n�um�b�Ger�eld��L��o�v�er�a���ground��1eld��K�9M�(see��bnr��at�the�b�Geginning�of�this�section�for�the�meaning�of��a�1,��g�a�2,��a�3),�outputs��1a���3-comp�Gonen���t�}�ro�w�v�ector�[�N���;���R����1��|s�;�D�G�],��where��N���is�the�(absolute)�degree�of��L�,��R����1���d�the�n���um�b�Ger�of�real���places�UUof��L�,�and��D��r�the�discriminan���t�of��L=�Q�,�including�sign�(if���flag��T9�=��0).����If��
�flag����=��1,��as�
ab�Go���v�e�but�outputs�relativ�e�data.�U��N�%�is�no�w�the�degree�of��L=K���,��R����1��}}�is�the�n�um�b�Ger���of�real�places�of��K��2�unramied�in��L��(so�that�the�n���um�b�Ger�of�real�places�of��L��is�equal�to��R����1�����times�the���relativ���e�UUdegree��N��),�and��D��r�is�the�relativ�e�discriminan�t�ideal�of��L=K���.����If��!&�flag��s��=��2,�Tdo�Ges�!&as�in�case�0,�except�that�if�the�mo�Gdulus�is�not�the�exact�conductor�corre-���sp�Gonding�UUto�the��L�,�no�data�is�computed�and�the�result�is�0�(�gzero�).����If��UU�flag��T9�=��3,�UUas�case�2,�outputting�relativ���e�data.����The�UUlibrary�syn���tax�is���bnrdisc0��-�ګ(�a�1�;���a�2�;�a�3�;���flag���t�).��'ʍ�3.6.24�
bnrdisclist�(��bnf��h��;�����b��}'ound����;����f��ar��}'ch��Kv�g�;��f��flag�� �=���0�g�):�����bnf��\ëb�Geing�daa�big�n���um�b�er�daeld�as�output�b���y����bnfinit��-�(the�units�are�mandatory),��"computes�a�list�of�discriminan���ts�of�Ab�Gelian�extensions�of�the���n���um�b�Ger�4�eld�b���y�increasing�mo�dulus�norm�up�to�b�ound���b��}'ound���ޫ,�lbwhere�the�ramied�Arc���himedean���places�@�are�giv���en�b�y���ar��}'ch���\�(unramied�at�innit�y�if���ar��}'ch���\�is�v�oid�or�omitted).�j�If���flag�����is�non-zero,�Egiv�e�����ar��}'ch��"��all�׈the�p�Gossible�v��q�alues.��a(See��bnr��at�the�b�eginning�of�this�section�for�the�meaning�of��a�1,���a�2,����a�3.)����The�alternativ���e�syn�tax���bnrdisclist��<��(��bnf��h��;�����list����)�is�supp�Gorted,�#|where���list��)e�is�as�output�b�y��ideal-���list�UU�or��ideallistarch��(with�units).����The�\�output�format�is�as�follo���ws.��The�output��v��ʫis�a�ro�w�v�ector�of�ro�w�v�ectors,���allo�wing�the�b�Gound���to�R�b�Ge�greater�than�2���^��16���z�for�32-bit�mac���hines,�S!and��v�[٫[�i�][�j����]�is�understo�o�d�to�b�e�in�fact��V�8�[2���^��15��x�(�i�3]���1)�+��j����]���of�_�a�unique�big�v���ector��V����(note�that�2���^��15��ر�is�hardwired�and�can�b�Ge�increased�in�the�source�co�de�only���on�UU64-bit�mac���hines�and�higher).����Suc���h��a�comp�Gonen�t��V�8�[�k�P��]�is�itself�a�v�ector��W�Q��(ma�yb�Ge�of�length�0)�whose�comp�onen���ts�corresp�ond���to�|eac���h�p�Gossible�ideal�of�norm��k�P��.��#Eac�h�comp�Gonen�t��W�c��[�i�]�corresp�Gonds�to�an�Ab�elian�extension��L��of�����bnf���K�whose�+�mo�Gdulus�is�an�ideal�of�norm��k�|_�and�no�Arc���himedean�comp�onen���ts�(hence�the�extension�is��������106���k+M�����Kf�����卫unramied�at�innit���y).�[�The�extension��W�c��[�i�]�is�represen�ted�b�y�a�4-comp�Gonen�t�ro�w�v�ector�[�m;���d;�r���;�D�G�]���with�\the�follo���wing�meaning.��ͱm��is�the�prime�ideal�factorization�of�the�mo�Gdulus,����d�|�=�[�L��:��Q�]�\is���the�:�absolute�degree�of��L�,�t(�r���is�the�n���um�b�Ger�:�of�real�places�of��L�,�and��D���is�the�factorization�of�the���absolute�2[discriminan���t.�fEac�h�prime�ideal��pr�5�=��[�p;����	z;�e;�f��V;����]�in�the�prime�factorization��m��is�co�Gded�as����p�8���n���^��2���S�+�(�f�Lo���1)����n��+�(�j��k���1),�UUwhere��n��is�the�degree�of�the�base�eld�and��j���is�suc���h�that������pr�?�=�idealprimedec(��nf��
���,p)[j]�.�����m�UU�can�b�Ge�deco�ded�using��bnfdecodemodule�.����The�UUlibrary�syn���tax�is���bnrdisclist0��=9��(�a�1�;���a�2�;�a�3�;���b��}'ound����;���ar��}'ch����;���flag���t�).��d.��3.6.25���bnrinit�(��bnf��h��;�����ide��}'al����;����f��flag��76�=��j0�g�):����bnf��aΫis��as�output�b���y��bnfinit�,��?��ide��}'al��G��is�a�v��q�alid�ideal�(or�a���mo�Gdule),��initializes���data�link���ed�to�the�ra�y�class�group�structure�corresp�Gonding�to�this�mo�dule.�L�This���is�UUthe�same�as���bnrclass��-U=�(��bnf��h��;�����ide��}'al����;�����flag��T�+�8�1).�����The�UUlibrary�syn���tax�is���bnrinit0��+�֫(��bnf��h��;�����ide��}'al����;�����flag���t�).����3.6.26��Rbnrisconductor�(�a�1�;����f�a�2�g�;��f�a�3�g�):�px�a�1,�S=�a�2,��a�3�R�represen���t�an�extension�of�the�base�eld,�S=giv�en���b���y��fclass�eld�theory�for�some�mo�Gdulus�enco�ded�in�the�parameters.�R"Outputs�1�if�this�mo�dulus�is�the���conductor,�UUand�0�otherwise.�q�This�is�sligh���tly�faster�than��bnrconductor�.�����The�UUlibrary�syn���tax�is���bnrisconductor��N���(�a�1�;���a�2�;�a�3)�UUand�the�result�is�a��long�.����3.6.27���bnrisprincipal�(��bnr����;���x;��f��flag��(v�=��1�g�):�����bnr��b��b�Geing��the�n���um�b�er��eld�data�whic���h�is�output�b�y����bnrinit�(�;���;��1)���and��x��b�Geing�an�ideal�in�an���y�form,��`outputs�the�comp�onen���ts�of��x��on�the�ra�y�class�group���generators�e2in�a�w���a�y�e2similar�to��bnfisprincipal�.��^That�is�a�2-comp�Gonen���t�v�ector��v���where��v�[٫[1]�is�the���v���ector�,of�comp�Gonen�ts�of��x��on�the�ra�y�class�group�generators,�a��v�[٫[2]�giv�es�on�the�in�tegral�basis�an���elemen���t�UU��^ϫsuc�h�that��x���=�����"����Q���%��i��$߱g����:��[ٴx���i���;Z��i������.�����If��	��flag��ȫ=��0,��outputs�	�only��v����1��|s�.�X�In�that�case,���bnr�����need�not�con���tain�the�ra�y�class�group�generators,���i.e.�UUit�ma���y�b�Ge�created�with��bnrinit�(�;���;��0)����The�UUlibrary�syn���tax�is���isprincipalra��9y�all��R���(��bnr����;���x;���flag���t�).��d.��3.6.28���bnrro�Q�otn��9um�b�er�(��bnr����;�����chi��v��;����f��flag����=��0�g�):�W^if� ����=���chi�����is�a�(not�necessarily�primitiv���e)�c�haracter���o���v�er���D�bnr��p%�,�Hlet��D�L�(�s;����)��=������P���
US��id��}���(�id�)�N��(�id�)���^���s��
r�b�Ge�the�asso�ciated�Artin�L-function.�N�Returns�the�so-called���Artin�UUro�Got�n���um�b�er,�UUi.e.�the�complex�n���um�b�er�UU�W�c��(��)�of�mo�dulus�1�suc���h�that���\����M(1�8���s;����)��=��W�c��(��)(�s;����~��feAş�g�����m�)���where�UU(�s;����)��=��A�(��)���^��s=�2��[��
�������(�s�)�L�(�s;��)�UUis�the�enlarged�L-function�asso�Gciated�to��L�.����The�u�generators�of�the�ra���y�class�group�are�needed,�}�and�y�ou�can�set���flag����=���1�if�the�c�haracter�is���kno���wn�UUto�b�Ge�primitiv�e.�q�Example:�����bnf�?�=�bnfinit(x^2�-�145);����bnr�?�=�bnrinit(bnf,7,1);����bnrrootnumber(bnr,�?�[5])����returns��2the�ro�Got�n���um�b�er��2of�the�c���haracter����of��C��l����7��|s�(�Q�(�����P�p���UW���P�fe�E���145����UZ))�suc�h�that���(�g�[٫)�M�=�������^��5��9V�,��iwhere��2�g��is�the���generator�E�of�the�ra���y-class�eld�and���p�=�W��e���^��2�i�@L=���N��D&�where��N�\��is�the�order�of��g��u�(�N�n��=�12�as��bnr.cyc����readily�UUtells�us).����The�UUlibrary�syn���tax�is���bnrro�Q�otn��9um�b�er��PO�(��bnf��h��;�����chi��v��;�����flag���t�)��������107���l>>�����Kf�������3.6.29��nbnrstark��(��bnr����;����f��sub��}'gr�oup��&�g�;��f��flag����=��0�g�)��|͉:��|d�bnr��Z�b�Geing�Z�as�output�b���y��bnrinit(,,1)�,�[�nds�a�rel-���ativ���e�[equation�for�the�class�eld�corresp�Gonding�to�the�mo�dulus�in���bnr�����and�the�giv���en�congruence���subgroup�using�Stark�units�(omit���sub��}'gr�oup��,���=��0�if�y���ou�w�an�t�the�whole�ra�y�class�group).��The�main���v��q�ariable�P�of���bnr��%��m���ust�not�b�Ge��x�,�Q�and�the�ground�eld�and�the�class�eld�m�ust�b�Ge�totally�real.�pKWhen���the�UUbase�eld�is��Q�,�the�v��q�astly�simpler��galoissubcyclo��is�used�instead.����flag��&��#�is�#optional�and�ma���y�b�Ge�set�to�0�(default)�to�obtain�a�reduced�relativ�e�p�Golynomial,�Vz1�to�b�e���satised�uwith�an���y�relativ�e�p�Golynomial,���2�to�obtain�an�absolute�p�olynomial�and�3�to�obtain�the���irreducible�UUrelativ���e�p�Golynomial�of�the�Stark�unit.�q�Example:������bnf�?�=�bnfinit(y^2�-�3);��b��bnr�?�=�bnrinit(bnf,�5,�1);����bnrstark(bnr,�?�0)����returns�UUthe�ra���y�class�eld�of��Q�(�����P�p���UW���P�fe�E���3����
UX)�mo�Gdulo�5.�����Remark.�{��The�X�result�of�the�computation�dep�Gends�on�the�c���hoice�of�a�mo�dulus�v���erifying�sp�ecial���conditions.�GWBy��default�the�function�will�try�few�mo�Gduli,��zc���ho�osing��the�one�giving�the�smallest�result.���In�Tsome�cases�where�the�result�is�ho���w�ev�er�Tv�ery�large,�T\y�ou�can�tell�the�function�to�try�more�mo�Gduli���b���y�#$adding�4�to�the�v��q�alue�of�
ag.��3Whether�this�
ag�is�set�or�not,�V�the�function�ma�y�fail�in�some���extreme�UUcases,�returning�the�error�message�����"Cannot�?�find�a�suitable�modulus�in�FindModule"�.����In�+�this�case,�athe�corresp�Gonding�congruence�group�is�a�pro�duct�of�cyclic�groups�and,�afor�the���time�UUb�Geing,�the�class�eld�has�to�b�e�obtained�b���y�splitting�this�group�in�to�its�cyclic�comp�Gonen�ts.����The�library�syn���tax�is���bnrstark��.��(��bnr����;�����sub��}'gr�oup��'���;�����flag���t�),�/�where�an�omitted���sub��}'gr�oup��.�is�co�Gded�b�y����NULL�.��L��3.6.30�`�dirzetak�(��nf��
��;���b�):�c�giv���es��^as�a�v�ector�the�rst��b��co�Gecien�ts�of�the�Dedekind�zeta�function�of���the�UUn���um�b�Ger�eld���nf��y��considered�as�a�Diric�hlet�series.����The�UUlibrary�syn���tax�is���dirzetak��,*��(��nf��
��;���b�).��L��3.6.31�factornf�(�x;���t�):�factorization���of�the�univ��q�ariate�p�Golynomial��x��o���v�er���the�n���um�b�er���eld�dened�b���y���the�\�(univ��q�ariate)�p�Golynomial��t�.��e�x��ma���y�ha�v�e�co�Gecien�ts�in��Q��or�in�the�n�um�b�Ger�eld.��eThe�algorithm���reduces�G�to�factorization�o���v�er�G��Q��(T��*�rager's�tric���k).�mCThe�direct�approac�h�of��nffactor�,�J~whic�h�uses�v��q�an���Ho�Geij's�UUmetho�d�in�a�relativ���e�setting,�is�in�general�faster.����The��Fmain�v��q�ariable�of��t��m���ust�b�Ge�of��lower��ӫpriorit�y�than�that�of��x��(see�Section�2.6.2).�:�Ho�w�ev�er���if�*�the�co�Gecien���ts�of�the�n�um�b�Ger�eld�o�ccur�explicitly�(as�p�olmo�ds)�as�co�ecien���ts�of��x�,�33the�v��q�ariable���of�UUthese�p�Golmo�ds�UU�must�H-�b�e�the�same�as�the�main�v��q�ariable�of��t�.�q�F��*�or�example������?�?�factornf(x^2�+�Mod(y,�y^2+1),�y^2+1);��b��?�?�factornf(x^2�+�1,�y^2+1);�\\����these�two�ar��}'e�OK�����?�?�factornf(x^2�+�Mod(z,z^2+1),�y^2+1)�����***���incorrect�?�type�in�gmulsg�����The�UUlibrary�syn���tax�is���p�Q�olf�nf��"�H�(�x;���t�).��������108���m[email protected]�����Kf�������3.6.32�2�galoisexp�Q�ort�(��gal��
Lȱ;����f��flag����=��0�g�):��+�gal��?��b�Geing���b�e�a�Galois�eld�as�output�b���y��galoisinit�,��/exp�ort���the�V�underlying�p�Germ���utation�group�as�a�string�suitable�for�(no�
ags�or���flag��W��=��(0)�GAP�V�or�(��flag���=�1)���Magma.��7��The��Jfollo���wing�example�compute�the�index�of�the�underlying�abstract�group�in�the�GAP��library:��Z��?�?�G=galoisinit(x^6+108);��V���?�?�s=galoisexport(G)����%2�?�=�"Group((1,�2,�3)(4,�5,�6),�(1,�4)(2,�6)(3,�5))"����?�?�extern("echo�\"IdGroup("s");\"|�gap�-q")����%3�?�=�[6,�1]����?�?�galoisidentify(G)����%4�?�=�[6,�1]�����The�UUlibrary�syn���tax�is���galoisexp�Q�ort��@Z�(��gal��
Lȱ;�����flag���t�).��n��3.6.33��$galoisfixedfield�(��gal��
Lȱ;�����p��}'erm��.�;����f��flag��/�=��0�g�;��f�v�S�=��y�[ٷg�)):�����gal��l�b�Geing�r�b�e�a�Galois�eld�as�output�b���y����galoisinit��̫and���p��}'erm��Z�an�elemen���t�of���gal��K��:g�[�r�Goup��or�a�v�ector�of�suc�h�elemen�ts,�))computes�the�xed���eld���of���gal��B��b���y�the�automorphism�dened�b�y�the�p�Germ�utations���p��}'erm��RL�of�the�ro�Gots���gal��G��:r�oots�.�bq�P�^r�is���guaran���teed�UUto�b�Ge�squarefree�mo�dulo���gal����:p�.����If�}no�
ags�or���flag��a�=��0,�output�format�is�the�same�as�for��nfsubfield�,�returning�[�P�G;���x�]�suc���h�that����P���is�UUa�p�Golynomial�dening�the�xed�eld,�and��x��is�a�ro�ot�of��P���expressed�as�a�p�olmo�d�in���gal����:pol�2`�.����If��UU�flag��T9�=��1�UUreturn�only�the�p�Golynomial��P�c��.����If���$�flag����=��2��$return�[�P�G;���x;�F�c��]��$where��P�8��and��x��are�as�ab�Go���v�e��$and��F��is�the�factorization�of���gal��!�:pol����o���v�er�V�the�eld�dened�b���y��P�c��,�V�where�v��q�ariable��v��k�(�y��b�y�V�default)�stands�for�a�ro�Got�of��P�c��.�u}The�priorit�y�of����v��.�m���ust�UUb�Ge�less�than�the�priorit�y�of�the�v��q�ariable�of���gal����:pol����(see�Section�2.6.2).�q�Example:��Z��G�?�=�galoisinit(x^4+1);��V���galoisfixedfield(G,G.group[2],2)�����[x^2�?�+�2,�Mod(x^3�+�x,�x^4�+�1),�[x^2�-�y*x�-�1,�x^2�+�y*x�-�1]]�����computes�UUthe�factorization��x���^��4���S�+�8�1��=�(�x���^��2������8��$�p���
�7��$��fe�����2����UV�x�8���1)(�x���^��2���+�����$��p���
�7��$��fe�����2����UV�x����1)����The�\
library�syn���tax�is���galoisf�ixedf�ield��P��(��gal��
Lȱ;�����p��}'erm��.�;�����flag���t�;�v),���where��v���is�a�v��q�ariable�n�um�b�Ger,���an���omitted�UU�v��.�b�Geing�co�ded�b���y���1.��n��3.6.34�]�galoisiden��9tify�(��gal��
Lȫ):��Z�gal����b�Geing���b�e�a�Galois�eld�as�output�b���y��galoisinit�,���output�the���isomorphism��class�of�the�underlying�abstract�group�as�a�t���w�o-comp�Gonen�ts��v�ector�[�o;���i�],�
where��o��is���the��jgroup�order,��3and��i��is�the�group�index�in�the�GAP4�Small�Group�library��*�,�b���y�Hans�Ulric�h�Besc�he,���Bettina�UUEic���k�and�Eamonn�O'Brien.����The���curren���t�implemen�tation�is�limited�to�degree�less�or�equal�to�127.�3�Some�larger�\easy"�orders���are�UUalso�supp�Gorted.����The��Koutput�is�similar�to�the�output�of�the�function��IdGroup��in�GAP4.���Note�that�GAP4����IdGroup�'l�handles�all�groups�of�order�less�than�2000�except�1024,�0�so�y���ou�can�use��galoisexport��and���GAP4�UUto�iden���tify�large�Galois�groups.����The�UUlibrary�syn���tax�is���galoisiden��9tif�y��FŖ�(��gal��
Lȫ).��������109���n]W�����Kf�������3.6.35�aloisinit�(��p��}'ol��
Lȱ;����f�den�g�):��computes��:the�Galois�group�and�all�necessary�information�for�com-���puting�1the�xed�elds�of�the�Galois�extension��K�(�=�Q��where��K��M�is�the�n���um�b�Ger�1eld�dened�b���y���p��}'ol�����(monic���irreducible�p�Golynomial�in��Z�[�X���]�or�a�n���um�b�er���eld�as�output�b���y��nfinit�).�9�The�extension��K�(�=�Q����m���ust�UUb�Ge�Galois�with�Galois�group�\w�eakly"�sup�Ger-solv��q�able�(see��nfgaloisconj�)�����The�UUoutput�is�an�8-comp�Gonen���t�v�ector���gal����.������gal��!Lȫ[1]�UUcon���tains�the�p�Golynomial���p��}'ol���r�(��gal��
L��.pol�).������gal��!Lȫ[2]��Yis�a�three{comp�Gonen���ts�v�ector�[�p;���e;�q�[٫]��Ywhere��p��is�a�prime�n�um�b�Ger�(��gal��
L��.p�)�suc�h�that���p��}'ol�����totally�m3split�mo�Gdulo��p��,����e��is�an�in���teger�and��q�"�=���p���^��e���~�(��gal��
L��.mod�)�is�the�mo�dulus�of�the�ro�ots�in���gal�����.roots�.������gal��!Lȫ[3]��qis�a�v���ector��L��con�taining�the��p�-adic�ro�Gots�of���p��}'ol�����as�in�tegers�implicitly�mo�Gdulo���gal��$9�.mod�.���(��gal��
L��.roots�).������gal��!Lȫ[4]�R�is�the�in���v�erse�R�of�the�V��*�an�der�Monde�matrix�of�the��p�-adic�ro�Gots�of���p��}'ol�����,��]m���ultiplied�b�y�����gal��
Lȫ[5].������gal��!Lȫ[5]���is�a�m���ultiple�of�the�least�common�denominator�of�the�automorphisms�expressed�as���p�Golynomial�UUin�a�ro�ot�of���p��}'ol����.������gal��!Lȫ[6]�UUis�the�Galois�group��G��expressed�as�a�v���ector�of�p�Germ�utations�of��L��(��gal��
L��.group�).������gal��!Lȫ[7]��xis�a�generating�subset��S��5�=�B�[�s����1��|s�;����:�:�:����;���s����g����]�of��G��expressed�as�a�v���ector�of�p�Germ�utations�of��L����(��gal��
L��.gen�).������gal��!Lȫ[8]�UUcon���tains�the�relativ�e�orders�[�o����1��|s�;����:�:�:����;���o����g����]�of�the�generators�of��S���(��gal��
L��.orders�).����Let�H%�H�#�b�Ge�the�maximal�normal�sup�ersolv��q�able�subgroup�of��G�,�J�w���e�ha�v�e�the�follo�wing�prop�Gerties:������UU�if��G=H���'���A����4���ȫthen�[�o����1��|s�;����:�:�:����;���o����g����]�ends�b���y�[2�;��2�;��3].������UU�if��G=H���'���S����4���ȫthen�[�o����1��|s�;����:�:�:����;���o����g����]�ends�b���y�[2�;��2�;��3�;��2].������UU�else��G��is�sup�Ger-solv��q�able.������TE�for�1�����i����g���the�TEsubgroup�of��G��generated�b���y�[�s����1��|s�;����:�:�:����;���s����g����]�is�normal,�T{with�the�exception�of����i���=��g�����8�2�UUin�the�second�case�and�of��i���=��g���8�3�UUin�the�third.�������t�the�relativ���e�order��o����i��6��of��s����i���is�its�order�in�the�quotien���t�group��G=�h�s����1��|s�;����:�:�:����;���s����i��1��
���i�,��nwith�the�same���exceptions.������UU�for�an���y��x���2��G�UU�there�exists�a�unique�family�[�e����1��|s�;����:�:�:����;���e����g����]�suc�h�that�(no�exceptions):����{�UUfor�1�����i����g��.�w���e�UUha�v�e�0�����e����i��d�<�o����i������{�UU�x���=��g����:��[ٴe���1���l��1����D�g����:��[ٴe���2���l��2����
8�:���:�:���;g���^���[ٴe���n���፴n�������If�UUpresen���t��den��m�ust�b�Ge�a�suitable�v��q�alue�for���gal����[5].����The�UUlibrary�syn���tax�is���galoisinit��0�,�(��gal��
Lȱ;�����den���Z�).��'��3.6.36�̆galoisisab�Q�elian�(��gal��
Lȱ;����f��l��x�=��0��'):��m��gal��h�b�Geing�M�as�output�b���y��galoisinit�,�O5return�0�if���gal���"�is�not�an���ab�Gelian�UUgroup,�and�the�HNF�matrix�of���gal���r�o���v�er�UU�gal.gen��if��f��l��x�=��0,�1�if��f�l��x�=��1.����The�UUlibrary�syn���tax�is���galoisisab�Q�elian��K%�(��gal��
Lȱ;�����
����)�where���
��
��is�a�C�long�in�teger.��������110���ok_�����Kf�������3.6.37��Wgaloisp�Q�erm��9top�ol�(��gal��
Lȱ;�����p��}'erm��.�):��qY�gal����b�Geing�Tya�Galois�eld�as�output�b���y��galoisinit��and���p��}'erm�����a�oelemen���t�of���gal����:g�[�r�Goup�,���return�the�p�olynomial�dening�the�Galois�automorphism,���as�output�b���y����nfgaloisconj�,���asso�Gciated��with�the�p�erm���utation���p��}'erm��֜�of�the�ro�ots���gal��	ӱ:r�oots�.�����p��}'erm���z�can�also�b�e�a���v���ector�UUor�matrix,�in�this�case,��galoispermtopol��is�applied�to�all�comp�Gonen�ts�recursiv�ely��*�.��q*�Note�UUthat�����G�?�=�galoisinit(pol);����galoispermtopol(G,�?�G[6])��&f~�����is�UUequiv��q�alen���t�to��nfgaloisconj(pol)�,�if�degree�of���p��}'ol���r�is�greater�or�equal�to�2.����The�UUlibrary�syn���tax�is���galoisp�Q�erm��9top�ol��S3̫(��gal��
Lȱ;�����p��}'erm��.�).��S~��3.6.38��Ugaloissub�Q�cyclo�(�N���;���H�A�;��f�f��l����=�T10�g�;��f�v�[ٷg�):�NNcomputes�C�the�sub�Gextension�of��Q�(�����n��q~�)�xed�b���y�the���subgroup���H�*���Z��(�Z�=n�Z�)���^������.�	By�the�Kronec���k�er-W��*�eb�Ger��theorem,�Dall�ab�elian�n���um�b�er��elds�can�b�e���generated�UUin�this�w���a�y�UU(uniquely�if��n��is�tak���en�to�b�Ge�minimal).���The�UUpair�(�n;���H����)�is�deduced�from�the�parameters�(�N���;�H����)�as�follo���ws��������N���an�in���teger:�q#then��n���=��N��;�ڱH���is��a�generator,���i.e.���an�in�teger�or�an�in�teger�mo�Gdulo��n�;��or�a���v���ector�UUof�generators.�������i�N����the�output�of��znstar(�n�)�.�G�H�lg�as�in�the�rst�case�ab�Go���v�e,��-or��ia�matrix,�tak���en�to�b�Ge�a�HNF���left�ʫdivisor�of�the�SNF�ʈfor�(�Z�=n�Z�)���^����c��(of�t���yp�Ge��N��.cyc�),��ggiving�the�generators�of��H����in�terms�of��N��.gen�.�������N��the�output�of��bnrinit(bnfinit(y),�?��m�,�1)��where��m��is�a�mo�Gdule.�WR�H���as�in�the�rst�case,���or���a�matrix�tak���en�to�b�Ge�a�HNF���left�divisor�of�the�SNF�for�the�ra���y�class�group�mo�Gdulo��m��(of�t�yp�Ge����N��.cyc�),�UUgiving�the�generators�of��H�%S�in�terms�of��N��.gen�.����In�8	this�last�case,�p�b�Gew���are�that��H��is�understo�o�d�relativ���ely�to��N��;��cin�particular,�p�if�the�innite���place�Jqdo�Ges�not�divide�the�mo�dule,�L�e.g�if��m��is�an�in���teger,�then�it�is�not�a�subgroup�of�(�Z�=n�Z�)���^������,�but���of�UUits�quotien���t�b�y��f�1�g�.����If�%�f��l��x�=��0,�.�compute�a�p�Golynomial�(in�the�v��q�ariable���v���(�)�dening�the�the�subeld�of��Q�(�����n��q~�)�xed�b���y���the�UUsubgroup���H���$�of�(�Z�=n�Z�)���^������.����If�UU�f��l��x�=��1,�compute�only�the�conductor�of�the�ab�Gelian�extension,�as�a�mo�dule.����If�Vٱf��l����=�tG2,��9output�[�pol�2`;���N��],�where��pol��9�is�the�p�Golynomial�as�output�when��f��l����=�tG0�and��N�m�the���conductor�UUas�output�when��f��l��x�=��1.����The�kfollo���wing�function�can�b�Ge�used�to�compute�all�subelds�of��Q�(�����n��q~�)�(of�exact�degree��d�,��if��d��is���set):�����subcyclo(n,�?�d�=�-1)=����{�����local(bnr,L,IndexBound);�����IndexBound�?�=�if�(d�<�0,�n,�[d]);�����bnr�?�=�bnrinit(bnfinit(y),�[n,[1]],�1);�����L�?�=�subgrouplist(bnr,�IndexBound,�1);�����vector(#L,i,�?�galoissubcyclo(bnr,L[i]));����}����Setting�UU�L�?�=�subgrouplist(bnr,�[d])��w���ould�pro�Gduce�subelds�of�exact�conductor��n�1�.����The��!library�syn���tax�is���galoissub�Q�cyclo��I���(�N���;���H�A�;�f��l�2`;�v�[٫)��!where���
��G~�is�a�C���long�in�teger,��_and���v��f�a�v��q�ariable���n���um�b�Ger.��������111���pzs�����Kf�������3.6.39���galoissubfields�(�G;����f�f��l�B��=��0�g�;��f�v�[ٷg�):��1Output�
all�the�subelds�of�the�Galois�group���G���«,�Lwas�a���v���ector.�m�This�I�w�orks�b�y�applying��galoisfixedfield��to�all�subgroups.�m�The�meaning�of�the�
ag���
��
}2�is���the�UUsame�as�for��galoisfixedfield�.��Ki��The�UUlibrary�syn���tax�is���galoissubf�ields��K�֫(��G�����;���f��l�2`;�v�[٫),�UUwhere���
��
��is�a�long�and���v��WΫa�v��q�ariable�n�um�b�Ger.���ҍ�3.6.40��zgaloissubgroups�(�G�):���Output��all�the�subgroups�of�the�Galois�group��G�.�A��subgroup�is�a���v���ector���[�g�[�en;���or�Gder�s�],���with�the�same�meaning�as�for���gal��鐱:g�[�en��and���gal���:or�Gder�s�.�H Hence���gen���i�is�a�v���ector���of�9fp�Germ���utations�generating�the�subgroup,�>�and���or��}'ders��"5�is�the�relativ�es�orders�of�the�generators.�hxThe���cardinal�UUof�a�subgroup�is�the�pro�Gduct�of�the�relativ���e�orders.����The�UUlibrary�syn���tax�is���galoissubgroups��R6G�(��G�����).���ҍ�3.6.41�0�idealadd�(��nf��
��;���x;�y�[٫):�,sum��of�the�t���w�o��ideals��x��and��y��in�the�n���um�b�Ger��eld���nf��s�.�`�When��x��and��y����are�J&giv���en�b�y��Z�-bases,�Lcthis�do�Ges�not�dep�end�on���nf��c8�and�can�b�e�used�to�compute�the�sum�of�an���y�t�w�o����Z�-mo�Gdules.�q�The�UUresult�is�giv���en�in�HNF.����The�UUlibrary�syn���tax�is���idealadd��-W�(��nf��
��;���x;�y�[٫).���ҍ�3.6.42�P�idealaddto�Q�one�(��nf��
��;���x;��f�y�[ٷg�):�8,�x���and��y�=��b�Geing�t���w�o��co-prime�in���tegral�ideals�(giv�en�in�an�y�form),���this�UUgiv���es�a�t�w�o-comp�Gonen�t�ro�w�v�ector�[�a;���b�]�suc�h�that��a���2��x�,�UU�b��2��y��.�and��a�8�+��b���=�1.����The�u�alternativ���e�syn�tax���idealaddtoone��G���(��nf��
��;���v�[٫),�}�is�supp�Gorted,�where��v�ц�is�a��k�P��-comp�Gonen���t�v�ector���of��.ideals�(giv���en�in�an�y�form)�whic�h�sum�to��Z����K�����.�-RThis�outputs�a��k�P��-comp�Gonen�t�v�ector��e��suc�h�that����e�[�i�]���2��x�[�i�]�UUfor�1�����i����k���and��UU����P���
㐟�1��i��k��'ʉ�e�[�i�]�=�1.����The�UUlibrary�syn���tax�is���idealaddto�Q�one0��O
��(��nf��
��;���x;�y�[٫),�UUwhere�an�omitted��y��.�is�co�Gded�as��NULL�.���ҍ�3.6.43�}
idealappr�(��nf��
��;���x;��f��flag����=��0�g�):�Kdif���x��is�a�fractional�ideal�(giv���en�in�an�y�form),��giv�es�an�elemen�t�����Aƫin��8L�nf��?��suc���h�8Lthat�for�all�prime�ideals��}��suc�h�that�the�v��q�aluation�of��x��at��}��is�non-zero,�q
w�e�ha�v�e����v����}���\�(��	z�)��=��v����}���(�x�),�UUand.�qDZv����}���(��	z�)����0�UUfor�all�other��}�.����If��I��flag����is�I�non-zero,�K��x��m���ust�b�Ge�giv�en�as�a�prime�ideal�factorization,�K�as�output�b�y��idealfactor�,���but�5p�Gossibly�with�zero�or�negativ���e�exp�onen���ts.��This�yields�an�elemen�t���>��suc�h�that�for�all�prime���ideals��ʱ}��o�Gccurring�in��x�,�
��v����}���\�(��	z�)�is�equal�to�the�exp�onen���t�of��}��in��x�,�
�and�for�all�other�prime�ideals,����v����}���\�(��	z�)��ݷ��0.��_This��2generalizes���idealappr��3
�(��nf��
��;���x;��0)��2since�zero�exp�Gonen���ts�are�allo�w�ed.��_Note�that�the���algorithm�Շused�is�sligh���tly�dieren�t,���so�that��idealappr(��nf��
���,idealfactor(��nf���,x))�Շ�ma�y�not�b�Ge�the���same�UUas��idealappr(��nf��
���,x,1)�.����The�UUlibrary�syn���tax�is���idealappr0��7�z�(��nf��
��;���x;���flag���t�).���ҍ�3.6.44���idealc��9hinese�(��nf��
��;���x;�y�[٫):�^
�x�-ګb�Geing�a�prime�ideal�factorization�(i.e.�a�2�b���y�2�matrix�whose�rst���column�4�con���tain�prime�ideals,�;oand�the�second�column�in�tegral�exp�Gonen�ts),�;o�y��ϫa�v�ector�of�elemen�ts�in�����nf��$A�indexed�UUb���y�the�ideals�in��x�,�computes�an�elemen�t��b��suc�h�that�����v����}���\�(�b�8���y����}���)�����v����}���(�x�)�UUfor�all�prime�ideals�in��x��and��v����}���(�b�)�����0�UUfor�all�other��}�.����The�UUlibrary�syn���tax�is���idealc��9hinese��>�E�(��nf��
��;���x;�y�[٫).���ҍ�3.6.45��;idealcoprime�(��nf��
��;���x;�y�[٫):�_
giv���en�/�t�w�o�in�tegral�ideals��x��and��y����in�the�n�um�b�Ger�eld���nf��
�ǫ,�7Znds�a������in�UUthe�eld,�expressed�on�the�in���tegral�basis���nf��$A�[7],�suc�h�that�������8�x��is�an�in�tegral�ideal�coprime�to��y�[٫.����The�UUlibrary�syn���tax�is���idealcoprime��C��(��nf��
��;���x;�y�[٫).��������112���q�ݍ����Kf�������3.6.46�q�idealdiv�(��nf��
��;���x;�y�[�;��f��flag����=��0�g�):�F�quotien���t���x�����y����^���1��:�of���the�t���w�o���ideals��x��and��y�Zƫin�the�n���um�b�Ger���eld�����nf��
��.�q�The�UUresult�is�giv���en�in�HNF.���o��If���K�flag��\b�is��Knon-zero,���the�quotien���t��x�a����y��[ٟ�^���1�����is��Kassumed�to�b�Ge�an�in�tegral�ideal.�(�This�can�b�Ge�m�uc�h���faster�UUwhen�the�norm�of�the�quotien���t�is�small�ev�en�though�the�norms�of��x��and��y��.�are�large.����The�(library�syn���tax�is���idealdiv0��02��(��nf��
��;���x;�y�[�;���flag���t�).�b�Also�(a�v��q�ailable�are���idealdiv��*���(��nf��
��;���x;�y�[٫)�((��flag����=��0)���and��UU�idealdiv��9exact��DѮ�(��nf��
��;���x;�y�[٫)�UU(��flag����=��1).��<ލ�3.6.47���idealfactor�(��nf��
��;���x�):�Pzfactors��in���to�prime�ideal�p�Go�w�ers�the�ideal��x��in�the�n�um�b�Ger�eld���nf��
᧫.�[�The���output�~�format�is�similar�to�the��factor��function,��Gand�the�prime�ideals�are�represen���ted�in�the�form���output�UUb���y�the��idealprimedec��function,�i.e.�as�5-elemen�t�v�ectors.����The�UUlibrary�syn���tax�is���idealf�actor��9<\�(��nf��
��;���x�).��<ލ�3.6.48�CLidealhnf�(��nf��
��;���a;��f�b�g�):�2Igiv���es��Ythe�Hermite�normal�form�matrix�of�the�ideal��a�.�GsThe�ideal�can�b�Ge���giv���en�o�in�an�y�form�whatso�Gev�er�(t�ypically�b�y�an�algebraic�n�um�b�Ger�if�it�is�principal,�v_b�y�a��Z����K�����-system���of�UUgenerators,�as�a�prime�ideal�as�giv���en�b�y��idealprimedec�,�or�b�y�a��Z�-basis).����If�s�b��is�not�omitted,�{�assume�the�ideal�giv���en�w�as��a�Z����K��
��+�MC�b�Z����K�����,�{�where��a��and��b��are�elemen�ts�of��K����giv���en�UUeither�as�v�ectors�on�the�in�tegral�basis���nf��$A�[7]�or�as�algebraic�n�um�b�Gers.����The�`�library�syn���tax�is���idealhnf�0��2&2�(��nf��
��;���a;�b�)�`�where�an�omitted��b��is�co�Gded�as��NULL�.�Also�a�v��q�ailable���is��UU�idealhermite��A�y�(��nf��
��;���a�)�UU(�b��omitted).��<ލ�3.6.49�idealin��9tersect�(��nf��
��;���x;�y�[٫):���in���tersection�n�of�the�t�w�o�ideals��x��and��y�ʦ�in�the�n�um�b�Ger�eld���nf��=��.���When�}��x��and��y��ϫare�giv���en�b�y��Z�-bases,��this�do�Ges�not�dep�end�on���nf���ثand�can�b�e�used�to�compute�the���in���tersection�UUof�an�y�t�w�o��Z�-mo�Gdules.�q�The�result�is�giv�en�in�HNF.����The�UUlibrary�syn���tax�is���idealin��9tersect��F�(��nf��
��;���x;�y�[٫).��<ލ�3.6.50�qRidealin��9v�(��nf��
��;���x�):��in���v�erse���of�the�ideal��x��in�the�n���um�b�Ger���eld���nf����.��The�result�is�the�Hermite���normal��form�of�the�in���v�erse��of�the�ideal,��together�with�the�opp�Gosite�of�the�Arc���himedean�information���if�UUit�is�giv���en.����The�UUlibrary�syn���tax�is���idealin��9v��*w�(��nf��
��;���x�).��<ލ�3.6.51��ideallist�(��nf��
��;�����b��}'ound����;����f��flag����=�P4�g�):�Iccomputes�A#the�list�of�all�ideals�of�norm�less�or�equal�to�����b��}'ound��6��in��`the�n���um�b�Ger��`eld���nf���L�.��The�result�is�a�ro���w�v�ector�with�exactly���b��}'ound��"�comp�Gonen�ts.��Eac�h���comp�Gonen���t��is�itself�a�ro�w�v�ector�con�taining�the�information�ab�Gout�ideals�of�a�giv�en�norm,�M�in�no���sp�Gecic��Aorder.�RThis�information�can�b�e�either�the�HNF��)of�the�ideal�or�the��idealstar��with�p�ossibly���some�UUadditional�information.����If��UU�flag���v�is�UUpresen���t,�its�binary�digits�are�toggles�meaning����1:�q�giv���e�UUalso�the�generators�in�the��idealstar�.����2:�q�output�UU[�L;���U��],�where��L��is�as�b�Gefore�and��U�lp�is�a�v���ector�of��zinternallog�s�of�the�units.����4:�q�giv���e�UUonly�the�ideals�and�not�the��idealstar��or�the��ideallog��of�the�units.����The�D0library�syn���tax�is���ideallist0��0
]�(��nf��
��;�����b��}'ound����;�����flag���t�),�G�where���b��}'ound�� ݫ�m�ust�b�Ge�a�C�D,long�in�teger.�lAlso���a���v��q�ailable�UUis���ideallist��*^��(��nf��
��;�����b��}'ound����),�corresp�Gonding�to�the�case���flag��T9�=��0.��������113���r�o�����Kf�������3.6.52���ideallistarc��9h�(��nf��
��;�����list����;����f��ar��}'ch����=��[�]�g�;��f��flag����=�0�g�):�\�v���ector�+of�v�ectors�of�all��idealstarinit��(see����idealstar�)�WBof�all�mo�Gdules�in���list��R��,���with�Arc���himedean�part���ar��}'ch�����added�(v�oid�if�omitted).��w��list���*�is���a��tv���ector�of�big�ideals,���as�output�b�y��ideallist�(��:���:�:��
UO;�����flag���t�)�for�instance.��%�flag��e�is�optional;�its�binary���digits�UUare�toggles�meaning:�q�1:�giv���e�UUgenerators�as�w�ell,�2:�q�list�format�is�[�L;���U��]�(see��ideallist�).������The�3&library�syn���tax�is���ideallistarc��9h0��F~�(��nf��
��;�����list����;�����ar��}'ch����;�����flag���t�),�j�where�an�omitted���ar��}'ch���«is�co�Gded�as����NULL�.��em��3.6.53�˂ideallog�(��nf��
��;���x;���bid��zH�):��m��nf���9�b�Geing�L�a�n���um�b�er�L�eld,��N��bid��j�b�eing�a�\big�ideal"�as�output�b���y��ideal-���star��ԫand��x��b�Geing�a�non-necessarily�in���tegral�elemen�t�of���nf�����whic�h�m�ust�ha�v�e�v��q�aluation�equal�to�0���at��Eall�prime�ideals�dividing��I�[4�=���R�bid��a�[1],���computes�the�\discrete�logarithm"�of��x��on�the�generators���giv���en��&in���bid��gƫ[2].�:;In�other�w�ords,���if��g����i���r�are�these�generators,�of�orders��d����i���r�resp�Gectiv���ely��*�,�the�result�is�a���column�UUv���ector�of�in�tegers�(�x����i��TL�)�suc�h�that�0�����x����i��d�<�d����i�����and��������*�x�����������Y����t�����i���8ޱg����:��[ٴx���i���;Z��i������(�mo�Gd����T�������n8�I���)��:��!p�Note�UUthat�when��I�7�is�a�mo�Gdule,�this�implies�also�sign�conditions�on�the�em���b�eddings.����The�UUlibrary�syn���tax�is���zideallog��.��(��nf��
��;���x;���bid��zH�).��em��3.6.54�m�idealmin�(��nf��
��;���x;��f��vdir���g�):�z�computes���a�minim���um�of�the�ideal��x��in�the�direction���vdir���ūin�the���n���um�b�Ger�UUeld���nf��$A�.����The�UUlibrary�syn���tax�is���minideal��.#~�(��nf��
��;���x;���vdir�����;���pr��}'e�c�����),�UUwhere�an�omitted���vdir���ëis�co�Gded�as��NULL�.��em��3.6.55�;�idealm��9ul�(��nf��
��;���x;�y�[�;��f��flag����=��0�g�):�.�ideal�Ϩm���ultiplication�of�the�ideals��x��and��y�+��in�the�n�um�b�Ger�eld�����nf��
��.�bSThe�&�result�is�a�generating�set�for�the�ideal�pro�Gduct�with�at�most��n��elemen���ts,�0>and�is�in�Hermite���normal���form�if�either��x��or��y��h�is�in�HNF��|or�is�a�prime�ideal�as�output�b���y��idealprimedec�,��]and�this���is�UUgiv���en�together�with�the�sum�of�the�Arc�himedean�information�in��x��and��y��.�if�b�Goth�are�giv�en.����If��UU�flag���v�is�UUnon-zero,�reduce�the�result�using��idealred�.����The���library�syn���tax�is���idealm��9ul��.`�(��nf��
��;���x;�y�[٫)���(��flag��`��=�(�0)�or���idealm��9ulred��>q��(��nf���;���x;�y�[�;���pr��}'e�c�����)���(��flag��`��6�=�(�0),���where�UUas�usual,���pr��}'e�c�����is�a�C�long�in���teger�represen�ting�the�precision.��em��3.6.56��Tidealnorm�(��nf��
��;���x�):�q�computes�UUthe�norm�of�the�ideal��x��in�the�n���um�b�Ger�UUeld���nf��$A�.����The�UUlibrary�syn���tax�is���idealnorm��5n'�(��nf��
��;���x�).����3.6.57���idealp�Q�o��9w�(��nf��
��;���x;�k�P�;��f��flag����=��0�g�):�g�computes�A�the��k��-th�p�Go���w�er�A�of�the�ideal��x��in�the�n���um�b�er�A�eld�����nf��
��.�B2�k�+�can�Ɣb�Ge�p�ositiv���e,��"negativ�e�Ɣor�zero.�B2The�result�is�NOT��preduced,�it�is�really�the��k�P��-th�ideal�p�Go���w�er,���and�UUis�giv���en�in�HNF.����If��u�flag��D��is�unon-zero,�;reduce�the�result�using��idealred�.�W|Note�ho���w�ev�er�uthat�this�is�NOT�athe�same���as�/=as���idealpow��./%�(��nf��
��;���x;�k�P��)�/=follo���w�ed�b�y�reduction,�e�since�the�reduction�is�p�Gerformed�throughout�the���p�Go���w�ering�UUpro�cess.����The��library�syn���tax�corresp�Gonding�to���flag��ԯ�=��a0�is���idealp�Q�o��9w��0#��(��nf��
��;���x;�k�P��).�"MIf�傱k�6�is�a��long�,�	�y�ou�can���use��_X�idealp�Q�o��9ws��3�٫(��nf��
��;���x;�k�P��).���Corresp�Gonding�_Xto���flag��n�=���1�is���idealp�Q�o��9wred��?��(��nf���;���v�[�p;�k�P�;���pr��}'e�c�����),�a�where��_X�pr��}'e�c���ǫis���a�UU�long�.��������114���s�������Kf�������3.6.58���idealprimedec�(��nf��
��;���p�):��<computes�hthe�prime�ideal�decomp�Gosition�of�the�prime�n���um�b�er�h�p��in���the���n���um�b�Ger�eld���nf���y�.��n�p��m�ust�b�Ge�a�(p�ositiv���e)�prime�n�um�b�Ger.��nNote�that�the�fact�that��p��is�prime�is���not�UUc���hec�k�ed,�so�if�a�non-prime�n�um�b�Ger��p��is�giv�en�it�ma�y�lead�to�unpredictable�results.���b��The�)result�is�a�v���ector�of�5-comp�Gonen�t�v�ectors,�1�eac�h�represen�ting�one�of�the�prime�ideals�ab�Go�v�e����p�ݙ�in�the�n���um�b�Ger�ݙeld���nf��
���.�I�The�represen���tation��v�[�p���=�[�p;���a;�e;�f��V;�b�]�ݙof�a�prime�ideal�means�the�follo�wing.���The���prime�ideal�is�equal�to��p�Z����K���'�+��t��	z�Z����K��
WQ�where��Z����K���is�the�ring�of�in���tegers�of�the�eld�and����=�������P���
US��i��TG�a����i��TL�!����i�����where�Xthe��!����i��b��form�the�in���tegral�basis���nf��
�D�.zk�,���e��is�the�ramication�index,��f�!�is�the�residual�index,�and����b���is�an��n�-comp�Gonen���t�column�v�ector�represen�ting�a���Ł�2�>e�Z����K��R��suc�h�that��v�[�p���^���1��
�٫=�>e�Z����K��
L�+�h����=p�Z����K��R��whic�h���will���b�Ge�useful�for�computing�v��q�aluations,�тbut�whic���h�the�user�can�ignore.�:�The�n�um�b�Ger�����is�guaran�teed���to�UUha���v�e�a�v��q�aluation�equal�to�1�at�the�prime�ideal�(this�is�automatic�if��e��>��1).����The�UUlibrary�syn���tax�is���primedec��1G�(��nf��
��;���p�).����3.6.59�9#idealprincipal�(��nf��
��;���x�):�ܓcreates���the�principal�ideal�generated�b���y�the�algebraic�n�um�b�Ger��x����(whic���h�Ìm�ust�b�Ge�of�t�yp�Ge�in�teger,��rational�or�p�Golmo�d)�in�the�n���um�b�Ger�eld���nf���x�.��mThe�result�is�a�one-���column�UUmatrix.����The�UUlibrary�syn���tax�is���principalideal��G(ʫ(��nf��
��;���x�).����3.6.60��didealred�(��nf��
��;���I���;��f��vdir���1�=��0�g�):�YuLLL�$�reduction�$�of�the�ideal��I�퓫in�the�n���um�b�Ger�$�eld���nf��
�,�.kalong�the���direction�����vdir����.�UIf�����vdir���ͫis���presen���t,���it�m�ust�b�Ge�an��r��1��8+��r��2-comp�onen���t���v�ector�(�r�G�1�and��r��2�n���um�b�Ger�of���real�UUand�complex�places�of���nf��y��as�usual).����This�"�function�nds�a�\small"��a��in��I��~�(it�is�an�LLL�"�pseudo-minim���um�along�direction���vdir��4��).�`�The���result��ris�the�Hermite�normal�form�of�the�LLL-reduced�ideal��r�GI���=a�,��lwhere��r���is�a�rational�n���um�b�er��rsuc�h���that�2the�resulting�ideal�is�in���tegral�and�primitiv�e.��]This�is�often,�O)but�not�alw�a�ys,�O)a�reduced�ideal���in���the�sense�of�Buc���hmann.���If��I�K��is�an�idele,��the�logarithmic�em�b�Geddings�of��a��are�subtracted�to�the���Arc���himedean�UUpart.����More�9often�than�not,�>�a�principal�ideal�will�yield�the�iden���tit�y�9matrix.�h^This�is�a�quic���k�and�dirt�y���w���a�y��to�c���hec�k��if�ideals�are�principal�without�computing�a�full��bnf��structure,��but�it's�not�a�necessary���condition;�UUhence,�a�non-trivial�result�do�Gesn't�pro���v�e�UUthe�ideal�is�non-trivial�in�the�class�group.����Note�Dxthat�this�is��not�7P�the�same�as�the�LLL�Dtreduction�of�the�lattice��I�
Z�since�ideal�op�Gerations�are���in���v�olv�ed.����The�UUlibrary�syn���tax�is���ideallllred��4�}�(��nf��
��;���x;���vdir�����;���pr��}'e�c�����),�UUwhere�an�omitted���vdir���ëis�co�Gded�as��NULL�.���Í�3.6.61� �idealstar�(��nf��
��;���I���;��f��flag��lE�=�4y1�g�):���	�nf��Z�b�Geing���a�n���um�b�er���eld,��^and��I�_ثeither�and�ideal�in�an���y�form,���or�sWa�ro���w�v�ector�whose�rst�comp�Gonen�t�is�an�ideal�and�whose�second�comp�Gonen�t�is�a�ro�w�v�ector�of����r����1���ȫ0�UUor�1,�outputs�necessary�data�for�computing�in�the�group�(�Z����K�����=I���)���^������.����If���7�flag���=���2,�'/the��7result�is�a�5-comp�Gonen���t�v�ector��w�D�.�il�w��[1]��7is�the�ideal�or�mo�Gdule��I���itself.��w�D�[2]���is�y�the�structure�of�the�group.�ޤThe�other�comp�Gonen���ts�are�dicult�to�describ�e�and�are�used�only�in���conjunction�UUwith�the�function��ideallog�.����If�����flag�����=��1���(default),�a�as���flag���=��2,�a�but�do�not�compute�explicit�generators�for�the�cyclic���comp�Gonen���ts,�UUwhic�h�sa�v�es�time.����If�����flag�����=��0,��hcomputes���the�structure�of�(�Z����K�����=I���)���^����"��as�a�3-comp�Gonen���t�v�ector��v�[٫.�-�v��[1]���is�the�order,��h�v�[٫[2]���is���the�v���ector�of�SNF���cyclic�comp�Gonen�ts�and��v�[٫[3]�the�corresp�Gonding�generators.�7TWhen�the�ro�w�v�ector���is�E�explicitly�included,�H�the�non-zero�elemen���ts�of�this�v�ector�are�considered�as�real�em�b�Geddings�of���nf���������115���t�������Kf�����卫in�:xthe�order�giv���en�b�y��polroots�,�?�i.e.�in���nf��	d�[6]�(��nf��
���.roots�),�and�then��I�Z�is�a�mo�Gdule�with�comp�onen���ts���at�UUinnit���y��*�.���o��T��*�o�UUsolv���e�discrete�logarithms�(using��ideallog�),�y�ou�ha�v�e�to�c�ho�Gose���flag��T9�=��2.����The�UUlibrary�syn���tax�is���idealstar0��4��(��nf��
��;���I���;���flag���t�).��<ލ�3.6.62���idealt��9w�o�Q�elt�(��nf��
��;���x;��f�a�g�):���computes�Gqa�t���w�o-elemen�t�Gqrepresen�tation�of�the�ideal��x��in�the�n�um�b�Ger���eld��~%�nf��
M�,��/using�~%a�straigh���tforw�ard�~%(exp�Gonen�tial�time)�searc�h.�*
�x��can�b�Ge�an�ideal�in�an�y�form,��/(including���p�Gerhaps�}�an�Arc���himedean�part,�Ǯwhic�h�is�ignored)�and�the�result�is�a�ro�w�v�ector�[�a;����	z�]�with�t�w�o���comp�Gonen���ts���suc�h�that��x�&��=��a�Z����K��
ի+�_"��	z�Z����K��Dk�and��a��2��Z�,��where��a��is�the�one�passed�as�argumen���t�if�an�y��*�.���If�UU�x��is�giv���en�b�y�at�least�t�w�o�generators,��a��is�c�hosen�to�b�Ge�the�p�ositiv���e�generator�of��x�8�\��Z�.����Note�7�that�when�an�explicit��a��is�giv���en,�ppw�e�7�use�an�asymptotically�faster�metho�Gd,�ho���w�ev�er�7�in���practice�UUit�is�usually�slo���w�er.����The�UUlibrary�syn���tax�is���ideal�����ffs4��#�t��9w�o�����ffs4��elt0��G��(��nf��
��;���x;�a�),�UUwhere�an�omitted��a��is�en�tered�as��NULL�.��<ލ�3.6.63��idealv��\ral�(��nf��
��;���x;���vp��G�):�ɬgiv���es��Gthe�v��q�aluation�of�the�ideal��x��at�the�prime�ideal���vp��Z-�in�the�n�um�b�Ger���eld��UU�nf��$A�,�UUwhere���vp��I�m���ust�b�Ge�a�5-comp�onen���t�v�ector�as�giv�en�b�y��idealprimedec�.����The�UUlibrary�syn���tax�is���idealv��\ral��)/�(��nf��
��;���x;���vp��G�),�UUand�the�result�is�a��long��in�teger.��<ލ�3.6.64�NWideleprincipal�(��nf��
��;���x�):�screates��+the�principal�idele�generated�b���y�the�algebraic�n�um�b�Ger��x����(whic���h���m�ust�b�Ge�of�t�yp�Ge�in�teger,��Srational�or�p�Golmo�d)�in�the�n���um�b�Ger�eld���nf���r�.��[The�result�is�a�t�w�o-���comp�Gonen���t�2�v�ector,�i�the�rst�b�Geing�a�one-column�matrix�represen�ting�the�corresp�Gonding�principal���ideal,�a�and�+�the�second�b�Geing�the�v���ector�with��r����1��Df�+���r����2���e�comp�onen���ts�giving�the�complex�logarithmic���em���b�Gedding�UUof��x�.����The�UUlibrary�syn���tax�is���principalidele��F��(��nf��
��;���x�).��<ލ�3.6.65�N`matalgtobasis�(��nf��
��;���x�):��DL�nf���ϫb�Geing���a�n���um�b�er���eld�in��nfinit��format,���and��x��a�matrix�whose���co�Gecien���ts��are�expressed�as�p�olmo�ds�in���nf��
ۆ�,�&transforms�this�matrix�in���to�a�matrix�whose�co�ecien���ts���are�շexpressed�on�the�in���tegral�basis�of���nf��
���.�G=This�is�the�same�as�applying��nfalgtobasis��to�eac�h�en�try��*�,���but�UUit�w���ould�b�Ge�dangerous�to�use�the�same�name.����The�UUlibrary�syn���tax�is���matalgtobasis��G�B�(��nf��
��;���x�).��<ލ�3.6.66�N`matbasistoalg�(��nf��
��;���x�):��DL�nf���ϫb�Geing���a�n���um�b�er���eld�in��nfinit��format,���and��x��a�matrix�whose���co�Gecien���ts��are�expressed�as�column�v�ectors�on�the�in�tegral�basis�of���nf��N��,��Dtransforms�this�matrix���in���to��Aa�matrix�whose�co�Gecien�ts�are�algebraic�n�um�b�Gers�expressed�as�p�olmo�ds.��This�is�the�same�as���applying�UU�nfbasistoalg��to�eac���h�en�try��*�,�but�it�w�ould�b�Ge�dangerous�to�use�the�same�name.����The�UUlibrary�syn���tax�is���matbasistoalg��H$&�(��nf��
��;���x�).��<ލ�3.6.67��mo�Q�drev��9erse�(�a�):�bt�a�6��b�Geing�a�p�olmo�d��A�(�X���)�mo�dulo��T�c��(�X���),�<�nds�the�\rev���erse�p�olmo�d"��B��q�(�X���)���mo�Gdulo����Q�(�X���),���where��Q��is�the�minimal�p�olynomial�of��a�,���whic���h�m�ust�b�Ge�equal�to�the�degree�of��T�c��,���and�UUsuc���h�that�if����r�is�a�ro�Got�of��T���then���5�=���B��q�(��	z�)�for�a�certain�ro�ot���^ϫof��Q�.����This�UUis�v���ery�useful�when�one�c�hanges�the�generating�elemen�t�in�algebraic�extensions.����The�UUlibrary�syn���tax�is���p�Q�olmo�drecip��A���(�x�).��������116���u�O�����Kf�������3.6.68���newtonp�Q�oly�(�x;���p�):�Y giv���es�$the�v�ector�of�the�slop�Ges�of�the�Newton�p�olygon�of�the�p�olynomial����x��n�with�resp�Gect�to�the�prime�n���um�b�er��n�p�.�The��n��comp�onen���ts�of�the�v�ector�are�in�decreasing�order,���where�ࢱn��is�equal�to�the�degree�of��x�.��V��*�ertical�slop�Ges�o�ccur�i�the�constan���t�co�ecien���t�of��x��is�zero���and�fGare�denoted�b���y��VERYBIGINT�,�the�biggest�single�precision�in�teger�represen�table�on�the�mac�hine���(2���^��31��
�Ʒ�8�1�UU(resp.�2���^��63����8�1)�on�32-bit�(resp.�64-bit)�mac���hines),�see�Section�3.2.48.��1��The�UUlibrary�syn���tax�is���newtonp�Q�oly��=ʗ�(�x;���p�).��b��3.6.69�
�nfalgtobasis�(��nf��
��;���x�):��this���is�the�in���v�erse���function�of��nfbasistoalg�.�7�Giv���en�an�ob��8ject��x��whose���en���tries�"�are�expressed�as�algebraic�n�um�b�Gers�in�the�n�um�b�Ger�eld���nf��
�ȫ,�,�transforms�it�so�that�the�en�tries���are�UUexpressed�as�a�column�v���ector�on�the�in�tegral�basis���nf��$A�.zk�.����The�UUlibrary�syn���tax�is���algtobasis��4U��(��nf��
��;���x�).��b��3.6.70�"Nnfbasis�(�x;����f��flag��ns�=�6�0�g�;��f�f��a�g�):���in���tegral��Ebasis�of�the�n�um�b�Ger�eld�dened�b�y�the�irreducible,���preferably�Kmonic,�Mp�Golynomial��x�,�using�a�mo�Gdied�v���ersion�of�the�round�4�algorithm�b�y�default,�Mdue���to�Da���vid�F��*�ord,�>�Sebastian�P�auli�and�Xa�vier�Roblot.��$The�binary�digits�of���flag��X
�ha�v�e�the�follo�wing���meaning:����1:�Yassume�#�that�no�square�of�a�prime�greater�than�the�default��primelimit��divides�the�discrim-���inan���t�UUof��x�,�i.e.�that�the�index�of��x��has�only�small�prime�divisors.����2:���use�]�round�2�algorithm.��rF��*�or�small�degrees�and�co�Gecien���t�size,��this�is�sometimes�a�little���faster.�q�(This�UUprogram�is�the�translation�in���to�C�of�a�program�written�b�y�Da�vid�F��*�ord�in�Algeb.)����Th���us�
�for�instance,�if���flag����=��3,�this�uses�the�round�2�algorithm�and�outputs�an�order�whic���h�will���b�Ge�UUmaximal�at�all�the�small�primes.����If��2�f��a��is�presen���t,�V�w�e��2assume�(without�c���hec�king!)�	B_that��2it�is�the�t���w�o-column��2matrix�of�the���factorization�@uof�the�discriminan���t�of�the�p�Golynomial��x�.�j�Note�that�it�do�es��not�3M�ha���v�e�@uto�b�e�a�complete���factorization.�~This���is�esp�Gecially�useful�if�only�a�lo�cal�in���tegral�basis�for�some�small�set�of�places�is���desired:�q�only�UUfactors�with�exp�Gonen���ts�greater�or�equal�to�2�will�b�e�considered.����The��library�syn���tax�is���nf�basis0��-�(�x;�����flag���t�;���f��a�).���An�extended�v�ersion�is���nf�basis��'B�(�x;����&�d;���flag���t�;�f��a�),���where��C�d��will�receiv���e�the�discriminan�t�of�the�n�um�b�Ger�eld�(�not���of�the�p�olynomial��x�),���and�an�omitted����f��a�餫should�b�Ge�input�as��NULL�.�Also�a���v��q�ailable�are���base���٫(�x;����&�d�)�(��flag����=��0),���.�base2���a�(�x;��&�d�)�(��flag����=��2)�and�����f�actoredbase��?���(�x;���f��a;��&�d�).��b��3.6.71�
�nfbasistoalg�(��nf��
��;���x�):��this���is�the�in���v�erse���function�of��nfalgtobasis�.�7�Giv���en�an�ob��8ject��x��whose���en���tries�care�expressed�on�the�in�tegral�basis���nf���O�.zk�,�Eftransforms�it�in�to�an�ob��8ject�whose�en�tries�are���algebraic�UUn���um�b�Gers�(i.e.�p�olmo�ds).����The�UUlibrary�syn���tax�is���basistoalg��4~٫(��nf��
��;���x�).��b��3.6.72�D�nfdetin��9t�(��nf��
��;���x�):�2�giv���en��va�pseudo-matrix��x�,��computes�a�non-zero�ideal�con�tained�in�(i.e.�m�ul-���tiple�UUof��)�the�determinan���t�of��x�.�q�This�is�particularly�useful�in�conjunction�with��nfhnfmod�.����The�UUlibrary�syn���tax�is���nf�detin��9t��,1��(��nf��
��;���x�).��������117���vޡ�����Kf�������3.6.73��nfdisc�(�x;����f��flag��a۫=�*0�g�;��f�f��a�g�):��field���discriminan���t�of�the�n�um�b�Ger�eld�dened�b�y�the�in�tegral,���preferably��monic,�5�irreducible�p�Golynomial��x�.�����flag���E�and��f��a��are�exactly�as�in��nfbasis�.���That�is,��f��a����pro���vides�4the�matrix�of�a�partial�factorization�of�the�discriminan�t�of��x�,�:�and�binary�digits�of���flag����are���as�UUfollo���ws:���3��1:�q�assume�UUthat�no�square�of�a�prime�greater�than��primelimit��divides�the�discriminan���t.����2:��6use���the�round�2�algorithm,�%instead�of�the�default�round�4.�dnThis�should�b�Ge�slo���w�er���except���ma���yb�Ge�UUfor�p�olynomials�of�small�degree�and�co�ecien���ts.����The��library�syn���tax�is���nf�discf�0��+�x�(�x;�����flag���t�;���f��a�)�where,��to�omit��f�a�,��y���ou�should�input��NULL�.�Y��*�ou�can���also�UUuse���discf��*��(�x�)�(��flag����=��0).��\e��3.6.74�X�nfeltdiv�(��nf��
��;���x;�y�[٫):�VQgiv���en�ǚt�w�o�elemen�ts��x��and��y�#s�in���nf�����,��+computes�their�quotien�t��x=y�#s�in�the���n���um�b�Ger�UUeld���nf��$A�.����The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�div��>j�(��nf��
��;���x;�y�[٫).��\e��3.6.75�5�nfeltdiv��9euc�(��nf��
��;���x;�y�[٫):��giv���en��Kt�w�o�elemen�ts��x��and��y�$�in���nf��x7�,��Icomputes�an�algebraic�in�teger��q����in��pthe�n���um�b�Ger��peld���nf���̫suc���h�that�the�comp�onen���ts�of��x�����q�[�y�8I�are��preasonably�small.�In�fact,��7this�is���functionally�UUiden���tical�to��round(nfeltdiv(��nf��
���,x,y))�.����The�UUlibrary�syn���tax�is���nf�div��9euc��.n)�(��nf��
��;���x;�y�[٫).��\e��3.6.76��nfeltdivmo�Q�dpr�(��nf��
��;���x;�y�[�;���pr���):��giv���en��t�w�o�elemen�ts��x��and��y�z��in���nf����and���pr����a�prime�ideal�in����modpr�UU�format�(see��nfmodprinit�),�computes�their�quotien���t��x=y��.�mo�Gdulo�the�prime�ideal���pr��
�ǫ.����The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�divmo�Q�dpr��_l��(��nf��
��;���x;�y�[�;���pr���).��\e��3.6.77�F&nfeltdivrem�(��nf��
��;���x;�y�[٫):�5�giv���en��pt�w�o�elemen�ts��x��and��y�I�in���nf���\�,���giv�es�a�t�w�o-elemen�t�ro�w�v�ector���[�q�[�;���r�G�]�J�suc���h�that��x���=��q�y���+�#߱r�G�,�L�q����is�J�an�algebraic�in���teger�in���nf����,�and�the�comp�Gonen���ts�of��r���are�reasonably���small.����The�UUlibrary�syn���tax�is���nf�divres��,���(��nf��
��;���x;�y�[٫).��\e��3.6.78��|nfeltmo�Q�d�(��nf��
��;���x;�y�[٫):�mgiv���en�K�t�w�o�elemen�ts��x��and��y����in���nf��ӫ,�M�computes�an�elemen�t��r���of���nf��f��of�the���form��Y�r�5�=���x�>���q�[�y�42�with��q��and�algebraic�in���teger,��Xand�suc�h�that��r�v�is�small.�HThis�is�functionally�iden�tical���to���3���n��x�8���nfeltmul�(��nf��
��;����round�(�nfeltdiv�(��nf���;��x�;��y�))�;��y�)��<5ͱ:��\f���The�UUlibrary�syn���tax�is���nf�mo�Q�d��$^,�(��nf��
��;���x;�y�[٫).����3.6.79���nfeltm��9ul�(��nf��
��;���x;�y�[٫):���giv���en�lht�w�o�elemen�ts��x��and��y��A�in���nf��;T�,�r,computes�their�pro�Gduct��x�HB���y��A�in�the���n���um�b�Ger�UUeld���nf��$A�.���3��The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�m�ul��As«(��nf��
��;���x;�y�[٫).����3.6.80���nfeltm��9ulmo�Q�dpr�(��nf��
��;���x;�y�[�;���pr���):��giv���en��1t�w�o�elemen�ts��x��and��y�H
�in���nf���N�and���pr��?ԫa�prime�ideal�in����modpr�UU�format�(see��nfmodprinit�),�computes�their�pro�Gduct��x�8���y��.�mo�dulo�UUthe�prime�ideal���pr��
�ǫ.���3��The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�m�ulmo�Q�dpr��b�b�(��nf��
��;���x;�y�[�;���pr���).��������118���w�ύ����Kf�������3.6.81��nfeltp�Q�o��9w�(��nf��
��;���x;�k�P��):��giv���en���an�elemen�t��x��in���nf��
i�,��=and�a�p�Gositiv�e�or�negativ�e�in�teger��k�P��,��=computes����x���^��k��@�in�UUthe�n���um�b�Ger�UUeld���nf��$A�.���卑The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�p�Q�o�w��C5��(��nf��
��;���x;�k�P��).���ɍ�3.6.82���nfeltp�Q�o��9wmo�dpr�(��nf��
��;���x;�k�P�;���pr���):�]wgiv���en�,�an�elemen�t��x��in���nf��
���,�4�an�in�teger��k�}L�and�a�prime�ideal���pr�����in�UU�modpr��format�(see��nfmodprinit�),�computes��x���^��k��@�mo�Gdulo�the�prime�ideal���pr��
�ǫ.����The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�p�Q�o�wmo�dpr��d7E�(��nf��
��;���x;�k�P�;���pr���).���ɍ�3.6.83���nfeltreduce�(��nf��
��;���x;���ide��}'al����):���giv���en�w�an�ideal�in�Hermite�normal�form�and�an�elemen�t��x��of�the���n���um�b�Ger�UUeld���nf��$A�,�nds�an�elemen���t��r��r�in���nf��y��suc�h�that��x�8���r��r�b�Gelongs�UUto�the�ideal�and��r��is�small.����The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�reduce��Oņ�(��nf��
��;���x;���ide��}'al����).���ɍ�3.6.84�.znfeltreducemo�Q�dpr�(��nf��
��;���x;���pr���):�);giv���en��>an�elemen�t��x��of�the�n�um�b�Ger�eld���nf��Wh�and�a�prime�ideal�����pr��
�ǫin�UU�modpr��format�compute�a�canonical�represen���tativ�e�UUfor�the�class�of��x��mo�Gdulo���pr���.����The�UUlibrary�syn���tax�is���nf�reducemo�Q�dpr��P�ʫ(��nf��
��;���x;���pr���).���ɍ�3.6.85���nfeltv��\ral�(��nf��
��;���x;���pr���):�_=giv���en�0Aan�elemen�t��x��in���nf��/n�and�a�prime�ideal���pr����in�the�format�output�b�y����idealprimedec�,�xcomputes��qtheir�the�v��q�aluation�at���pr��JT�of�the�elemen���t��x�.�FThe�same�result�could�b�Ge���obtained��using��idealval(��nf��
���,x,��pr��
gr�)��(since��x��w���ould�then�b�Ge�con�v�erted�to�a�principal�ideal),���but�it���w���ould�UUb�Ge�less�ecien�t.����The�UUlibrary�syn���tax�is���elemen��9t�����ffs4��#�v��\ral��<���(��nf��
��;���x;���pr���),�UUand�the�result�is�a��long�.���ɍ�3.6.86�+�nffactor�(��nf��
��;���x�):�(factorization���of�the�univ��q�ariate�p�Golynomial��x��o���v�er���the�n���um�b�er���eld���nf��R~�giv���en���b���y�^~�nfinit�.��B�x��has�co�Gecien�ts�in���nf����(i.e.�either�scalar,�`�p�Golmo�d,�p�olynomial�^~or�column�v���ector).��BThe���main��#v��q�ariable�of���nf���2�m���ust�b�Ge�of��lower���priorit�y�than�that�of��x��(see�Section�2.6.2).�<1Ho�w�ev�er�if�the���p�Golynomial�zhdening�the�n���um�b�er�zheld�o�ccurs�explicitly�in�the�co�ecien���ts�of��x��(as�mo�dulus�of�a����t_POLMOD�),�UUits�main�v��q�ariable�m���ust�b�Ge��the���same���as�the�main�v�ariable�of��x�.�q�F��*�or�example,��G܍��?�?�nf�=�nfinit(y^2�+�1);��Q���?�?�nffactor(nf,�x^2�+�y);�\\����OK�����?�?�nffactor(nf,�x^2�+�Mod(y,�y^2+1));�\\����OK�����?�?�nffactor(nf,�x^2�+�Mod(z,�z^2+1));�\\����WR���ONG�����The�UUlibrary�syn���tax�is���nf�f�actor��,��(��nf��
��;���x�).���ɍ�3.6.87��nffactormo�Q�d�(��nf��
��;���x;���pr���):�|7factorization�Z�of�the�univ��q�ariate�p�Golynomial��x��mo�dulo�the�prime���ideal����pr����in��the�n���um�b�Ger��eld���nf����.���x��can�ha���v�e��co�ecien�ts��in�the�n���um�b�er��eld�(scalar,�;5p�olmo�d,���p�Golynomial,�7column��qv���ector)�or�mo�dulo�the�prime�ideal�(in���tegermo�d�mo�dulo�the�rational�prime���under��x��pr��
�I�,���p�Golmo�d�x�or�p�Golynomial�with�in���tegermo�d�co�ecien���ts,���column�v�ector�of�in�tegermo�Gd).��MThe���prime�%Yideal���pr���$must�1�b�Ge�in�the�format�output�b���y��idealprimedec�.�a�The�main�v��q�ariable�of���nf����m�ust�b�Ge���of�v�lo���w�er�priorit�y�than�that�of��x��(see�Section�2.6.2).���Ho�w�ev�er�if�the�co�Gecien�ts�of�the�n�um�b�Ger�eld���o�Gccur���explicitly�(as�p�olmo�ds)�as�co�ecien���ts�of��x�,��	the�v��q�ariable�of�these�p�olmo�ds��must�u��b�e�the�same���as�UUthe�main�v��q�ariable�of��t��(see��nffactor�).����The�UUlibrary�syn���tax�is���nf�f�actormo�Q�d��B���(��nf��
��;���x;���pr���).��������119���x�������Kf�������3.6.88��#nfgaloisapply�(��nf��
��;�����aut��jG�;���x�):�����nf���}�b�Geing��a�n���um�b�er��eld�as�output�b���y��nfinit�,�0�and���aut���A�b�eing���a���Galois�automorphism�of���nf���expressed�either�as�a�p�Golynomial�or�a�p�olmo�d�(suc���h�automorphisms���b�Geing�͠found�using�for�example�one�of�the�v��q�arian���ts�of��nfgaloisconj�),��computes�the�action�of�the���automorphism��{T�aut���G�on�{Tthe�ob��8ject��x��in�the�n���um�b�Ger�{Teld.��ñx��can�b�e�an�elemen���t�(scalar,���p�olmo�d,���p�Golynomial�Рor�column�v���ector)�of�the�n�um�b�Ger�eld,��ran�ideal�(either�giv�en�b�y��Z����K�����-generators�or�b�y���a��o�Z�-basis),��ua�prime�ideal�(giv���en�as�a�5-elemen�t�ro�w�v�ector)�or�an�idele�(giv�en�as�a�2-elemen�t�ro�w���v���ector).�o�Because�N�of�p�Gossible�confusion�with�elemen�ts�and�ideals,�P'other�v�ector�or�matrix�argumen�ts���are�UUforbidden.��k��The�UUlibrary�syn���tax�is���galoisapply��;#ҫ(��nf��
��;�����aut��jG�;���x�).��0֍�3.6.89���nfgaloisconj�(��nf��
��;����f��flag����=��0�g�;��f�d�g�):��R%�nf��7"�b�Geing�a�n���um�b�er�eld�as�output�b���y��nfinit�,�"�computes���the�уconjugates�of�a�ro�Got��r���of�the�non-constan���t�p�olynomial��x���=���nf��d��[1]�уexpressed�as�p�olynomials�in����r�G�.�v�This�V�can�b�e�used�ev���en�if�the�n�um�b�Ger�eld���nf��|ȫis�not�Galois�since�some�conjugates�ma�y�lie�in�the���eld.������nf��"$A�can�UUsimply�b�Ge�a�p�olynomial�if���flag��T9�6�=��1.����If�ػno�
ags�or���flag��ן�=��0,��if���nf���b�is�a�n���um�b�Ger�ػeld�use�a�com���bination�of�
ag�4�and�1�and�the�result�is���alw���a�ys�_�complete,�bvelse�use�a�com���bination�of�
ag�4�and�2�and�the�result�is�sub��8ject�to�the�restriction���of��UU�flag��T9�=��2,�UUbut�a�w���arning�is�issued�when�it�is�not�pro�v�en�complete.����If��UU�flag��T9�=��1,�UUuse��nfroots��(require�a�n���um�b�Ger�UUeld).����If���6�flag����=���2,���use��6complex�appro���ximations�to�the�ro�Gots�and�an�in�tegral�LLL.�The�result�is�not���guaran���teed��to�b�Ge�complete:�3some�conjugates�ma�y�b�Ge�missing�(no�w�arning�issued),���esp�Gecially�so�if���the�Jzcorresp�Gonding�p�olynomial�has�a�h���uge�index.�n)In�that�case,�L�increasing�the�default�precision�ma�y���help.����If��W{�flag����=�uV4,��use�W{Allom���b�Gert's�algorithm�and�p�erm���utation�testing.�x:If�the�eld�is�Galois�with���\w���eakly"�X�sup�Ger�solv��q�able�Galois�group,���return�the�complete�list�of�automorphisms,�else�only�the���iden���tit�y�<elemen�t.�\iIf�presen�t,�"�d��is�assumed�to�b�Ge�a�m�ultiple�of�the�least�common�denominator�of�the���conjugates�UUexpressed�as�p�Golynomial�in�a�ro�ot�of���p��}'ol����.����A��group��G�is�\w���eakly"�sup�Ger�solv��q�able�(WKSS)�if�it�con���tains�a�sup�Ger�solv��q�able�normal�subgroup����H�T��suc���h���that��G���=��H��,��Nor����G=H�巷'��A����4����,�or����G=H�巷'��S����4��|s�.��OAb�Gelian�and�nilp�oten���t�groups�are�WKSS.�In���practice,�P�almost�O�all�groups�of�small�order�are�WKSS,�the�exceptions�ha���ving�order�36(1�exception),���48(2),�UU56(1),�60(1),�72(5),�75(1),�80(1),�96(10)�and�����108.����Hence��ߣ�flag����=���4�ߣp�Germits�to�quic���kly�c�hec�k�whether�a�p�Golynomial�of�order�strictly�less�than�36���is��_Galois�or�not.�@�This�metho�Gd�is�m���uc�h��_faster�than��nfroots��and�can�b�e�applied�to�p�olynomials�of���degree�UUlarger�than�50.����This��routine�can�only�compute��Q�-automorphisms,�	but�it�ma���y�b�Ge�used�to�get��K���-automorphism���for�UUan���y�base�eld��K�q�as�follo�ws:�� �����rnfgaloisconj(nfK,�?�R)�=�\\�K-automorphisms�of�L�=�K[X]�/�(R)��$���{�?�local(polabs,�N,�H);����(��R�?�*=�Mod(1,�nfK.pol);�D?�\\�convert�coeffs�to�polmod�elts�of�K����(��polabs�?�=�rnfequation(nfK,�R);����(��N�?�=�nfgaloisconj(polabs)�%�R;�?�\\�Q-automorphisms�of�L����(��H�?�=�[];����(��for(i=1,�?�#N,�s�\\�select�the�ones�that�fix�K����3�if�?�(subst(R,�variable(R),�Mod(N[i],R))�==�0,��������120���y
�����Kf�����卑=���H�?�=�concat(H,N[i])��m��3�)����(��);�?�H�����}�����K�
�=�?�nfinit(y^2�+�7);�����polL�?�=�x^4�-�y*x^3�-�3*x^2�+�y*x�+�1;�����rnfgaloisconj(K,�?�polL)�D?�\\�K-automorphisms�of�L��G���The���library�syn���tax�is���galoisconj0��;w-�(��nf��
��;�����flag���t�;���d;���pr��}'e�c�����).�	A(Also���a�v��q�ailable�are���galoisconj��5�/�(��nf��
��)�for�����flag��㧫=���0,����galoisconj2��:�J�(��nf��
��;���n;���pr��}'e�c�����)�ޘfor���flag���?�=�2�where��n��is�a�b�Gound�on�the�n���um�b�er�ޘof�conjugates,���and��UU�galoisconj4��9ܷ�(��nf��
��;���d�)�UUcorresp�Gonding�to���flag��T9�=��4.�� ���3.6.90�_nfhilb�Q�ert�(��nf��
��;���a;�b;��f��pr��
gr�g�):��if�����pr���f�is���omitted,���compute�the�global�Hilb�Gert�sym���b�ol�(�a;���b�)�in���nf��b�,���that��Gis�1�if��x���^��2���I��rֱay��[ٟ�^��2��K"���bz��p���^��2���Q�has��Ga�non�trivial�solution�(�x;���y�[�;�z�p��)��Gin���nf��{3�,��and���1�otherwise.�v�Otherwise���compute�UUthe�lo�Gcal�sym���b�ol�mo�dulo�the�prime�ideal���pr���(as�output�b���y��idealprimedec�).����The�UUlibrary�syn���tax�is���nf�hilb�Q�ert��0J��(��nf��
��;���a;�b;���pr���),�UUwhere�an�omitted���pr���is�co�Gded�as��NULL�.�� ���3.6.91�ynfhnf�(��nf��
��;���x�):�I�giv���en�'a�pseudo-matrix�(�A;�I���),�0nds�a�pseudo-basis�in�Hermite�normal�form�of���the�UUmo�Gdule�it�generates.����The�UUlibrary�syn���tax�is���nf�hermite��5>(�(��nf��
��;���x�).�� ���3.6.92�ˈnfhnfmo�Q�d�(��nf��
��;���x;���detx�����):�m�giv���en�L�a�pseudo-matrix�(�A;���I���)�and�an�ideal���detx��y�whic�h�is�con�tained���in�4 (read�in���tegral�m�ultiple�of��)�the�determinan�t�of�(�A;���I���),�k�nds�a�pseudo-basis�in�Hermite�normal���form��Oof�the�mo�Gdule�generated�b���y�(�A;���I���).�^�This�a�v�oids�co�Gecien�t�explosion.��^��detx���W�can�b�Ge�computed���using�UUthe�function��nfdetint�.����The�UUlibrary�syn���tax�is���nf�hermitemo�Q�d��KH˫(��nf��
��;���x;���detx�����).�� ���3.6.93�Ănfinit�(��p��}'ol��
Lȱ;����f��flag����=��0�g�):��jw�p��}'ol����b�Geing�F�a�non-constan���t,�I�preferably�monic,�irreducible�p�Golynomial���in���Z�[�X���],��Ginitializes�a��numb��}'er��eld����structure�(�nf�)�asso�Gciated�to�the�eld��K�M3�dened�b���y���p�ol���߫.�4
As���suc���h,���it's��]a�tec�hnical�ob��8ject�passed�as�the�rst�argumen�t�to�most��nf��xxx���H�functions,���but�it�con�tains���some��information�whic���h�ma�y�b�Ge�directly�useful.�M^Access�to�this�information�via��memb��}'er�/jfunctions��<�is���preferred�Psince�the�sp�Gecic�data�organization�sp�ecied�b�elo���w�ma�y�c�hange�in�the�future.�p
Curren�tly��*�,����nf�UU�is�a�ro���w�v�ector�with�9�comp�Gonen�ts:������nf����[1]�UUcon���tains�the�p�Golynomial���p��}'ol���r�(��nf��
���.pol�).������nf����[2]�UUcon���tains�[�r�G�1�;���r��2]�UU(��nf��
���.sign�),�the�n�um�b�Ger�of�real�and�complex�places�of��K���.������nf����[3]�UUcon���tains�the�discriminan�t��d�(�K���)�(��nf��
���.disc�)�of��K��.������nf����[4]�UUcon���tains�the�index�of���nf��$A�[1],�i.e.�[�Z����K��
|˫:���Z�[��G�]],�where����r�is�an�y�ro�Got�of���nf��$A�[1].������nf����[5]��eis�a�v���ector�con�taining�7�matrices��M��,��)�G�,��T�c��2,��T��,��M�D�G�,��T�I���,��M�D�GI�qG�useful��efor�certain�com-���putations�UUin�the�n���um�b�Ger�UUeld��K���.������EX�M�\s�is�the�(�r�G�1��+��r��2)����n�EX�matrix�whose�columns�represen���t�the�n�umerical�v��q�alues�of�the�conjugates���of�UUthe�elemen���ts�of�the�in�tegral�basis.�������E�G��is�suc���h�that��T�c��2�9�=����^��t���S�GG�,���where��E�T��2�is�the�quadratic�form��T����2��|s�(�x�)�9�=������P��r�j��[٫(�x�)�j���^��2���,�������running���o���v�er�UUthe�em���b�Geddings�of��K�q�in�to��C�.������UU�The��T�c��2�comp�Gonen���t�is�deprecated�and�curren�tly�un�used.��������121���z9�����Kf�����卑��b�T���is�the��n������n�b�matrix�whose�co�Gecien���ts�are��T��*�r��
k�(�!����i��TL�!����j��6��)�where�the��!����i��q��are�the�elemen�ts�of�the���in���tegral�UUbasis.�q�Note�also�that��det��8�(�T�c��)�is�equal�to�the�discriminan�t�of�the�eld��K���.��1����?�The�columns�of��M�D��%�(��nf��
���.diff�)�express�a��Z�-basis�of�the�dieren���t�of��K��$�on�the�in�tegral���basis.������㱱T�c�I����is�equal�to��d�(�K���)�T����^���1�� �,��kwhic���h�has�in�tegral�co�Gecien�ts.�K�Note�that,��kundersto�Go�d��as�as�ideal,���the�UUmatrix��T��c���^���1��uX�generates�the�co�Gdieren���t�ideal.������)	�Finally��*�,�1�M�D�GI���is�a�t���w�o-elemen�t�)	represen�tation�(for�faster�ideal�pro�Gduct)�of��d�(�K���)�times�the���co�Gdieren���t��ideal�(��nf��
���.disc���nf���.codiff�,��whic�h��is�an�in�tegral�ideal).�YO�M�D�GI��ϫis�only�used�in��idealinv�.������nf����[6]��9is�the�v���ector�con�taining�the��r�G�1��+��r��2��9ro�ots�(��nf��
���.roots�)�of���nf��
}%�[1]�corresp�onding�to�the��r��1��+��r��2���em���b�Geddings�.qof�the�n�um�b�Ger�eld�in�to��C��(the�rst��r�G�1�comp�onen���ts�are�real,�68the�next��r��2�ha���v�e�.qp�ositiv�e���imaginary�UUpart).������nf����[7]���is�an�in���tegral�basis�for��Z����K�����(��nf��
���.zk�)�expressed�on�the�p�Go�w�ers�of���G�.��sIts�rst�elemen�t���is��nguaran���teed�to�b�Ge�1.��This�basis�is�LLL-reduced�with�resp�ect�to��T����2����(strictly�sp�eaking,�ʹit�is�a���p�Germ���utation�UUof�suc�h�a�basis,�due�to�the�condition�that�the�rst�elemen�t�b�Ge�1).������nf����[8]��cis�the��n������n��c�in���tegral�matrix�expressing�the�p�Go�w�er�basis�in�terms�of�the�in�tegral�basis,��and���nally������nf����[9]�UUis�the��n�8���n���^��2���ȫmatrix�UUgiving�the�m���ultiplication�table�of�the�in�tegral�basis.����If�^�a�non�monic�p�Golynomial�is�input,�`��nfinit��will�transform�it�in���to�a�monic�one,�then�reduce�it���(see����flag��6(�=�TM3).�o�It��is�allo���w�ed,��=though��not�v���ery�useful�giv�en�the�existence�of��nfnewprec�,��=to�input�a����nf�UU�or�a��bnf��instead�of�a�p�Golynomial.����The��sp�Gecial�input�format�[�x;���B��q�]�is�also�accepted�where��x��is�a�p�olynomial�as�ab�o���v�e��and��B��*�is�the���in���teger��tbasis,���as�w�ould�b�Ge�computed�b�y��nfbasis�.�$This�can�b�Ge�useful�if�the�in�teger�basis�is�kno�wn���in�UUadv��q�ance.����If����flag��
��=��2:��M�p��}'ol�����is��c���hanged�in�to�another�p�Golynomial��P�oc�dening�the�same�n�um�b�Ger�eld,��whic�h�is���as�9�simple�as�can�easily�b�Ge�found�using�the��polred��algorithm,�?iand�all�the�subsequen���t�computations���are�Bdone�using�this�new�p�Golynomial.�UlIn�particular,�Fthe�rst�comp�onen���t�of�the�result�is�the�mo�died���p�Golynomial.����If��ko�flag���)�=���3,�p�do�Ges�koa��polred��as�in�case�2,�but�outputs�[��nf��
��;�����Mod��j��(�a;���P�c��)],�where���nf���ʫis�as�b�Gefore�and�����Mod�����(�a;���P�c��)��=���Mod�����(�x;���p��}'ol���p�)�n=giv���es�the�c�hange�of�v��q�ariables.��This�is�implicit�when���p��}'ol��)B�is�not�monic:���rst���a�UUlinear�c���hange�of�v��q�ariables�is�p�Gerformed,�to�get�a�monic�p�olynomial,�then�a��polred��reduction.����If��UU�flag��T9�=��4,�UUas�2�but�uses�a�partial��polred�.����If��UU�flag��T9�=��5,�UUas�3�using�a�partial��polred�.����The�UUlibrary�syn���tax�is���nf�init0��%S��(�x;�����flag���t�;�����pr��}'e�c�����).��b��3.6.94��Tnfisideal�(��nf��
��;���x�):�q�returns�UU1�if��x��is�an�ideal�in�the�n���um�b�Ger�UUeld���nf��$A�,�0�otherwise.����The�UUlibrary�syn���tax�is���isideal��"�ܫ(�x�).��������122���{,������Kf�������3.6.95�nfisincl�(�x;���y�[٫):��tests��!whether�the�n���um�b�Ger��!eld��K�X=�dened�b���y�the�p�olynomial��x��is�conjugate�to���a�#'subeld�of�the�eld��L��dened�b���y��y��(where��x��and��y��m���ust�b�Ge�in��Q�[�X���]).�a
If�they�are�not,�-0the�output���is�$�the�n���um�b�Ger�$�0.�a�If�they�are,�.Kthe�output�is�a�v���ector�of�p�olynomials,�.Keac���h�p�olynomial��a��represen���ting���an�UUem���b�Gedding�of��K�q�in�to��L�,�i.e.�b�Geing�suc�h�that��y�"�j���x�8���a�.���}��If��۱y�
��is�a�n���um�b�Ger���eld�(��nf��
��),��'a�m���uc�h���faster�algorithm�is�used�(factoring��x��o���v�er��۱y��using��nffactor�).���Before�<6v���ersion�2.0.14,�A<this�w�asn't�guaran�teed�to�return�all�the�em�b�Geddings,�A<hence�w�as�triggered�b�y���a�UUsp�Gecial�
ag.�q�This�is�no�more�the�case.����The�UUlibrary�syn���tax�is���nf�isincl��'��(�x;���y�[�;���flag���t�).��N���3.6.96��Bnfisisom�(�x;���y�[٫):��
as�]��nfisincl�,�` but�tests�for�isomorphism.���If�either��x��or��y��ѫis�a�n���um�b�Ger�]�eld,���a�UUm���uc�h�faster�algorithm�will�b�Ge�used.����The�UUlibrary�syn���tax�is���nf�isisom��-ݫ(�x;���y�[�;���flag���t�).��N���3.6.97���nfnewprec�(��nf��
��):�Q�transforms�ithe�n���um�b�Ger�ield���nf�����in���to�the�corresp�onding�data�using�curren���t���(usually��Slarger)�precision.�H�This�function�w���orks�as�exp�Gected�if���nf�����is�in�fact�a���bnf��M)�(up�date���bnf��M)�to���curren���t���precision)�but�ma�y�b�Ge�quite�slo�w�(man�y�generators�of�principal�ideals�ha�v�e�to�b�Ge�computed).����The�UUlibrary�syn���tax�is���nf�newprec��7�`�(��nf��
��;�����pr��}'e�c�����).��N���3.6.98���nfk��9ermo�Q�dpr�(��nf��
��;���a;���pr���):��lk���ernel��of�the�matrix��a��in��Z����K�����=��pr��
gr�,�|where���pr��H��is�in��mo�dpr��format���(see�UU�nfmodprinit�).����The�UUlibrary�syn���tax�is���nf�k��9ermo�Q�dpr��??�(��nf��
��;���a;���pr���).��N���3.6.99��nfmo�Q�dprinit�(��nf��
��;�����pr���):���transforms�hthe�prime�ideal���pr��vB�in���to��modpr��format�necessary�for�all���op�Gerations�:�mo�dulo���pr��܆�in�the�n���um�b�Ger�eld���nf��	v�.�!fReturns�a�t�w�o-comp�Gonen�t�v�ector�[�P�G;���a�],�s�where��P����is�>the�Hermite�normal�form�of���pr�����,�xLand��a��is�an�in���tegral�elemen�t�congruen�t�to�1�mo�Gdulo���pr�����,�xLand���congruen���t�UUto�0�mo�Gdulo��p=pr����^��e���h�.�q�Here��p���=��Z�8�\���pr�����and�UU�e��is�the�absolute�ramication�index.����The�UUlibrary�syn���tax�is���nf�mo�Q�dprinit��@�#�(��nf��
��;�����pr���).��N���3.6.100�o�nfsubfields�(��p��}'ol��
Lȱ;����f�d��۫=�0�g�):�~Lnds�ۗall�subelds�of�degree��d��of�the�n���um�b�Ger�ۗeld�dened�b���y���the��i(monic,��in���tegral)�p�Golynomial���p��}'ol����(all�subelds�if��d��is�n�ull�or�omitted).�The�result�is�a�v�ector���of�Z�subelds,��aeac���h�b�Geing�giv�en�b�y�[�g�[�;���h�],��awhere��g��ҫis�an�absolute�equation�and��h��expresses�one�of���the�fmro�Gots�of��g��F�in�terms�of�the�ro�ot��x��of�the�p�olynomial�dening���nf��5Y�.��This�routine�uses�J.�Kl�����uners's���algorithm��cin�the�general�case,��`and�B.�Allom���b�Gert's��galoissubfields��when���nf�����is�Galois�(with�w�eakly���sup�Gersolv��q�able�UUGalois�group).����The�UUlibrary�syn���tax�is���subf�ields��/���(��nf��
��;���d�).��N���3.6.101�snfro�Q�ots�(�f��nf��
��g�;���x�):�ATro�Gots��of�the�p�olynomial��x��in�the�n���um�b�er��eld���nf��I$�giv���en�b�y��nfinit����without�%tm���ultiplicit�y�(in��Q��if���nf��ԫis�omitted).�aѱx��has�co�Gecien�ts�in�the�n�um�b�Ger�eld�(scalar,�/p�olmo�d,���p�Golynomial,���column�_v���ector).��The�main�v��q�ariable�of���nf���&�m�ust�b�Ge�of�lo�w�er�priorit�y�than�that�of��x����(see�lSection�2.6.2).��
Ho���w�ev�er�lif�the�co�Gecien���ts�of�the�n�um�b�Ger�eld�o�ccur�explicitly�(as�p�olmo�ds)���as�{�co�Gecien���ts�of��x�,��3the�v��q�ariable�of�these�p�olmo�ds��must�nx�b�e�the�same�as�the�main�v��q�ariable�of��t��(see����nffactor�).����The�UUlibrary�syn���tax�is���nf�ro�Q�ots��'�۫(��nf��
��;���x�).��������123���|;����Kf�������3.6.102�T�nfro�Q�otsof1�(��nf��
��):�Oycomputes��.the�n���um�b�Ger��.of�ro�ots�of�unit���y��w�	�and�a�primitiv�e��w�D�-th�ro�Got�of���unit���y��(expressed�on�the�in�tegral�basis)�b�Gelonging�to�the�n�um�b�Ger�eld���nf��W�.��The�result�is�a�t�w�o-���comp�Gonen���t���v�ector�[�w�D�;���z�p��]�where��z�Tl�is�a�column�v�ector�expressing�a�primitiv�e��w�D�-th�ro�Got�of�unit�y�on���the�UUin���tegral�basis���nf��$A�.zk�.��ؽ��The�UUlibrary�syn���tax�is���ro�Q�otsof�1��-K�(��nf��
��).���6��3.6.103�-nfsnf�(��nf��
��;���x�):�
kgiv���en���a�torsion�mo�Gdule��x��as�a�3-comp�onen���t�ro�w�v�ector�[�A;���I���;�J��9�]���where��A��is���a�I2square�in���v�ertible�I2�n� ����n��matrix,�K��I��and��J�?k�are�t���w�o�ideal�lists,�K�outputs�an�ideal�list��d����1��|s�;����:�:�:����;���d����n�����whic�h���is���the�Smith�normal�form�of��x�.��In�other�w���ords,��ݱx��is�isomorphic�to��Z����K�����=d����1�������J�������;��J�Z����K���=d����n��	Ns�and����d����i�����divides�b�d����i��1���ǫfor��i��A���2.���The�blink�b�Get���w�een�b�x��and�[�A;���I���;�J��9�]�bis�as�follo���ws:��,if��e����i���S�is�the�canonical�basis�of����K�����^��n��(��,�UU�I����=��[�b����1��|s�;����:�:�:����;���b����n��q~�]�and��J��Q�=�[�a����1��|s�;����:�:�:����;���a����n��q~�],�then��x��is�isomorphic�to��l��z�!(�b����1��|s�e����1���S���8�������g�8�b����n��q~�e����n���)�=�(�a����1���A����1���S���8�������g�8�a����n���A����n���)��;����where�u�the��A����j�����are�the�columns�of�the�matrix��A�.��GNote�that�ev���ery�nitely�generated�torsion�mo�Gdule���can�UUb�Ge�giv���en�in�this�w�a�y��*�,�and�ev�en�with��b����i��d�=���Z����K���for�all��i�.����The�UUlibrary�syn���tax�is���nf�smith��*�K�(��nf��
��;���x�).���6��3.6.104�4�nfsolv��9emo�Q�dpr�(��nf��
��;���a;�b;���pr���):�Tsolution��of��a�p���x�Q
�=��b���in��Z����K�����=��pr��
gr�,���where��a��is�a�matrix�and��b��a���column�UUv���ector,�and�where���pr���is�in��mo�Q�dpr��format�(see��nfmodprinit�).����The�UUlibrary�syn���tax�is���nf�solv��9emo�Q�dpr��G�{�(��nf��
��;���a;�b;���pr���).���6��3.6.105�o�p�Q�olcomp�ositum�(�P�G;���Q;��f��flag����=��0�g�):�E��P�`��and��!�Q��b�Geing�squarefree�p�olynomials�in��Z�[�X���]�in�the���same�'0v��q�ariable,�0koutputs�the�simple�factors�of�the����Getale��Q�-algebra��A���=��Q�(�X�:�;���Y�8�)�=�(�P�c��(�X���)�;�Q�(�Y��)).�beThe���factors���are�giv���en�b�y�a�list�of�p�Golynomials��R���in��Z�[�X���],�
�asso�ciated�to�the�n���um�b�er���eld��Q�(�X���)�=�(�R�ǫ),�
�and���sorted�kb���y�increasing�degree�(with�resp�Gect�to�lexicographic�ordering�for�factors�of�equal�degrees).���Returns�UUan�error�if�one�of�the�p�Golynomials�is�not�squarefree.����Note���that�it�is�more�ecien���t�to�reduce�to�the�case�where��P�O�and��Q��are�irreducible�rst.��The���routine���will�not�p�Gerform�this�for�y���ou,���since�it�ma�y�b�Ge�exp�ensiv���e,���and�the�inputs�are�irreducible�in���most��applications�an���yw�a�y��*�.�Z+Assuming���P�r�is�irreducible�(of�smaller�degree�than��Q��for�eciency),��it�is���in�UUgeneral��much���faster�to�pro�Gceed�as�follo���ws����#���nf�?�=�nfinit(P);�L�=�nffactor(nf,�Q)[,1];����#��vector(#L,�?�i,�rnfequation(nf,�L[i]))�����to��eobtain�the�same�result.�@�If�y���ou�are�only�in�terested�in�the�degrees�of�the�simple�factors,���the����rnfequation�UU�instruction�can�b�Ge�replaced�b���y�a�trivial��poldegree(P)�?�*�poldegree(L[i])�.����If����flag���e�=���1,���outputs��a�v���ector�of�4-comp�Gonen�t�v�ectors�[�R��;���a;�b;�k�P��],���where���R��ͫranges�through�the���list��+of�all�p�Gossible�comp�ositums�as�ab�o���v�e,���and��+�a��(resp.�.H�b�)�expresses�the�ro�ot�of��P����(resp.�.H�Q�)�as�an���elemen���t�UUof��Q�(�X���)�=�(�R�ǫ).�q�Finally��*�,��k���is�a�small�in�teger�suc�h�that��b�8���k�P�a���=��X�7�mo�Gdulo�UU�R�ǫ.����A�B�comp�Gositum�B�is�quite�often�dened�b���y�a�complicated�p�olynomial,�~>whic���h�it�is�advisable�to���reduce�UUb�Gefore�further�w���ork.�q�Here�is�a�simple�example�in�v�olving�the�eld��Q�(�����5��|s�;����5���^��1�=�5���ʫ):�����?�?�z�=�polcompositum(x^5�-�5,�polcyclo(5),�1)[1];����?�?�pol�=�z[1]�Y?�\\���pol��denes�the�c��}'omp�ositum�����%2�?�=�x^20�+�5*x^19�+�15*x^18�+�35*x^17�+�70*x^16�+�141*x^15�+�260*x^14�\�����+�?�355*x^13�+�95*x^12�-�1460*x^11�-�3279*x^10�-�3660*x^9�-�2005*x^8���\�����+�?�705*x^7�+�9210*x^6�+�13506*x^5�+�7145*x^4�-�2740*x^3�+�1040*x^2�?�\��������124���}L������Kf�����卑��-�?�320*x�+�256��Ǎ�?�?�a�=�z[2];�a^5�-�5�4�\\���a��is�a�fth�r��}'o�ot���of��5�����%3�?�=�0����?�?�z�=�polredabs(pol,�1);�?�\\����lo��}'ok�for�a�simpler�p�olynomial�����?�?�pol�=�z[1]����%5�?�=�x^20�+�25*x^10�+�5����?�?�a�=�subst(a.pol,�x,�z[2])�
�\\���a��in�the�new�c��}'o�or�dinates�����%6�?�=�Mod(-5/22*x^19�+�1/22*x^14�-�123/22*x^9�+�9/11*x^4,�x^20�+�25*x^10�+�5)��T���The�UUlibrary�syn���tax�is���p�Q�olcomp�ositum0��U�=�(�P�G;���Q;���flag���t�).��"���3.6.106��dp�Q�olgalois�(�x�):�a�Galois�M6group�of�the�non-constan���t�p�Golynomial��x�d8�2��Q�[�X���].�YkIn�M6the�presen�t���v���ersion���2.2.7,��ֱx��m�ust�b�Ge�irreducible�and�the�degree�of��x��m�ust�b�Ge�less�than�or�equal�to�7.�2�On���certain���v���ersions�for�whic�h�the�data�le�of�Galois�resolv�en�ts�has�b�Geen�installed�(a�v��q�ailable�in�the�Unix���distribution�UUas�a�separate�pac���k��q�age),�degrees�8,�9,�10�and�11�are�also�implemen�ted.����The���output�is�a�3-comp�Gonen���t�v�ector�[�n;���s;�k�P��]���with�the�follo�wing�meaning:�4�n��is�the�cardinalit�y�of���the�Y�group,�Z�s��is�its�signature�(�s�΃�=�1�Y�if�the�group�is�a�subgroup�of�the�alternating�group��A����n��q~�,��s�΃�=���1���otherwise).�����k�\��is�more�arbitrary�and�the�c���hoice�made�up�to�v�ersion�2.2.3�of�P��*�ARI��is�rather�unfortunate:���for�a��n��g>��7,�d��k���is�the�n���um�b�Gering�of�the�group�among�all�transitiv�e�subgroups�of��S����n��q~�,�d�as�giv�en�in�\The���transitiv���e���groups�of�degree�up�to�elev�en",�BG.�Butler�and�J.�McKa�y��*�,�BComm�unications�in�Algebra,���v���ol.��k11,��p1983,�pp.�863{911�(group��k�
�is�denoted��T����k�����there).��And�for��n�m���7,��pit�w���as�ad�ho�Gc,�so�as�to���ensure�athat�a�giv���en�triple�w�ould�design�a�unique�group.�Z�Sp�Gecically��*�,�+for�p�olynomials�of�degree�����7,���the�UUgroups�are�co�Gded�as�follo���ws,�using�standard�notations����In�UUdegree�1:�qDZS����1��C��=��[1�;����1�;��1].����In�UUdegree�2:�qDZS����2��C��=��[2�;�����1�;��1].����In�UUdegree�3:�qDZA����3��C��=���C����3���=�[3�;����1�;��1],�UU�S����3��C��=�[6�;���1�;��1].����In�UUdegree�4:�qDZC����4��C��=��[4�;�����1�;��1],�UU�V����4���=��[4�;��1�;��1],�UU�D����4���=��[8�;���1�;��1],�UU�A����4���=��[12�;��1�;��1],�UU�S����4���=��[24�;���1�;��1].����In�UUdegree�5:�qDZC����5��C��=��[5�;����1�;��1],�UU�D����5���=��[10�;��1�;��1],�UU�M����20��?��=�[20�;���1�;��1],�UU�A����5��C��=�[60�;��1�;��1],�UU�S����5��C��=�[120�;���1�;��1].����In�odegree�6:��9�C����6��nj�=���[6�;�����1�;��1],�u|�S����3���=���[6�;���1�;��2],�u|�D����6���=���[12�;���1�;��1],�u|�A����4���=���[12�;��1�;��1],�u|�G����18��jݫ=�[18�;���1�;��1],����S����䍑�������4���v�=�"}[24�;�����1�;��1],�Y�A����4��@H���ձC����2����=�[24�;���1�;��2],�Y�S����䍑���+���4���Y��=�[24�;��1�;��1],�Y�G����䍺����36����c�=�[36�;���1�;��1],�Y�G����䍮+���36����c�=�[36�;��1�;��1],�Y�S����4��@H�����C����2��	�/�=��[48�;�����1�;��1],�R�A����5���=���P�c�S���L����2��|s�(5)�=�[60�;����1�;��1],�R�G����72��
���=��[72�;���1�;��1],��S����5��	�/�=���P�c�GL����2��|s�(5)�=�[120�;�����1�;��1],����A����6��C��=��[360�;����1�;��1],�UU�S����6���=��[720�;���1�;��1].����In�'degree�7:��k�C����7��t=�=���[7�;����1�;��1],�9۱D����7���=���[14�;���1�;��1],�9۱M����21��p��=�[21�;��1�;��1],�9۱M����42��p��=�[42�;���1�;��1],�9۱P�c�S���L����2��|s�(7)�=����P�c�S���L����3��|s�(2)��=�[168�;����1�;��1],�UU�A����7��C��=��[2520�;��1�;��1],��S����7��C��=��[5040�;���1�;��1].����This�O�is�deprecated�and�obsolete,�P�but�for�reasons�of�bac���kw�ard�O�compatibilit�y��*�,�w�e�O�cannot�c���hange���this���b�Geha���viour�y�et.�,RSo�y�ou�can�use�the�default��new_galois_format��to�switc�h�to�a�consisten�t�naming���sc���heme,��2namely��9�k�Ыis�alw�a�ys�the�standard�n�um�b�Gering�of�the�group�among�all�transitiv�e�subgroups���of�UU�S����n��q~�.�q�If�this�default�is�in�eect,�the�ab�Go���v�e�UUgroups�will�b�e�co�ded�as:����In�UUdegree�1:�qDZS����1��C��=��[1�;����1�;��1].����In�UUdegree�2:�qDZS����2��C��=��[2�;�����1�;��1].��������125���~_-�����Kf�����卑�In�UUdegree�3:�qDZA����3��C��=���C����3���=�[3�;����1�;��1],�UU�S����3��C��=�[6�;���1�;��2].������In�UUdegree�4:�qDZC����4��C��=��[4�;�����1�;��1],�UU�V����4���=��[4�;��1�;��2],�UU�D����4���=��[8�;���1�;��3],�UU�A����4���=��[12�;��1�;��4],�UU�S����4���=��[24�;���1�;��5].����In�UUdegree�5:�qDZC����5��C��=��[5�;����1�;��1],�UU�D����5���=��[10�;��1�;��2],�UU�M����20��?��=�[20�;���1�;��3],�UU�A����5��C��=�[60�;��1�;��4],�UU�S����5��C��=�[120�;���1�;��5].����In�odegree�6:��9�C����6��nj�=���[6�;�����1�;��1],�u|�S����3���=���[6�;���1�;��2],�u|�D����6���=���[12�;���1�;��3],�u|�A����4���=���[12�;��1�;��4],�u|�G����18��jݫ=�[18�;���1�;��5],����A����4��	�����C����2��IR�=���[24�;�����1�;��6],���S����䍑���+���4�����=�[24�;��1�;��7],���S����䍑�������4��� m�=�[24�;���1�;��8],���G����䍺����36���Eū=�[36�;���1�;��9],���G����䍮+���36���Eū=�[36�;��1�;��10],���S����4��	�����C����2��*�=��p[48�;�����1�;��11],�ױA����5���=��p�P�c�S���L����2��|s�(5)�=�[60�;����1�;��12],�ױG����72��'V�=��p[72�;���1�;��13],��S����5��*�=��p�P�c�GL����2��|s�(5)�=�[120�;�����1�;��14],����A����6��C��=��[360�;����1�;��15],�UU�S����6���=��[720�;���1�;��16].������In�'degree�7:��k�C����7��t=�=���[7�;����1�;��1],�9۱D����7���=���[14�;���1�;��2],�9۱M����21��p��=�[21�;��1�;��3],�9۱M����42��p��=�[42�;���1�;��4],�9۱P�c�S���L����2��|s�(7)�=����P�c�S���L����3��|s�(2)��=�[168�;����1�;��5],�UU�A����7��C��=��[2520�;��1�;��6],��S����7��C��=��[5040�;���1�;��7].��o���W��
�arning:�mɫThe�MYmetho�Gd�used�is�that�of�resolv���en�t�MYp�olynomials�and�is�sensitiv���e�to�the�curren�t�preci-���sion.�`^The�!precision�is�up�Gdated�in���ternally�but,�+�in�v�ery�rare�cases,�+�a�wrong�result�ma�y�b�Ge�returned�if���the�UUinitial�precision�w���as�not�sucien�t.������The��library�syn���tax�is���galois��䇫(�x;�����pr��}'e�c�����).�J�T��*�o�enable�the�new�format�in�library�mo�Gde,���set�the�global���v��q�ariable�UU�new_galois_format��to�1.����3.6.107���p�Q�olred�(�x;����f��flag����=��0�g�;��f�f��a�g�):�dunds�:�p�Golynomials�with�reasonably�small�co�ecien���ts�dening���subelds��of�the�n���um�b�Ger��eld�dened�b���y��x�.�O�One�of�the�p�olynomials�alw���a�ys��denes��Q��(hence�is�equal���to�(��x��Y���1),�1�and�another�alw���a�ys�denes�the�same�n�um�b�Ger�eld�as��x��if��x��is�irreducible.�b�All��x��accepted���b���y�UU�nfinit��are�also�allo�w�ed�here�(e.g.�q�non-monic�p�Golynomials,��nf�,��bnf�,��[x,Z���E�ff&f��ǫK���E�ff&f��basis]�).������The�UUfollo���wing�binary�digits�of���flag���v�are�signican�t:����1:���p�Gossibly���use�a�sub�order�of�the�maximal�order.�-<The�primes�dividing�the�index�of�the�order���c���hosen�UUare�larger�than��primelimit��or�divide�in�tegers�stored�in�the��addprimes��table.����2:�:7giv���es��6also�elemen�ts.�L�The�result�is�a�t�w�o-column�matrix,��othe�rst�column�giving�the�elemen�ts���dening�UUthese�subelds,�the�second�giving�the�corresp�Gonding�minimal�p�olynomials.����If��Q�f��a��is�giv���en,�\it�is�assumed�that�it�is�the�t�w�o-column�matrix�of�the�factorization�of�the���discriminan���t�UUof�the�p�Golynomial��x�.����The�GWlibrary�syn���tax�is���p�Q�olred0��(��(�x;�����flag���t�;���f��a�),�}Wwhere�an�omitted��f�a��is�co�Gded�b���y��NULL�.�Also�a�v��q�ailable���are��UU�p�Q�olred��#a��(�x�)�UUand���f�actoredp�Q�olred��MN�(�x;���f��a�),�b�Goth�corresp�onding�to���flag��T9�=��0.��o���3.6.108��p�Q�olredabs�(�x;����f��flag��5��=���0�g�):��mnds�v(one�of�the�p�Golynomial�dening�the�same�n���um�b�er�v(eld�as���the�ؾone�dened�b���y��x�,���and�suc�h�that�the�sum�of�the�squares�of�the�mo�Gdulus�of�the�ro�ots�(i.e.�the����T����2��|s�-norm)��is�minimal.�VUAll��x��accepted�b���y��nfinit��are�also�allo�w�ed�here�(e.g.�VUnon-monic�p�Golynomials,����nf�,�UU�bnf�,��[x,Z���E�ff&f��ǫK���E�ff&f��basis]�).��������126���p������Kf�������W��
�arning:���this���routine�uses�an�exp�Gonen���tial-time�algorithm�to�en�umerate�all�p�Goten�tial�generators,���and�0}ma���y�b�Ge�exceedingly�slo�w�when�the�n�um�b�Ger�eld�has�man�y�subelds,�7�hence�a�lot�of�elemen�ts�of���small��<�T����2��|s�-norm.�M�E.g.�do�not�try�it�on�the�comp�Gositum�of�man���y�quadratic�elds,���use��polred��instead.��Wb��The�UUbinary�digits�of���flag���v�mean����1:���outputs���a�t���w�o-comp�Gonen�t���ro�w�v�ector�[�P�G;���a�],��where��P��p�is�the�default�output�and��a��is�an���elemen���t�UUexpressed�on�a�ro�Got�of�the�p�olynomial��P�c��,�whose�minimal�p�olynomial�is�equal�to��x�.����4:�A�giv���es��]�al���l���p�Golynomials�of�minimal��T����2��9Ыnorm�(of�the�t�w�o�p�Golynomials��P�c��(�x�)�and��P��(��x�),��_only���one�UUis�giv���en).����16:�n�p�Gossibly�Ouse�a�sub�order�of�the�maximal�order.�o�The�primes�dividing�the�index�of�the�order���c���hosen��are�larger�than��primelimit��or�divide�in�tegers�stored�in�the��addprimes��table.�In�that�case���it�UUma���y�happ�Gen�that�the�output�p�olynomial�do�es�not�ha���v�e�UUminimal��T����2���ȫnorm.����The�UUlibrary�syn���tax�is���p�Q�olredabs0��9���(�x;�����flag���t�).��&��3.6.109��p�Q�olredord�(�x�):�
nds���p�Golynomials�with�reasonably�small�co�ecien���ts�and�of�the�same�degree���as�"=that�of��x��dening�sub�Gorders�of�the�order�dened�b���y��x�.�`�One�of�the�p�olynomials�alw���a�ys�"=denes��Q����(hence��5is�equal�to�(�x�cu���1)���^��n��q~�,��-where��5�n��is�the�degree),�and�another�alw���a�ys��5denes�the�same�order�as����x�UU�if��x��is�irreducible.����The�UUlibrary�syn���tax�is���ordred��$���(�x�).��&��3.6.110�p�p�Q�oltsc��9hirnhaus�(�x�):��applies��wa�random�Tsc���hirnhausen�transformation�to�the�p�Golynomial����x�,�%�whic���h��is�assumed�to�b�Ge�non-constan�t�and�separable,�%�so�as�to�obtain�a�new�equation�for�the�ҁ��Getale���algebra��ydened�b���y��x�.� 2This�is�for�instance�useful�when�computing�resolv�en�ts,��hence�is�used�b�y�the����polgalois�UU�function.����The�UUlibrary�syn���tax�is���tsc��9hirnhaus��<�ث(�x�).��&��3.6.111�Q�rnfalgtobasis�(��rnf��a�;���x�):�J;expresses����x��on�the�relativ���e�in�tegral�basis.��uHere,��ܝ�rnf�����is�a�relativ�e���n���um�b�Ger���eld�extension��L=K��ܫas�output�b���y��rnfinit�,���and��x��an�elemen�t�of��L��in�absolute�form,���i.e.���expressed�UUas�a�p�Golynomial�or�p�olmo�d�with�p�olmo�d�co�ecien���ts,��not�H-�on�the�relativ�e�in�tegral�basis.����The�UUlibrary�syn���tax�is���rnf�algtobasis��D��(��rnf��a�;���x�).��&��3.6.112�9�rnfbasis�(��bnf��h��;���L�):�݄giv���es��3either�a�true���bnf���-basis�of��Z����L��
���if�it�exists,�ثor�an��n�s�+�1-elemen�t���generating��set�of��L��if�not,�%�where��n��is�the�rank�of��L��o���v�er����bnf���L�.�]�Here,���bnf�����is��as�output�b���y��bnfinit�;�-��L����is��either�a�p�Golynomial�with�co�ecien���ts�in���bnf��(��dening�a�relativ�e�extension�of���bnf��H��,���or�a�pseudo-basis���of�UUsuc���h�an�extension,�as�ouput�b�y��rnfpseudobasis�.����The�UUlibrary�syn���tax�is���rnf�basis��+Nݫ(��bnf��h��;���x�).��&��3.6.113�+rnfbasistoalg�(��rnf��a�;���x�):�'�computes��Nthe�represen���tation�of��x��as�a�p�Golmo�d��Nwith�p�Golmo�ds��Nco�e-���cien���ts.�P�Here,����rnf�����is��a�relativ�e�n�um�b�Ger�eld�extension��L=K��֫as�output�b�y��rnfinit�,��and��x��an�elemen�t���of�UU�L��expressed�on�the�relativ���e�in�tegral�basis.����The�UUlibrary�syn���tax�is���rnf�basistoalg��D9~�(��rnf��a�;���x�).��&��3.6.114�=2rnfc��9harp�Q�oly�(��nf��
��;���T��V;�a;��f�v��x�=�]��x�g�):�&jc���haracteristic���p�Golynomial�of��a��o�v�er���nf��~��,��;where��a��b�Gelongs���to�U�the�algebra�dened�b���y��T��c�o�v�er���nf��$��,���i.e.���nf���[�X���]�=�(�T�c��).�sDReturns�a�p�Golynomial�in�v��q�ariable��v����(�x��b���y���default).����The�UUlibrary�syn���tax�is���rnf�c��9harp�Q�oly��>sy�(��nf��
��;���T��V;�a;�v�[٫),�UUwhere��v��.�is�a�v��q�ariable�n�um�b�Ger.��������127�����&�����Kf�������3.6.115�/�rnfconductor�(��bnf��h��;�����p��}'ol���p�;����f��flag�����=�I�0�g�):��giv���en�����bnf���+�as���output�b�y��bnfinit�,��sand���p��}'ol���p�a�relativ�e���p�Golynomial���dening�an�Ab�elian�extension,���computes�the�class�eld�theory�conductor�of�this�Ab�elian���extension.��\The��result�is�a�3-comp�Gonen���t�v�ector�[��c��}'onductor��+�F�;�����r��}'ayclgp�� �%�;�����sub��}'gr�oup��'���],�5�where���c��}'onductor��3���is���the���conductor�of�the�extension�giv���en�as�a�2-comp�Gonen�t�ro�w�v�ector�[�f����0��|s�;���f����1��x�],�����r��}'ayclgp��&�V�is�the�full�ra�y���class�g�group�corresp�Gonding�to�the�conductor�giv���en�as�a�3-comp�onen���t�v�ector�[h,cyc,gen]�as�usual�for���a��[group,��'and���sub��}'gr�oup��+Η�is�a�matrix�in�HNF��=dening�the�subgroup�of�the�ra���y�class�group�on�the�giv�en���generators�{gen.��&If���flag��.
�is�non-zero,���c���hec�k�{that���p��}'ol��C�indeed�denes�an�Ab�Gelian�extension,�return�0�if���it�UUdo�Ges�not.��xҍ�The�UUlibrary�syn���tax�is���rnf�conductor��E(ͫ(��rnf��a�;�����p��}'ol���p�;�����flag���t�).����3.6.116�b�rnfdedekind�(��nf��
��;�����p��}'ol���p�;�����pr���):�?�giv���en��a�n�um�b�Ger�eld���nf�����as�output�b�y��nfinit��and�a�p�Golynomial�����p��}'ol��ez�with��co�Gecien���ts�in���nf��P�dening�a�relativ�e�extension��L��of���nf��瞫,�I�ev��q�aluates�the�relativ�e�Dedekind���criterion�E�o���v�er�the�order�dened�b�y�a�ro�Got�of���p��}'ol���R�for�the�prime�ideal���pr�����and�outputs�a�3-comp�onen���t���v���ector�IJas�the�result.�m�The�rst�comp�Gonen�t�is�a�
ag�equal�to�1�if�the�enlarged�order�could�b�Ge�pro�v�en���to�4Xb�Ge���pr���ʫ-maximal�and�to�0�otherwise�(it�ma���y�b�e�maximal�in�the�latter�case�if���pr���"�is�ramied�in����L�),��the���second�comp�Gonen���t�is�a�pseudo-basis�of�the�enlarged�order�and�the�third�comp�onen���t�is�the���v��q�aluation�UUat���pr���of�the�order�discriminan���t.����The�UUlibrary�syn���tax�is���rnf�dedekind��@l]�(��nf��
��;�����p��}'ol���p�;�����pr���).����3.6.117�2rnfdet�(��nf��
��;���M��):�{Jgiv���en�Za�pseudo-matrix��M�q1�o�v�er�the�maximal�order�of���nf��)�,��Fcomputes�its���determinan���t.����The�UUlibrary�syn���tax�is���rnf�det��#1��(��nf��
��;���M��).����3.6.118���rnfdisc�(��nf��
��;�����p��}'ol���p�):�Tcgiv���en��a�n�um�b�Ger�eld���nf���as�output�b�y��nfinit��and�a�p�Golynomial���p��}'ol����with���co�Gecien���ts�$�in���nf��^�dening�a�relativ�e�extension��L��of���nf���,�X�computes�the�relativ�e�discriminan�t�of��L�.���This�?�is�a�t���w�o-elemen�t�?�ro�w�v�ector�[�D�G;���d�],�zwhere��D����is�the�relativ�e�ideal�discriminan�t�and��d��is�the��
D��relativ���e��discriminan�t�considered�as�an�elemen�t�of���nf�����������I��=���nf���
���������gП��6�2���C�.��The�main�v��q�ariable�of���nf���^must�ԑ�b�Ge�of���lo���w�er�UUpriorit�y�than�that�of���p��}'ol����,�see�Section�2.6.2.����The�UUlibrary�syn���tax�is���rnf�discf��*堫(��bnf��h��;�����p��}'ol���p�).����3.6.119��rnfeltabstorel�(��rnf��a�;���x�):���rnf��Fҫb�Geing�(qa�relativ���e�n�um�b�Ger�eld�extension��L=K�ߍ�as�output�b�y����rnfinit�B�and��x��b�Geing�an�elemen���t�of��L��expressed�as�a�p�olynomial�mo�dulo�the�absolute�equation�����rnf��a�.pol�,�ePcomputes����x��as�an�elemen���t�of�the�relativ�e�extension��L=K��ԫas�a�p�Golmo�d���with�p�Golmo�d���co�Gecien���ts.����The�UUlibrary�syn���tax�is���rnf�elemen��9tabstorel��b"�(��rnf��a�;���x�).����3.6.120�A9rnfeltdo��9wn�(��rnf��a�;���x�):��-l�rnf�����b�Geing��(a�relativ���e�n�um�b�Ger�eld�extension��L=K�jD�as�output�b�y��rn-���finit�(�and��x��b�Geing�an�elemen���t�of��L��expressed�as�a�p�olynomial�or�p�olmo�d�with�p�olmo�d�co�ecien���ts,���computes��Ʊx��as�an�elemen���t�of��K�]�as�a�p�Golmo�d,��"assuming��Ʊx��is�in��K��(otherwise�an�error�will�o�Gccur).���If�S��x��is�giv���en�on�the�relativ�e�in�tegral�basis,�TAapply��rnfbasistoalg��rst,�otherwise�P��*�ARI�will�b�Geliev���e���y���ou�UUare�dealing�with�a�v�ector.����The�UUlibrary�syn���tax�is���rnf�elemen��9tdo�wn��T�:�(��rnf��a�;���x�).��������128�����������Kf�������3.6.121��rnfeltreltoabs�(��rnf��a�;���x�):���rnf��Fҫb�Geing�(qa�relativ���e�n�um�b�Ger�eld�extension��L=K�ߍ�as�output�b�y����rnfinit���and��x��b�Geing�an�elemen���t�of��L��expressed�as�a�p�olynomial�or�p�olmo�d�with�p�olmo�d�co�ecien���ts,���computes�P��x��as�an�elemen���t�of�the�absolute�extension��L=�Q��as�a�p�Golynomial�mo�dulo�the�absolute���equation�����rnf����.pol�.�T�If����x��is�giv���en�on�the�relativ�e�in�tegral�basis,�apply��rnfbasistoalg��rst,�otherwise���P��*�ARI�UUwill�b�Geliev���e�y�ou�are�dealing�with�a�v�ector.���A��The�UUlibrary�syn���tax�is���rnf�elemen��9treltoabs��b"�(��rnf��a�;���x�).��Í�3.6.122���rnfeltup�(��rnf��a�;���x�):��\��rnf���j�b�Geing�+Ha�relativ���e�n�um�b�Ger�eld�extension��L=K��d�as�output�b�y��rnfinit����and����x��b�Geing�an�elemen���t�of��K�]ܫexpressed�as�a�p�olynomial�or�p�olmo�d,��computes��x��as�an�elemen���t�of���the���absolute�extension��L=�Q��as�a�p�Golynomial�mo�dulo�the�absolute�equation���rnf���!�.pol�.�	If��x��is�giv���en���on�v�the�in���tegral�basis�of��K���,�~�apply��nfbasistoalg��rst,�otherwise�P��*�ARI�v�will�b�Geliev���e�y�ou�are�dealing���with�UUa�v���ector.����The�UUlibrary�syn���tax�is���rnf�elemen��9tup��F�ͫ(��rnf��a�;���x�).��Í�3.6.123�Igrnfequation�(��nf��
��;�����p��}'ol���p�;����f��flag����=��0�g�):�4�giv���en�ۨa�n�um�b�Ger�eld���nf���<�as�output�b�y��nfinit��(or�simply���a��4p�Golynomial)�and�a�p�olynomial���p��}'ol��0�with�co�ecien���ts�in���nf���T�dening�a�relativ�e�extension��L��of���nf��� �,���computes�UUthe�absolute�equation�of��L��o���v�er�UU�Q�.����If���M�flag��f�is��Mnon-zero,��outputs�a�3-comp�Gonen���t�ro�w�v�ector�[�z�p�;���a;�k�P��],��where��M�z�`�is�the�absolute�equation���of�E�L��o���v�er�E�Q�,�Has�in�the�default�b�Geha���viour,��a��expresses�as�an�elemen���t�of��L��a�ro�Got�����of�the�p�olynomial���dening�@�the�base�eld���nf��ܫ,�Eand��k����is�a�small�in���teger�suc�h�that���5�=�����1�+��k�P��Jj�where����
�is�a�ro�Got�of��z����and������q�a�UUro�Got�of���p��}'ol����.����The��6main�v��q�ariable�of���nf��=Xmust���b�Ge�of�lo���w�er��6priorit�y�than�that�of���p��}'ol���4�(see�Section�2.6.2).��iNote���that��<for�eciency��*�,���this�do�Ges�not�c���hec�k��<whether�the�relativ���e�equation�is�irreducible�o�v�er���nf��
�(�,���but�only���if���it�is�squarefree.�t�If�it�is�reducible�but�squarefree,��Lthe�result�will�b�Ge�the�absolute�equation�of�the��������Getale�UUalgebra�dened�b�y���p��}'ol����.�q�If���p��}'ol���r�is�not�squarefree,�an�error�message�will�b�Ge�issued.����The�UUlibrary�syn���tax�is���rnf�equation0��C��(��nf��
��;�����p��}'ol���p�;�����flag���t�).��Í�3.6.124���rnfhnfbasis�(��bnf��h��;���x�):���giv���en�ma�big�n�um�b�Ger�eld���bnf���]�as�output�b�y��bnfinit�,�I3and�either�a���p�Golynomial�S��x��with�co�ecien���ts�in���bnf��׫dening�a�relativ�e�extension��L��of���bnf���-�,�Tor�a�pseudo-basis��x��of���suc���h� San�extension,�*�giv�es�either�a�true���bnf���֫-basis�of��L��in�upp�Ger�triangular�Hermite�normal�form,�*�if�it���exists,�UUand�returns�0�otherwise.����The�UUlibrary�syn���tax�is���rnf�hermitebasis��R9|�(��nf��
��;���x�).��Í�3.6.125���rnfidealabstorel�(��rnf��a�;���x�):�h�let��P��rnf����b�Ge�P�a�relativ���e�n�um�b�Ger�eld�extension��L=K���as�output���b���y���rnfinit�,�?�and��x��an�ideal�of�the�absolute�extension��L=�Q��giv�en�b�y�a��Z�-basis�of�elemen�ts�of��L�.���Returns��the�relativ���e�pseudo-matrix�in�HNF��giving�the�ideal��x��considered�as�an�ideal�of�the�relativ�e���extension�UU�L=K���.����If�`ɱx��is�an�ideal�in�HNF�`Bform,��asso�Gciated�to�an���nf���~�structure,�for�instance�as�output�b���y�����idealhnf��)��(��nf��
��;����:�:�:��
UO�),�UUuse��rnfidealabstorel(rnf,�?�nf.zk�*�x)�UU�to�con���v�ert�UUit�to�a�relativ���e�ideal.����The�UUlibrary�syn���tax�is���rnf�idealabstorel��R�˫(��rnf��a�;���x�).��Í�3.6.126�؀rnfidealdo��9wn�(��rnf��a�;���x�):�4�let��6��rnf��sūb�Ge�6�a�relativ���e�n�um�b�Ger�eld�extension��L=K��Ϋas�output�b�y����rnfinit�,���and��±x��an�ideal�of��L�,�giv���en�either�in�relativ�e�form�or�b�y�a��Z�-basis�of�elemen�ts�of��L��(see���Section�UU3.6.125),�returns�the�ideal�of��K�q�b�Gelo���w��x�,�i.e.�the�in�tersection�of��x��with��K���.����The�UUlibrary�syn���tax�is���rnf�idealdo��9wn��E7�(��rnf��a�;���x�).��������129�����l�����Kf�������3.6.127�7Arnfidealhnf�(��rnf��a�;���x�):���rnf����b�Geing��}a�relativ���e�n�um�b�Ger�eld�extension��L=K�a��as�output�b�y��rn-���finit�Zi�and��x��b�Geing�a�relativ���e�ideal�(whic�h�can�b�Ge,�[�as�in�the�absolute�case,�of�man���y�dieren�t�t�yp�Ges,���including�]�of�course�elemen���ts),�_�computes�the�HNF�]~pseudo-matrix�asso�Gciated�to��x�,�view���ed�as�a��Z����K�����-���mo�Gdule.���荑The�UUlibrary�syn���tax�is���rnf�idealhermite��Q��(��rnf��a�;���x�).���Ѝ�3.6.128��mrnfidealm��9ul�(��rnf��a�;���x;�y�[٫):��2��rnf��nȫb�Geing�5�a�relativ���e�n�um�b�Ger�eld�extension��L=K��߫as�output�b�y����rnfinit�Z�and��x��and��y�^3�b�Geing�ideals�of�the�relativ���e�extension��L=K��v�giv�en�b�y�pseudo-matrices,��outputs���the�UUideal�pro�Gduct,�again�as�a�relativ���e�ideal.����The�UUlibrary�syn���tax�is���rnf�idealm��9ul��=�\�(��rnf��a�;���x;�y�[٫).���Ѝ�3.6.129���rnfidealnormabs�(��rnf��a�;���x�):��A2�rnf�����b�Geing�=
a�relativ���e�n�um�b�Ger�eld�extension��L=K��&�as�output���b���y��L�rnfinit��and��x��b�Geing�a�relativ�e�ideal�(whic�h�can�b�Ge,��Jas�in�the�absolute�case,�of�man���y�dieren�t���t���yp�Ges,��including��of�course�elemen�ts),��computes�the�norm�of�the�ideal��x��considered�as�an�ideal�of�the���absolute�UUextension��L=�Q�.�q�This�is�iden���tical�to��idealnorm(rnfidealnormrel(��rnf��a�,x))�,�but�faster.����The�UUlibrary�syn���tax�is���rnf�idealnormabs��U���(��rnf��a�;���x�).���Ѝ�3.6.130���rnfidealnormrel�(��rnf��a�;���x�):���5�rnf���"�b�Geing�]�a�relativ���e�n�um�b�Ger�eld�extension��L=K���as�output�b�y����rnfinit���and��x��b�Geing�a�relativ���e�ideal�(whic�h�can�b�Ge,��las�in�the�absolute�case,�of�man���y�dieren�t�t�yp�Ges,���including�UUof�course�elemen���ts),�computes�the�relativ�e�norm�of��x��as�a�ideal�of��K�q�in�HNF.����The�UUlibrary�syn���tax�is���rnf�idealnormrel��R\W�(��rnf��a�;���x�).���Ѝ�3.6.131�؇rnfidealreltoabs�(��rnf��a�;���x�):��wW�rnf���իb�Geing�Xa�relativ���e�n�um�b�Ger�eld�extension��L=K�9�as�output�b�y����rnfinit�l��and��x��b�Geing�a�relativ���e�ideal�(whic�h�can�b�Ge,��eas�in�the�absolute�case,�of�man���y�dieren�t���t���yp�Ges,��Bincluding�yFof�course�elemen�ts),��Bgiv�es�the�ideal��x�Z����L��	u��as�an�absolute�ideal�of��L=�Q�,��Bin�the�form���of�zka��Z�-basis,���giv���en�b�y�a�v�ector�of�p�Golynomials�(mo�dulo��rnf.pol�).��
The�follo���wing�routine�migh�t�b�Ge���useful:���5��(���\\�?�return�y�=�rnfidealreltoabs(rnf,...)�as�an�ideal�in�HNF�form���M��(��\\�?�associated�to�nf�=�nfinit(�rnf.pol�);����(��idealgentoHNF(nf,�?�y)�=����(��{����3�local(z);�?�z�=�nfalgtobasis(nf,�y);����3�z[1]�?�=�Mat(z[1]);�mathnf(�concat(z)�);����(��}�����The�UUlibrary�syn���tax�is���rnf�idealreltoabs��R�˫(��rnf��a�;���x�).���Ѝ�3.6.132��brnfidealt��9w�o�Q�elt�(��rnf��a�;���x�):��ͳ�rnf���_�b�Geing�Ka�relativ���e�n�um�b�Ger�eld�extension��L=K��g�as�output�b�y����rnfinit�W֫and��x��b�Geing�an�ideal�of�the�relativ���e�extension��L=K��giv�en�b�y�a�pseudo-matrix,��vgiv�es�a���v���ector�UUof�t�w�o�generators�of��x��o�v�er��Z����L��	Qɫexpressed�as�p�Golmo�ds�UUwith�p�Golmo�d�UUco�ecien�ts.����The�UUlibrary�syn���tax�is���rnf�idealt��9w�o�Q�elemen�t��d
��(��rnf��a�;���x�).��������130�����m�����Kf�������3.6.133���rnfidealup�(��rnf��a�;���x�):���x�rnf��I��b�Geing�R�a�relativ���e�n�um�b�Ger�eld�extension��L=K�	ԫas�output�b�y��rnfinit����and����x��b�Geing�an�ideal�of��K���,���giv���es�the�ideal��x�Z����L���(�as�an�absolute�ideal�of��L=�Q�,�in�the�form�of�a��Z�-basis,���giv���en�UUb�y�a�v�ector�of�p�Golynomials�(mo�dulo��rnf.pol�).�q�The�follo���wing�routine�migh�t�b�Ge�useful:���w��(���\\�?�return�y�=�rnfidealup(rnf,...)�as�an�ideal�in�HNF�form�associated�to��>^��(��\\�?�nf�=�nfinit(�rnf.pol�);����(��idealgentoHNF(nf,�?�y)�=����(��{����3�local(z);�?�z�=�nfalgtobasis(nf,�y);����3�z[1]�?�=�Mat(z[1]);�mathnf(�concat(z)�);����(��}������The�UUlibrary�syn���tax�is���rnf�idealup��7z��(��rnf��a�;���x�).��v2��3.6.134�!Crnfinit�(��nf��
��;�����p��}'ol���p�):�����nf��\�b�Geing��\a�n���um�b�er��\eld�in��nfinit��format�considered�as�base�eld,���and�����p��}'ol��)��a�ܽp�Golynomial�dening�a�relativ���e�extension�o�v�er���nf��
���,���this�computes�all�the�necessary�data�to�w�ork���in��Xthe�relativ���e�extension.���The�main�v��q�ariable�of���p��}'ol���x�m�ust�b�Ge�of�higher�priorit�y�(see�Section�2.6.2)���than�UUthat�of���nf��$A�,�and�the�co�Gecien���ts�of���p��}'ol���r�m�ust�b�Ge�in���nf��$A�.����The��dresult�is�a�ro���w�v�ector,���whose�comp�Gonen�ts�are�tec�hnical.��In�the�follo�wing�description,���w�e���let����K�T�b�Ge�the�base�eld�dened�b���y���nf��k�,���m��the�degree�of�the�base�eld,��n��the�relativ���e�degree,��L��the���large�T�eld�(of�relativ���e�degree��n��or�absolute�degree��nm�),�T��r����1���T�and��r����2���the�n���um�b�Ger�T�of�real�and�complex���places�UUof��K���.������rnf��#a�[1]�UUcon���tains�the�relativ�e�p�Golynomial���p��}'ol����.������rnf��#a�[2]�UUis�curren���tly�un�used.������rnf��#a�[3]�Vis�a�t���w�o-comp�Gonen�t�Vro�w�v�ector�[�6�%n�

eufm10�d�(�L=K���)�;���s�]�where��d�(�L=K��)�is�the�relativ���e�ideal�discrimi-���nan���t�_Yof��L=K�u�and��s��is�the�discriminan�t�of��L=K�u�view�ed�as�an�elemen�t�of��K�����^����P�=�(�K�����^�����)���^��2��|s�,�a�in�_Yother�w�ords���it�UUis�the�output�of��rnfdisc�.������rnf��#a�[4]�UUis�the�ideal�index��f�,�i.e.�suc���h�that��d�(�pol�2`�)�Z����K��
|˫=���f���^��2��|s�d�(�L=K���).������rnf��#a�[5]�UUis�curren���tly�un�used.������rnf��#a�[6]�UUis�curren���tly�un�used.������rnf��#a�[7]�ɸis�a�t���w�o-comp�Gonen�t�ɸro�w�v�ector,��where�the�rst�comp�Gonen�t�is�the�relativ�e�in�tegral�pseudo���basis���expressed�as�p�Golynomials�(in�the�v��q�ariable�of��pol�2`�)�with�p�olmo�d�co�ecien���ts�in���nf��Wl�,��Jand�the���second�UUcomp�Gonen���t�is�the�ideal�list�of�the�pseudobasis�in�HNF.������rnf��#a�[8]�UUis�the�in���v�erse�UUmatrix�of�the�in���tegral�basis�matrix,�with�co�Gecien�ts�p�Golmo�ds�UUin���nf��$A�.������rnf��#a�[9]�UUis�curren���tly�un�used.������rnf��#a�[10]�UUis���nf��$A�.������rnf��#a�[11]�z�is�the�output�of��rnfequation(nf,�?�pol,�1)�.��MNamely��*�,��7a�z�v���ector���vabs��.-�with�3�en�tries���describing���the��absolute�z��extension��L=�Q�.��>5�vabs��v��[1]�is�an�absolute�equation,�ُmore�con���v�enien�tly���obtained���as�r��rnf.pol�.�����vabs��V�[2]�expresses�the�generator���|*�of�the�n���um�b�Ger�r�eld���nf���L�as�a�p�olynomial�mo�dulo�the���absolute�7�equation���vabs��p`�[1].��g��vabs���u�[3]�is�a�small�in���teger��k��x�suc�h�that,�=�if������is�an�abstract�ro�Got�of���p��}'ol�����and�������the�generator�of���nf�����,�.~the�generator�whose�ro�Got�is���vabs��>��will�b�e���3ͫ+����k�P��	z�.�z�Note�that�one�m���ust�b�e���v���ery��3careful�if��k��u�6�=���0�when�dealing�sim�ultaneously�with�absolute�and�relativ�e�quan�tities�since�the���generator��c���hosen�for�the�absolute�extension�is�not�the�same�as�for�the�relativ�e�one.�Y�If�this�happ�Gens,��������131�����ٍ����Kf�����卫one�V#can�of�course�go�on�w���orking,�VWbut�w�e�strongly�advise�to�c�hange�the�relativ�e�p�Golynomial�so�that���its�UUro�Got�will�b�e������+�8�k�P��	z�.�q�T���ypically��*�,�the�GP�instruction�w�ould�b�Ge��󾍑�pol�?�=�subst(pol,�x,�x�-�k*Mod(y,��nf��
���.pol))������rnf��#a�[12]�Jyis�b���y�default�un�used�and�set�equal�to�0.�n(This�eld�is�used�to�store�further�information���ab�Gout��the�eld�as�it�b�ecomes�a���v��q�ailable�(whic�h�is�rarely�needed,��hence�w�ould�b�Ge�to�o�exp�ensiv���e�to���compute�UUduring�the�initial��rnfinit��call).����The�UUlibrary�syn���tax�is���rnf�initalg��3��(��nf��
��;�����p��}'ol���p�;�����pr��}'e�c�����).���;��3.6.135���rnfisfree�(��bnf��h��;���x�):���giv���en�ha�big�n�um�b�Ger�eld���bnf��kS�as�output�b�y��bnfinit�,�lland�either�a���p�Golynomial����x��with�co�ecien���ts�in���bnf�����dening�a�relativ�e�extension��L��of���bnf���,���or�a�pseudo-basis����x�UU�of�suc���h�an�extension,�returns�true�(1)�if��L=��bnf���ثis�free,�false�(0)�if�not.����The�UUlibrary�syn���tax�is���rnf�isf�ree��.���(��bnf��h��;���x�),�and�the�result�is�a��long�.���;��3.6.136�X�rnfisnorm�(�T��V;���a;��f��flag����=��0�g�):�;�similar���to��bnfisnorm��but�in�the�relativ���e�case.�M��T�L{�is�as�output���b���y��rnfisnorminit��applied�to�the�extension��L=K���.�_VThis�tries�to�decide�whether�the�elemen�t��a��in��K����is�UUthe�norm�of�some��x��in�the�extension��L=K���.����The���output�is�a�v���ector�[�x;���q�[٫],�"�where��a��4�=���Norm����(�x�)������q��.�_/The���algorithm�lo�Goks�for�a�solution��x����whic���h�U�is�an��S����-in�teger,���with��S���a�list�of�places�of��K���con�taining�at�least�the�ramied�primes,���the���generators��of�the�class�group�of��L�,�Was�w���ell�as�those�primes�dividing��a�.�Y3If��L=K�³�is�Galois,�then�this�is���enough;���otherwise,�����flag��F1�is���used�to�add�more�primes�to��S����:��mall�the�places�ab�Go���v�e���the�primes��p������flag�����(resp.�UU�p�j��flag��7̫)�if���flag��T9�>���0�(resp.���flag���<���0).����The�D{answ���er�is�guaran�teed�(i.e.��a��is�a�norm�i��q�"�=��1)�if�the�eld�is�Galois,�G�or,�under�D{GRH,�if��S����con���tains�UUall�primes�less�than�12����log����T����2�����o�j������disc��(<q(�M��)��j���=�V�,�where��M�lp�is�the�normal�closure�of��L=K���.����If�v|�rnfisnorminit��has�determined�(or�w���as�told)�that��L=K�-��is�Galois,�~�and���flag�����6�=��Y0,�a�W��*�arning���is��%issued�(so�that�y���ou�can�set���flag��ӹ�=��1�to�c�hec�k�whether��L=K�<A�is�kno�wn�to�b�Ge�Galois,��according�to����T�c��).�q�Example:�����bnf�?�=�bnfinit(y^3�+�y^2�-�2*y�-�1);����p�?�=�x^2�+�Mod(y^2�+�2*y�+�1,�bnf.pol);����T�?�=�rnfisnorminit(bnf,�p);����rnfisnorm(T,�?�17)����c���hec�ks�TIwhether�17�is�a�norm�in�the�Galois�extension��Q�(����)�=�Q�(��	z�),�Twhere������^��3�����+�6ȱ����^��2����6ȫ2��@B���1��=�0�TIand���������^��2��<o�+�8���	z��^��2���ͫ+�2��BZ�+�1��=�0�UU(it�is).����The�UUlibrary�syn���tax�is���rnf�isnorm��[email protected]�(��T��|m�;���x;���flag���t�).���;��3.6.137��rnfisnorminit�(��p��}'ol��
Lȱ;�����p��}'olr�el���۱;����f��flag��٫=��
2�g�):��"let��K����b�Ge�dened�b���y�a�ro�ot�of���p��}'ol��?J�,��and��L=K����the���extension���dened�b���y�the�p�Golynomial���p��}'olr�el����.�S�As�usual,�����p��}'ol�����can�in�fact�b�e�an���nf��o��,���or���bnf��	3�,�etc;��]if���p��}'ol�����has�Ekdegree�1�(the�base�eld�is��Q�),�H�p�Golrel�is�also�allo���w�ed�Ekto�b�e�an���nf��W�,�H�etc.�lyComputes�tec���hnical�data���needed�UUb���y��rnfisnorm��to�solv�e�norm�equations��N�x���=��a�,�UUfor��x��in��L�,�and��a��in��K���.����If��UU�flag��T9�=��0,�UUdo�not�care�whether��L=K�q�is�Galois�or�not.����If��UU�flag��T9�=��1,�UU�L=K�q�is�assumed�to�b�Ge�Galois�(unc���hec�k�ed),�UUwhic�h�sp�Geeds�up��rnfisnorm�.����If��UU�flag��T9�=��2,�UUlet�the�routine�determine�whether��L=K�q�is�Galois.����The�UUlibrary�syn���tax�is���rnf�isnorminit��F�C�(��p��}'ol��
Lȱ;�����p��}'olr�el���۱;�����flag���t�).��������132����ш�����Kf�������3.6.138���rnfkummer�(��bnr����;����f��sub��}'gr�oup��&�g�;��f�deg�"�=��0�g�):�����bnr��ֆ�b�Geing�]as�output�b���y��bnrinit�,���nds�a�relativ�e���equation��for�the�class�eld�corresp�Gonding�to�the�mo�dule�in���bnr�����and�the�giv���en�congruence�subgroup���(the�$full�ra���y�class�eld�if���sub��}'gr�oup��.Z�is�omitted).��If���de��}'g���t�is�p�Gositiv�e,�W�outputs�the�list�of�all�relativ�e���equations��of�degree���de��}'g���`�con���tained�in�the�ra�y�class�eld�dened�b�y���bnr���p�,�Pwith�the��same���conductor�as���(��bnr����;�����sub��}'gr�oup��'���).��ᴍ�W��
�arning:�.��this���routine�only�w���orks�for�subgroups�of�prime�index.�EBIt�uses�Kummer�theory��*�,��{adjoining���necessary�)�ro�Gots�of�unit���y�(it�needs�to�compute�a�tough��bnfinit��here),�_)and�nds�a�generator�via���Hec���k�e's���c�haracterization�of�ramication�in�Kummer�extensions�of�prime�degree.�'
If�y�our�extension���do�Ges��not�ha���v�e��prime�degree,���for�the�time�b�eing,���y���ou�ha�v�e�to�split�it�b�y�hand�as�a�to�w�er�/�comp�Gositum���of�UUsuc���h�extensions.���l��The�Dlibrary�syn���tax�is���rnf�kummer��<g��(��bnr����;�����sub��}'gr�oup��'���;�����de��}'g��Y�;�����pr��}'e�c�����),�where���de��}'g���ʫis�a��long��and�an�omit-���ted��UU�sub��}'gr�oup��,���is�UUco�Gded�as��NULL��ٍ�3.6.139���rnflllgram�(��nf��
��;�����p��}'ol���p�;�����or��}'der��|��):��5giv���en�N0a�p�Golynomial���p��}'ol���(�with�co�ecien���ts�in���nf��kL�dening�a�relativ�e���extension�z�L��and�a�sub�Gorder���or��}'der���%�of��L��(of�maximal�rank),��5as�output�b���y��rnfpseudobasis�(��nf��
��;�����p��}'ol���p�)���or���similar,�W�giv���es�[[��newor��}'der��(��]�;���U��],�where���newor��}'der��2��is�a�reduced�order�and��U��is�the�unimo�Gdular���transformation�UUmatrix.����The�UUlibrary�syn���tax�is���rnf�lllgram��6N&�(��nf��
��;�����p��}'ol���p�;�����or��}'der��|��;�����pr��}'e�c�����).��ٍ�3.6.140��!rnfnormgroup�(��bnr����;�����p��}'ol���p�):��c��bnr�� ��b�Geing�9Ua�big�ra���y�class�eld�as�output�b�y��bnrinit��and���p��}'ol���r�a���relativ���e��jp�Golynomial�dening�an�Ab�elian�extension,�3computes�the�norm�group�(alias�Artin�or�T��*�ak��q�agi���group)��corresp�Gonding�to�the�Ab�elian�extension�of���bnf���ë=�r<�bnr��[1]�dened�b���y���p��}'ol��̫,�հwhere�the�mo�dule���corresp�Gonding�b~to���bnr��Hݫis�assumed�to�b�e�a�m���ultiple�of�the�conductor�(i.e.���p��}'ol��īdenes�a�sub�extension���of�Pbnr).�pThe�result�is�the�HNF�Pdening�the�norm�group�on�the�giv���en�generators�of���bnr����[5][3].�Note���that���neither�the�fact�that���p��}'ol���֫denes�an�Ab�Gelian�extension�nor�the�fact�that�the�mo�dule�is�a�m���ultiple���of�UUthe�conductor�is�c���hec�k�ed.�q�The�UUresult�is�undened�if�the�assumption�is�not�correct.����The�UUlibrary�syn���tax�is���rnf�normgroup��J�̫(��bnr����;�����p��}'ol���p�).��ٍ�3.6.141���rnfp�Q�olred�(��nf��
��;�����p��}'ol���p�):���relativ���e��Zv�ersion�of��polred�.�T�Giv�en�a�monic�p�Golynomial���p��}'ol��9|�with�co-���ecien���ts��ein���nf���Q�,��nds�a�list�of�relativ�e�p�Golynomials�dening�some�subelds,��hop�efully�simpler�and���con���taining��Uthe�original�eld.�=�In�the�presen�t�v�ersion�2.2.7,��Uthis�is�slo�w�er�and�less�ecien�t�than����rnfpolredabs�.����The�UUlibrary�syn���tax�is���rnf�p�Q�olred��3b�(��nf��
��;�����p��}'ol���p�;�����pr��}'e�c�����).��ٍ�3.6.142��8rnfp�Q�olredabs�(��nf��
��;�����p��}'ol���p�;����f��flag����=��0�g�):�gLrelativ���e�@^v�ersion�of��polredabs�.�j�Giv�en�a�monic�p�Golyno-���mial���{�p��}'ol��5��with��{co�Gecien���ts�in���nf���g�,�Dnds�a�simpler�relativ�e�p�Golynomial�dening�the�same�eld.�O9The���binary�UUdigits�of���flag���v�mean����1:��returns���[�P�G;���a�]�where��P�r�is�the�default�output�and��a��is�an�elemen���t�expressed�on�a�ro�Got�of��P����whose�UUc���haracteristic�p�Golynomial�is���p��}'ol������2:���returns�~oan�absolute�p�Golynomial�(same�as��rnfequation(��nf��
���,rnfpolredabs(��nf���,��p��}'ol��
L��))�~o�but���faster).����16:�s�p�Gossibly��puse�a�sub�order�of�the�maximal�order.��This�is�slo���w�er��pthan�the�default�when�the���relativ���e�UUdiscriminan�t�is�smo�Goth,�and�m�uc�h�faster�otherwise.�q�See�Section�3.6.108.��������133�����(�����Kf�������Remark.�8��In���the�presen���t�implemen�tation,��this�is�b�Goth�faster�and�m�uc�h�more�ecien�t�than��rnf-���polred�,��the���dierence�b�Geing�more�dramatic�than�in�the�absolute�case.�'�This�is�b�ecause�the�imple-���men���tation�>Wof��rnfpolred��is�based�on�(a�partial�implemen�tation�of��)�an�incomplete�reduction�theory���of�UUlattices�o���v�er�UUn�um�b�Ger�elds,�the�function��rnflllgram�,�whic�h�deserv�es�to�b�Ge�impro�v�ed.���O��The�UUlibrary�syn���tax�is���rnf�p�Q�olredabs��C�C�(��nf��
��;�����p��}'ol���p�;�����flag���t�;�����pr��}'e�c�����).�����3.6.143�jrnfpseudobasis�(��nf��
��;�����p��}'ol���p�):�Llgiv���en�
�a�n�um�b�Ger�eld���nf���,�as�output�b�y��nfinit��and�a�p�Golynomial�����p��}'ol��~īwith�1�co�Gecien���ts�in���nf��2�dening�a�relativ�e�extension��L��of���nf���,�9computes�a�pseudo-basis�(�A;���I���)�for���the�hmaximal�order��Z����L��	dt�view���ed�as�a��Z����K�����-mo�Gdule,�l�and�the�relativ�e�discriminan�t�of��L�.���This�is�output���as��a�four-elemen���t�ro�w�v�ector�[�A;���I���;�D�G;�d�],�Rcwhere�DZD�f�is�the�relativ�e�ideal�discriminan�t�and��d��is�the��
D��relativ���e�UUdiscriminan�t�considered�as�an�elemen�t�of���nf���$A�������%�=���nf���
���������g��6�2���C�.����The�UUlibrary�syn���tax�is���rnf�pseudobasis��N�(��nf��
��;�����p��}'ol���p�).�����3.6.144��rnfsteinitz�(��nf��
��;���x�):�giv���en���a�n�um�b�Ger�eld���nf���as�output�b�y��nfinit��and�either�a�p�Golynomial��x����with��"co�Gecien���ts�in���nf��A0�dening�a�relativ�e�extension��L��of���nf��
��,��_or�a�pseudo-basis��x��of�suc�h�an�extension���as�}Ooutput�for�example�b���y��rnfpseudobasis�,��Mcomputes�another�pseudo-basis�(�A;���I���)�(not�in�HNF�}Ein���general)���suc���h�that�all�the�ideals�of��I�m��except�p�Gerhaps�the�last�one�are�equal�to�the�ring�of�in�tegers���of��$��nf��
�,�.Uand�$�outputs�the�four-comp�Gonen���t�ro�w�v�ector�[�A;���I���;�D�G;�d�]�$�as�in��rnfpseudobasis�.�a�The�name�of���this�.Pfunction�comes�from�the�fact�that�the�ideal�class�of�the�last�ideal�of��I���,�6whic���h�is�w�ell�dened,�6is���the�UUSteinitz�class�of�the��Z����K�����-mo�Gdule��Z����L��	Qɫ(its�image�in��S���K����0��|s�(�Z����K���)).����The�UUlibrary�syn���tax�is���rnf�steinitz��7�֫(��nf��
��;���x�).�����3.6.145�(fsubgrouplist�(��bnr����;����f��b��}'ound��UK�g�;��f��flag���J�=��~0�g�):���w�bnr�����b�Geing�|-as�output�b���y��bnrinit��or�a�list�of���cyclic���comp�Gonen���ts�of�a�nite�Ab�elian�group��G�,���outputs�the�list�of�subgroups�of��G�.�8Subgroups�are���giv���en�UUas�HNF�left�divisors�of�the�SNF�matrix�corresp�Gonding�to��G�.��܄��W��
�arning:�J��the���presen���t�implemen�tation�cannot�treat�a�group��G��where�an�y�cyclic�factor�has�more���than��2���^��31��x�,��resp.�2���^��63��
��elemen���ts�on�a�32-bit,�resp.�64-bit�arc���hitecture.�+�forsubgroup��is�a�bit�more���general�UUand�can�handle��G��if�all��p�-Sylo���w�subgroups�of��G��satisfy�the�condition�ab�Go�v�e.����If���F�flag����=���0��F(default)�and���bnr��fm�is�as�output�b���y���bnrinit��(�1�(�;���;��1),�Bgiv�es��Fonly�the�subgroups�whose���mo�Gdulus�UUis�the�conductor.�q�Otherwise,�the�mo�dulus�is�not�tak���en�in�to�accoun�t.����If���b�b��}'ound����is��bpresen���t,���and�is�a�p�Gositiv�e�in�teger,���restrict�the�output�to�subgroups�of�index�less�than�����b��}'ound��UK�.�I�If����b��}'ound��":��is��a�v���ector�con�taining�a�single�p�Gositiv�e�in�teger��B��q�,�then�only�subgroups�of�index���exactly�UUequal�to��B��ƫare�computed.�q�F��*�or�instance���i���?�?�subgrouplist([6,2])��,��%1�?�=�[[6,�0;�0,�2],�[2,�0;�0,�2],�[6,�3;�0,�1],�[2,�1;�0,�1],�[3,�0;�0,�2],����3�[1,�?�0;�0,�2],�[6,�0;�0,�1],�[2,�0;�0,�1],�[3,�0;�0,�1],�[1,�0;�0,�1]]����?�?�subgrouplist([6,2],3)���\\����index�less�than�3�����%2�?�=�[[2,�1;�0,�1],�[1,�0;�0,�2],�[2,�0;�0,�1],�[3,�0;�0,�1],�[1,�0;�0,�1]]����?�?�subgrouplist([6,2],[3])�
�\\����index�3�����%3�?�=�[[3,�0;�0,�1]]����?�?�bnr�=�bnrinit(bnfinit(x),�[120,[1]],�1);����?�?�L�=�subgrouplist(bnr,�[8]);����In�)�the�last�example,�2\�L��corresp�Gonds�to�the�24�subelds�of��Q�(�����120��uY�),�of�degree�8�and�conductor�120�1����(b���y�UUsetting���flag���!�,�w�e�see�there�are�a�total�of�43�subgroups�of�degree�8).��������134����󟍟���Kf�����卑�?�?�vector(#L,�i,�galoissubcyclo(bnr,�L[i]))��ߍ�will�4pro�Gduce�their�equations.��e(F��*�or�a�general�base�eld,�H�y���ou�w�ould�ha�v�e�to�rely�on��bnrstark�,�H�or����rnfkummer�.)����The�9Blibrary�syn���tax�is���subgrouplist0��G�ë(��bnr����;�����b��}'ound����;�����flag���t�),�r=where���flag���P�is�a�long�in�teger,�r=and�an���omitted��UU�b��}'ound�� ���is�UUco�Gded�b���y��NULL�.��=���3.6.146�H0zetak�(��znf��嬱;���x;��f��flag��\�=��0�g�):�����znf��t>�b�Geing���a�n���um�b�er���eld�initialized�b���y��zetakinit��(�not����b�y����nfinit�),���computes�H�the�v��q�alue�of�the�Dedekind�zeta�function�of�the�n���um�b�Ger�H�eld�at�the�complex���n���um�b�Ger��}�x�.�H*If���flag���a�=��1�computes�Dedekind��function�instead�(i.e.�the�pro�duct�of�the�Dedekind�zeta���function�UUb���y�its�gamma�and�exp�Gonen�tial�factors).����The���accuracy�of�the�result�dep�Gends�in�an�essen���tial�w�a�y�on�the�accuracy�of�b�Goth�the��zetakinit����program�2�and�the�curren���t�accuracy��*�.�f3Be�w�ary�in�particular�that��x��of�large�imaginary�part�or,�9�on�the���con���trary��*�,��v�ery���close�to�an�ordinary�in���teger�will�suer�from�precision�loss,�yielding�less�signican���t���digits�UUthan�exp�Gected.�q�Computing�with�28�eigh���t�digits�of�relativ�e�accuracy��*�,�w�e�ha�v�e��))���?�?�zeta(3)��
J��%1�?�=�1.202056903159594285399738161����?�?�zeta(3-1e-20)����%2�?�=�1.202056903159594285401719424����?�?�zetak(zetakinit(x),�3-1e-20)����%3�?�=�1.202056903159594285401720529�
�\\�the�last�4�digits�are�wrong����?�?�zetak(zetakinit(x),�3-1e-28)����%4�?�=�1.202056914058477276496200278�
�\\�the�last�20�digits�are�wrong����?�?�zetak(zetakinit(x),�3-1e-40)����%5�?�=�-1989629366932171.633904021690�\\�junk��ߍ��The�UUlibrary�syn���tax�is���glam��9b�Q�dak��3�z�(��znf��嬱;���x;���pr��}'e�c�����)�UUor���gzetak��#�׫(��znf���;���x;���pr��}'e�c�����).��=���3.6.147�H5zetakinit�(�x�):�9�computes��:a�n���um�b�Ger��:of�initialization�data�concerning�the�n���um�b�er��:eld�de-���ned��Mb���y�the�p�Golynomial��x��so�as�to�b�e�able�to�compute�the�Dedekind�zeta�and�lam���b�da�functions���(resp�Gectiv���ely����zetak��C}�(�x�)��and���zetak���(�x;����1)).�|mThis�function�calls�in�particular�the��bnfinit��program.���The��result�is�a�9-comp�Gonen���t�v�ector��v�J��whose�comp�Gonen�ts�are�v�ery�tec�hnical�and�cannot�really�b�Ge���used�o�b���y�the�user�except�through�the��zetak��function.��uThe�only�comp�Gonen�t�whic�h�can�b�Ge�used�if�it���has�UUnot�b�Geen�computed�already�is��v�[٫[1][4]�whic���h�is�the�result�of�the��bnfinit��call.����This��function�is�v���ery�inecien�t�and�should�b�Ge�rewritten.�K�It�needs�to�computes�millions�of�co�ef-���cien���ts�Pof�the�corresp�Gonding�Diric�hlet�series�if�the�precision�is�big.�\pUnless�the�discriminan�t�is�small���it�>�will�not�b�Ge�able�to�handle�more�than�9�digits�of�relativ���e�precision.�jBF��*�or�instance,�CH�zetakinit(x^8���-�?�2)�UU�needs�440MB�of�memory�at�default�precision.����The�UUlibrary�syn���tax�is���initzeta��)�(�x�).��������135����3�����Kf�������3.7��P��olynomials�and�p�`o�w�er�series�.��>b��W��*�e�24group�here�all�functions�whic���h�are�sp�Gecic�to�p�olynomials�or�p�o���w�er�24series.�cMan�y�other���functions�b�whic���h�can�b�Ge�applied�on�these�ob��8jects�are�describ�ed�in�the�other�sections.���Also,�f\some�of���the�UUfunctions�describ�Ged�here�can�b�e�applied�to�other�t���yp�es.��ְ��3.7.1��?O�(�a�^�b�):�
ϱp�-adic�#Y(if��a��is�an�in���teger�greater�or�equal�to�2)�or�p�Go�w�er�series�zero�(in�all�other���cases),�UUwith�precision�giv���en�b�y��b�.���;��The�UUlibrary�syn���tax�is���ggrando�Q�cp��7���(�a;���b�),�where��b��is�a��long�.����3.7.2���deriv�(�x;����f�v�[ٷg�):��deriv��q�ativ���e��of��x��with�resp�Gect�to�the�main�v�ariable�if��v�x��is�omitted,�N�and�with���resp�Gect��to��v���otherwise.��x��can�b�e�an���y�t�yp�Ge�except�p�olmo�d.�The�deriv��q�ativ���e�of�a�scalar�t�yp�Ge�is�zero,���and�٬the�deriv��q�ativ���e�of�a�v�ector�or�matrix�is�done�comp�Gonen�t�wise.���One�can�use��x���^��0����as�a�shortcut�if���the�UUderiv��q�ativ���e�is�with�resp�Gect�to�the�main�v�ariable�of��x�.���;��The�TElibrary�syn���tax�is���deriv��&�(�x;���v�[٫),�T|where��v���is�a��long�,�and�an�omitted��v���is�co�Gded�as���1.�qlWhen����x�UU�is�a��t_POL�,���derivpol��-U=�(�x�)�is�a�shortcut�for���deriv���F�(�x;�����1).����3.7.3�v�ev��\ral�(�x�):���replaces���in��x��the�formal�v��q�ariables�b���y�the�v�alues�that�ha���v�e���b�Geen�assigned�to�them���after�hithe�creation�of��x�.��This�is�mainly�useful�in�GP��*�,�and�not�in�library�mo�Gde.�Do�not�confuse�this���with�V�substitution�(see��subst�).�u�Applying�this�function�to�a�c���haracter�string�yields�the�output�from���the�UUcorresp�Gonding�GP�command,�as�if�directly�input�from�the�k���eyb�oard�(see�Section�2.6.6).���;��The�q`library�syn���tax�is���gev��\ral���ȫ(�x�).���The�more�basic�functions���p�Q�olev��\ral��'��(�q�[�;���x�),���b�qf�ev��\ral��"�9�(�q�;�x�),��band�����hqf�ev��\ral��$�c�(�q�[�;���x�)�J�ev��q�aluate��q����at��x�,��
where��q��is�resp�Gectiv���ely�assumed�to�b�e�a�p�olynomial,��
a�quadratic���form�UU(a�symmetric�matrix),�or�an�Hermitian�form�(an�Hermitian�complex�matrix).����3.7.4�+!factorpadic�(��p��}'ol��
Lȱ;���p;�r���;��f��flag��{=�=�Cq0�g�):��p�-adic���factorization�of�the�p�Golynomial���p��}'ol�����to�precision��r��,���the���result�b�Geing�a�t���w�o-column���matrix�as�in��factor�.�7�The�factors�are�normalized�so�that�their�leading���co�Gecien���t���is�a�p�o���w�er���of��p�.�N,�r���m���ust�b�e�strictly�larger�than�the��p�-adic�v��q�aluation�of�the�discriminan���t���of��4��p��}'ol���ܫfor�4�the�result�to�mak���e�an�y�sense.�fThe�metho�Gd�used�is�a�mo�died�v���ersion�of�the�round�4���algorithm�UUof�Zassenhaus.���;��If��UU�flag��T9�=��1,�UUuse�an�algorithm�due�to�Buc���hmann�and�Lenstra,�whic�h�is�usually�less�ecien�t.����The�UUlibrary�syn���tax�is���f�actorpadic4��B<�(��p��}'ol��
Lȱ;���p;�r�G�),�UUwhere��r��r�is�a��long��in�teger.����3.7.5��in��9tformal�(�x;����f�v�[ٷg�):�hIformal�BYin���tegration�of��x��with�resp�Gect�to�the�main�v��q�ariable�if��v��2�is�omitted,���with��>resp�Gect�to�the�v��q�ariable��v���otherwise.�.�Since�P��*�ARI��.do�es�not�kno���w�ab�out�\abstract"�logarithms���(they�?Jare�immediately�ev��q�aluated,�y�if�only�to�a�p�Go���w�er�?Jseries),�logarithmic�terms�in�the�result�will���yield��-an�error.��O�x��can�b�Ge�of�an���y�t�yp�Ge.��OWhen��x��is�a�rational�function,��cit�is�assumed�that�the�base���ring�UUis�an�in���tegral�domain�of�c�haracteristic�zero.���;��The�UUlibrary�syn���tax�is���in��9teg��?��(�x;���v�[٫),�where��v��.�is�a��long��and�an�omitted��v��is�co�Gded�as���1.����3.7.6�\Opadicappr�(��p��}'ol��
Lȱ;���a�):��v���ector��Qof��p�-adic�ro�Gots�of�the�p�olynomial��pol�۱�congruen���t�to�the��p�-adic���n���um�b�Ger�s|�a��mo�dulo��p��(or�mo�dulo�4�if��p��Y�=�2),�{and�s|with�the�same��p�-adic�precision�as��a�.��=The�n���um�b�er����a�/7�can�b�Ge�an�ordinary��p�-adic�n���um�b�er�/7(t�yp�e�/7�t_PADIC�,�i.e.�an�elemen���t�of��Q����p���R�)�or�can�b�e�an�elemen���t�of���a�8lnite�extension�of��Q����p���R�,�>4in�whic���h�case�it�is�of�t�yp�Ge��t_POLMOD�,�where�at�least�one�of�the�co�ecien���ts���of��ethe�p�Golmo�d��eis�a��p�-adic�n���um�b�Ger.���In��ethis�case,��ithe�result�is�the�v���ector�of�ro�ots�b�elonging�to�the���same�UUextension�of��Q����p���as��a�.���;��The�/�library�syn���tax�is���apprgen9��1st�(��p��}'ol��
Lȱ;���a�),�7obut�if��a��is�kno�wn�to�b�Ge�simply�a��p�-adic�n�um�b�Ger�(t�yp�Ge����t_PADIC�),�UUthe�syn���tax���apprgen��+�ի(��p��}'ol��
Lȱ;���a�)�can�b�Ge�used.��������136����э����Kf�������3.7.7��zp�Q�olco�eff�(�x;���s;��f�v�[ٷg�):�sco�Gecien���t�U�of�degree��s��of�the�p�olynomial��x�,��%with�resp�ect�to�the�main���v��q�ariable�d�if��v��ëis�omitted,��with�resp�Gect�to��v��otherwise.�!�Also�applies�to�p�Go���w�er�d�series,��scalars�(p�olynomial���of�UUdegree�0),�and�to�rational�functions�pro���vided�the�denominator�is�a�monomial.��4���The�|library�syn���tax�is���p�Q�olco�ef�f�0��2��(�x;���s;�v�[٫),���where�|�v���is�a��long��and�an�omitted��v��is�co�Gded�as���1.���Also�UUa���v��q�ailable�is��trueco�Q�eff�(�x;���v�[٫).��i:��3.7.8�VJp�Q�oldegree�(�x;����f�v�[ٷg�):�Rdegree��yof�the�p�Golynomial��x��in�the�main�v��q�ariable�if��v�!R�is�omitted,��in�the���v��q�ariable�UU�v��.�otherwise.�q�This�is�to�b�Ge�understo�o�d�as�follo���ws:����The�UUdegree�of�0�is����VERYBIGINT��7�7�b���y�con�v�en�tion�(�VERYBIGINT��is�2���^��31��
�Ʒ�8�1�for�32-bit�mac�hines�or���2���^��63��
�Ʒ�8�1�UUfor�64-bit�mac���hines).����When�aX�x��is�a�non-zero�scalar,��%its�degree�is�0.� sWhen��x��is�non-zero�p�Golynomial�or�rational�function,���it�UUis�the�ordinary�degree�of��x�.�q�Return�an�error�otherwise.����The�Nvlibrary�syn���tax�is���p�Q�oldegree��3���(�x;���v�[٫),�O�where��v��O�and�the�result�are��long�s�(and�an�omitted��v��is���co�Gded�UUas���1).�q�Also�a���v��q�ailable�is��degree�(�x�),�whic�h�is�equiv��q�alen�t�to��poldegree(�x�,-1)�.��i:��3.7.9���p�Q�olcyclo�(�n;����f�v�"�=���x�g�):�^ϱn�-th�/fcyclotomic�p�Golynomial,�6�in�v��q�ariable��v��?�(�x��b���y�default).�e"The�in�teger����n�UU�m���ust�b�Ge�p�ositiv���e.����The���library�syn���tax�is���cyclo��8�(�n;���v�[٫),�%:where��n��and��v�W�are��long��in�tegers�(�v�W�is�a�v��q�ariable�n�um�b�Ger,���usually�UUobtained�through��varn�).��i:��3.7.10���p�Q�oldisc�(��p��}'ol��
Lȱ;����f�v�[ٷg�):���discriminan���t�rPof�the�p�Golynomial���p��}'ol��1h�in�the�main�v��q�ariable�is��v��)�is�omitted,���in�UU�v��.�otherwise.�q�The�algorithm�used�is�the�subresultan���t�algorithm.����The�)�library�syn���tax�is���p�Q�oldisc0��+��(�x;���v�[٫).�cQAlso�a�v��q�ailable�is��discsr�(�x�),�2�equiv�alen���t�to��poldisc0(x,-���1)�.��i:��3.7.11��#p�Q�oldiscreduced�(�f���):�5�reduced�[email protected]���t�v�ector�of�the�(in�tegral,�o�monic)�p�Golynomial��f���.���This�Bzis�the�v���ector�of�elemen�tary�divisors�of��Z�[��	z�]�=f�����^��0���ȫ(���)�Z�[���],�[email protected]�Bz��K�is�a�ro�Got�of�the�p�olynomial��f���.���The��!comp�Gonen���ts�of�the�result�are�all�p�ositiv���e,���and�their�pro�duct�is�equal�to�the�absolute�v��q�alue�of���the�UUdiscriminan���t�of��f���.����The�UUlibrary�syn���tax�is���reduceddiscsmith��ZKB�(�x�).��i:��3.7.12�-
p�Q�olhensellift�(�x;���y�[�;�p;�e�):�(�giv���en��a�prime��p�,��Ean�in�tegral�p�Golynomial��x��whose�leading�co�ecien���t���is�~ha��p�-unit,��ea�v���ector��y��A�of�in�tegral�p�Golynomials�that�are�pairwise�relativ�ely�prime�mo�Gdulo��p�,��eand�whose���pro�Gduct�nis�congruen���t�to��x��mo�dulo��p�,��Tlift�the�elemen���ts�of��y���to�p�olynomials�whose�pro�duct�is�congruen���t���to�UU�x��mo�Gdulo��p���^��e��KK�.����The�UUlibrary�syn���tax�is���p�Q�olhensellif�t��A�D�(�x;���y�[�;�p;�e�)�UUwhere��e��m�ust�b�Ge�a��long�.��i:��3.7.13���p�Q�olin��9terp�olate�(�xa;����f�y�[�a�g�;��f�v�K!�=��H�x�g�;��f�&�e�g�):��6giv���en�the�data�v�ectors��xa��and��y�[�a��of�the�same���length�t��n��(�xa��con���taining�the��x�-co�Gordinates,�|hand��y�[�a��the�corresp�onding��y�[٫-co�ordinates),�|hthis�function���nds��
the�in���terp�Golating�p�olynomial�passing�through�these�p�oin���ts�and�ev��q�aluates�it�at��v�[٫.��If��y�a��is���omitted,�[Qreturn��the�p�Golynomial�in���terp�olating�the�(�i;���xa�[�i�]).�	L�If�presen���t,�[Q�e��will�con�tain�an�error���estimate�UUon�the�returned�v��q�alue.����The��vlibrary�syn���tax�is���p�Q�olin��9t��"H��(�xa;���y�[�a;�v�;��&�e�),�I~where��v�e��will�con���tain�an�error�estimate�on�the���returned�UUv��q�alue.��������137����$������Kf�������3.7.14��:p�Q�olisirreducible�(��p��}'ol��
Lȫ):��<��p��}'ol���S�b�Geing�:�a�p�olynomial�(univ��q�ariate�in�the�presen���t�v�ersion�2.2.7),���returns���1�if���p��}'ol��b^�is�non-constan���t�and�irreducible,��(0�otherwise.�(Irreducibilit�y�is�c�hec�k�ed�o�v�er�the���smallest�UUbase�eld�o���v�er�UUwhic�h���p��}'ol���r�seems�to�b�Ge�dened.��W��The�UUlibrary�syn���tax�is���gisirreducible��F�E�(��p��}'ol��
Lȫ).�����3.7.15���p�Q�ollead�(�x;����f�v�[ٷg�):���leading�fOco�Gecien���t�of�the�p�olynomial�or�p�o���w�er�fOseries��x�.���This�is�computed���with�UUresp�Gect�to�the�main�v��q�ariable�of��x��if��v��.�is�omitted,�with�resp�ect�to�the�v��q�ariable��v��.�otherwise.����The�Glibrary�syn���tax�is���p�Q�ollead��'_׫(�x;���v�[٫),�I�where��v��ګis�a��long��and�an�omitted��v��is�co�Gded�as���1.�mAlso���a���v��q�ailable�UUis��leadingco�Q�eff�(�x�).�����3.7.16��Tp�Q�ollegendre�(�n;����f�v�"�=���x�g�):�q�creates�UUthe��n���^��th��`�Legendre�p�Golynomial,�in�v��q�ariable��v�[٫.����The�UUlibrary�syn���tax�is���legendre��-���(�n�),�where��x��is�a��long�.����3.7.17���p�Q�olrecip�(��p��}'ol��
Lȫ):��lrecipro�Gcal��(p�olynomial�of���p��}'ol��8�,��i.e.�the�co�ecien���ts�are�in�rev�erse�order.��6?�p��}'ol�����m���ust�UUb�Ge�a�p�olynomial.����The�UUlibrary�syn���tax�is���p�Q�olrecip��+��(�x�).����3.7.18�r�p�Q�olresultan��9t�(�x;���y�[�;��f�v��g�;��f��flag��⮫=���0�g�):��!resultan���t��of�the�t�w�o�p�Golynomials��x��and��y�9۫with�exact���en���tries,���with��[resp�Gect�to�the�main�v��q�ariables�of��x��and��y��4�if��v��is�omitted,���with�resp�Gect�to�the�v��q�ariable����v��.�otherwise.�q�The�UUalgorithm�used�is�the�subresultan���t�algorithm�b�y�default.����If��`��flag��_��=��1,���uses�`�the�determinan���t�of�Sylv�ester's�matrix�instead�(here��x��and��y����ma�y�ha�v�e�non-exact���co�Gecien���ts).����If���a�flag��X�=�D+2,��#uses��aDucos's�mo�Gdied�subresultan���t�algorithm.�R�It�should�b�e�m���uc�h��afaster�than�the���default��2if�the�co�Gecien���t�ring�is�complicated�(e.g�m�ultiv��q�ariate�p�Golynomials�or�h�uge�co�Gecien�ts),�land���sligh���tly�UUslo�w�er�otherwise.����The��blibrary�syn���tax�is���p�Q�olresultan��9t0��El�(�x;���y�[�;�v�;���flag���t�),���where��b�v�@;�is�a��long��and�an�omitted��v��is�co�Gded���as�UU��1.�q�Also�a���v��q�ailable�are���subres��#0��(�x;���y�[٫)�(��flag����=��0)�and���resultan��9t2��5�H�(�x;�y�[٫)�(��flag����=��1).�����3.7.19�&�p�Q�olro�ots�(��p��}'ol��
Lȱ;����f��flag��t��=�=00�g�):��~complex��1ro�Gots�of�the�p�olynomial���p��}'ol�����,���giv���en�as�a�column�v�ector���where�x�eac���h�ro�Got�is�rep�eated�according�to�its�m���ultiplicit�y��*�.�(.The�x�precision�is�giv���en�as�for�transcenden�tal���functions:��under���GP���it�is�k���ept�in�the�v��q�ariable��realprecision��and�is�transparen�t�to�the�user,���but���it�UUm���ust�b�Ge�explicitly�giv�en�as�a�second�argumen�t�in�library�mo�Gde.����The�N�algorithm�used�is�a�mo�Gdication�of�A.�Sc���h����onhage's�ro�ot-nding�algorithm,��?due�to�and���implemen���ted���b�y�X.�Gourdon.�`�Barring�bugs,���it�is�guaran�teed�to�con�v�erge�and�to�giv�e�the�ro�Gots�to���the�UUrequired�accuracy��*�.����If�����flag���{�=��1,��Wuse���a�v��q�arian���t�of�the�Newton-Raphson�metho�Gd,�whic���h�is��not��o�guaran�teed�to�con�v�erge,���but��is�rather�fast.�H	If�y���ou�get�the�messages�\to�Go�man�y�iterations�in�ro�Gots"�or�\INTERNAL���ERR�OR:���incorrect��result�in�ro�Gots",��use�the�default�algorithm.���This�used�to�b�e�the�default�ro�ot-nding���function�UUin�P��*�ARI�un���til�v�ersion�1.39.06.����The�UUlibrary�syn���tax�is���ro�Q�ots��姫(��p��}'ol��
Lȱ;�����pr��}'e�c�����)�or���ro�Q�otsold��,:��(��p��}'ol���;�����pr��}'e�c�����).��������138����4؍����Kf�������3.7.20���p�Q�olro�otsmo�d�(��p��}'ol��
Lȱ;���p;��f��flag����=��0�g�):�UJro���w�[v�ector�of�ro�Gots�mo�dulo��p��of�the�p�olynomial���p��}'ol��i#�.�^�The���particular���non-prime�v��q�alue��p�Nv�=�4���is�accepted,���mainly�for�2-adic�computations.�eqMultiple�ro�Gots�are����not�H-�rep�Geated.��°��If��u�p��<��100,��oy���ou�ma�y�try�setting���flag���Y�=��1,��owhic�h�uses�a�naiv�e�searc�h.�K}In�this�case,��om�ultiple�ro�Gots����ar��}'e���rep�Geated�UUwith�their�order�of�m���ultiplicit�y��*�.����The�UUlibrary�syn���tax�is���ro�Q�otmo�d��.g�(��p��}'ol��
Lȱ;���p�)�(��flag����=��0)�or���ro�Q�otmo�d2��4'�(��p��}'ol���;���p�)�(��flag����=��1).���`��3.7.21��p�Q�olro�otspadic�(��p��}'ol��
Lȱ;���p;�r�G�):�l�ro���w���v�ector�of��p�-adic�ro�Gots�of�the�p�olynomial���p��}'ol���with��p�-adic���precision�� equal�to��r�G�.��)Multiple�ro�ots�are��not����rep�eated.��)�p��is�assumed�to�b�e�a�prime,��Sand���p��}'ol����to�b�e���non-zero�UUmo�Gdulo��p�.����The�UUlibrary�syn���tax�is���ro�Q�otpadic��3ҫ(��p��}'ol��
Lȱ;���p;�r�G�),�UUwhere��r��r�is�a��long�.���`��3.7.22��<p�Q�olsturm�(��p��}'ol��
Lȱ;����f�a�g�;��f�b�g�):�Eqn���um�b�Ger�?*of�real�ro�ots�of�the�real�p�olynomial���p��}'ol����in�the�in���terv��q�al���]�a;���b�],�UUusing�Sturm's�algorithm.�qDZa��(resp.��b�)�is�tak���en�to�b�Ge��1��(resp.�+�1�)�if�omitted.����The��library�syn���tax�is���sturmpart��6���(��p��}'ol��
Lȱ;���a;�b�).�}Use���NULL�d�to�omit�an�argumen�t.�}�sturm�(��p��}'ol��
L��)��is���equiv��q�alen���t�UUto��sturmpart�(��p��}'ol��
L��,NULL,NULL)�.�The�result�is�a��long�.���`��3.7.23��p�Q�olsub�cyclo�(�n;���d;��f�v����=��߱x�g�):���giv���es�r4p�Golynomials�(in�v��q�ariable��v�[٫)�dening�the�sub-Ab�elian���extensions�UUof�degree��d��of�the�cyclotomic�eld��Q�(�����n��q~�),�where��d���j���(�n�).����If�MSthere�is�exactly�one�suc���h�extension�the�output�is�a�p�Golynomial,�N�else�it�is�a�v�ector�of�p�Golyno-���mials,�UUev���en�tually�empt�y��*�.����T��*�o�UUb�Ge�sure�to�get�a�v���ector,�y�ou�can�use��concat([],polsubcyclo(n,d))�����The��Lfunction��galoissubcyclo��allo���ws�to�sp�Gecify�more�closely�whic�h�sub-Ab�Gelian�extension���should�UUb�Ge�computed.����The�\�library�syn���tax�is���p�Q�olsub�cyclo��>�F�(�n;���d;�v�[٫),���where�\��n�,��d��and��v����are��long��and��v��is�a�v��q�ariable���n���um�b�Ger.�jcWhen�?((�Z�=n�Z�)���^������is�cyclic,�C�y���ou�can�use��sub�Q�cyclo�(�n;���d;�v�[٫),�where�?(�n�,��d��and��v���are��long��and��v����is�UUa�v��q�ariable�n���um�b�Ger.���`��3.7.24�UWp�Q�olsylv��9estermatrix�(�x;���y�[٫):�:!forms��	the�Sylv���ester�matrix�corresp�Gonding�to�the�t�w�o�p�Golynomi-���als�Ts�x��and��y�[٫,�T�where�the�co�Gecien���ts�of�the�p�olynomials�are�put�in�the�columns�of�the�matrix�(whic���h���is��Cthe�natural�direction�for�solving�equations�afterw���ards).�I�The�use�of�this�matrix�can�b�Ge�essen�tial���when��dealing�with�p�Golynomials�with�inexact�en���tries,�>since�p�olynomial�Euclidean�division�do�esn't���mak���e�UUm�uc�h�sense�in�this�case.����The�UUlibrary�syn���tax�is���sylv��9estermatrix��PК�(�x;���y�[٫).���`��3.7.25��p�Q�olsym�(�x;���n�):�]�creates�-the�v���ector�of�the�symmetric�p�Go�w�ers�of�the�ro�Gots�of�the�p�olynomial��x����up�UUto�p�Go���w�er�UU�n�,�using�Newton's�form���ula.����The�UUlibrary�syn���tax�is���p�Q�olsym��',��(�x�).���`��3.7.26��Tp�Q�oltc��9hebi�(�n;����f�v�"�=���x�g�):�q�creates�UUthe��n���^��th��`�Cheb���yshev�p�Golynomial,�in�v��q�ariable��v�[٫.����The�UUlibrary�syn���tax�is���tc��9hebi��!��(�n;���v�[٫),�where��n��and��v��.�are��long��in�tegers�(�v��.�is�a�v��q�ariable�n�um�b�Ger).��������139����DD�����Kf�������3.7.27���p�Q�olzagier�(�n;���m�):���creates�SIZagier's�p�Golynomial��P����:��c��(�m�)��]"��n����u�used�in�the�functions��sumalt��and��sumpos����(with���R�flag�����=��e1).�1�One��Rm���ust�ha�v�e��m��e���n�.�1�The��Rexact�denition�can�b�Ge�found�in�\Con�v�ergence���acceleration�UUof�alternating�series",�Cohen�et�al.,�Exp�Gerimen���t.�Math.,�v�ol.�9,�2000,�pp.�3{12.���⍑The�0�library�syn���tax�is���p�Q�olzagreel��5��(�n;���m;���pr��}'e�c�����)�0�if�the�result�is�only�w�an�ted�as�a�p�Golynomial�with���real�G�co�Gecien���ts�to�the�precision���pr��}'e�c��Z�,�J�or���p�Q�olzag��#�y�(�n;���m�)�if�the�result�is�w�an�ted�exactly��*�,�J�where��n��and����m�UU�are��long�s.��⧍�3.7.28�[isercon��9v�ol�(�x;���y�[٫):�Z�con���v�olution���(or�Hadamard�pro�Gduct)�of�the�t���w�o���p�o�w�er���series��x��and��y�[٫;�8in���other�UUw���ords�if��x���=������P�����a����k��$p��8�X�����^��k��		ǫand�UU�y�"�=������P���b����k��$p��8�X�����^��k��		ǫthen��UU�serconvol��2�:�(�x;���y�[٫)�=������P���a����k��$p��8�b����k�����X�����^��k���r�.����The�UUlibrary�syn���tax�is���con��9v�ol��"�J�(�x;���y�[٫).��⧍�3.7.29�%serlaplace�(�x�):�8i�x�8��m���ust�b�Ge�a�p�o���w�er�8�series�with�only�non-negativ���e�exp�onen���ts.�
�If��x�웫=��������P��
�;�(�a����k��됱=k�P��!)�8���X�����^��k��		ǫthen�UUthe�result�is������P���8�a����k��$p��8�X�����^��k���r�.����The�UUlibrary�syn���tax�is���laplace��%�c�(�x�).��⧍�3.7.30�serrev��9erse�(�x�):� _rev���erse���p�Go�w�er�series�(i.e.��x���^���1��
�t�,��not�1�=x�)�of��x�.�;��x��m�ust�b�Ge�a�p�o���w�er�series�whose���v��q�aluation�UUis�exactly�equal�to�one.����The�UUlibrary�syn���tax�is���recip��ܫ(�x�).��⧍�3.7.31��Xsubst�(�x;���y�[�;�z�p��):�/replace�3�the�simple�v��q�ariable��y��ͫb���y�the�argumen�t��z����in�the�\p�Golynomial"�ex-���pression����x�.��Ev���ery�t�yp�Ge�is�allo�w�ed�for��x�,�̗but�if�it�is�not�a�gen�uine�p�Golynomial�(or�p�o���w�er���series,�̗or���rational��function),�Vthe�substitution�will�b�Ge�done�as�if�the�scalar�comp�onen���ts�w�ere�p�Golynomials�of���degree�UUzero.�q�In�particular,�b�Gew���are�that:�����?�?�subst(1,�x,�[1,2;�3,4])����%1�?�=����[1�?�0]����[0�?�1]����?�?�subst(1,�x,�Mat([0,1]))�����***���forbidden�?�substitution�by�a�non�square�matrix����If�UU�x��is�a�p�Go���w�er�UUseries,��z���m���ust�b�e�either�a�p�olynomial,�a�p�o���w�er�UUseries,�or�a�rational�function.����The�}\v��q�ariable"��y�pV�is�in�fact�allo���w�ed�}to�b�Ge�an���y�p�olynomial,�DFin�whic���h�case,�the�substitution�is���done�UUas�p�Ger�the�follo���wing�script:����#���subst_poly(pol,�?�from,�to)�=����#��{�?�local(t�=�'subst_poly_t,�M�=�from�-�t);����.?�subst(lift(Mod(pol,M),�?�variable(M)),�t,�to)����#��}����F��*�or�UUinstance�����?�?�subst(x^4�+�x^2�+�1,�x^2,�y)����%1�?�=�y^2�+�y�+�1����?�?�subst(x^4�+�x^2�+�1,�x^3,�y)����%2�?�=�x^2�+�y*x�+�1����?�?�subst(x^4�+�x^2�+�1,�(x+1)^2,�y)����%3�?�=�(-4*y�-�6)*x�+�(y^2�+�3*y�-�3)�����The��]library�syn���tax�is���gsubst��"�ͫ(�x;���v�[�;�z�p��),��(where��]�v�!6�is�the�n�um�b�Ger�of�the�v��q�ariable��y�!6�for�regular�usage.���Also�UUa���v��q�ailable�is��gsubst0�(�x;���y�[�;�z�p��)�UUwhere��y��.�is�a��GEN��p�Golynomial.��������140����S]�����Kf�������3.7.32��ta��9ylor�(�x;���y�[٫):��nT��*�a���ylor���expansion�around�0�of��x��with�resp�Gect�to�the�simple�v��q�ariable��y��.���x��can���b�Ge�Rof�an���y�reasonable�t�yp�Ge,�R�for�example�a�rational�function.�p�The�n�um�b�Ger�of�terms�of�the�expansion���is�UUtransparen���t�to�the�user�under�GP��*�,�but�m�ust�b�Ge�giv�en�as�a�second�argumen�t�in�library�mo�Gde.��9;��The�#�library�syn���tax�is���ta��9yl��%L�(�x;���y�[�;�n�),�-�where�#�the��long��in�teger��n��is�the�desired�n�um�b�Ger�of�terms�in���the�UUexpansion.��rv��3.7.33��th��9ue�(��tnf��!g�;���a;��f��sol����g�):�b$solv���es�M�the�equation��P�c��(�x;���y�[٫)�d�=��a�M��in�in�tegers��x��and��y�[٫,���where���tnf���m�w�as���created�Lwith���thueinit��.4�(�P�c��).�����sol��{��,�EJif�presen���t,�con�tains�Lthe�solutions�of��Norm���P(�x�)�=��a�L�mo�Gdulo�units���of�"	p�Gositiv���e�norm�in�the�n�um�b�Ger�eld�dened�b�y��P����(as�computed�b�y��bnfisintnorm�).���If���tnf��ey�w�as���computed��5without�assuming�GRH��
(��flag����=��1�in��thueinit�),��<the�result�is�unconditional.�9F��*�or�instance,���here's�UUho���w�to�solv�e�the�Th�ue�equation��x���^��13��
�Ʒ�8�5�y��[ٟ�^��13���׫=����4:��LO���?�?�tnf�=�thueinit(x^13�-�5);����?�?�thue(tnf,�-4)����%1�?�=�[[1,�1]]�����Hence,�UUassuming�GRH,�the�only�solution�is��x���=�1,�UU�y�"�=�1.����The�UUlibrary�syn���tax�is���th��9ue���ܫ(��tnf��!g�;���a;���sol��t��),�UUwhere�an�omitted���sol��t��is�co�Gded�as��NULL�.��rv��3.7.34��th��9ueinit�(�P�G;����f��flag���(�=�Z\0�g�):�U�initializes�GLthe���tnf�����corresp�Gonding�to��P�c��.�G�It�is�mean���t�to�b�e�used���in�-�conjunction�with��thue��to�solv���e�Th�ue�equations��P�c��(�x;���y�[٫)�0=��a�,�dwhere�-�a��is�an�in�teger.��kIf���flag�����is���non-zero,�4certify��the�result�unconditionnally��*�,�Otherwise,�assume�GRH,�this�b�Geing�m���uc�h��faster�of���course.����The�UUlibrary�syn���tax�is���th��9ueinit��*�֫(�P�G;�����flag���t�;�����pr��}'e�c�����).��$����3.8��V���ectors,�matrices,�linear�algebra�and�sets�.��LO��Note���that�most�linear�algebra�functions�op�Gerating�on�subspaces�dened�b���y�generating�sets���(suc���h��as��mathnf�,�,��qflll�,�etc.)�vNtak�e��matrices�as�argumen�ts.�vNAs�usual,�,�the�generating�v�ectors�are���tak���en�UUto�b�Ge�the��c��}'olumns�'v�of�the�giv�en�matrix.��rv��3.8.1�j algdep�(�x;���k�P�;��f��flag��ֈ�=���0�g�):�t��x�ָ�b�Geing�real,��complex,�or�ָ�p�-adic,�nds�a�p�Golynomial�of�degree�at���most�zU�k���with�in���teger�co�Gecien�ts�ha�ving��x��as�appro�ximate�ro�Got.���Note�that�the�p�olynomial�whic���h�is���obtained��is�not�necessarily�the�\correct"�one�(it's�not�ev���en�guaran�teed�to�b�Ge�irreducible!).�]�One�can���c���hec�k�Fthe�closeness�either�b���y�a�p�Golynomial�ev��q�aluation�or�substitution,��or�b�y�computing�the�ro�Gots�of���the�UUp�Golynomial�giv���en�b�y�algdep.����If���x��is��p�-adic,��޵�flag��׍�is�meaningless�and�the�algorithm�LLL-reduces�the�\dual�lattice"�corresp�Gond-���ing�UUto�the�p�Go���w�ers�UUof��x�.����Otherwise,�3if��*��flag����is�*�zero,�the�algorithm�used�is�a�v��q�arian���t�of�the�LLL�*�algorithm�due�to�Hastad,���Lagarias�k�and�Sc���hnorr�(ST��*�A�CS�k�1986).��[If�the�precision�is�to�Go�lo�w,�qthe�routine�ma�y�en�ter�an�innite���lo�Gop.����If����flag��M�is��non-zero,���use�a�standard�LLL.���flag���then�indicates�a�precision,���whic���h�should�b�Ge�b�et���w�een���0�:�5�UUand�1�:�0�times�the�n���um�b�Ger�UUof�decimal�digits�to�whic���h��x��w�as�computed.����The��ilibrary�syn���tax�is���algdep0��*��(�x;���k�P�;���flag���t�;���pr��}'e�c�����),��where��i�k��and���flag��Ğ�are��long�s.��Also�a�v��q�ailable�is�����algdep�� �I�(�x;���k�P�;���pr��}'e�c�����)�UU(��flag����=��0).��������141����`⍟���Kf�������3.8.2��c��9harp�Q�oly�(�A;����f�v�"�=���x�g�;��f��flag����=�0�g�):�Lc���haracteristic��_p�Golynomial�of��A��with�resp�ect�to�the�v��q�ariable����v�[٫,�Jei.e.�G�determinan���t�of��v�ya����I��j���A�G��if��A��is�a�square�matrix,�determinan���t�of�the�map�\m�ultiplication�b�y����A�"���if��A��is�a�scalar,��]in�particular�a�p�Golmo�d���(e.g.��charpoly(I,x)=x^2+1�).�Note�that�in�the�latter���case,�UUthe�minimal�p�Golynomial�can�b�e�obtained�as��hO���minpoly(A)=����{�����local(y);�����y�?�=�charpoly(A);�����y�?�/�gcd(y,y')����}��N;��The�UUv��q�alue�of���flag���v�is�only�signican���t�for�matrices.����If���6�flag���:�=��80,�ݮthe��6metho�Gd�used�is�essen���tially�the�same�as�for�computing�the�adjoin�t�matrix,���i.e.�UUcomputing�the�traces�of�the�p�Go���w�ers�UUof��A�.����If��UU�flag��T9�=��1,�UUuses�Lagrange�in���terp�Golation�whic�h�is�almost�alw�a�ys�slo�w�er.����If��74�flag��6�=��2,�=;uses�74the�Hessen���b�Gerg�form.�g�This�is�faster�than�the�default�when�the�co�ecien���ts�are���in���tegermo�Gd�UUa�prime�or�real�n�um�b�Gers,�but�is�usually�slo�w�er�in�other�base�rings.����The�
library�syn���tax�is���c��9harp�Q�oly0��5�(�A;���v�[�;���flag���t�),�;�where�
�v�iX�is�the�v��q�ariable�n�um�b�Ger.��DAlso�a�v��q�ailable���are�B3the�functions���caract��!ޘ�(�A;���v�[٫)�(��flag����=��1),��F�carhess��'qY�(�A;�v�[٫)�(��flag����=��2),�Fand���caradj��"0_�(�A;�v�[�;���pt��k�)�where,�Fin���this��Slast�case,���S�pt��4i�is�a��GEN*��whic���h,��Sif�not�equal�to��NULL�,�will�receiv�e�the�address�of�the�adjoin�t�matrix���of�UU�A��(see��matadjoint�),�so�b�Goth�can�b�e�obtained�at�once.���v��3.8.3�b�concat�(�x;����f�y�[ٷg�):�@
concatenation���of��x��and��y��.�P�If��x��or��y�M��is�not�a�v���ector�or�matrix,��it�is�considered���as��a�one-dimensional�v���ector.���All�t�yp�Ges�are�allo�w�ed�for��x��and��y�[٫,��~but�the�sizes�m�ust�b�Ge�compatible.���Note�ۨthat�matrices�are�concatenated�horizon���tally��*�,��=i.e.�the�n�um�b�Ger�of�ro�ws�sta�ys�the�same.��Using���transp�Gositions,�UUit�is�easy�to�concatenate�them�v���ertically��*�.����T��*�o�=�concatenate�v���ectors�sidew�a�ys�(i.e.�to�obtain�a�t�w�o-ro�w�or�t�w�o-column�matrix),�u�rst�transform���the��v���ector�in�to�a�one-ro�w�or�one-column�matrix�using�the�function��Mat�.�<�Concatenating�a�ro�w�v�ector���to�Ra�matrix�ha���ving�the�same�n�um�b�Ger�of�columns�will�add�the�ro�w�to�the�matrix�(top�ro�w�if�the���v���ector�UUis��x�,�i.e.�comes�rst,�and�b�Gottom�ro�w�otherwise).����The�
�empt���y�matrix��[;]�#��is�considered�to�ha�v�e�a�n�um�b�Ger�of�ro�ws�compatible�with�an�y�op�Geration,���in�E\particular�concatenation.�A�(Note�that�this�is�denitely��not�84�the�case�for�empt���y�v�ectors��[�?�]��or����[�?�]��&f~���.)����If�.p�y��I�is�omitted,�67�x��has�to�b�Ge�a�ro���w�v�ector�or�a�list,�67in�whic�h�case�its�elemen�ts�are�concatenated,���from�UUleft�to�righ���t,�using�the�ab�Go�v�e�rules.��hO���?�?�concat([1,2],�[3,4])����%1�?�=�[1,�2,�3,�4]����?�?�a�=�[[1,2]��&f~��,�[3,4]��&f~��];�concat(a)����%2�?�=�[1,�2,�3,�4]��&f~�����?�?�a[1]�=�Mat(a[1]);�concat(a)����%3�?�=����[1�?�3]��4(��[2�?�4]����?�?�concat([1,2;�3,4],�[5,6]��&f~��)��������142����ps�����Kf�����卑�%4�?�=��N퍑[1�?�2�5]���ڍ�[3�?�4�6]����?�?�concat([%,�[7,8]��&f~��,�[1,2,3,4]])����%5�?�=����[1�?�2�5�7]����[3�?�4�6�8]����[1�?�2�3�4]���ƍ��The�UUlibrary�syn���tax�is���concat��#���(�x;���y�[٫).��ٌ��3.8.4�*�lindep�(�x;����f��flag����=��0�g�):�x���b�Geing�a�v���ector�with�real�or�complex�co�ecien���ts,�ޫnds�a�small�in�tegral���linear�UUcom���bination�among�these�co�Gecien�ts.����If��1��flag��0��=��0,�8�uses�1�a�v��q�arian���t�of�the�LLL�1�algorithm�due�to�Hastad,�Lagarias�and�Sc���hnorr�(ST��*�A�CS���1986).����If��4��flag��3v�>���0,�;uses�4�the�LLL�4�algorithm.��f��flag���9�is�a�parameter�whic���h�should�b�Ge�b�et���w�een�4�one�half�the���n���um�b�Ger�UUof�decimal�digits�of�precision�and�that�n���um�b�er�UU(see��algdep�).����If��:��flag��9б<���0,�@4�x�:�is�allo���w�ed�:�to�b�Ge�(and�in�an���y�case�in�terpreted�as)�a�matrix.�h�Returns�a�non�trivial���elemen���t�UUof�the�k�ernel�of��x�,�or�0�if��x��has�trivial�k�ernel.����The�UUlibrary�syn���tax�is���lindep0��'�׫(�x;�����flag���t�;�����pr��}'e�c�����).�q�Also�a�v��q�ailable�is���lindep��"(٫(�x;�����pr��}'e�c�����)�(��flag����=��0).��ٌ��3.8.5��Tlistcreate�(�n�):�q�creates�UUan�empt���y�list�of�maximal�length��n�.����This�UUfunction�is�useless�in�library�mo�Gde.����3.8.6��zlistinsert�(��list��
�[�;���x;�n�):��inserts���the�ob��8ject��x��at�p�Gosition��n��in���list��;�(whic���h�m�ust�b�Ge�of�t�yp�Ge��t_LIST�).���All�?the�remaining�elemen���ts�of���list��y��(from�p�Gosition��n�d�+�1�?on�w�ards)�are�shifted�to�the�righ�t.�j]This�and����listput�*<�are�the�only�commands�whic���h�enable�y�ou�to�increase�a�list's�eectiv�e�length�(as�long�as�it���remains�UUunder�the�maximal�length�sp�Gecied�at�the�time�of�the��listcreate�).���ƍ�This�UUfunction�is�useless�in�library�mo�Gde.����3.8.7�l�listkill�(��list��
�[�):�x�kill�����list���1�.��JThis���deletes�all�elemen���ts�from���list����and�sets�its�eectiv�e�length�to�0.���The�UUmaximal�length�is�not�aected.���ƍ�This�UUfunction�is�useless�in�library�mo�Gde.����3.8.8��Nlistput�(��list��
�[�;���x;��f�n�g�):��!sets��the��n�-th�elemen���t�of�the�list���list���_�(whic�h�m�ust�b�Ge�of�t�yp�Ge��t_LIST�)���equal��uto��x�.�M'If��n��is�omitted,���or�greater�than�the�list�curren���t�eectiv�e�length,���just�app�Gends��x�.�M'This���and����listinsert��are�the�only�commands�whic���h�enable�y�ou�to�increase�a�list's�eectiv�e�length�(as���long�UUas�it�remains�under�the�maximal�length�sp�Gecied�at�the�time�of�the��listcreate�).���ƍ�If��#y���ou�w�an�t�to�put�an�elemen�t�in�to�an�o�Gccupied�cell,��.i.e.�if�y�ou�don't�w�an�t�to�c�hange�the�eectiv�e���length,�UUy���ou�can�consider�the�list�as�a�v�ector�and�use�the�usual��list[n]�?�=�x�UU�construct.����This�UUfunction�is�useless�in�library�mo�Gde.��������143����}֍����Kf�������3.8.9�dlistsort�(��list��
�[�;����f��flag��Gq�=��0�g�):���sorts�����list����(whic���h���m�ust�b�Ge�of�t�yp�Ge��t_LIST�)���in�place.��`If���flag��9��is�non-���zero,�C�suppresses�?all�rep�Geated�co�ecien���ts.�j_This�is�m�uc�h�faster�than�the��vecsort��command�since�no���cop���y�UUhas�to�b�Ge�made.���T��This�UUfunction�is�useless�in�library�mo�Gde.�����3.8.10�matadjoin��9t�(�x�):���adjoin���t���matrix�of��x�,��{i.e.�the�matrix��y�糫of�cofactors�of��x�,�satisfying��x�]8���y�}Ϋ=����det��
�(�x�)�8����Id��c�.�qDZx�UU�m���ust�b�Ge�a�(non-necessarily�in�v�ertible)�square�matrix.����The�UUlibrary�syn���tax�is���adj��Ӈ�(�x�).�����3.8.11��Tmatcompanion�(�x�):�q�the�UUleft�companion�matrix�to�the�p�Golynomial��x�.����The�UUlibrary�syn���tax�is���assmat��%�3�(�x�).����3.8.12��Tmatdet�(�x;����f��flag����=��0�g�):�q�determinan���t�UUof��x�.��x��m���ust�b�Ge�a�square�matrix.����If��UU�flag��T9�=��0,�UUuses�Gauss-Bareiss.����If�����flag��k�=���1,�&}uses���classical�Gaussian�elimination,�whic���h�is�b�Getter�when�the�en�tries�of�the�ma-���trix�7are�reals�or�in���tegers�for�example,�okbut�usually�m�uc�h�w�orse�for�more�complicated�en�tries�lik�e���m���ultiv��q�ariate�UUp�Golynomials.����The�UUlibrary�syn���tax�is���det��w�(�x�)�(��flag����=��0)�and���det2��7�(�x�)�(��flag���=��1).�����3.8.13��matdetin��9t�(�x�):���x���b�Geing�an��m�c���n���matrix�with�in���teger�co�ecien���ts,��this�function�computes���a���multiple�lb�of�the�determinan���t�of�the�lattice�generated�b�y�the�columns�of��x��if�it�is�of�rank��m�,���and���returns�vzero�otherwise.�s)This�function�can�b�Ge�useful�in�conjunction�with�the�function��mathnfmod����whic���h���needs�to�kno�w�suc�h�a�m�ultiple.��T��*�o�obtain�the�exact�determinan�t�(assuming�the�rank�is���maximal),�UUy���ou�can�compute��matdet(mathnfmod(x,�?�matdetint(x)))�.����Note��$that�as�so�Gon�as�one�of�the�dimensions�gets�large�(�m��or��n��is�larger�than�20,���sa���y),�it��$will���often�UUb�Ge�m���uc�h�UUfaster�to�use��mathnf(x,�?�1)��or��mathnf(x,�4)��directly��*�.����The�UUlibrary�syn���tax�is���detin��9t��!3��(�x�).�����3.8.14��matdiagonal�(�x�):�a#�x�4
�b�Geing�a�v���ector,�:�creates�the�diagonal�matrix�whose�diagonal�en�tries�are���those�UUof��x�.����The�UUlibrary�syn���tax�is���diagonal��-.'�(�x�).�����3.8.15��Tmateigen�(�x�):�q�giv���es�UUthe�eigen�v�ectors�of��x��as�columns�of�a�matrix.����The�UUlibrary�syn���tax�is���eigen��5M�(�x�).����3.8.16��Tmathess�(�x�):�q�Hessen���b�Gerg�UUform�of�the�square�matrix��x�.����The�UUlibrary�syn���tax�is���hess����(�x�).����3.8.17�&�mathilb�Q�ert�(�x�):�%�x����b�Geing�a��long�,���creates�the�Hilb�ert�matrix�of�order��x�,���i.e.�the�matrix�whose���co�Gecien���t�UU(�i�,�j����)�is�1�=�(�i�8�+��j��k���1).����The�UUlibrary�syn���tax�is���mathilb�Q�ert��8�(�x�).��������144�����������Kf�������3.8.18�ɀmathnf�(�x;����f��flag����=��0�g�):�l�if�K�x��is�a�(not�necessarily�square)�matrix,�Mnds�the��upp��}'er��ptriangular����Hermite��"normal�form�of��x�.��.If�the�rank�of��x��is�equal�to�its�n���um�b�Ger��"of�ro���ws,��the�result�is�a�square���matrix.�eIn�/!general,�6�the�columns�of�the�result�form�a�basis�of�the�lattice�spanned�b���y�the�columns�of����x�.������If��/�flag���=��0,�uses�/the�naiv���e�algorithm.�Z�This�should�nev�er�b�Ge�used�if�the�dimension�is�at�all�large���(larger��than�10,��sa���y).�V�It�is�recommanded�to�use�either��mathnfmod(x,�?�matdetint(x))��(when��x��has���maximal��rank)�or��mathnf(x,�?�1)�.��Note�that�the�latter�is�in�general�faster�than��mathnfmod�,�>[and���also�UUpro���vides�a�base�c�hange�matrix.����If����flag��l��=�e1,�P�uses��Batut's�algorithm,�whic���h�is�m�uc�h�faster�than�the�default.��UOutputs�a�t�w�o-���comp�Gonen���t���ro�w�v�ector�[�H�A�;���U��],��cwhere��H�r��is�the��upp��}'er��Vtriangular����Hermite�normal�form�of��x��dened���as�\ab�Go���v�e,�]�and��U�s2�is�the�unimo�Gdular�transformation�matrix�suc�h�that��xU��v�=��[[0�j�H����].��
�U�s2�has�in�general���h���uge�UUco�Gecien�ts,�in�particular�when�the�k�ernel�is�large.����If�����flag��텫=���3,�1uses���Batut's�algorithm,�but�outputs�[�H�A�;���U���;�P�c��],�suc���h���that��H��Ыand��U��are�as�b�Gefore���and���P��is�a�p�Germ���utation�of�the�ro�ws�suc�h�that��P��applied�to��xU���giv�es��H����.�!�The�matrix��U���is�smaller���than�UUwith���flag��T9�=��1,�but�ma���y�still�b�Ge�large.����If�����flag���
�=��|4,��`as���in�case�1�ab�Go���v�e,�but���uses�a�heuristic�v��q�arian���t�of�LLL�ףreduction�along�the�w�a�y��*�.���The��pmatrix��U�ߋ�is�in�general�close�to�optimal�(in�terms�of�smallest��L����2��D�norm),��6but�the�reduction�is���slo���w�er�UUthan�in�case�1.����The��Zlibrary�syn���tax�is���mathnf�0��.�e�(�x;�����flag���t�).���Also�a�v��q�ailable�are���hnf��'�(�x�)�(��flag�����=���0)�and���hnf�all��!!��(�x�)���(��flag����=��1).�l�T��*�o�F�reduce��huge�.�(sa���y�400�ܷ��400�F�and�more)�relation�matrices�(sparse�with�small�en�tries),���y���ou�Lcan�use�the�pair��hnfspec��/��hnfadd�.�U�Since�this�is�rather�tec�hnical�and�the�calling�in�terface�ma�y���c���hange,�UUthey�are�not�do�Gcumen�ted�y�et.�q�Lo�Gok�at�the�co�de�in��basemath/alglin1.c�.����3.8.19��mathnfmo�Q�d�(�x;���d�):��if��бx��is�a�(not�necessarily�square)�matrix�of�maximal�rank�with�in���teger���en���tries,�I�and�Fñd��is�a�m�ultiple�of�the�(non-zero)�determinan�t�of�the�lattice�spanned�b�y�the�columns�of����x�,�UUnds�the��upp��}'er���triangular�h�Hermite�normal�form�of��x�.����If��the�rank�of��x��is�equal�to�its�n���um�b�Ger��of�ro���ws,���the�result�is�a�square�matrix.�^In�general,�the���columns�^�of�the�result�form�a�basis�of�the�lattice�spanned�b���y�the�columns�of��x�.��jThis�is�m�uc�h�faster���than�UU�mathnf��when��d��is�kno���wn.����The�UUlibrary�syn���tax�is���hnf�mo�Q�d��*���(�x;���d�).����3.8.20���mathnfmo�Q�did�(�x;���d�):���outputs��ethe�(upp�Ger�triangular)�Hermite�normal�form�of��x��concate-���nated�UUwith��d��times�the�iden���tit�y�UUmatrix.����The�UUlibrary�syn���tax�is���hnf�mo�Q�did��4W
�(�x;���d�).����3.8.21��Tmatid�(�n�):�q�creates�UUthe��n�8���n�UU�iden���tit�y�matrix.����The�UUlibrary�syn���tax�is���idmat�� ��(�n�)�where��n��is�a��long�.����Related��functions�are���gscalmat��/٧�(�x;���n�),�1�whic���h�creates��x��times�the�iden�tit�y�matrix�(�x��b�Geing�a����GEN�UU�and��n��a��long�),�and���gscalsmat��3�g�(�x;���n�)�whic���h�is�the�same�when��x��is�a��long�.����3.8.22�	�matimage�(�x;����f��flag���:�=��n0�g�):���giv���es�a�a�basis�for�the�image�of�the�matrix��x��as�columns�of�a���matrix.�m;A�G�priori�G�the�matrix�can�ha���v�e�G�en�tries�of�an�y�t�yp�Ge.�m;If���flag��F��=��0,�Jluse�standard�Gauss�piv�ot.�m;If�����flag����=��1,�UUuse��matsupplement�.����The�UUlibrary�syn���tax�is���matimage0��:#�(�x;�����flag���t�).�q�Also�a�v��q�ailable�is���image�� �ث(�x�)�(��flag����=��0).��������145�����������Kf�������3.8.23���matimagecompl�(�x�):�ڙgiv���es�	�the�v�ector�of�the�column�indices�whic�h�are�not�extracted�b�y���the��Mfunction��matimage�.�+�Hence�the�n���um�b�Ger��Mof�comp�onen���ts�of��matimagecompl(x)��plus�the�n�um�b�Ger���of�UUcolumns�of��matimage(x)��is�equal�to�the�n���um�b�Ger�UUof�columns�of�the�matrix��x�.�����The�UUlibrary�syn���tax�is���imagecompl��>��(�x�).���]��3.8.24�\matindexrank�(�x�):�=
�x���b�Geing�a�matrix�of�rank��r��,��giv���es�t�w�o�v�ectors��y�G��and��z�\x�of�length��r�2��giving���a��list�of�ro���ws�and�columns�resp�Gectiv�ely�(starting�from�1)�suc�h�that�the�extracted�matrix�obtained���from�UUthese�t���w�o�UUv�ectors�using���vecextract��7�7�(�x;���y�[�;�z�p��)�is�in���v�ertible.����The�UUlibrary�syn���tax�is���indexrank��5n'�(�x�).���]��3.8.25�œmatin��9tersect�(�x;���y�[٫):�q�x�#��and��y���b�Geing�t���w�o�#�matrices�with�the�same�n���um�b�er�#�of�ro���ws�eac�h�of���whose��columns�are�indep�Genden���t,�Ends�a�basis�of�the��Q�-v�ector�space�equal�to�the�in�tersection�of�the���spaces�!�spanned�b���y�the�columns�of��x��and��y�}��resp�Gectiv�ely��*�.���See�also�the�function��idealintersect�,���whic���h�UUdo�Ges�the�same�for�free��Z�-mo�dules.����The�UUlibrary�syn���tax�is���in��9tersect��.wi�(�x;���y�[٫).���]��3.8.26���matin��9v�erseimage�(�x;���y�[٫):��<giv���es�[email protected]�column�v�ector�b�Gelonging�to�the�in�v�erse�image�of�the�column���v���ector�f�y�]?�b�y�the�matrix��x��if�one�exists,�,jthe�empt�y�v�ector�otherwise.�u�T��*�o�get�the�complete�in�v�erse���image,���it��.suces�to�add�to�the�result�an���y�elemen�t�of�the�k�ernel�of��x��obtained�for�example�b�y��matker�.����The�UUlibrary�syn���tax�is���in��9v�erseimage��C���(�x;���y�[٫).���]��3.8.27��Tmatisdiagonal�(�x�):�q�returns�UUtrue�(1)�if��x��is�a�diagonal�matrix,�false�(0)�if�not.����The�UUlibrary�syn���tax�is���isdiagonal��4�)�(�x�),�and�this�returns�a��long��in�teger.����3.8.28���matk��9er�(�x;����f��flag����=��0�g�):�b�giv���es�7ga�basis�for�the�k�ernel�of�the�matrix��x��as�columns�of�a�matrix.���A�UUpriori�the�matrix�can�ha���v�e�UUen�tries�of�an�y�t�yp�Ge.����If�UU�x��is�kno���wn�to�ha�v�e�in�tegral�en�tries,�set���flag��T9�=��1.���>��Note:��The���library�function���FpM���E�ff&f��ǫker��%с�(�x;���p�),���where��x��has�in���teger�en�tries��r��}'e�duc�e�d���mo�d�p�+��and���p��is�prime,���is�ܴequiv��q�alen���t�to,���but�orders�of�magnitude�faster�than,��matker(x*Mod(1,p))��and�needs�m���uc�h�ܴless���stac���k�UUspace.�q�T��*�o�use�it�under�GP�,�t���yp�Ge��install(FpM���E�ff&f��ǫker,�?�GG)��rst.����The��tlibrary�syn���tax�is���matk��9er0��+���(�x;�����flag���t�).�,�Also�a�v��q�ailable�are���k��9er��H7�(�x�)�(��flag����=��0),�����k��9eri���]�(�x�)�(��flag���=��1)���and��UU�FpM���E�ff&f��ǫker��&��(�x;���p�).���]��3.8.29���matk��9erin�t�(�x;����f��flag����=��0�g�):�iZgiv���es�D{an�LLL-reduced��Z�-basis�for�the�lattice�equal�to�the�k�ernel���of�޺the�matrix��x��as�columns�of�the�matrix��x��with�in���teger�en�tries�(rational�en�tries�are�not�p�Germitted).����If��UU�flag��T9�=��0,�UUuses�a�mo�Gdied�in���teger�LLL�algorithm.����If����flag���q�=�
�1,��huses����matrixqz��-��(�x;�����2).��'If��LLL��reduction�of�the�nal�result�is�not�desired,�y���ou�can���sa���v�e�UUtime�using��matrixqz(matker(x),-2)��instead.����The�UUlibrary�syn���tax�is���matk��9erin�t0��:8Ы(�x;�����flag���t�).�q�Also�a�v��q�ailable�is���k��9erin�t�� Ӆ�(�x�)�(��flag����=��0).���]��3.8.30�~ematm��9uldiagonal�(�x;���d�):���pro�Gduct��Xof�the�matrix��x��b���y�the�diagonal�matrix�whose�diagonal���en���tries�UUare�those�of�the�v�ector��d�.�q�Equiv��q�alen�t�to,�but�m�uc�h�faster�than��x�8����matdiagonal��;���(�d�).����The�UUlibrary�syn���tax�is���matm��9uldiagonal��S�Q�(�x;���d�).��������146�����N�����Kf�������3.8.31�HAmatm��9ulto�Q�diagonal�(�x;���y�[٫):�9�pro�Gduct��Dof�the�matrices��x��and��y��assuming�that�the�result�is�a���diagonal��Omatrix.�D�Muc���h�faster�than��x�*շ��y�*(�in��Othat�case.�The�result�is�undened�if��x�*շ��y�*(�is��Onot�diagonal.������The�UUlibrary�syn���tax�is���matm��9ulto�Q�diagonal��^6��(�x;���y�[٫).���l��3.8.32��!matpascal�(�x;����f�q�[ٷg�):���creates�c�as�a�matrix�the�lo���w�er�c�triangular�P���ascal�triangle�of�order��x�B��+�1���(i.e.�I�with�binomial�co�Gecien���ts�up�to��x�).�N�If��q��y�is�giv�en,���compute�the��q�[٫-P�ascal�triangle�(i.e.�using����q�[٫-binomial�UUco�Gecien���ts).����The��Clibrary�syn���tax�is���matqpascal��;���(�x;���q�[٫),��~where��x��is�a��long��and��q�}�=�����NULL��~۫is�used�to�omit��q��.���Also�UUa���v��q�ailable�is���matpascal��5cҫ(�x�).���l��3.8.33��Tmatrank�(�x�):�q�rank�UUof�the�matrix��x�.����The�UUlibrary�syn���tax�is���rank��0�(�x�),�and�the�result�is�a��long�.����3.8.34���matrix�(�m;���n;��f�X���g�;��f�Y�8�g�;��f��expr��.I�=���0�g�):���creation��Mof�the��m�S����n��M�matrix�whose�co�Gecien���ts���are��giv���en�b�y�the�expression���expr��,��.�	�There�are�t�w�o�formal�parameters�in���expr��,��,�Լthe�rst�one�(�X���)���corresp�Gonding�{�to�the�ro���ws,��5the�second�(�Y�8�)�to�the�columns,�and��X�D��go�Ges�from�1�to��m�,��Y����go�Ges�from���1�UUto��n�.�q�If�one�of�the�last�3�parameters�is�omitted,�ll�the�matrix�with�zero�Ges.����The�UUlibrary�syn���tax�is��matrice�(�GEN�?�nlig,GEN�ncol,entree�*e1,entree�*e2,char�*expr�).���l��3.8.35��Wmatrixqz�(�x;���p�):�_�x�/�b�Geing�an��m�����n�/�matrix�with��m�����n�/�with�rational�or�in���teger�en�tries,�7nthis���function�UUhas�v��q�arying�b�Geha���viour�dep�ending�on�the�sign�of��p�:����If�T�p�����0,�Qӱx��is�assumed�to�b�Ge�of�maximal�rank.���This�function�returns�a�matrix�ha���ving�only���in���tegral���en�tries,���ha�ving�the�same�image�as��x�,���suc�h�that�the�GCD���of�all�its��n�[ط��n��sub�Gdeterminan���ts���is�8�equal�to�1�when��p��is�equal�to�0,�>�or�not�divisible�b���y��p��otherwise.�hOHere��p��m�ust�b�Ge�a�prime�n�um�b�Ger���(when���it�is�non-zero).��uHo���w�ev�er,��if���the�function�is�used�when��p��has�no�small�prime�factors,�it�will���either�UUw���ork�or�giv�e�the�message�\imp�Gossible�in�v�erse�mo�Gdulo"�and�a�non-trivial�divisor�of��p�.����If���p�z��=���1,��this�function�returns�a�matrix�whose�columns�form�a�basis�of�the�lattice�equal�to����Z���^��n���ӫin���tersected�UUwith�the�lattice�generated�b�y�the�columns�of��x�.����If�_�p��\�=���2,�a�returns�a�matrix�whose�columns�form�a�basis�of�the�lattice�equal�to��Z���^��n��Ж�in���tersected���with�UUthe��Q�-v���ector�space�generated�b�y�the�columns�of��x�.����The�UUlibrary�syn���tax�is���matrixqz0��5�ѫ(�x;���p�).���l��3.8.36��Dmatsize�(�x�):���x��t�b�Geing�a�v���ector�or�matrix,�{returns�a�ro�w�v�ector�with�t�w�o�comp�Gonen�ts,�{the���rst�#rb�Geing�the�n���um�b�er�#rof�ro���ws�(1�for�a�ro�w�v�ector),�V�the�second�the�n�um�b�Ger�of�columns�(1�for�a���column�UUv���ector).����The�UUlibrary�syn���tax�is���matsize��)h�(�x�).��������147���������Kf�������3.8.37�t�matsnf�(�X�:�;����f��flag����=��O0�g�):��>if���X���is�a�(singular�or�non-singular)�matrix�outputs�the�v���ector�of���elemen���tary�UUdivisors�of��X�7�(i.e.�the�diagonal�of�the�Smith�normal�form�of��X���).���l��The�UUbinary�digits�of���flag���v�mean:����1��(complete�output):�ʜif�set,�,�outputs�[�U���;���V��9;�D�G�],�where���U�۫and��V�:��are�t���w�o��unimo�Gdular�matrices���suc���h�UUthat��U�X���V��9�is�the�diagonal�matrix��D�G�.�q�Otherwise�output�only�the�diagonal�of��D��.����2�
�(generic�input):�ܟif�set,�8allo���ws�p�Golynomial�en�tries,�8in�whic�h�case�the�input�matrix�m�ust�b�Ge���square.�q�Otherwise,�UUassume�that��X�7�has�in���teger�co�Gecien�ts�with�arbitrary�shap�Ge.����4�y�(clean���up):��8if�set,�›cleans�up�the�output.��pThis�means�that�elemen�tary�divisors�equal�to�1���will��b�Ge�deleted,��Fi.e.�outputs�a�shortened�v���ector��D����^��0���l�instead�of��D��.��
If�complete�output�w���as�required,���returns�N�[�U����^��0���T�;���V��8��^��0���;�D��G��^��0��V�]�so�that��U����^��0���T�X���V��8��^��0���5�=���D��G��^��0��dI�holds.�o�If�this�
ag�is�set,�P:�X�իis�allo���w�ed�to�b�Ge�of�the�form��D����or�UU[�U���;���V��9;�D�G�]�as�w���ould�normally�b�e�output�with�the�clean���up�
ag�unset.����The�UUlibrary�syn���tax�is���matsnf�0��,B�(�X�:�;�����flag���t�).�q�Also�a�v��q�ailable�is���smith����(�X���)�(��flag����=��0).���؍�3.8.38�h�matsolv��9e�(�x;���y�[٫):�B��x���b�Geing�an�in���v�ertible��matrix�and��y�R�a�column�v���ector,�	�nds�the�solution��u��of����x������u���=��y�[٫,�*using�_Gaussian�elimination.�Z�This�has�the�same�eect�as,�but�is�a�bit�faster,�than��x���^���1��kj�����y�[٫.����The�UUlibrary�syn���tax�is���gauss��"p�(�x;���y�[٫).���؍�3.8.39���matsolv��9emo�Q�d�(�m;���d;�y�[�;��f��flag���E�=�ty0�g�):�u
�m�V��b�Geing�an���y�in�tegral�matrix,��_�d��a�v�ector�of�p�Gositiv�e���in���teger��mo�Gduli,�Moand��y�w��an�in�tegral�column�v�ector,�Mogiv�es�a�small�in�teger�solution�to�the�system�of���congruences���џ���P���F��i��E�m����i;j��	j��x����j�����k;�y����i��
T<�(�mo�Gd����d����i��TL�)���if�one�exists,��potherwise�returns�zero.��;Shorthand�notation:����y�y��(resp.���d�)�can�b�Ge�giv���en�as�a�single�in�teger,�(�in�whic�h�case�all�the��y����i��r
�(resp.��d����i��TL�)�ab�Go�v�e�are�tak�en�to�b�Ge���equal�UUto��y��.�(resp.��d�).�������?�?�m�=�[1,2;3,4];��E$���?�?�matsolvemod(m,�[3,4],�[1,2]��&f~��)�����%2�?�=�[-2,�0]��&f~������?�?�matsolvemod(m,�3,�1)�\\�m�X�=�[1,1]��&f~��
�over�F_3�����%3�?�=�[-1,�1]��&f~����l���If��_��flag��o��=��C1,�b6all�_�solutions�are�returned�in�the�form�of�a�t���w�o-comp�Gonen�t�_�ro�w�v�ector�[�x;���u�],�b6where����x�hw�is�a�small�in���teger�solution�to�the�system�of�congruences�and��u��is�a�matrix�whose�columns�giv�e�a���basis��7of�the�homogeneous�system�(so�that�all�solutions�can�b�Ge�obtained�b���y�adding��x��to�an�y�linear���com���bination�UUof�columns�of��u�).�q�If�no�solution�exists,�returns�zero.����The�'library�syn���tax�is���matsolv��9emo�Q�d0��J�g�(�m;���d;�y�[�;���flag���t�).�VbAlso�'a�v��q�ailable�are���gaussmo�Q�dulo��C05�(�m;���d;�y�[٫)���(��flag����=��0)�UUand���gaussmo�Q�dulo2��IBa�(�m;���d;�y�[٫)�UU(��flag���=��1).���؍�3.8.40��{matsupplemen��9t�(�x�):��,assuming�_that�the�columns�of�the�matrix��x��are�linearly�indep�Genden���t���(if��Uthey�are�not,���an�error�message�is�issued),�nds�a�square�in���v�ertible��Umatrix�whose�rst�columns���are�UUthe�columns�of��x�,�i.e.�supplemen���t�the�columns�of��x��to�a�basis�of�the�whole�space.����The�UUlibrary�syn���tax�is���suppl��:��(�x�).���؍�3.8.41��Tmattransp�Q�ose�(�x�)�UUor��x���~��:�q�transp�Gose�of��x�.�This�has�an�eect�only�on�v���ectors�and�matrices.����The�UUlibrary�syn���tax�is���gtrans��"·�(�x�).��������148�����덟���Kf�������3.8.42���qfgaussred�(�q�[٫):�krdecomp�Gosition�H�in���to�squares�of�the�quadratic�form�represen�ted�b�y�the�sym-���metric�gmatrix��q�[٫.�"XThe�result�is�a�matrix�whose�diagonal�en���tries�are�the�co�Gecien�ts�of�the�squares,���and���the��cnon-diagonal�en���tries�represen�t�the�bilinear�forms.��More�precisely��*�,���if�(�a����ij��
��)�denotes�the�output,���one�UUhas��}؍���q�[٫(�x�)��=��������X����t���״i���㉱a����ii��(��(�x����i���,�+����8����X����t��H�j�g�>i���UQ�a����ij��
��x����j��6��)������2���(�����The�UUlibrary�syn���tax�is���sqred��U��(�x�).������3.8.43��^qfjacobi�(�x�):�w�x�W��b�Geing�a�real�symmetric�matrix,�X�this�giv���es�a�v�ector�ha�ving�t�w�o�comp�Gonen�ts:���the�/Srst�one�is�the�v���ector�of�eigen�v��q�alues�of��x�,�6�the�second�is�the�corresp�Gonding�orthogonal�matrix�of���eigen���v�ectors�UUof��x�.�q�The�metho�Gd�used�is�Jacobi's�metho�d�for�symmetric�matrices.��}؍�The�UUlibrary�syn���tax�is���jacobi�� ừ(�x�).����3.8.44�qflll�(�x;����f��flag��X^�=� �0�g�):��'LLL���algorithm��applied�to�the��c��}'olumns�]&�of�the�(not�necessarily�square)���matrix����x�.�xThe�columns�of��x��m���ust�ho�w�ev�er�b�Ge�linearly�indep�enden���t,��unless�sp�ecied�otherwise���b�Gelo���w.�7�The�Bresult�is�a�transformation�matrix��T����suc�h�that��x�֨���T����is�Ban�LLL-reduced�basis�of�the���lattice�UUgenerated�b���y�the�column�v�ectors�of��x�.��}؍�If�����flag�����=��0���(default),��	the�computations�are�done�with�real�n���um�b�Gers���(i.e.�not�with�rational���n���um�b�Gers),���using���Householder�matrices�for�orthogonalization�(as�presen���tly�programmed:�qslo�w�but���stable).����If��/��flag��.��=��1,�7Git�/�is�assumed�that�the�corresp�Gonding�Gram�matrix�is�in���tegral.�eAThe�computation�is���done�en���tirely�with�in�tegers�and�the�algorithm�is�b�Goth�accurate�and�quite�fast.�_In�this�case,�(E�x��needs���not�UUb�Ge�of�maximal�rank,�but�if�it�is�not,��T���will�not�b�e�square.����If��5"�flag��4�=��2,�;�similar�5"to�case�1,�except��x��should�b�Ge�an�in���teger�matrix�whose�columns�are�linearly���indep�Genden���t.�x�The���lattice�generated�b�y�the�columns�of��x��is�rst�partially�reduced�b�Gefore�applying���the�¯LLL�“algorithm.���[A�basis�is�said�to�b�Ge��p��}'artial���ly���r�e�duc�e�d��8�if��j�v����i������Ʊv����j��6��j�}W�j�v����i��TL�j��for�an���y�t�w�o�distinct���basis�UUv���ectors��v����i��TL�;�UPv����j��6��.]����This�".can�b�Ge�signican���tly�faster�than���flag��vy�=�1�when�one�ro�w�is�h�uge�compared�to�the�other���ro���ws.����If��6��flag�����=�>c4,�nαx�6��is�assumed�to�ha���v�e�6�in�tegral�en�tries,�n�but�needs�not�b�Ge�of�maximal�rank.�PThe���result��6is�a�t���w�o-comp�Gonen�t��6v�ector�of�matrices:��the�columns�of�the�rst�matrix�represen�t�a�basis�of���the�]�in���teger�k�ernel�of��x��(not�necessarily�LLL-reduced)�and�the�second�matrix�is�the�transformation���matrix�UU�T���suc���h�that��x�8���T��is�UUan�LLL-reduced��Z�-basis�of�the�image�of�the�matrix��x�.����If��UU�flag��T9�=��5,�UUcase�as�case�4,�but��x��ma���y�ha�v�e�p�Golynomial�co�ecien���ts.����If��UU�flag��T9�=��8,�UUsame�as�case�0,�where��x��ma���y�ha�v�e�p�Golynomial�co�ecien���ts.����The��library�syn���tax�is���qf�lll0���g�(�x;�����flag���t�;�����pr��}'e�c�����).�@�Also�a�v��q�ailable�are���lll��
���(�x;�����pr��}'e�c�����)�(��flag���=��P0),��?�lllin��9t��g��(�x�)���(��flag����=��1),�UUand���lllk��9erim��)s��(�x�)�(��flag���=��4).��������149�����Ս����Kf�������3.8.45�
�qflllgram�(�x;����f��flag��LS�=��0�g�):�γsame���as��qflll�,��hexcept�that�the�matrix��x��is�the�Gram�matrix�of���the�Élattice�v���ectors,��and�not�the�co�Gordinates�of�the�v�ectors�themselv�es.��dIn�particular,���x��m�ust�no�w���b�Ge�!�a�square�symmetric�real�matrix,�,)corresp�onding�to�a�p�ositiv���e�denite�quadratic�form.�`�The�result���is�auagain�the�transformation�matrix��T���whic���h�giv�es�(as�columns)�the�co�Gecien�ts�with�resp�Gect�to�the���initial��basis�v���ectors.�Z�The�
ags�ha�v�e�more�or�less�the�same�meaning,��but�some�are�missing.�Z�In�brief:��������flag��&��=��0:�q�n���umerically�UUunstable�in�the�presen�t�v�ersion�2.2.7.������flag��&��=��1:�qDZx�UU�has�in���teger�en�tries,�the�computations�are�all�done�in�in�tegers.������flag��&��=��4:�qDZx�UU�has�in���teger�en�tries,�giv�es�the�k�ernel�and�reduced�image.������flag��&��=��5:�q�same�UUas�4�for�generic��x�.����The��library�syn���tax�is���qf�lllgram0��6�G�(�x;�����flag���t�;�����pr��}'e�c�����).�_�Also�a�v��q�ailable�are���lllgram��&\ܫ(�x;�����pr��}'e�c�����)�(��flag����=��0),�����lllgramin��9t��0���(�x�)�UU(��flag����=��1),�and���lllgramk��9erim��C\�(�x�)�(��flag���=��4).�����3.8.46���qfminim�(�x;���b;�m;��f��flag��	��=���0�g�):�~��x�[ɫb�Geing�a�square�and�symmetric�matrix�represen���ting�a�p�osi-���tiv���e�UUdenite�quadratic�form,�this�function�deals�with�the�minimal�v�ectors�of��x�,�dep�Gending�on���flag���!�.������If����flag��ʫ=��0��(default),�0seeks�v���ectors�of�square�norm�less�than�or�equal�to��b��(for�the�norm�dened���b���y����x�),���and�at�most�2�m��of�these�v�ectors.�8�The�result�is�a�three-comp�Gonen�t�v�ector,���the�rst�comp�Gonen�t���b�Geing���the�n���um�b�er���of�v���ectors,�#the�second�b�eing�the�maxim���um�norm�found,�#and�the�last�v�ector�is���a���matrix�whose�columns�are�the�v���ectors�found,��ionly�one�b�Geing�giv�en�for�eac�h�pair���v��׫(at�most��m����suc���h�UUpairs).����If��UU�flag��T9�=��1,�UUignores��m��and�returns�the�rst�v���ector�whose�norm�is�less�than��b�.����In��*b�Goth�these�cases,�
_�x��is�&assume��}'d�to�have�inte�gr�al�entries��!�,�
_and��*the�function�searc���hes�for�the���minimal�UUnon-zero�v���ectors�whenev�er��b���=�0.����If��Yu�flag��XY�=��2,��ֱx�Yu�can�ha���v�e�Yunon�in���tegral�real�en�tries,���but��b���=�0�Yuis�no�w�meaningless�(uses�Finc�k�e-P�ohst���algorithm).����The�w�library�syn���tax�is���qf�minim0��3��(�x;���b;�m;���flag���t�;���pr��}'e�c�����),��[also�w�a�v��q�ailable�are���minim��#i|�(�x;���b;�m�)�w�(��flag��8A�=���0),��UU�minim2��)�(�x;���b;�m�)�UU(��flag����=��1),�and�nally���f�inc��9k�e�����ffs4��#�p�Q�ohst��AT�(�x;���b;�m;���pr��}'e�c�����)�UU(��flag���=��2).�����3.8.47��1qfp�Q�erfection�(�x�):�Vñx�M�b�Geing�a�square�and�symmetric�matrix�with�in���teger�en�tries�represen�ting���a�/7p�Gositiv���e�denite�quadratic�form,�6�outputs�the�p�erfection�rank�of�the�form.�eThat�is,�6�giv���es�the�rank���of�_the�family�of�the��s��symmetric�matrices��v����i��TL�v���^���[ٴt��;Z�i����/�,�azwhere��s��is�half�the�n���um�b�Ger�_of�minimal�v���ectors�and���the�UU�v����i�����(1�����i����s�)�are�the�minimal�v���ectors.����As��a�side�note�to�old-timers,�O�this�used�to�fail�blun���tly�when��x��had�more�than�5000�minimal���v���ectors.�BBew�are��that�the�computations�can�no���w�b�Ge�v�ery�length�y�when��x��has�man�y�minimal�v�ectors.����The�UUlibrary�syn���tax�is���p�Q�erf����(�x�).�����3.8.48�Ŋqfrep�(�q�[�;���B��q;��f��flag����=��0�g�):�j�q��s�b�Geing�G�a�square�and�symmetric�matrix�with�in���teger�en�tries�repre-���sen���ting���a�p�Gositiv�e�denite�quadratic�form,���outputs�the�v�ector�whose��i�-th�en�try��*�,���1�u���i����B�>0�is���half���the�In���um�b�Ger�of�v�ectors��v�h"�suc�h�that��q�[٫(�v��)��=��i�.�YnThis�routine�uses�a�naiv���e�algorithm�based�on��qfminim�,���and�UUwill�fail�if�an���y�en�try�b�Gecomes�larger�than�2���^��31��x�.���The�UUbinary�digits�of���flag���v�mean:������UU�1:�q�coun���t�v�ectors�of�ev�en�norm�from�1�to�2�B��q�.������UU�2:�q�return�a��t_VECSMALL��instead�of�a��t_GEN�����The�UUlibrary�syn���tax�is���qf�rep0��$'�(�q�[�;���B��q;���flag���t�).��������150�����U�����Kf�������3.8.49��qfsign�(�x�):���signature��pof�the�quadratic�form�represen���ted�b�y�the�symmetric�matrix��x�.�7The���result�UUis�a�t���w�o-comp�Gonen�t�UUv�ector.���[��The�UUlibrary�syn���tax�is���signat��!Cܫ(�x�).�����3.8.50��Tsetin��9tersect�(�x;���y�[٫):�q�in���tersection�UUof�the�t�w�o�sets��x��and��y�[٫.����The�UUlibrary�syn���tax�is���setin��9tersect��<�۫(�x;���y�[٫).����3.8.51�D�setisset�(�x�):�3Wreturns��true�(1)�if��x��is�a�set,��Ofalse�(0)�if�not.��In�P��*�ARI,�a�set�is�simply�a�ro���w���v���ector���whose�en�tries�are�strictly�increasing.�q�T��*�o�con�v�ert�an�y�v�ector�(and�other�ob��8jects)�in�to�a�set,���use�UUthe�function��Set�.���[��The�UUlibrary�syn���tax�is���setisset��'�;�(�x�),�and�this�returns�a��long�.����3.8.52�R�setmin��9us�(�x;���y�[٫):�K�dierence��7of�the�t���w�o��7sets��x��and��y��,��pi.e.�set�of�elemen���ts�of��x��whic�h�do�not���b�Gelong�UUto��y�[٫.���[��The�UUlibrary�syn���tax�is���setmin��9us��/bl�(�x;���y�[٫).����3.8.53�d�setsearc��9h�(�x;���y�[�;��f��flag����=��0�g�):�kfsearc���hes��$if��y�-��b�Gelongs�to�the�set��x�.��5If�it�do�es�and���flag����is�zero���or�qkomitted,�xqreturns�the�index��j���suc���h�that��x�[�j����]���=��y�[٫,�otherwise�qkreturns�0.��
If���flag����is�non-zero�returns���the���index��j�"j�where��y�븫should�b�Ge�inserted,���and�0�if�it�already�b�elongs�to��x��(this�is�mean���t�to�b�e�used���in�UUconjunction�with��listinsert�).���[��This�UUfunction�w���orks�also�if��x��is�a��sorte��}'d�]ޫlist�(see��listsort�).����The�UUlibrary�syn���tax�is���setsearc��9h��0��(�x;���y�[�;���flag���t�)�UUwhic�h�returns�a��long��in�teger.����3.8.54��Tsetunion�(�x;���y�[٫):�q�union�UUof�the�t���w�o�UUsets��x��and��y��.����The�UUlibrary�syn���tax�is���setunion��-�/�(�x;���y�[٫).����3.8.55�.�trace�(�x�):�
this���applies�to�quite�general��x�.�Z�If��x��is�not�a�matrix,��hit�is�equal�to�the�sum�of��x����and�UUits�conjugate,�except�for�p�Golmo�ds�UUwhere�it�is�the�trace�as�an�algebraic�n���um�b�Ger.����F��*�or�6#�x��a�square�matrix,�<ait�is�the�ordinary�trace.�gaIf��x��is�a�non-square�matrix�(but�not�a�v���ector),���an�UUerror�o�Gccurs.����The�UUlibrary�syn���tax�is���gtrace��"C��(�x�).�����3.8.56�v��9ecextract�(�x;���y�[�;��f�z�p��g�):���extraction�^Wof�comp�Gonen���ts�of�the�v�ector�or�matrix��x��according�to����y�[٫.�P�In�Jdcase��x��is�a�matrix,���its�comp�Gonen���ts�are�as�usual�the��c��}'olumns���of��x�.�The�parameter��y��=�is�a���comp�Gonen���t�UUsp�ecier,�whic���h�is�either�an�in�teger,�a�string�describing�a�range,�or�a�v�ector.����If��0�y�	�is�an�in���teger,���it�is�considered�as�a�mask:�~the�binary�bits�of��y��are�read�from�righ���t�to�left,���but�Acorresp�Gond�to�taking�the�comp�onen���ts�from�left�to�righ�t.�]�F��*�or�example,�%Eif��y�"�=��13�=�(1101)����2�����then���the�UUcomp�Gonen���ts�1,3�and�4�are�extracted.����If��%�y�F��is�a�v���ector,��whic�h��%m�ust�ha�v�e�in�teger�en�tries,��these�en�tries�corresp�Gond�to�the�comp�onen���t���n���um�b�Gers�UUto�b�e�extracted,�in�the�order�sp�ecied.����If�UU�y��.�is�a�string,�it�can�b�Ge�������?�a�single�(non-zero)�index�giving�a�comp�Gonen���t�n�um�b�Ger�(a�negativ�e�index�means�w�e�start���coun���ting�UUfrom�the�end).��������151�����ύ����Kf�����卑��ʫa�range�of�the�form��"�a�..�b�"�,�L'where��a��and��b��are�indexes�as�ab�Go���v�e.��&An�y��of��a��and��b��can�b�e���omitted;��in��0this�case,���w���e�tak�e�as�default�v��q�alues��a���=�1��0and��b���=���1,���i.e.��the��0rst�and�last�comp�Gonen�ts���resp�Gectiv���ely��*�.�q�W�e�UUthen�extract�all�comp�onen���ts�in�the�in�terv��q�al�[�a;���b�],�in�rev�erse�order�if��b��<�a�.��*ˍ�In�]caddition,�_gif�the�rst�c���haracter�in�the�string�is��^�,�the�complemen���t�of�the�giv�en�set�of�indices���is�UUtak���en.����If�쏱z�]&�is�not�omitted,���x��m���ust�b�Ge�a�matrix.�Nڱy�Hh�is�then�the��line���sp�ecier,��and��z�]&�the��c��}'olumn���sp�ecier,���where�UUthe�comp�Gonen���t�sp�ecier�is�as�explained�ab�o���v�e.��9���?�?�v�=�[a,�b,�c,�d,�e];��D��?�?�vecextract(v,�5)�4�\\����mask�����%1�?�=�[a,�c]����?�?�vecextract(v,�[4,�2,�1])�
�\\����c��}'omp�onent�list�����%2�?�=�[d,�b,�a]����?�?�vecextract(v,�"2..4")�?�\\����interval�����%3�?�=�[b,�c,�d]����?�?�vecextract(v,�"-1..-3")���\\����interval�+�r��}'everse�or�der�����%4�?�=�[e,�d,�c]����?�?�vecextract(v,�"^2")�$��\\����c��}'omplement�����%5�?�=�[a,�c,�d,�e]����?�?�vecextract(matid(3),�"2..",�"..")����%6�?�=����[0�?�1�0]�����[0�?�0�1]�����The�UUlibrary�syn���tax�is���extract��',�(�x;���y�[٫)�or���matextract��:�y�(�x;�y�[�;�z�p��).��U���3.8.57��	v��9ecsort�(�x;����f�k�P��g�;��f��flag��t�=�=0�g�):�e�sorts��Wthe�v���ector��x��in�ascending�order,�-�using�the�heapsort���metho�Gd.�qDZx�UU�m���ust�b�e�a�v���ector,�and�its�comp�onen���ts�in�tegers,�reals,�or�fractions.����If�s�k�g
�is�presen���t�and�is�an�in�teger,�F�sorts�according�to�the�v��q�alue�of�the��k�P��-th�sub�Gcomp�onen�ts�sof���the��-comp�Gonen���ts�of��x�.�?N�k�?īcan�also�b�e�a�v���ector,��in�whic�h�case�the�sorting�is�done�lexicographically���according�'to�the�comp�Gonen���ts�listed�in�the�v�ector��k�P��.��<F��*�or�example,�<[if��k�K��=��[2�;����1�;��3],�sorting�'will�b�Ge���done��:with�resp�Gect�to�the�second�comp�onen���t,��and�when�these�are�equal,�with�resp�Gect�to�the�rst,���and�UUwhen�these�are�equal,�with�resp�Gect�to�the�third.���The�UUbinary�digits�of���flag���v�mean:������M��1:�nindirect�sorting�of�the�v���ector��x�,�Oui.e.�if��x��is�an��n�-comp�Gonen�t�v�ector,�Oureturns�a�p�Germ�utation���of�yw[1�;����2�;��:�:�:����;�n�]�whic���h�applied�to�the�comp�Gonen�ts�of��x��sorts��x��in�increasing�order.��-F��*�or�example,����vecextract(x,�?�vecsort(x,,1))�UU�is�equiv��q�alen���t�to��vecsort(x)�.������UU�2:�q�sorts��x��b���y�ascending�lexicographic�order�(as�p�Ger�the��lex��comparison�function).������UU�4:�q�use�descending�instead�of�ascending�order.����The�.�library�syn���tax�is���v��9ecsort0��,���(�x;���k�P�;�f��l�2`ag�[٫).�d�T��*�o�.�omit��k��,�6euse��NULL�.��instead.�d�Y��*�ou�can�also�use�the���simpler�UUfunctions������sort��'~��(�x�)�UU(=���vecsort0��-U=�(�x;�����NULL��*��;����0)).������indexsort��B΄�(�x�)�UU(=���vecsort0��-U=�(�x;�����NULL��*��;����1)).������lexsort��6l�(�x�)�UU(=���vecsort0��-U=�(�x;�����NULL��*��;����2)).��������152����	E�����Kf�����卑�Also�3�a���v��q�ailable�are��sindexsort��and��sindexlexsort��whic�h�return�a�v�ector�of�C-long�in�tegers���(priv��q�ate�UUt���yp�Ge��t_VECSMALL�)��v�[٫,�where��v��[1]�����:�:�:����v��[�n�]�con���tain�the�indices.���u��3.8.58�nv��9ector�(�n;����f�X���g�;��f��expr���`�=�)�0�g�):��6creates���a�ro���w�v�ector�(t�yp�Ge��t_VEC�)��}with��n��comp�onen���ts�whose���comp�Gonen���ts�;are�the�expression���expr��īev��q�aluated�at�the�in�teger�p�Goin�ts�b�Get�w�een�1�and��n�.�iIf�one�of�the���last�UUt���w�o�argumen�ts�is�omitted,�ll�the�v�ector�with�zero�Ges.��i:��The�UUlibrary�syn���tax�is��v��9ecteur�(�GEN�?�nmax,�entree�*ep,�char�*expr�).����3.8.59�	�v��9ectorsmall�(�n;����f�X���g�;��f��expr��k��=��0�g�):�(creates��a�ro���w�v�ector�of�small�in�tegers�(t�yp�Ge��t_VECSMALL�)���with���n��comp�Gonen���ts�whose�comp�onen���ts�are�the�expression���expr����ev��q�aluated�at�the�in�teger�p�Goin�ts���b�Get���w�een�UU1�and��n�.�q�If�one�of�the�last�t���w�o�UUargumen�ts�is�omitted,�ll�the�v�ector�with�zero�Ges.��i:��The�UUlibrary�syn���tax�is��v��9ecteursmall�(�GEN�?�nmax,�entree�*ep,�char�*expr�).����3.8.60��Tv��9ectorv�(�n;���X�:�;���expr��O>�):�q�as�UU�vector�,�but�returns�a�column�v���ector�(t�yp�Ge��t_COL�).����The�UUlibrary�syn���tax�is��vv��9ecteur�(�GEN�?�nmax,�entree�*ep,�char�*expr�).��%;���3.9��Sums,�pro�`ducts,�in��tegrals�and�similar�functions�.���M��Although���the�GP��ncalculator�is�programmable,��it�is�useful�to�ha���v�e���preprogrammed�a�n���um�b�Ger���of���lo�Gops,���including���sums,�pro�ducts,�and���a�certain�n���um�b�er���of�recursions.�#�Also,���a�n���um�b�er���of�functions���from�Mn���umerical�analysis�lik�e�n�umerical�in�tegration�and�summation�of�series�will�b�Ge�describ�ed�here.��i:��One�4�of�the�parameters�in�these�lo�Gops�m���ust�b�e�the�con���trol�v��q�ariable,�l�hence�a�simple�v�ariable���name.�c�The�+�last�parameter�can�b�Ge�an���y�legal�P��*�ARI�+�expression,�3�including�of�course�expressions�using���lo�Gops.�3�Since��Tit�is�m���uc�h��Teasier�to�program�directly�the�lo�ops�in�library�mo�de,��these�functions�are���mainly�ۡuseful�for�GP�ۃprogramming.�I6The�use�of�these�functions�in�library�mo�Gde�is�a�little�tric���ky�and���its�5$explanation�will�b�Ge�mostly�omitted,�;�although�the�reader�can�try�and�gure�it�out�b���y�himself�b�y���c���hec�king��%the�example�giv���en�for�the��sum��function.��6In�this�section�w�e�only�giv�e�the�library�syn�tax,���with�UUno�seman���tic�explanation.����The���letter��X�[��will�alw���a�ys���denote�an���y�simple�v��q�ariable�name,���and�represen�ts�the�formal�parameter���used�UUin�the�function.���a��(n��9umerical)��in�tegration�:��pA�r�n���um�b�Ger�r�of�Rom���b�erg-lik�e�r�in�tegration�metho�Gds�are�implemen�ted�(see����intnum����as�opp�Gosed�to��intformal��whic���h�w�e�already�describ�Ged).�q�The�user�should�not�require�to�o���m���uc�h�k�accuracy:��18�or�28�decimal�digits�is�OK,�but�not�m���uc�h�k�more.�#�In�addition,���analytical�clean���up�of���the�tXin���tegral�m�ust�ha�v�e�b�Geen�done:�Hthere�m�ust�b�Ge�no�singularities�in�the�in�terv��q�al�or�at�the�b�Goundaries.���In�v"practice�this�can�b�Ge�accomplished�with�a�simple�c���hange�of�v��q�ariable.��-F��*�urthermore,�~Ufor�improp�er���in���tegrals,�}�where�BYone�or�b�Goth�of�the�limits�of�in�tegration�are�plus�or�min�us�innit�y��*�,�}�the�function���m���ust���decrease�sucien�tly�rapidly�at�innit�y��*�.�VGThis�can�often�b�Ge�accomplished�through�in�tegration���b���y�7�parts.�g�Finally��*�,�=�the�function�to�b�Ge�in�tegrated�should�not�b�Ge�v�ery�small�(compared�to�the�curren�t���precision)�3on�the�en���tire�in�terv��q�al.�
�This�can�of�course�b�Ge�accomplished�b�y�just�m�ultiplying�b�y�an���appropriate�UUconstan���t.����Note�J�that�infinit���y�can�b�Ge�represen�ted�with�essen�tially�no�loss�of�accuracy�b�y�1e4000.�n7Ho�w�ev�er���b�Gew���are��Qof�real�under
o�w�when�dealing�with�rapidly�decreasing�functions.�DF��*�or�example,��if�one�w�an�ts���to�v�compute�the�����ĽR����j���	!��1��	#���/Ů0���E�e���^���x����r�2���ڭ�dx��to�28�decimal�digits,��_then�one�should�set�innit���y�equal�to�10�for�example,���and�UUcertainly�not�to�1e4000.��������153����	
F�����Kf�����卑�The��Oin���tegrand�ma�y�ha�v�e�v��q�alues�b�Gelonging�to�a�v�ector�space�o�v�er�the�real�n�um�b�Gers;�ʧin�particular,���it�UUcan�b�Ge�complex-v��q�alued�or�v���ector-v�alued.���A��See�UUalso�the�discrete�summation�metho�Gds�b�elo���w�(sharing�the�prex��sum�).���Í�3.9.1��in��9tn�um�(�X���=��.�a;���b;���expr��O>�;��f��flag�����=�0�g�):��n���umerical���in�tegration�of���expr�����(smo�Goth�in�]�a;���b�[),�fwith���resp�Gect�UUto��X���.����Set��ޙ�flag���C�=���0�ޙ(or�omit�it�altogether)�when��a��and��b��are�not�to�Go�large,��the�function�is�smo�oth,���and�UUcan�b�Ge�ev��q�aluated�exactly�ev���erywhere�on�the�in�terv��q�al�[�a;���b�].����If����flag����=��1,�"]uses��a�general�driv���er�routine�for�doing�n�umerical�in�tegration,�"]making�no�particular���assumption�UU(slo���w).������flag��&��=��2�J�is�tailored�for�b�Geing�used�when��a��or��b��are�innite.�n.One��must�=b�ha���v�e�J��ab�>��0,�L�and�in�fact���if�UUfor�example��b���=�+�1�,�UUthen�it�is�preferable�to�ha���v�e�UU�a��as�large�as�p�Gossible,�at�least��a�����1.����If��%��flag��$Ы=��3,�/gthe�%�function�is�allo���w�ed�%�to�b�Ge�undened�(but�con���tin�uous)�%�at��a��or��b�,�for�example�the���function��UUsin���s(�x�)�=x�UU�at��x���=�0.����The��library�syn���tax�is��in��9tn�um�(�void�?�*E,�GEN�(*eval)(GEN,void*),�GEN�a,�GEN�b,�long���flag,�?�long�prec�).��Where���h�eval���\�(�x;���E����)��hreturns�the�v��q�alue�of�the�function�at��x�.�Y��*�ou�ma���y�store�an�y���additional�UUinformation�required�b���y��eval��in��E����,�or�set�it�to��NULL�.���Í�3.9.2�p�pro�Q�d�(�X��}�=���a;���b;���expr��O>�;��f�x��=�1�g�):�=�pro�Gduct��?of�expression���expr��_ի,��initialized�at��x�,�the�formal���parameter��j�X�NL�going�from��a��to��b�.�As�for��sum�,��othe�main�purp�Gose�of�the�initialization�parameter��x��is���to�<�force�the�t���yp�Ge�of�the�op�erations�b�eing�p�erformed.�i�F��*�or�example�if�it�is�set�equal�to�the�in���teger�1,���op�Gerations��fwill�start�b�eing�done�exactly��*�.�R�If�it�is�set�equal�to�the�real�1�:�,�
�they�will�b�e�done�using�real���n���um�b�Gers�Cha�ving�the�default�precision.�k�If�it�is�set�equal�to�the�p�Go�w�er�series�1�R+��O�G�(�X�����^��k���r�)�for�a�certain����k�P��,��they��will�b�Ge�done�using�p�o���w�er��series�of�precision�at�most��k�P��.�
 These�are�the�three�most�common���initializations.���As�UUan�extreme�example,�compare�����?�?�prod(i=1,�100,�1�-�X^i);�
�\\����this�has�de��}'gr�e�e���5050��!!�����time�?�=�3,335�ms.����?�?�prod(i=1,�100,�1�-�X^i,�1�+�O(X^101))����time�?�=�43�ms.����%2�?�=�1�-�X�-�X^2�+�X^5�+�X^7�-�X^12�-�X^15�+�X^22�+�X^26�-�X^35�-�X^40�+�\�����X^51�?�+�X^57�-�X^70�-�X^77�+�X^92�+�X^100�+�O(X^101)�����The�UUlibrary�syn���tax�is��pro�Q�duit�(�entree�?�*ep,�GEN�a,�GEN�b,�char�*expr,�GEN�x�).���Í�3.9.3��pro�Q�deuler�(�X����=���a;���b;���expr��O>�):��pro�Gduct���of�expression���expr��/��,��hinitialized�at�1.�.O(i.e.�to�a��r��}'e�al��v�n���um�b�er���equal���to�1�to�the�curren���t��realprecision�),��qthe�formal�parameter��X�z��ranging�o�v�er�the�prime�n�um�b�Gers���b�Get���w�een�UU�a��and��b�.����The�UUlibrary�syn���tax�is��pro�Q�deuler�(�entree�?�*ep,�GEN�a,�GEN�b,�char�*expr,�long�prec�).���Í�3.9.4��(pro�Q�dinf�(�X����=���a;�����expr��O>�;����f��flag����=�0�g�):�a.infinite�4#pro�Gduct�of�expression���expr��ع�,�:�the�formal�parameter����X��B�starting��`at��a�.�T The�ev��q�aluation�stops�when�the�relativ���e�error�of�the�expression�min�us�1�is�less�than���the�UUdefault�precision.�q�The�expressions�m���ust�alw�a�ys�ev��q�aluate�to�an�elemen�t�of��C�.����If��UU�flag��T9�=��1,�UUdo�the�pro�Gduct�of�the�(1�8�+���expr���v�)�UUinstead.����The�Wlibrary�syn���tax�is��pro�Q�dinf�(�entree�?�*ep,�GEN�a,�char�*expr,�long�prec�)�W(��flag����=��0),�&�or����pro�Q�dinf1�UU�with�the�same�argumen���ts�(��flag����=��1).��������154����	p�����Kf�������3.9.5�šsolv��9e�(�X����=���a;���b;���expr��O>�):��Tnd�fpa�real�ro�Got�of�expression���expr��qv�b�et���w�een�fp�a��and��b�,��7under�the�condition�����expr�����(�X��k�=�5��a�)�e
����expr��	��(�X��=�5��b�)����0.�8�This���routine�uses�Bren���t's�metho�Gd�and�can�fail�miserably�if���expr�����is�UUnot�dened�in�the�whole�of�[�a;���b�]�(try��solve(x=1,�?�2,�tan(x)�).��"֍�The���library�syn���tax�is��zbren��9t�(�void�?�*E,�GEN�(*eval)(GEN,�void*),�GEN�a,�GEN�b,�long���prec�).��XWhere��0�eval��$�(�x;���E����)�0returns�the�v��q�alue�of�the�function�at��x�.�Y��*�ou�ma���y�store�an�y�additional���information�UUrequired�b���y��eval��in��E����,�or�set�it�to��NULL�.��E���3.9.6��:sum�(�X����=���a;���b;���expr��O>�;��f�x��=�0�g�):�N�sum��of�expression���expr���D�,��initialized�at��x�,�the�formal�parameter���going��from��a��to��b�.�V�As�for��prod�,�the�initialization�parameter��x��ma���y�b�Ge�giv�en�to�force�the�t�yp�Ge�of�the���op�Gerations�UUb�eing�p�erformed.���As�UUan�extreme�example,�compare���ȍ��?�?�sum(i=1,�5000,�1/i);�\\����r��}'ational�numb�er:�denominator�has��2166��digits.��`��time�?�=�1,241�ms.����?�?�sum(i=1,�5000,�1/i,�0.)����time�?�=�158�ms.����%2�?�=�9.094508852984436967261245533�����The��:library�syn���tax�is��somme�(�entree�?�*ep,�GEN�a,�GEN�b,�char�*expr,�GEN�x�).�C�This��:is�to���b�Ge�UUused�as�follo���ws:�q��ep��represen�ts�the�dumm�y�v��q�ariable�used�in�the�expression��expr���ȍ�/*�?�compute�a^2�+���:���:�:���I�+�b^2�*/����{�����/*�?�define�the�dummy�variable�"i"�*/�����entree�?�*ep�=�is_entry("i");�����/*�?�sum�for�a�<=�i�<=�b�*/�����return�?�somme(ep,�a,�b,�"i^2",�gzero);����}��E���3.9.7�sumalt�(�X����=��a;�����expr��O>�;����f��flag��<�=�0�g�):��-n���umerical�z�summation�of�the�series���expr���,���whic�h�should�b�Ge���an�UUalternating�series,�the�formal�v��q�ariable��X�7�starting�at��a�.��"֍�If��
��flag��m�=��0,��use�
�an�algorithm�of�F.�Villegas�as�mo�Gdied�b���y�D.�Zagier.�Y�This�is�m�uc�h�b�Getter�than���Euler-V��*�an�UUWijngaarden's�metho�Gd�whic���h�w�as�used�formerly��*�.����If��UU�flag��T9�=��1,�UUuse�a�v��q�arian���t�with�sligh�tly�dieren�t�p�Golynomials.�q�Sometimes�faster.����Div���ergen�t�
�alternating�series�can�sometimes�b�Ge�summed�b���y�this�metho�d,��as�w���ell�as�series�whic�h���are�UUnot�exactly�alternating�(see�for�example�Section�2.6.4).����The�UUlibrary�syn���tax�is��sumalt�(�entree�?�*ep,�GEN�a,�char�*expr,�long���flag��w��,�long�prec�).��E���3.9.8��Tsumdiv�(�n;���X�:�;���expr��O>�):�q�sum�UUof�expression���expr��[email protected]�o���v�er�UUthe�p�Gositiv���e�divisors�of��n�.����Arithmetic�A)functions�lik���e��sigma��use�the�m�ultiplicativit�y�of�the�underlying�expression�to�sp�Geed���up�ͱthe�computation.���In�the�presen���t�v�ersion�2.2.7,���there�is�no�w�a�y�to�indicate�that���expr��?��is�m�ulti-���plicativ���e�UUin��n�,�hence�sp�Gecialized�functions�should�b�e�preferred�whenev���er�p�ossible.����The�UUlibrary�syn���tax�is��divsum�(�entree�?�*ep,�GEN�num,�char�*expr�).��������155����	.|�����Kf�������3.9.9�4nsuminf�(�X�Ϋ=�P�a;�����expr��O>�):�,infinite��sum�of�expression���expr��L��,���the�formal�parameter��X�p�starting�at����a�.�g7The�5�ev��q�aluation�stops�when�the�relativ���e�error�of�the�expression�is�less�than�the�default�precision.���The�UUexpressions�m���ust�alw�a�ys�ev��q�aluate�to�a�complex�n�um�b�Ger.������The�UUlibrary�syn���tax�is��suminf�(�entree�?�*ep,�GEN�a,�char�*expr,�long�prec�).���D��3.9.10�֫sump�Q�os�(�X���=��
�a;�����expr��O>�;����f��flag��֫=�0�g�):�tn���umerical�V�summation�of�the�series���expr����,�V�whic�h�m�ust�b�Ge���a�Z�series�of�terms�ha���ving�the�same�sign,�[�the�formal�v��q�ariable��X�#��starting�at��a�.���The�algorithm�used�is���V��*�an�UUWijngaarden's�tric���k�for�con�v�erting�suc�h�a�series�in�to�an�alternating�one,�and�is�quite�slo�w.����If��UU�flag��T9�=��1,�UUuse�sligh���tly�dieren�t�p�Golynomials.�q�Sometimes�faster.����The�UUlibrary�syn���tax�is��sump�Q�os�(�entree�?�*ep,�GEN�a,�char�*expr,�long���flag��w��,�long�prec�).��!����3.10��Plotting�functions�.��RB��Although���plotting�is�not�ev���en�a�side�purp�Gose�of�P��*�ARI,�a�n�um�b�Ger�of�plotting�functions�are���pro���vided.�ԨMoreo�v�er,��3a�ˠlot�of�p�Geople�felt�lik���e�suggesting�ideas�or�submitting�h�uge�patc�hes�for�this���section�9�of�the�co�Gde.�Among�these,�r�sp�ecial�thanks�go�to�Klaus-P���eter�Nisc�hk�e�who�suggested�the���recursiv���e��.plotting�and�the�forking/resizing�stu�under�X11,���and�Ily�a�Zakharevic�h�who�underto�Gok���a�;5complete�rewrite�of�the�graphic�co�Gde,�@oso�that�most�of�it�is�no���w�platform-indep�enden���t�and�should���b�Ge�UUrelativ���ely�easy�to�p�ort�or�expand.����These�UUgraphic�functions�are�either������
��high-lev���el�plotting�functions�(all�the�functions�starting�with��ploth�)�in�whic�h�the�user�has���little�J�to�do�but�explain�what�t���yp�Ge�of�plot�he�w�an�ts,�L�and�whose�syn�tax�is�similar�to�the�one�used�in���the�UUpreceding�section�(with�somewhat�more�complicated�
ags).��������lo���w-lev�el�plotting�functions,���where�ev�ery�dra�wing�primitiv�e�(p�Goin�t,���line,�b�o���x,�etc.)�O
m�ust��b�Ge���sp�Gecied�V�b���y�the�user.�v�These�lo�w-lev�el�functions�(called���r��}'e�ctplot��'q��functions,�WTsharing�the�prex��plot�)���w���ork�UOas�follo�ws.�q�Y��*�ou�ha�v�e�at�y�our�disp�Gosal�16�virtual�windo�ws�whic�h�are�lled�indep�Genden�tly��*�,�UPand���can�\�then�b�Ge�ph���ysically�ORed�on�a�single�windo�w�at�user-dened�p�Gositions.��cThese�windo�ws�are���n���um�b�Gered��from�0�to�15,��and�m���ust�b�e�initialized�b�efore�b�eing�used�b���y�the�function��plotinit�,��whic�h���sp�Gecies�Ithe�heigh���t�and�width�of�the�virtual�windo�w�(called�a���r��}'e�ctwindow��9��in�the�sequel).���A�t�all���times,��a��[virtual�cursor�(initialized�at�[0�;����0])�is�asso�Gciated�to�the�windo���w,�and�its�curren���t�v��q�alue�can���b�Ge�UUobtained�using�the�function��plotcursor�.����A�Z�n���um�b�Ger�[of�primitiv���e�graphic�ob��8jects�(called���r��}'e�ct��`Z�ob�jects)�can�then�b�Ge�dra���wn�in�these�windo�ws,���using���a�default�color�asso�Gciated�to�that�windo���w�(whic�h�can�b�Ge�c�hanged�under�X11,�AAusing�the����plotcolor��@�function,���blac���k�otherwise)�and�only�the�part�of�the�ob��8ject�whic�h�is�inside�the�windo�w���will��2b�Ge�dra���wn,���with�the�exception�of�p�olygons�and�strings�whic���h�are�dra�wn�en�tirely�(but�the�virtual���cursor�WKcan�mo���v�e�WKoutside�of�the�windo���w).�w�The�ones�sharing�the�prex��plotr��dra�w�relativ�ely�to�the���curren���t� >p�Gosition�of�the�virtual�cursor,�*�the�others�use�absolute�co�ordinates.�`Those�ha���ving�the�prex����plotrecth�_��put�in�the�rect���windo�w�_�a�large�batc���h�of�rect�ob��8jects�corresp�Gonding�to�the�output�of�the���related�UU�ploth��function.����Finally��*�,�J�the��Wactual�ph���ysical�dra�wing�is�done�using�the�function��plotdraw�.�	$�Note�that�the���windo���ws��are�preserv�ed�so�that�further�dra�wings�using�the�same�windo�ws�at�dieren�t�p�Gositions�or���dieren���t���windo�ws�can�b�Ge�done�without�extra�w�ork.��If�y�ou�w�an�t�to�erase�a�windo�w�(and�free�the���corresp�Gonding�7�memory),�=use�the�function��plotkill�.�g�It�is�not�p�ossible�to�partially�erase�a�windo���w.���Erase��it�completely��*�,�/Ginitialize�it�again�and�then�ll�it�with�the�graphic�ob��8jects�that�y���ou�w�an�t�to���k���eep.��������156����	;+�����Kf�����卑�In�	�addition�to�initializing�the�windo���w,�6�y�ou�	�ma�y�w�an�t�to�ha�v�e�a�scaled�windo�w�to�a�v�oid�un-���necessary�H�con���v�ersions.�LWF��*�or�this,���use�the�function��plotscale��b�Gelo�w.�LWAs�long�as�this�function�is���not��called,�
Uthe�scaling�is�simply�the�n���um�b�Ger��of�pixels,�the�origin�b�Geing�at�the�upp�er�left�and�the����y�[٫-co�Gordinates�UUgoing�do���wn�w�ards.���9��Note�[that�in�the�presen���t�v�ersion�2.2.7�all�these�plotting�functions�(b�Goth�lo�w�and�high�lev�el)���ha���v�e���b�Geen�written�for�the�X11-windo���w�system�(hence�also�for�GUI's�based�on�X11�suc�h�as�Op�Gen-���windo���ws�~and�Motif��)�only��*�,�Cthough�v�ery�little�co�Gde�remains�whic�h�is�actually�platform-dep�Genden�t.�U�A���Sun���to�Gols/Sun�view,�KHMacin�tosh,�and�H�an�A���tari/Gem�p�Gort�w�ere�pro�vided�for�previous�v�ersions.�m�These����may�7ҫb�Ge�UUadapted�in�future�releases.����Under�ܑX11/Sun���to�Gols,��`the�ph�ysical�windo�w�(op�Gened�b�y��plotdraw��or�an�y�of�the��ploth*��func-���tions)��Fis�completely�separated�from�GP��'(tec���hnically��*�,��|a��fork��is�done,�and�the�non-graphical�memory���is��immediately�freed�in�the�c���hild�pro�Gcess),���whic�h�means�y�ou�can�go�on�w�orking�in�the�curren�t�GP���session,���without��ha���ving�to�kill�the�windo�w�rst.�l�Under�X11,���this�windo�w�can�b�Ge�closed,���enlarged���or��reduced�using�the�standard�windo���w�manager�functions.���No�zo�Goming�pro�cedure�is�implemen���ted���though�UU(y���et).��������Finally��*�,���note�that�in�the�same�w���a�y��that��printtex��allo���ws�y�ou�to�ha�v�e�a�T���U>�'E���xX�output�corre-���sp�Gonding��to�prin���ted�results,��the�functions�starting�with��ps��allo�w�y�ou�to�ha�v�e��PostScript��output�of���the���plots.�G�This�will�not�b�Ge�absolutely�iden���tical�with�the�screen�output,��2but�will�b�e�sucien���tly�close.���Note��^that�y���ou�can�use�P�ostScript�output�ev�en�if�y�ou�do�not�ha�v�e�the�plotting�routines�enabled.�? The���P���ostScript�
�output�is�written�in�a�le�whose�name�is�deriv�ed�from�the��psfile��default�(�./pari.ps��if���y���ou�‰did�not�tamp�Ger�with�it).�@�Eac�h�time�a�new�P�ostScript�output�is�ask�ed�for,���the�P�ostScript�output���is�Oqapp�Gended�to�that�le.�o�Hence�the�user�m���ust�remo�v�e�this�le,�P�or�c�hange�the�v��q�alue�of��psfile�,�P�rst���if��rhe�do�Ges�not�w���an�t��runnecessary�dra���wings�from�preceding�sessions�to�app�ear.�VOn�the�other�hand,���in�UUthis�manner�as�man���y�plots�as�desired�can�b�Ge�k�ept�in�a�single�le.��V����None�1�of�the�gr��}'aphic�functions�ar�e�available�within�the�P��;�ARI�1�libr�ary,�Y'you�must�b�e�under�GP���to��'use�them��c�.��JThe�i+reason�for�that�is�that�y���ou�really�should�not�use�P��*�ARI�i&for�hea�vy-dut�y�graphical���w���ork,���there���are�m�uc�h�b�Getter�sp�ecialized�alternativ���es�around.��}This�whole�set�of�routines�w�as�only���mean���t��<as�a�con�v�enien�t,���but�simple-minded,�visual�aid.��}If�y���ou�really�insist�on�using�these�in�y�our���program��;(w���e�w�arned�y�ou),��4the�source�(�plot*.c�)�should�b�Ge�readable�enough�for�y�ou�to�ac�hiev�e���something.���r��3.10.1��jplot�(�X��,�=��J�a;���b;���expr��O>�;��f��Ymin��'�g�;��f��Ymax�����g�):��crude�vs(ASCI�GI)�vkplot�of�the�function�represen���ted�b�y���expression�����expr���z�from���a��to��b�,���with���Y����ranging�from���Ymin�� k�to���Ymax��=��.�x�If���Ymin���(resp.��x��Ymax�� 	L�)�is�not���giv���en,�UUthe�minima�(resp.�q�the�maxima)�of�the�computed�v��q�alues�of�the�expression�is�used�instead.����3.10.2��plotb�Q�o��9x�(�w�D�;���x�2�;�y�[٫2):�Ҕlet���(�x�1�;�y��1)���b�Ge�the�curren���t�p�osition�of�the�virtual�cursor.��Dra���w�in�the���rect���windo�w���w���the�outline�of�the�rectangle�whic���h�is�suc�h�that�the�p�Goin�ts�(�x�1�;���y�[٫1)�and�(�x�2�;�y�[٫2)�are���opp�Gosite��]corners.���Only�the�part�of�the�rectangle�whic���h�is�in��w��@�is�dra�wn.���The�virtual�cursor�do�Ges����not�H-�mo���v�e.����3.10.3�),plotclip�(�w�D�):��`clips'��=the�con���ten�t��=of�rect���windo�w��=�w��,��wi.e�remo���v�e��=all�parts�of�the�dra���wing�that���w���ould�uRnot�b�Ge�visible�on�the�screen.�ѾT��*�ogether�with��plotcopy��this�function�enables�y�ou�to�dra�w�on���a�UUscratc���hpad�b�Gefore�commiting�the�part�y�ou're�in�terested�in�to�the�nal�picture.��������157����	L卟���Kf�������3.10.4��"plotcolor�(�w�D�;���c�):��set�@default�color�to��c��in�rect���windo�w�@�w��.���In�presen���t�v�ersion�2.2.7,�=�this�is���only��implemen���ted�for�X11�windo�w�system,�!�and�y�ou�only�ha�v�e�the�follo�wing�palette�to�c�ho�Gose�from:����1=blac���k,�UU2=blue,�3=sienna,�4=red,�5=cornsilk,�6=grey��*�,�7=gainsb�Gorough.����Note�ʥthat�it�should�b�Ge�fairly�easy�for�y���ou�to�hardwire�some�more�colors�b�y�t�w�eaking�the���les��c�rect.h��and��plotX.c�.�a�User-dened�colormaps�w���ould�b�Ge�nice,��fand��may���b�e�a���v��q�ailable�in�future���v���ersions.������3.10.5�BKplotcop��9y�(�w�D�1�;���w��2�;�dx;�dy�[٫):��cop���y���the�con�ten�ts�of�rect�windo�w��w�D�1�to�rect�windo�w��w�D�2,��with���oset�UU(�dx;���dy�[٫).����3.10.6�[�plotcursor�(�w�D�):�[9giv���e��as�a�2-comp�Gonen�t�v�ector�the�curren�t�(scaled)�p�Gosition�of�the�virtual���cursor�UUcorresp�Gonding�to�the�rect���windo�w�UU�w�D�.����3.10.7���plotdra��9w�(�l�2`ist�):�ph���ysically��dra�w�the�rect�windo�ws�giv�en�in��l�2`ist��whic�h�m�ust�b�Ge�a�v�ector�whose���n���um�b�Ger��7of�comp�onen���ts�is�divisible�b�y�3.�.lIf��l�2`ist�/�=�[�w�D�1�;���x�1�;�y�[٫1�;�w��2�;�x�2�;�y�[٫2�;��:�:�:��
UO�],���the��7windo���ws��w��1,���w��2,���etc.�x�are�ph���ysically�placed�with�their�upp�Ger�left�corner�at�ph�ysical�p�Gosition�(�x�1�;���y�[٫1),��\(�x�2�;�y��2),��:�:�:�����resp�Gectiv���ely��*�,��Uand�|�are�then�dra�wn�together.��`Ov�erlapping�regions�will�th�us�b�Ge�dra�wn�t�wice,��Uand�the���windo���ws�I�are�considered�transparen�t.�m�Then�displa�y�the�whole�dra�wing�in�a�sp�Gecial�windo�w�on�y�our���screen.����3.10.8�fGplotfile�(�s�):�m�set��`the�output�le�for�plotting�output.���The�sp�Gecial�lename��"-"��redirects�to���the�UUsame�place�as�P��*�ARI�output.�q�This�is�only�tak���en�in�to�accoun�t�b�y�the��gnuplot��in�terface.����3.10.9���ploth�(�X��E�=��c�a;���b;���expr��O>�;��f��flag��-/�=�0�g�;��f�n��=�0�g�):�܉high�
�precision�plot�of�the�function��y�Q<�=��f���(�x�)���represen���ted��Kb�y�the�expression���expr��v�,��x��going�from��a��to��b�.��This�op�Gens�a�sp�ecic�windo���w�(whic�h�is���killed��whenev���er�y�ou�clic�k�on�it),�!
and�returns�a�four-comp�Gonen�t�v�ector�giving�the�co�Gordinates�of�the���b�Gounding�UUb�o���x�in�the�form�[��xmin��Eȱ;�����xmax��o��;�����ymin��'�;�����ymax���l�].��B��Imp�Q�ortan��9t�#Qnote�:��iSince��&this�ma���y�in�v�olv�e�a�lot�of�function�calls,��it�is�advised�to�k�eep�the�curren�t���precision�UUto�a�minim���um�(e.g.�9)�b�Gefore�calling�this�function.�����n�:��sp�Gecies�the�n���um�b�er�:�of�reference�p�oin���t�on�the�graph�(0�means�use�the�hardwired�default���v��q�alues,�UUthat�is:�q�1000�for�general�plot,�1500�for�parametric�plot,�and�15�for�recursiv���e�plot).����If���no���flag��y2�is�giv���en,����expr��8ӫis�either�a�scalar�expression��f���(�X���),��in�whic�h�case�the�plane�curv�e����y�8Ы=����f���(�X���)�buwill�b�Ge�dra���wn,�e�or�a�v�ector�[�f����1��|s�(�X���)�;����:�:�:����;���f����k��됫(�X��)],�e�and�buthen�all�the�curv�es��y�8Ы=����f����i��TL�(�X���)�will�b�Ge���dra���wn�UUin�the�same�windo�w.���The�UUbinary�digits�of���flag���v�mean:������^c�1���=���Parametric��9��:����p��}'ar�ametric���plot��ث.���Here���expr��a\�m���ust�b�Ge�a�v�ector�with�an�ev�en�n�um�b�Ger�of���comp�Gonen���ts.�u�Successiv�e�V�pairs�are�then�understo�o�d�as�the�parametric�co�ordinates�of�a�plane�curv���e.���Eac���h�UUof�these�are�then�dra�wn.����F��*�or�UUinstance:�����ploth(X=0,2*Pi,[sin(X),cos(X)],1)�UU�will�dra���w�a�circle.�����ploth(X=0,2*Pi,[sin(X),cos(X)])�UU�will�dra���w�t�w�o�en�t�wined�sin�usoidal�curv�es.�����ploth(X=0,2*Pi,[X,X,sin(X),cos(X)],1)�UU�will�dra���w�a�circle�and�the�line��y�"�=���x�.��������158����	^t�����Kf�����卑��9�2�D=���Recursive��3���:�:��r��}'e�cursive�f7plot��ث.��If�this�
ag�is�set,�sonly��one��I�curv���e�can�b�Ge�dra�wn�at�time,���i.e.����expr�����m���ust��b�Ge�either�a�t�w�o-comp�Gonen�t�v�ector�(for�a�single�parametric�curv�e,��and�the�parametric���
ag�p�has�B9�to�b�Ge�set),�v�or�a�scalar�function.��The�idea�is�to�c���ho�ose�pairs�of�successiv���e�reference�p�oin���ts,���and���if�their�middle�p�Goin���t�is�not�to�o�far�a���w�a�y���from�the�segmen���t�joining�them,��4dra�w�this�as�a�lo�Gcal���appro���ximation�Pto�the�curv�e.�pOtherwise,�Qadd�the�middle�p�Goin�t�to�the�reference�p�Goin�ts.�pThis�is�v�ery���fast,�UUand�usually�more�precise�than�usual�plot.�q�Compare�the�results�of��C����H���ploth�(�X���=���1�;����1�;��sin�(�1�=�X�)�;��2�)����J�and����g�ploth�(�X���=���1�;����1�;��sin�(�1�=�X�))����for�%�instance.��But�b�Gew���are�that�if�y�ou�are�extremely�unluc�ky��*�,�Zor�c�ho�Gose�to�o�few�reference�p�oin���ts,���y���ou�]ma�y�dra�w�some�nice�p�Golygon�b�earing�little�resem���blance�to�the�original�curv�e.�ZF��*�or�instance�y�ou���should�UU�never�h�plot�recursiv���ely�an�o�Gdd�function�in�a�symmetric�in�terv��q�al�around�0.�q�T��*�ry���u����ploth(x�?�=�-20,�20,�sin(x),�2)��C���to��{see�wh���y��*�.��:Hence,��Eit's�usually�a�go�Go�d��{idea�to�try�and�plot�the�same�curv�e�with�sligh�tly�dieren�t���parameters.����The�UUother�v��q�alues�toggle�v�arious�displa���y�options:���������4�#!=���no���E�ff&f��ǫRescale��6*��:��9do�not�rescale�plot�according�to�the�computed�extrema.�rThis�is�mean���t�to���b�Ge���used�when�graphing�m���ultiple�functions�on�a�rect�windo�w�(as�a��plotrecth��call),��zin�conjunction���with�UU�plotscale�.������UU�8��=���no���E�ff&f��ǫX���E�ff&f��axis��/Y�:�q�do�not�prin���t�the��x�-axis.������UU�16��=���no���E�ff&f��ǫY���E�ff&f��axis��/Y�:�q�do�not�prin���t�the��y�[٫-axis.������UU�32��=���no���E�ff&f��ǫFrame��+N��:�q�do�not�prin���t�frame.������UU�64��=���no���E�ff&f��ǫLines��+N��:�q�only�plot�reference�p�Goin���ts,�do�not�join�them.������UU�128��=���Points����5�C�scmtt8�t��8�oo��0��:�q�plot�b�Goth�lines�and�p�oin���ts.������UU�256��=���Splines��'��:�q�use�splines�to�in���terp�Golate�the�p�oin���ts.������UU�512��=���no���E�ff&f��ǫX���E�ff&f��ticks��4VV�:�q�plot�no��x�-tic���ks.������UU�1024��=���no���E�ff&f��ǫY���E�ff&f��ticks��4VV�:�q�plot�no��y�[٫-tic���ks.������UU�2048��=���Same���E�ff&f��ǫticks��5Ψ�:�q�plot�all�tic���ks�with�the�same�length.���0��3.10.10�(plothra��9w�(��listx���T�;�����listy��p��;����f��flag��v��=�>�0�g�):��giv���en���?�listx��ҫand���?�listy����t�w�o��?v�ectors�of�equal�length,��9plots���(in��Ihigh�precision)�the�p�Goin���ts�whose�(�x;���y�[٫)-co�ordinates�are�giv���en�in���listx��J�and���listy��{L�.���Automatic���p�Gositioning�W�and�scaling�is�done,���but�with�the�same�scaling�factor�on��x��and��y�[٫.�y�If���flag��綫is�1,�join���p�Goin���ts,�^�other�\�non-0�
ags�toggle�displa�y�options�and�should�b�Ge�com�binations�of�bits�2���^��k��됫,�^ȱk�$H��ӱ�3�as�in����ploth�.����3.10.11�$plothsizes�():�P�return�D�data�corresp�Gonding�to�the�output�windo���w�in�the�form�of�a�6-���comp�Gonen���t��}v�ector:��windo�w�width�and�heigh�t,�#�sizes�for�tic�ks�in�horizon�tal�and�v�ertical�directions���(this�_is�in���tended�for�the��gnuplot��in�terface�and�is�curren�tly�not�signican�t),�=�width�and�heigh�t�of���c���haracters.��������159����	m덟���Kf�������3.10.12��plotinit�(�w�D�;���x;�y�[�;��f��flag��7̷g�):�Npinitialize��the�rect���windo�w���w��,��destro�ying��an�y�rect�ob��8jects�y�ou�ma�y���ha���v�e���already�dra���wn�in��w�D�.��FThe�virtual�cursor�is�set�to�(0�;����0).�The�rect���windo�w���size�is�set�to�width����x����and�heigh���t��y�[٫.�qvIf���flag��7~�=�U#0,��ޱx��and��y�h�represen�t�pixel�units.�qvOtherwise,��ޱx��and��y�h�are�understo�Go�d���as���fractions���of�the�size�of�the�curren���t�output�device�(hence�m�ust�b�Ge�b�et���w�een���0�and�1)�and�in���ternally���con���v�erted�UUto�pixels.��|���The���plotting�device�imp�Goses�an�upp�er�b�ound�for��x��and��y�[٫,��for�instance�the�n���um�b�er���of�pixels���for�5screen�output.��hThese�b�Gounds�are�a���v��q�ailable�through�the��plothsizes��function.�The�follo���wing���sequence�T�initializes�in�a�p�Gortable�w���a�y�T�(i.e�indep�enden���t�of�the�output�device)�a�windo�w�of�maximal���size,�UUaccessed�through�co�Gordinates�in�the�[0�;����1000]�8���[0�;��1000]�UUrange:�����s�?�=�plothsizes();����plotinit(0,�?�s[1]-1,�s[2]-1);����plotscale(0,�?�0,1000,�0,1000);��v��3.10.13���plotkill�(�w�D�):�ѷerase�Mrect���windo�w��w�J0�and�free�the�corresp�Gonding�memory��*�.���Note�that�if�y�ou���w���an�t��/to�use�the�rect���windo�w��/�w�$�again,��y�ou�ha�v�e�to�use��plotinit��rst�to�sp�Gecify�the�new�size.�VSo���it's�
�b�Getter�in�this�case�to�use��plotinit��directly�as�this�thro���ws�a�w�a�y�an�y�previous�w�ork�in�the�giv�en���rect���windo�w.����3.10.14�O�plotlines�(�w�D�;���X�:�;�Y��9;��f��flag��#��=��0�g�):�(dra���w���on�the�rect�windo�w��w��i�the�p�Golygon�suc�h�that�the���(x,y)-co�Gordinates��of�the�v���ertices�are�in�the�v�ectors�of�equal�length��X��׫and��Y�8�.�t�F��*�or�simplicit�y��*�,�+�the���whole�/�p�Golygon�is�dra���wn,�7'not�only�the�part�of�the�p�olygon�whic���h�is�inside�the�rect�windo�w.�e4If���flag����is���non-zero,�UUclose�the�p�Golygon.�q�In�an���y�case,�the�virtual�cursor�do�es�not�mo���v�e.��|����X��Z�and��x�Y�8\�are�allo���w�ed��xto�b�Ge�scalars�(in�this�case,��b�oth�ha���v�e��xto).�U(There,��a�single�segmen���t�will�b�e���dra���wn,��@b�Get�w�een�лthe�virtual�cursor�curren���t�p�osition�and�the�p�oin���t�(�X�:�;���Y�8�).�E�And�only�the�part�thereof���whic���h���actually�lies�within�the�b�Goundary�of��w�D�.��Then��move�x�the�virtual�cursor�to�(�X�:�;���Y�8�),��Xev�en�if�it���is��@outside�the�windo���w.��If�y�ou�w�an�t�to�dra�w�a�line�from�(�x�1�;���y�[٫1)�to�(�x�2�;�y�[٫2)�where�(�x�1�;�y�[٫1)�is�not���necessarily�UUthe�p�Gosition�of�the�virtual�cursor,�use��plotmove(w,x1,y1)��b�efore�using�this�function.����3.10.15��4plotlinet��9yp�Q�e�(�w�D�;�����typ��}'e��˯�):�
c���hange��the�t�yp�Ge�of�lines�subsequen�tly�plotted�in�rect�windo�w��w�D�.�����typ��}'e���Ʒ�2���corresp�Gonds�to�frames,��w��1�to�axes,�larger�v��q�alues�ma���y�corresp�Gond�to�something�else.�/��w���=����1���c���hanges�UUhighlev�el�plotting.�q�This�is�only�tak�en�in�to�accoun�t�b�y�the��gnuplot��in�terface.����3.10.16��Tplotmo��9v�e�(�w�D�;���x;�y�[٫):�q�mo���v�e�UUthe�virtual�cursor�of�the�rect���windo�w�UU�w��8�to�p�Gosition�(�x;���y��).����3.10.17�Vplotp�Q�oin��9ts�(�w�D�;���X�:�;�Y�8�):�֪dra���w���on�the�rect�windo�w��w�̩�the�p�Goin�ts�whose�(�x;���y�[٫)-co�Gordinates�are���in�1�the�v���ectors�of�equal�length��X��}�and��Y�j�and�whic�h�are�inside��w�D�.�e�The�virtual�cursor�do�Ges��not�$s�mo�v�e.���This��Wis�basically�the�same�function�as��plothraw�,��Wbut�either�with�no�scaling�factor�or�with�a�scale���c���hosen�UUusing�the�function��plotscale�.��|���As��w���as�the�case�with�the��plotlines��function,�0ƱX��īand��Y�=ƫare�allo�w�ed�to�b�Ge�(sim�ultaneously)���scalar.��In��	this�case,���dra���w�the�single�p�Goin�t�(�X�:�;���Y�8�)�on�the�rect�windo�w��w���(if�it�is�actually�inside��w�D�),���and�UUin�an���y�case��move���the�virtual�cursor�to�p�Gosition�(�x;���y�[٫).����3.10.18���plotp�Q�oin��9tsize�(�w�D�;���siz�p�e�):��Mc���hanges�Rathe�\size"�of�follo�wing�p�Goin�ts�in�rect�windo�w��w�D�.�vIf��w���=����1,���c���hange�UUit�in�all�rect�windo�ws.�q�This�only�w�orks�in�the��gnuplot��in�terface.����3.10.19�5plotp�Q�oin��9tt�yp�e�(�w�D�;�����typ��}'e��˯�):�,c���hange���the�t�yp�Ge�of�p�oin���ts�subsequen�tly�plotted�in�rect�windo�w��w�D�.�����typ��}'e���ݫ=��ַ�1�c�corresp�Gonds�to�a�dot,�g#larger�v��q�alues�ma���y�corresp�ond�to�something�else.����w�#��=��ַ�1�c���hanges���highlev���el�UUplotting.�q�This�is�only�tak�en�in�to�accoun�t�b�y�the��gnuplot��in�terface.��������160����	|x�����Kf�������3.10.20���plotrb�Q�o��9x�(�w�D�;���dx;�dy�[٫):�Zedra���w�&�in�the�rect�windo�w��w�kt�the�outline�of�the�rectangle�whic�h�is�suc�h���that��rthe�p�Goin���ts�(�x�1�;���y�[٫1)�and�(�x�1�`�+��dx;�y�[٫1�+��dy��)��rare�opp�Gosite�corners,��ywhere�(�x�1�;���y��1)�is�the�curren���t���p�Gosition���of�the�cursor.���Only�the�part�of�the�rectangle�whic���h�is�in��w��|�is�dra�wn.���The�virtual�cursor���do�Ges�UU�not�H-�mo���v�e.��M��3.10.21�M[plotrecth�(�w�D�;���X���=���a;�b;���expr��O>�;��f��flag��ث=�0�g�;��f�n��=�0�g�):���writes��Oto�rect���windo�w��O�w��2�the�curv���e���output�UUof��ploth�(�w�D�;���X����=���a;�b;���expr��O>�;���flag���t�;�n�).����3.10.22��Oplotrecthra��9w�(�w�D�;�����data��ֱ;����f��flag��$��=��0�g�):���plot�k�graph(s)�for���data��D�in�rect���windo�w�k�w��.�����flag��YD�has�the���same�UUsignicance�here�as�in��ploth�,�though�recursiv���e�plot�is�no�more�signican�t.����data��&����is��ca�v���ector�of�v�ectors,���eac�h�corresp�Gonding�to�a�list�a�co�ordinates.�BwIf�parametric�plot�is�set,���there���m���ust�^�b�Ge�an�ev�en�n�um�b�Ger�of�v�ectors,�`�eac�h�successiv�e�pair�corresp�Gonding�to�a�curv�e.���Otherwise,�`�the���rst� one�con���tains�the��x��co�Gordinates,�+and�the�other�ones�con�tain�the��y�[٫-co�Gordinates�of�curv�es�to�plot.����3.10.23��plotrline�(�w�D�;���dx;�dy�[٫):���dra���w�kmin�the�rect�windo�w��w��P�the�part�of�the�segmen�t�(�x�1�;���y�[٫1)�G����(�x�1�+����dx;���y�[٫1�U+��dy��)��mwhic���h�is�inside��w�D�,��5where�(�x�1�;���y��1)�is�the�curren���t�p�Gosition�of�the�virtual�cursor,��5and�mo�v�e���the�UUvirtual�cursor�to�(�x�1�8�+��dx;���y�[٫1�+��dy��)�UU(ev���en�if�it�is�outside�the�windo�w).����3.10.24��Kplotrmo��9v�e�(�w�D�;���dx;�dy�[٫):�v=mo���v�e�W�the�virtual�cursor�of�the�rect���windo�w�W��w��s�to�p�Gosition�(�x�1��+����dx;���y�[٫1�=�+��dy��),�^�where�\�(�x�1�;���y��1)�is�the�initial�p�Gosition�of�the�cursor�(i.e.�to�p�osition�(�dx;���dy�[٫)�relativ���e�to���the�UUinitial�cursor).����3.10.25���plotrp�Q�oin��9t�(�w�D�;���dx;�dy�[٫):��dra���w�uthe�p�Goin�t�(�x�1���+��dx;���y�[٫1�+��dy��)�uon�the�rect���windo�w�u�w�WX�(if�it�is���inside�`�w�D�),�<�where�(�x�1�;���y�[٫1)�is�the�curren���t�p�Gosition�of�the�cursor,�and�in�an���y�case�mo�v�e�the�virtual���cursor�UUto�p�Gosition�(�x�1�8�+��dx;���y�[٫1�+��dy��).����3.10.26�)8plotscale�(�w�D�;���x�1�;�x�2�;�y�[٫1�;�y��2):�&�scale���the�lo�Gcal�co�ordinates�of�the�rect���windo�w����w���so�that��x��go�es���from����x�1�to��x�2�and��y��]�go�Ges�from��y�[٫1�to��y��2�(�x�2�#�<�x�1���and��y��2�#�<�y��1���b�Geing�allo���w�ed).�TInitially��*�,��Pafter���the���initialization��rof�the�rect���windo�w��r�w��U�using�the�function��plotinit�,��9the�default�scaling�is�the�graphic���pixel��coun���t,�$�and�in�particular�the��y�t��axis�is�orien�ted�do�wn�w�ards�since�the�origin�is�at�the�upp�Ger�left.���The���function��plotscale��allo���ws�to�c�hange�all�these�defaults�and�should�b�Ge�used�whenev�er�functions���are�UUgraphed.����3.10.27��plotstring�(�w�D�;���x;��f��flag��')�=��]0�g�):��dra���w�mon�the�rect�windo�w��w��b�the�String��x��(see�Section�2.6.6),���at�UUthe�curren���t�p�Gosition�of�the�cursor.����flag��&���D��is�D�used�for�justication:�ijbits�1�and�2�regulate�horizon���tal�alignmen�t:�ijleft�if�0,�G�righ�t�if�2,�G�cen�ter���if�r1.���Bits�4�and�8�regulate�v���ertical�alignmen�t:��8b�Gottom�if�0,��<top�if�8,�v-cen���ter�if�4.���Can�insert���additional��small�gap�b�Get���w�een��p�oin�t��and�string:��%horizon���tal�if�bit�16�is�set,��v�ertical�if�bit�32�is�set���(see�UUthe�tutorial�for�an�example).����3.10.28�7hplotterm�(��term��j�):�-sets��terminal�where�high�resolution�plots�go�(this�is�curren���tly�only�tak�en���in���to��accoun�t�b�y�the��gnuplot��graphical�driv�er).��Using�the��gnuplot��driv�er,��p�Gossible�terminals�are���the�UUsame�as�in�gn���uplot.�q�If���term����is�"?",�lists�p�Gossible�v��q�alues.��&���T��*�erminal��options�can�b�Ge�app�ended�to�the�terminal�name�and�space;��qterminal�size�can�b�e�put���immediately�UUafter�the�name,�as�in��"gif=300,200"�.�q�P���ositiv�e�UUreturn�v��q�alue�means�success.��������161����	�+�����Kf�������3.10.29��hpsdra��9w�(��list��
�[�):��Jsame�X[as��plotdraw�,���except�that�the�output�is�a�P���ostScript�program�app�Gended���to�UUthe��psfile�.������3.10.30��psploth�(�X��ޫ=����a;���b;���expr��O>�):��?same�`as��ploth�,�b�except�that�the�output�is�a�P���ostScript�program���app�Gended�UUto�the��psfile�.����3.10.31�,�psplothra��9w�(��listx���T�;�����listy��p��):�	�same��@as��plothraw�,��;except�that�the�output�is�a�P���ostScript�pro-���gram�UUapp�Gended�to�the��psfile�.��,TN��3.11��Programming�under�GP�.��!zu��3.11.1��TCon��9trol�statemen�ts�.���ō�A���n���um�b�Ger���of�con���trol�statemen�ts�are�a�v��q�ailable�under�GP��*�.�They�are�simpler�and�ha�v�e�a�syn�tax���sligh���tly�,�dieren�t�from�their�C�,�coun�terparts,�b�but�are�quite�p�Go�w�erful�enough�to�write�an�y�kind�of���program.�Some��of�them�are�sp�Gecic�to�GP��*�,�since�they�are�made�for�n���um�b�er��theorists.�As�usual,����X�-l�will�d�denote�an���y�simple�v��q�ariable�name,��Wand���se��}'q��r��will�alw�a�ys�denote�a�sequence�of�expressions,���including�UUthe�empt���y�sequence.������3.11.1.1�3�break�(�f�n�Oë=�1�g�):��in���terrupts��Vexecution�of�curren�t���se��}'q��P�,���and�immediately�exits�from�the��n����innermost��Yenclosing�lo�Gops,��%within�the�curren���t�function�call�(or�the�top�lev�el�lo�Gop).�E�n��m�ust�b�Ge�bigger���than�UU1.�q�If��n��is�greater�than�the�n���um�b�Ger�UUof�enclosing�lo�ops,�all�enclosing�lo�ops�are�exited.����3.11.1.2�j�for�(�X����=���a;���b;���se��}'q��T:�):�C�the���formal�v��q�ariable��X����going�from��a��to��b�,�Tthe���se��}'q���:�is�ev�aluated.�R�Nothing���is�UUdone�if��a��>�b�.�qDZa�UU�and��b��m���ust�b�Ge�in��R�.����3.11.1.3�0tfordiv�(�n;���X�:�;���se��}'q��T:�):�Bthe���formal�v��q�ariable��X�mt�ranging�through�the�p�Gositiv���e�divisors�of��n�,��bthe���sequence��UU�se��}'q��T<�is�UUev��q�aluated.�qDZn��m���ust�b�Ge�of�t�yp�Ge�in�teger.����3.11.1.4�|Uforprime�(�X����=���a;���b;���se��}'q��T:�):�Kthe��formal�v��q�ariable��X��ӫranging�o���v�er��the�prime�n���um�b�Gers��b�et���w�een����a�I7�to��b��(including��a��and��b��if�they�are�prime),�K�the���se��}'q��<�is�ev��q�aluated.�m�More�precisely��*�,�the�v��q�alue�of��X��is���incremen���ted���to�the�smallest�prime�strictly�larger�than��X�r��at�the�end�of�eac�h�iteration.�n�Nothing�is���done�UUif��a��>�b�.�q�Note�UUthat��a��and��b��m���ust�b�Ge�in��R�.�������?�?�{�forprime(p�=�2,�12,���썑3�print(p);����3�if�?�(p�==�3,�p�=�6);����(��)�����}����2����3����7����11��������162����	�M�����Kf�������3.11.1.5���forstep�(�X����=��˱a;���b;�s;���se��}'q��T:�):��lthe�'formal�v��q�ariable��X��	�going�from��a��to��b�,�*�in�incremen���ts�of��s�,���the���K�se��}'q��(�is��Kev��q�aluated.���Nothing�is�done�if��s�c�>��0��Kand��a�c�>�b��K�or�if��s�c�<��0��Kand��a�c�<�b�.��s��K�m���ust�b�Ge�in��R���^�������or���a�v���ector�of�steps�[�s����1��|s�;����:�:�:����;���s����n��q~�].�In�the�latter�case,��`the�successiv�e�steps�are�used�in�the�order�they���app�Gear�UUin��s�.��D����?�?�forstep(x=5,�20,�[2,4],�print(x))���!��5����7����11����13����17����19��գ��3.11.1.6��forsubgroup�(�H�Ӧ�=���G;����f�B��q�g�;���se��}'q��T:�):��texecutes��y��se��}'q����for�y�eac���h�subgroup��H�I��of�the��ab��}'elian�>�group����G����(giv���en�in�SNF��yform�or�as�a�v�ector�of�elemen�tary�divisors),��_whose�index�is�b�Gounded�b�y��B��q�.��xThe���subgroups���are�not�ordered�in�an���y�ob�vious�w�a�y��*�,��unless��G��is�a��p�-group�in�whic�h�case�Birkho��'s���algorithm��pro�Gduces�them�b���y�decreasing�index.�J�A��subgroup�is�giv�en�as�a�matrix�whose�columns�giv�e���its���generators�on�the�implicit�generators�of��G�.���F��*�or�example,��hthe�follo���wing�prin�ts�all�subgroups�of���index�UUless�than�2�in��G���=��Z�=�2�Z�g����1���S��8��Z�=�2�Z�g����2��|s�:�����?�?�G�=�[2,2];�forsubgroup(H=G,�2,�print(H))���!��[1;�?�1]����[1;�?�2]����[2;�?�1]����[1,�?�0;�1,�1]���b���The�Uvlast�one,�U~for�instance�is�generated�b���y�(�g����1��|s�;���g����1���i�+�8��g����2���).�r*This�Uvroutine�is�in�tended�to�treat�h�uge���groups,�UUwhen��subgrouplist��is�not�an�option�due�to�the�sheer�size�of�the�output.����F��*�or��maximal�sp�Geed�the�subgroups�ha���v�e��b�een�left�as�pro�duced�b���y�the�algorithm.�XMT��*�o�prin�t�them���in�UUcanonical�form�(as�left�divisors�of��G��in�HNF�form),�one�can�for�instance�use��D����?�?�G�=�matdiagonal([2,2]);�forsubgroup(H=G,�2,�print(mathnf(concat(G,H))))���!��[2,�?�1;�0,�1]����[1,�?�0;�0,�2]����[2,�?�0;�0,�1]����[1,�?�0;�0,�1]���b��Note��that�in�this�last�represen���tation,���the�index�[�G�"P�:��H����]��is�giv�en�b�y�the�determinan�t.��See��galois-���subcyclo�UU�and��galoisfixedfield��for��nfsubfields��applications�to�Galois�theory��*�.��դ��W��
�arning:�E�the���presen���t�implemen�tation�cannot�treat�a�group��G�,�"if�one�of�its��p�-Sylo�w�subgroups�has���a�UUcyclic�factor�has�more�than�2���^��31��x�,�resp.�2���^��63���;�elemen���ts�on�a�32-bit,�resp.�64-bit�arc�hitecture.��գ��3.11.1.7��lforv��9ec�(�X����=��ֱv�[�;�����se��}'q��T:�;����f��flag����=�0�g�):���v�Zԫb�Geing���an��n�-comp�onen���t�v�ector�(where��n��is�arbitrary)���of���t���w�o-comp�Gonen�t�v�ectors�[�a����i��TL�;���b����i���]�for�1�!���i����n�,��the���se��}'q���z�is�ev��q�aluated�with�the�formal�v�ariable��X���[1]���going�zfrom��a����1���y�to��b����1��|s�,��:���:�:��
UO�,�X���[�n�]�going�from��a����n��	넫to��b����n��q~�.���The�formal�v��q�ariable�with�the�highest�index���mo���v�es���the�fastest.�\�If���flag����=���1,�!�generate�only�nondecreasing�v���ectors��X���,�and�if���flag����=���2,�generate���only�UUstrictly�increasing�v���ectors��X���.��������163����	�Ѝ����Kf�������3.11.1.8��if�(�a;����f��se��}'q1��>��g�;��f��se��}'q2���g�):�"�if����a��is�non-zero,��+the�expression�sequence���se��}'q1���ͫis�ev��q�aluated,�otherwise���the���expression���se��}'q2��Vy�is�ev��q�aluated.��Of�course,�����se��}'q1��d"�or���se��}'q2���ma���y�b�Ge�empt�y��*�,���so��if�?�(�a�,��se��}'q��
���)��ev��q�aluates�����se��}'q�� �if�vy�a��is�not�equal�to�zero�(y���ou�don't�ha�v�e�to�write�the�second�comma),��and�do�Ges�nothing�otherwise,���whereas���if�?�(�a�,,��se��}'q��
���)��ev��q�aluates���se��}'q����if��a��is�equal�to�zero,�and�do�Ges�nothing�otherwise.�O�Y��*�ou�could�get���the�UUsame�result�using�the��!�qǫ(�not�)�op�Gerator:��if�?�(!�a�,��se��}'q��
���)�.�����Note�?ythat�the�b�Go�olean�?yop�erators��&&��and��||��are�ev��q�aluated�according�to�op�erator�precedence�as���explained�hFin�Section�2.4,�mbut�that,�con���trary�to�other�op�Gerators,�the�ev��q�aluation�of�the�argumen���ts�is���stopp�Ged�UUas�so�on�as�the�nal�truth�v��q�alue�has�b�een�determined.�q�F��*�or�instance�����if�?�(reallydoit�&&�longcomplicatedfunction(),�...)%����is�UUa�p�Gerfectly�safe�statemen���t.����Recall�zZthat�functions�suc���h�as��break��and��next��op�Gerate�on��lo��}'ops�L{�(suc�h�as��for�xxx�,��&�while�,��until�).���The�UU�if��statemen���t�is��not�H-�a�lo�Gop�(ob�viously!).���8��3.11.1.9�Nnext�(�f�n���=�1�g�):���in���terrupts�i�execution�of�curren�t��seq�[٫,���resume�the�next�iteration�of�the���innermost�g�enclosing�lo�Gop,��twithin�the�curren���t�function�call�(or�top�lev�el�lo�Gop).��EIf��n��is�sp�ecied,���resume�q�at�the��n�-th�enclosing�lo�Gop.���If��n��is�bigger�than�the�n���um�b�er�q�of�enclosing�lo�ops,�x�all�enclosing���lo�Gops�UUare�exited.����3.11.1.10�QKreturn�(�f�x���=�0�g�):�8_returns��from�curren���t�subroutine,��{with�result��x�.�K�If��x��is�omitted,�return���the�UU�(void)��v��q�alue�(return�no�result,�lik���e��print�).����3.11.1.11�;un��9til�(�a;�����se��}'q��T:�):��+ev��q�aluates��expression�sequence���se��}'q�����un���til��a��is�not�equal�to�0�(i.e.�un�til��a��is���true).���If����a��is�initially�not�equal�to�0,��֋�se��}'q��<Ыis�ev��q�aluated�once�(more�generally��*�,�֋the�condition�on��a��is���tested�UU�after�h�execution�of�the���se��}'q����,�not�b�Gefore�as�in��while�).����3.11.1.12�Dwhile�(�a;�����se��}'q��T:�):��~while�g1�a��is�non-zero�ev��q�aluate�the�expression�sequence���se��}'q��ë.��ZThe�test�is���made�!��b��}'efor�e���ev��q�aluating�the��seq�[٫,�,
hence�in�particular�if��a��is�initially�equal�to�zero�the���se�q����will�not�b�Ge���ev��q�aluated�UUat