RandomTools Flavor: nonzero - Maple Programming Help

Home : Support : Online Help : Programming : Random Objects : RandomTools package : Flavors : RandomTools/flavor/nonzero

RandomTools Flavor: nonzero

describe a flavor of a random nonzero rational number

 Calling Sequence nonzero nonzero(opts)

Parameters

 opts - equation(s) of the form option = value where option is one of range, character, or denominator; specify options for the random nonzero rational number

Description

 • The flavor nonzero describes a random nonzero rational number in a particular range.
 To describe a flavor of a random nonzero rational number, use either nonzero or nonzero(opts) (where opts is described following) as the argument to RandomTools[Generate] or as part of a structured flavor.
 • By default, the flavor nonzero describes a random nonzero rational number in the range $-1..1$, exclusive, with a denominator that is a factor of $499999999994$.
 • You can modify the properties of a random nonzero rational number by using the nonzero(opts) form of this flavor. The opts argument can contain one or more of the following equations.
 range = a..b
 This option specifies the range from which the random nonzero rational number is chosen. The left-hand endpoint a is a nonzero rational number and the right-hand endpoint b is a nonzero rational number.
 If the left-hand endpoint of the range is greater than the right-hand endpoint, an exception is raised.
 The default range is $-1..1$.
 character = boundary conditions
 This option specifies whether to include the endpoints of the range from which the random nonzero rational number is chosen. Six boundary definitions are valid: open, closed, open..open, open..closed, closed..open, and closed..closed. The default value for this option is open.
 The definitions open and closed are abbreviations for open..open and closed..closed, respectively.
 If the range option is used in conjunction with this option, and a value outside the boundary definition is returned, then the nonzero rational number closest to (but not touching) the range endpoint is chosen.
 denominator = posint
 This option specifies the positive integer to use as the denominator for the random nonzero rational number that is generated.
 The default denominator for a nonzero flavor is related to $999999999989$. (It depends on whether the endpoints are open or closed and the length of the interval.) The default denominator is $499999999994$.
 In the case of the closed interval $-1..1$, the denominator has only $4$ factors ($2$, $11$, $124847$, $182041$) only two of which are under $100000$. Therefore, a result of $\frac{1}{3}$ cannot occur. Instead, you can specify a denominator that is highly composite. For example, $720720$.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{Generate}\left(\mathrm{nonzero}\right)$
 ${-}\frac{{6952075964}}{{33333333333}}$ (1)
 > $\mathrm{Generate}\left(\mathrm{nonzero}\left(\mathrm{range}=-2..5\right)\right)$
 $\frac{{2224811806599}}{{499999999994}}$ (2)
 > $\mathrm{Generate}\left(\mathrm{nonzero}\left(\mathrm{range}=-5..\frac{1}{2},\mathrm{denominator}=720720\right)\right)$
 ${-}\frac{{691783}}{{144144}}$ (3)
 > $\mathrm{Generate}\left(\mathrm{nonzero}\left(\mathrm{denominator}=10\right)\right)$
 ${-}\frac{{2}}{{5}}$ (4)
 > $\mathrm{sort}\left(\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{nonzero}\left(\mathrm{denominator}=6,\mathrm{character}=\mathrm{open}..\mathrm{closed}\right)\right),i=1..10\right)\right],'\mathrm{numeric}'\right)$
 $\left[{-}\frac{{5}}{{6}}{,}{-}\frac{{2}}{{3}}{,}{-}\frac{{1}}{{3}}{,}{-}\frac{{1}}{{6}}{,}{-}\frac{{1}}{{6}}{,}\frac{{1}}{{6}}{,}\frac{{1}}{{2}}{,}\frac{{5}}{{6}}{,}{1}{,}{1}\right]$ (5)
 > $\mathrm{Generate}\left(\mathrm{list}\left(\mathrm{nonzero}\left(\mathrm{range}=\frac{7}{2}..\frac{13}{2}\right),10\right)\right)$
 $\left[\frac{{2824418766989}}{{499999999994}}{,}\frac{{266063157821}}{{45454545454}}{,}\frac{{1544922914891}}{{249999999997}}{,}\frac{{95648726854}}{{22727272727}}{,}\frac{{1067844633892}}{{249999999997}}{,}\frac{{1551762047716}}{{249999999997}}{,}\frac{{1783467275605}}{{499999999994}}{,}\frac{{2497150330775}}{{499999999994}}{,}\frac{{2549017297531}}{{499999999994}}{,}\frac{{2080428984921}}{{499999999994}}\right]$ (6)
 > $\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{nonzero}\left(\mathrm{range}=1..7,\mathrm{denominator}=720720\right)\right),i=1..10\right)$
 $\frac{{1254763}}{{180180}}{,}\frac{{671197}}{{240240}}{,}\frac{{1246991}}{{360360}}{,}\frac{{682763}}{{102960}}{,}\frac{{194569}}{{102960}}{,}\frac{{1634179}}{{720720}}{,}\frac{{219959}}{{180180}}{,}\frac{{67751}}{{10010}}{,}\frac{{1229909}}{{360360}}{,}\frac{{1074673}}{{240240}}$ (7)
 > $\mathrm{Matrix}\left(3,3,\mathrm{Generate}\left(\mathrm{nonzero}\left(\mathrm{denominator}=24\right)\mathrm{identical}\left(x\right)+\mathrm{nonzero}\left(\mathrm{denominator}=16\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{ccc}{-}\frac{{7}}{{8}}{}{x}{-}\frac{{11}}{{16}}& \frac{{7}}{{12}}{}{x}{-}\frac{{3}}{{8}}& \frac{{1}}{{8}}{}{x}{-}\frac{{3}}{{8}}\\ \frac{{1}}{{6}}{}{x}{-}\frac{{7}}{{8}}& {-}\frac{{2}}{{3}}{}{x}{+}\frac{{5}}{{16}}& {-}\frac{{11}}{{12}}{}{x}{-}\frac{{7}}{{16}}\\ {-}\frac{{1}}{{8}}{}{x}{-}\frac{{7}}{{16}}& \frac{{2}}{{3}}{}{x}{-}\frac{{3}}{{4}}& \frac{{7}}{{8}}{}{x}{-}\frac{{3}}{{16}}\end{array}\right]$ (8)