Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/doc/ref/   (GAP Algebra Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 18 kB image not shown  

Quelle  chap17_mj.html   Sprache: HTML

 

 products/Sources/formale Sprachen/GAP/doc/ref/chap17_mj.html


<?xml version="1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
<script
<title>GAP (ref) - Chapter 17: Rational Numbers</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap17"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <a href="chap1_mj.html">

<div class="chlinkprevnexttop"> <a href="chap0_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents"/*************ISO-2022-CN **********************

<p id="mathjaxlink" class="pcenter"><a href="chap17.html">[MathJax off]</a></p>
<p><a id="X87003045878E74DF" java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<div java.lang.StringIndexOutOfBoundsException: Range [64, 10) out of bounds for length 118
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap17_mj.html#X7A76497986DA921F">17.1 <span class="Heading">Rationals: Global Variables</span></a>
</span>
<div class="ContSSBlock">
<="< >span class"n;&<>a ="chap17_mj>1711Rationals/>/
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap17_mj.html#X826E2AA88679B3DF">17.2 <span class="Heading">Elementary Operations for Rationals</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap17_mj.html#X7ED018F5794935F7">17.2-1 IsRat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap17_mj.html#X7BD6E170840F045D">17.2-2 IsPosRat</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap17_mj.html#X81179AC87AC951A8">17.2-3 IsNegRat</a></span>
<span class="ContSS"><br /><span class="nocss"> &java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 1
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap17_mj.html#X81F6B5877A81E727">17.2-5 DenominatorRat</a></span>
<span class="ContSS"><br /><span class="nocss">  <*     -----  ----    -----
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap17_mj.html#X7C8F8693825C28A4">17.2-7 Random</a></span>
</div></div>
</div>

<h3>17 <span class="Heading">Rational Numbers</span></h3>

<p>The <em>rationals</em> form a very important field. On the one hand it is the quotient field of the integers (see chapter <a href="chap14_mj.html#X853DF11B80068ED5"><span class="RefLink">14</span></a>). On the other hand it is the prime field of the fields of characteristic zero (see chapter <*     SO           SO>        -11643-1992 Plane1,GB2312 --165

<p>The former comment suggests the representation actually used. A rational      SS3          ESCO     CNS11643-1992 Planes 3-7

<p>Because the underlying integer arithmetic can compute with arbitrary size integers, the rational arithmetic is always exact, even for rationals whose numerators and denominators have thousands of digits.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">2/3;</span>
2/3
<span class="GAPprompt">gap></span> <span class="GAPinput">66/123;  # numerator and denominator are made relatively prime</span>
22/41
<span class="GAPprompt">gap></span> <span class="GAPinput">17/-13;  # the numerator carries the sign;</span>
-17/13
<span class="GAPprompt">gap></span> <span class="GAPinput">121/11;  # rationals with denominator 1 (when canceled) are integers</span>
11
</pre></div>

<p><a id="X7A76497986DA921F" *      SOdesignator  : ESC"" ""finalchar_for_SO

<h4>17.1 <span class="Heading">Rationals: Global Variables</span></h4>

<p><a id="X7B6029D18570C08A" name="X7B6029D18570C08A"></a></p>

<h5>17.1-1 Rationals</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Rationals</code></td><td class="tdright">( global variable )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsRationals</code>( <var class="Arg">obj</var> )</td><td class="tdright">( filter )</td></tr></table></div>
<pjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

<p><code class="func">IsRationals</code> returns <code class="keyw">true</code> for a prime field that consists of cyclotomic numbers –for example the <strong class="pkg">GAP      $ E         bytes  SO  


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Size( Rationals ); 2/3 in Rationals;</span>
infinity
true
</pre></div>

<p><a id="X826E2AA88679B3DF" name="X826E2AA88679B3DF"></a></p>

<h4>17.2 <span class="Heading">Elementary Operations for Rationals</span></h4>

<p><a id="X7ED018F5794935F7" name="X7ED018F5794935F7"></a></p>

<h5>17.2-1 IsRat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">      $)G   SO 
<p>Every rational number lies in the category <code class="func">IsRat</code>, which is a subcategory of <code class="func">IsCyc</code> (<a href="chap18_mj.html#X841C425281A6F775"><span class="RefLink">18.1-3</span></*        11643plane,until another


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRat( 2/3 );</span>
true
<span class=*
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRat( 11 );</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRat( IsRat );  # `IsRat' is a function, not a rational</span>
   ESC$*H      Indicates the two bytes immediately following
</pre></div>

<p><a id="X7BD6E170840F045D" name="X7BD6E170840F045D"></a></p>

<h5>17.2-2 IsPosRat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsPosRat</java.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 52
<java.lang.StringIndexOutOfBoundsException: Range [33, 2) out of bounds for length 94

<p><a id="X81179AC87AC951A8" name="X81179AC87AC951A8"></a></p>

<h5>17.2-3 IsNegRat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; IsNegRat</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>Every negative rational number lies in the category <code class="func">IsNegRat</code>.</p>

<p><a id="X7D830E7482E7F528" name="X7D830E7482E7F528"></a></p>

<h5>17.2-4 NumeratorRat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; NumeratorRat</code>( <var class="Arg">rat</var> )</td><td class="tdright">(&       $+       Indicatesimmediate  bytes
<p><code class="func">NumeratorRat</code> returns the numerator of the rational <var class="Arg">rat</var>. Because the numerator holds the sign<       11643--3 untilanotherSS3designation


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">NumeratorRat( 2/3 );</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput"># numerator and denominator are made relatively prime:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">NumeratorRat( 66/123 );</span>
22
<span class="GAPprompt">gap></span> <span class="GAPinput">NumeratorRat( 17/-13 );  # numerator holds the sign of the rational</span>
-17
<span class="GAPprompt">gap></span> <span class="GAPinput">NumeratorRat( 11 );      # integers are rationals with denominator 1</span>
11
</pre></div>

<p><a id="X81F6B5877A81E727" name="X81F6B5877A81E727"></a></p>

<h5>17.2-5 DenominatorRat</h5>

<java.lang.StringIndexOutOfBoundsException: Range [16, 4) out of bounds for length 223
<>codeclass=func"DenominatorRat</code> returns the denominator of the rational <var class="Arg">rat</var>. Because the numerator holds the sign of the rational the denominator is always a positive integer. Integers are rationals with the denominator 1, thus <code class="func">DenominatorRat</code> returns 1 for integers.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">DenominatorRat( 2/3 );</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput"># numerator and denominator are made relatively prime:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DenominatorRat( 66/123 );</span>
41
<span class="GAPprompt">gap></span> <span class="GAPinput"># the denominator holds the sign of the rational:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DenominatorRat( 17/-13 );</span>
13
<span class="GAPprompt">gap></span> <span class="GAPinput">DenominatorRat( 11 ); # integers are rationals with denominator 1</span>
1
</pre></div>

<p><a id="X7EB4C646806A2BDE" name="X7EB4C646806A2BDE"></a></p>

<h5>17.2-6 Rat</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#an style='color: green'>8227; Rat</code>( <var class="Arg">elm</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p><code class="func">Rat</code> returns a rational number <var class="Arg">rat</var> whose meaning depends on the type of <var class="Arg">elm</var>.</p>

<p>If <var class="Arg">elm</var> is a string consisting of digits <code class="code">'0'</code>, <code class="code">'1'</code>, <span


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Rat( "1/2" );  Rat( "35/14" );  Rat*ESC $+K        immediatetwobytesjava.lang.StringIndexOutOfBoundsException: Range [70, 66) out of bounds for length 70
1/2
5/2
-35/27
314159/100000
</pre></div>

<p><a id="X7C8F8693825C28A4" name="X7C8F8693825C28A4"></a></p>

<h5>17.2-7 Random</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func",java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 51
<p><code class="func">Random</code> for rationals returns pseudo random rationals which are the quotient of two random integers. See the description of <code class="func">Random</code> (<a href="chap14_mj.html#X8185784B7E228DEA"><span class="RefLink">14


<div class="chlinkprevnextbot"> <a href="chap0_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents">[Contents]</a>    <a href="chap16_mj.html">[Previous Chapter]</*isa  java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 48


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <

<hr />
<p class="foot">generated by <a href="https://www.math.rwth java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
<
</html>

Messung V0.5 in Prozent
C=90 H=98 G=94

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.