~ubuntu-branches/debian/squeeze/maxima/squeeze

« back to all changes in this revision

Viewing changes to doc/info/maxima_12.html

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2006-10-18 14:52:42 UTC
  • mto: (1.1.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061018145242-vzyrm5hmxr8kiosf
ImportĀ upstreamĀ versionĀ 5.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
 
2
<html>
 
3
<!-- Created on September, 20 2006 by texi2html 1.76 -->
 
4
<!--
 
5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
 
6
            Karl Berry  <karl@freefriends.org>
 
7
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
 
8
            and many others.
 
9
Maintained by: Many creative people <dev@texi2html.cvshome.org>
 
10
Send bugs and suggestions to <users@texi2html.cvshome.org>
 
11
 
 
12
-->
 
13
<head>
 
14
<title>Maxima Manual: 12. Polynomials</title>
 
15
 
 
16
<meta name="description" content="Maxima Manual: 12. Polynomials">
 
17
<meta name="keywords" content="Maxima Manual: 12. Polynomials">
 
18
<meta name="resource-type" content="document">
 
19
<meta name="distribution" content="global">
 
20
<meta name="Generator" content="texi2html 1.76">
 
21
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
 
22
<style type="text/css">
 
23
<!--
 
24
a.summary-letter {text-decoration: none}
 
25
pre.display {font-family: serif}
 
26
pre.format {font-family: serif}
 
27
pre.menu-comment {font-family: serif}
 
28
pre.menu-preformatted {font-family: serif}
 
29
pre.smalldisplay {font-family: serif; font-size: smaller}
 
30
pre.smallexample {font-size: smaller}
 
31
pre.smallformat {font-family: serif; font-size: smaller}
 
32
pre.smalllisp {font-size: smaller}
 
33
span.sansserif {font-family:sans-serif; font-weight:normal;}
 
34
ul.toc {list-style: none}
 
35
body
 
36
{
 
37
    color: black;
 
38
    background: white; 
 
39
    margin-left: 8%;
 
40
    margin-right: 13%;
 
41
}
 
42
 
 
43
h1
 
44
{
 
45
    margin-left: +8%;
 
46
    font-size: 150%;
 
47
    font-family: sans-serif
 
48
}
 
49
 
 
50
h2
 
51
{
 
52
    font-size: 125%;
 
53
    font-family: sans-serif
 
54
}
 
55
 
 
56
h3
 
57
{
 
58
    font-size: 100%;
 
59
    font-family: sans-serif
 
60
}
 
61
 
 
62
h2,h3,h4,h5,h6 { margin-left: +4%; }
 
63
 
 
64
div.textbox
 
65
{
 
66
    border: solid;
 
67
    border-width: thin;
 
68
    /* width: 100%; */
 
69
    padding-top: 1em;
 
70
    padding-bottom: 1em;
 
71
    padding-left: 2em;
 
72
    padding-right: 2em
 
73
}
 
74
 
 
75
div.titlebox
 
76
{
 
77
    border: none;
 
78
    padding-top: 1em;
 
79
    padding-bottom: 1em;
 
80
    padding-left: 2em;
 
81
    padding-right: 2em;
 
82
    background: rgb(200,255,255);
 
83
    font-family: sans-serif
 
84
}
 
85
 
 
86
div.synopsisbox
 
87
{
 
88
    border: none;
 
89
    padding-top: 1em;
 
90
    padding-bottom: 1em;
 
91
    padding-left: 2em;
 
92
    padding-right: 2em;
 
93
     background: rgb(255,220,255);
 
94
    /*background: rgb(200,255,255); */
 
95
    /* font-family: fixed */
 
96
}
 
97
 
 
98
pre.example
 
99
{
 
100
    border: none;
 
101
    padding-top: 1em;
 
102
    padding-bottom: 1em;
 
103
    padding-left: 1em;
 
104
    padding-right: 1em;
 
105
    background: rgb(247,242,180); /* kind of sandy */
 
106
    /* background: rgb(200,255,255); */ /* sky blue */
 
107
    font-family: "Lucida Console", monospace
 
108
}
 
109
 
 
110
div.spacerbox
 
111
{
 
112
    border: none;
 
113
    padding-top: 2em;
 
114
    padding-bottom: 2em
 
115
}
 
116
 
 
117
div.image
 
118
{
 
119
    margin: 0;
 
120
    padding: 1em;
 
121
    text-align: center;
 
122
}
 
123
-->
 
124
</style>
 
125
 
 
126
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
 
127
</head>
 
128
 
 
129
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
 
130
 
 
131
<a name="Polynomials"></a>
 
132
<a name="SEC44"></a>
 
133
<table cellpadding="1" cellspacing="1" border="0">
 
134
<tr><td valign="middle" align="left">[<a href="maxima_11.html#SEC43" title="Previous section in reading order"> &lt; </a>]</td>
 
135
<td valign="middle" align="left">[<a href="#SEC45" title="Next section in reading order"> &gt; </a>]</td>
 
136
<td valign="middle" align="left"> &nbsp; </td>
 
137
<td valign="middle" align="left">[<a href="maxima_11.html#SEC42" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
 
138
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
 
139
<td valign="middle" align="left">[<a href="maxima_13.html#SEC47" title="Next chapter"> &gt;&gt; </a>]</td>
 
140
<td valign="middle" align="left"> &nbsp; </td>
 
141
<td valign="middle" align="left"> &nbsp; </td>
 
142
<td valign="middle" align="left"> &nbsp; </td>
 
143
<td valign="middle" align="left"> &nbsp; </td>
 
144
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
 
145
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
 
146
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
 
147
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
 
148
</tr></table>
 
149
<h1 class="chapter"> 12. Polynomials </h1>
 
150
 
 
151
<table class="menu" border="0" cellspacing="0">
 
152
<tr><td align="left" valign="top"><a href="#SEC45">12.1 Introduction to Polynomials</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">  
 
153
</td></tr>
 
154
<tr><td align="left" valign="top"><a href="#SEC46">12.2 Definitions for Polynomials</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">  
 
155
</td></tr>
 
156
</table>
 
157
 
 
158
<hr size="6">
 
159
<a name="Introduction-to-Polynomials"></a>
 
160
<a name="SEC45"></a>
 
161
<table cellpadding="1" cellspacing="1" border="0">
 
162
<tr><td valign="middle" align="left">[<a href="#SEC44" title="Previous section in reading order"> &lt; </a>]</td>
 
163
<td valign="middle" align="left">[<a href="#SEC46" title="Next section in reading order"> &gt; </a>]</td>
 
164
<td valign="middle" align="left"> &nbsp; </td>
 
165
<td valign="middle" align="left">[<a href="#SEC44" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
 
166
<td valign="middle" align="left">[<a href="#SEC44" title="Up section"> Up </a>]</td>
 
167
<td valign="middle" align="left">[<a href="maxima_13.html#SEC47" title="Next chapter"> &gt;&gt; </a>]</td>
 
168
<td valign="middle" align="left"> &nbsp; </td>
 
169
<td valign="middle" align="left"> &nbsp; </td>
 
170
<td valign="middle" align="left"> &nbsp; </td>
 
171
<td valign="middle" align="left"> &nbsp; </td>
 
172
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
 
173
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
 
174
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
 
175
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
 
176
</tr></table>
 
177
<h2 class="section"> 12.1 Introduction to Polynomials </h2>
 
178
 
 
179
<p>Polynomials are stored in Maxima either in General Form or as
 
180
Cannonical Rational Expressions (CRE) form.  The latter is a standard
 
181
form, and is used internally by operations such as factor, ratsimp, and
 
182
so on.
 
183
</p>
 
184
<p>Canonical Rational Expressions constitute a kind of representation
 
185
which is especially suitable for expanded polynomials and rational
 
186
functions (as well as for partially factored polynomials and rational
 
187
functions when RATFAC is set to <code>true</code>).  In this CRE form an
 
188
ordering of variables (from most to least main) is assumed for each
 
189
expression.  Polynomials are represented recursively by a list
 
190
consisting of the main variable followed by a series of pairs of
 
191
expressions, one for each term of the polynomial.  The first member of
 
192
each pair is the exponent of the main variable in that term and the
 
193
second member is the coefficient of that term which could be a number or
 
194
a polynomial in another variable again represented in this form.  Thus
 
195
the principal part of the CRE form of 3*X^2-1 is (X 2 3 0 -1) and that
 
196
of 2*X*Y+X-3 is (Y 1 (X 1 2) 0 (X 1 1 0 -3)) assuming Y is the main
 
197
variable, and is (X 1 (Y 1 2 0 1) 0 -3) assuming X is the main
 
198
variable. &quot;Main&quot;-ness is usually determined by reverse alphabetical
 
199
order.  The &quot;variables&quot; of a CRE expression needn't be atomic.  In fact
 
200
any subexpression whose main operator is not + - * / or ^ with integer
 
201
power will be considered a &quot;variable&quot; of the expression (in CRE form) in
 
202
which it occurs.  For example the CRE variables of the expression
 
203
X+SIN(X+1)+2*SQRT(X)+1 are X, SQRT(X), and SIN(X+1).  If the user does
 
204
not specify an ordering of variables by using the RATVARS function
 
205
Maxima will choose an alphabetic one.  In general, CRE's represent
 
206
rational expressions, that is, ratios of polynomials, where the
 
207
numerator and denominator have no common factors, and the denominator is
 
208
positive.  The internal form is essentially a pair of polynomials (the
 
209
numerator and denominator) preceded by the variable ordering list.  If
 
210
an expression to be displayed is in CRE form or if it contains any
 
211
subexpressions in CRE form, the symbol /R/ will follow the line label.
 
212
See the RAT function for converting an expression to CRE form.  An
 
213
extended CRE form is used for the representation of Taylor series.  The
 
214
notion of a rational expression is extended so that the exponents of the
 
215
variables can be positive or negative rational numbers rather than just
 
216
positive integers and the coefficients can themselves be rational
 
217
expressions as described above rather than just polynomials.  These are
 
218
represented internally by a recursive polynomial form which is similar
 
219
to and is a generalization of CRE form, but carries additional
 
220
information such as the degree of truncation.  As with CRE form, the
 
221
symbol /T/ follows the line label of such expressions.
 
222
</p>
 
223
<hr size="6">
 
224
<a name="Definitions-for-Polynomials"></a>
 
225
<a name="SEC46"></a>
 
226
<table cellpadding="1" cellspacing="1" border="0">
 
227
<tr><td valign="middle" align="left">[<a href="#SEC45" title="Previous section in reading order"> &lt; </a>]</td>
 
228
<td valign="middle" align="left">[<a href="maxima_13.html#SEC47" title="Next section in reading order"> &gt; </a>]</td>
 
229
<td valign="middle" align="left"> &nbsp; </td>
 
230
<td valign="middle" align="left">[<a href="#SEC44" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
 
231
<td valign="middle" align="left">[<a href="#SEC44" title="Up section"> Up </a>]</td>
 
232
<td valign="middle" align="left">[<a href="maxima_13.html#SEC47" title="Next chapter"> &gt;&gt; </a>]</td>
 
233
<td valign="middle" align="left"> &nbsp; </td>
 
234
<td valign="middle" align="left"> &nbsp; </td>
 
235
<td valign="middle" align="left"> &nbsp; </td>
 
236
<td valign="middle" align="left"> &nbsp; </td>
 
237
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
 
238
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
 
239
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
 
240
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
 
241
</tr></table>
 
242
<h2 class="section"> 12.2 Definitions for Polynomials </h2>
 
243
 
 
244
<dl>
 
245
<dt><u>Option variable:</u> <b>algebraic</b>
 
246
<a name="IDX382"></a>
 
247
</dt>
 
248
<dd><p>Default value: <code>false</code>
 
249
</p>
 
250
<p><code>algebraic</code> must be set to <code>true</code> in order for the
 
251
simplification of algebraic integers to take effect.
 
252
</p>
 
253
</dd></dl>
 
254
 
 
255
<dl>
 
256
<dt><u>Option variable:</u> <b>berlefact</b>
 
257
<a name="IDX383"></a>
 
258
</dt>
 
259
<dd><p>Default value: <code>true</code>
 
260
</p>
 
261
<p>When <code>berlefact</code> is <code>false</code> then the Kronecker factoring
 
262
algorithm will be used otherwise the Berlekamp algorithm, which is the
 
263
default, will be used.
 
264
</p>
 
265
</dd></dl>
 
266
 
 
267
<dl>
 
268
<dt><u>Function:</u> <b>bezout</b><i> (<var>p1</var>, <var>p2</var>, <var>x</var>)</i>
 
269
<a name="IDX384"></a>
 
270
</dt>
 
271
<dd><p>an alternative to the <code>resultant</code> command.  It
 
272
returns a matrix. <code>determinant</code> of this matrix is the desired resultant.
 
273
</p>
 
274
</dd></dl>
 
275
 
 
276
<dl>
 
277
<dt><u>Function:</u> <b>bothcoef</b><i> (<var>expr</var>, <var>x</var>)</i>
 
278
<a name="IDX385"></a>
 
279
</dt>
 
280
<dd><p>Returns a list whose first member is the
 
281
coefficient of <var>x</var> in <var>expr</var> (as found by <code>ratcoef</code> if <var>expr</var> is in CRE form
 
282
otherwise by <code>coeff</code>) and whose second member is the remaining part of
 
283
<var>expr</var>.  That is, <code>[A, B]</code> where <code><var>expr</var> = A*<var>x</var> + B</code>.
 
284
</p>
 
285
<p>Example:
 
286
</p>
 
287
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) islinear (expr, x) := block ([c],
 
288
        c: bothcoef (rat (expr, x), x),
 
289
        is (freeof (x, c) and c[1] # 0))$
 
290
(%i2) islinear ((r^2 - (x - r)^2)/x, x);
 
291
(%o2)                         true
 
292
</pre></td></tr></table>
 
293
</dd></dl>
 
294
 
 
295
<dl>
 
296
<dt><u>Function:</u> <b>coeff</b><i> (<var>expr</var>, <var>x</var>, <var>n</var>)</i>
 
297
<a name="IDX386"></a>
 
298
</dt>
 
299
<dd><p>Returns the coefficient of <code><var>x</var>^<var>n</var></code> in <var>expr</var>.  <var>n</var> may be
 
300
omitted if it is 1.  <var>x</var> may be an atom, or complete subexpression of
 
301
<var>expr</var> e.g., <code>sin(x)</code>, <code>a[i+1]</code>, <code>x + y</code>, etc. (In the last case the
 
302
expression <code>(x + y)</code> should occur in <var>expr</var>).  Sometimes it may be necessary
 
303
to expand or factor <var>expr</var> in order to make <code><var>x</var>^<var>n</var></code> explicit.  This is not
 
304
done automatically by <code>coeff</code>.
 
305
</p>
 
306
<p>Examples:
 
307
</p>
 
308
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) coeff (2*a*tan(x) + tan(x) + b = 5*tan(x) + 3, tan(x));
 
309
(%o1)                      2 a + 1 = 5
 
310
(%i2) coeff (y + x*%e^x + 1, x, 0);
 
311
(%o2)                         y + 1
 
312
</pre></td></tr></table>
 
313
</dd></dl>
 
314
 
 
315
<dl>
 
316
<dt><u>Function:</u> <b>combine</b><i> (<var>expr</var>)</i>
 
317
<a name="IDX387"></a>
 
318
</dt>
 
319
<dd><p>Simplifies the sum <var>expr</var> by combining terms with the same
 
320
denominator into a single term.
 
321
</p>
 
322
</dd></dl>
 
323
 
 
324
<dl>
 
325
<dt><u>Function:</u> <b>content</b><i> (<var>p_1</var>, <var>x_1</var>, ..., <var>x_n</var>)</i>
 
326
<a name="IDX388"></a>
 
327
</dt>
 
328
<dd><p>Returns a list whose first element is
 
329
the greatest common divisor of the coefficients of the terms of the
 
330
polynomial <var>p_1</var> in the variable <var>x_n</var> (this is the content) and whose
 
331
second element is the polynomial <var>p_1</var> divided by the content.
 
332
</p>
 
333
<p>Examples:
 
334
</p>
 
335
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) content (2*x*y + 4*x^2*y^2, y);
 
336
                                   2
 
337
(%o1)                   [2 x, 2 x y  + y]
 
338
</pre></td></tr></table>
 
339
</dd></dl>
 
340
 
 
341
<dl>
 
342
<dt><u>Function:</u> <b>denom</b><i> (<var>expr</var>)</i>
 
343
<a name="IDX389"></a>
 
344
</dt>
 
345
<dd><p>Returns the denominator of the rational expression <var>expr</var>.
 
346
</p>
 
347
</dd></dl>
 
348
 
 
349
<dl>
 
350
<dt><u>Function:</u> <b>divide</b><i> (<var>p_1</var>, <var>p_2</var>, <var>x_1</var>, ..., <var>x_n</var>)</i>
 
351
<a name="IDX390"></a>
 
352
</dt>
 
353
<dd><p>computes the quotient and remainder
 
354
of the polynomial <var>p_1</var> divided by the polynomial <var>p_2</var>, in a main
 
355
polynomial variable, <var>x_n</var>.
 
356
The other variables are as in the <code>ratvars</code> function.
 
357
The result is a list whose first element is the quotient
 
358
and whose second element is the remainder.
 
359
</p>
 
360
<p>Examples:
 
361
</p>
 
362
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) divide (x + y, x - y, x);
 
363
(%o1)                       [1, 2 y]
 
364
(%i2) divide (x + y, x - y);
 
365
(%o2)                      [- 1, 2 x]
 
366
</pre></td></tr></table>
 
367
 
 
368
<p>Note that <code>y</code> is the main variable in the second example.
 
369
</p>
 
370
</dd></dl>
 
371
 
 
372
<dl>
 
373
<dt><u>Function:</u> <b>eliminate</b><i> ([<var>eqn_1</var>, ..., <var>eqn_n</var>], [<var>x_1</var>, ..., <var>x_k</var>])</i>
 
374
<a name="IDX391"></a>
 
375
</dt>
 
376
<dd><p>Eliminates variables from
 
377
equations (or expressions assumed equal to zero) by taking successive
 
378
resultants. This returns a list of <code><var>n</var> - <var>k</var></code> expressions with the <var>k</var>
 
379
variables <var>x_1</var>, ..., <var>x_k</var> eliminated.  First <var>x_1</var> is eliminated yielding <code><var>n</var> - 1</code>
 
380
expressions, then <code>x_2</code> is eliminated, etc.  If <code><var>k</var> = <var>n</var></code> then a single expression in a
 
381
list is returned free of the variables <var>x_1</var>, ..., <var>x_k</var>.  In this case <code>solve</code>
 
382
is called to solve the last resultant for the last variable.
 
383
</p>
 
384
<p>Example:
 
385
</p>
 
386
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) expr1: 2*x^2 + y*x + z;
 
387
                                      2
 
388
(%o1)                    z + x y + 2 x
 
389
(%i2) expr2: 3*x + 5*y - z - 1;
 
390
(%o2)                  - z + 5 y + 3 x - 1
 
391
(%i3) expr3: z^2 + x - y^2 + 5;
 
392
                          2    2
 
393
(%o3)                    z  - y  + x + 5
 
394
(%i4) eliminate ([expr3, expr2, expr1], [y, z]);
 
395
             8         7         6          5          4
 
396
(%o4) [7425 x  - 1170 x  + 1299 x  + 12076 x  + 22887 x
 
397
 
 
398
                                    3         2
 
399
                            - 5154 x  - 1291 x  + 7688 x + 15376]
 
400
</pre></td></tr></table>
 
401
</dd></dl>
 
402
 
 
403
<dl>
 
404
<dt><u>Function:</u> <b>ezgcd</b><i> (<var>p_1</var>, <var>p_2</var>, <var>p_3</var>, ...)</i>
 
405
<a name="IDX392"></a>
 
406
</dt>
 
407
<dd><p>Returns a list whose first element is the g.c.d of
 
408
the polynomials <var>p_1</var>, <var>p_2</var>, <var>p_3</var>, ...  and whose remaining elements are the
 
409
polynomials divided by the g.c.d.  This always uses the <code>ezgcd</code>
 
410
algorithm.
 
411
</p>
 
412
</dd></dl>
 
413
 
 
414
<dl>
 
415
<dt><u>Option variable:</u> <b>facexpand</b>
 
416
<a name="IDX393"></a>
 
417
</dt>
 
418
<dd><p>Default value: <code>true</code>
 
419
</p>
 
420
<p><code>facexpand</code> controls whether the irreducible factors
 
421
returned by <code>factor</code> are in expanded (the default) or recursive (normal
 
422
CRE) form.
 
423
</p>
 
424
</dd></dl>
 
425
 
 
426
<dl>
 
427
<dt><u>Function:</u> <b>factcomb</b><i> (<var>expr</var>)</i>
 
428
<a name="IDX394"></a>
 
429
</dt>
 
430
<dd><p>Tries to combine the coefficients of factorials in <var>expr</var>
 
431
with the factorials themselves by converting, for example, <code>(n + 1)*n!</code>
 
432
into <code>(n + 1)!</code>.
 
433
</p>
 
434
<p><code>sumsplitfact</code> if set to <code>false</code> will cause <code>minfactorial</code> to be
 
435
applied after a <code>factcomb</code>.
 
436
</p>
 
437
</dd></dl>
 
438
 
 
439
<dl>
 
440
<dt><u>Function:</u> <b>factor</b><i> (<var>expr</var>)</i>
 
441
<a name="IDX395"></a>
 
442
</dt>
 
443
<dd><p>Factors the expression <var>expr</var>, containing any number of
 
444
variables or functions, into factors irreducible over the integers.
 
445
<code>factor (<var>expr</var>, p)</code> factors <var>expr</var> over the field of integers with an element
 
446
adjoined whose minimum polynomial is p.
 
447
</p>
 
448
<p><code>factor</code> uses <code>ifactors</code> function for factoring integers.
 
449
</p>
 
450
<p><code>factorflag</code> if <code>false</code> suppresses the factoring of integer factors
 
451
of rational expressions.
 
452
</p>
 
453
<p><code>dontfactor</code> may be set to a list of variables with respect to which
 
454
factoring is not to occur.  (It is initially empty).  Factoring also
 
455
will not take place with respect to any variables which are less
 
456
important (using the variable ordering assumed for CRE form) than
 
457
those on the <code>dontfactor</code> list.
 
458
</p>
 
459
<p><code>savefactors</code> if <code>true</code> causes the factors of an expression which
 
460
is a product of factors to be saved by certain functions in order to
 
461
speed up later factorizations of expressions containing some of the
 
462
same factors.
 
463
</p>
 
464
<p><code>berlefact</code> if <code>false</code> then the Kronecker factoring algorithm will
 
465
be used otherwise the Berlekamp algorithm, which is the default, will
 
466
be used.
 
467
</p>
 
468
<p><code>intfaclim</code> if <code>true</code> maxima will give up factorization of
 
469
integers if no factor is found after trial divisions and Pollard's rho
 
470
method.  If set to <code>false</code> (this is the case when the user calls
 
471
<code>factor</code> explicitly), complete factorization of the integer will be
 
472
attempted.  The user's setting of <code>intfaclim</code> is used for internal
 
473
calls to <code>factor</code>. Thus, <code>intfaclim</code> may be reset to prevent
 
474
Maxima from taking an inordinately long time factoring large integers.
 
475
</p>
 
476
<p>Examples:
 
477
</p>
 
478
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) factor (2^63 - 1);
 
479
                    2
 
480
(%o1)              7  73 127 337 92737 649657
 
481
(%i2) factor (-8*y - 4*x + z^2*(2*y + x));
 
482
(%o2)               (2 y + x) (z - 2) (z + 2)
 
483
(%i3) -1 - 2*x - x^2 + y^2 + 2*x*y^2 + x^2*y^2;
 
484
                2  2        2    2    2
 
485
(%o3)          x  y  + 2 x y  + y  - x  - 2 x - 1
 
486
(%i4) block ([dontfactor: [x]], factor (%/36/(1 + 2*y + y^2)));
 
487
                       2
 
488
                     (x  + 2 x + 1) (y - 1)
 
489
(%o4)                ----------------------
 
490
                           36 (y + 1)
 
491
(%i5) factor (1 + %e^(3*x));
 
492
                      x         2 x     x
 
493
(%o5)              (%e  + 1) (%e    - %e  + 1)
 
494
(%i6) factor (1 + x^4, a^2 - 2);
 
495
                    2              2
 
496
(%o6)             (x  - a x + 1) (x  + a x + 1)
 
497
(%i7) factor (-y^2*z^2 - x*z^2 + x^2*y^2 + x^3);
 
498
                       2
 
499
(%o7)              - (y  + x) (z - x) (z + x)
 
500
(%i8) (2 + x)/(3 + x)/(b + x)/(c + x)^2;
 
501
                             x + 2
 
502
(%o8)               ------------------------
 
503
                                           2
 
504
                    (x + 3) (x + b) (x + c)
 
505
(%i9) ratsimp (%);
 
506
                4                  3
 
507
(%o9) (x + 2)/(x  + (2 c + b + 3) x
 
508
 
 
509
     2                       2             2                   2
 
510
 + (c  + (2 b + 6) c + 3 b) x  + ((b + 3) c  + 6 b c) x + 3 b c )
 
511
(%i10) partfrac (%, x);
 
512
           2                   4                3
 
513
(%o10) - (c  - 4 c - b + 6)/((c  + (- 2 b - 6) c
 
514
 
 
515
     2              2         2                2
 
516
 + (b  + 12 b + 9) c  + (- 6 b  - 18 b) c + 9 b ) (x + c))
 
517
 
 
518
                 c - 2
 
519
 - ---------------------------------
 
520
     2                             2
 
521
   (c  + (- b - 3) c + 3 b) (x + c)
 
522
 
 
523
                         b - 2
 
524
 + -------------------------------------------------
 
525
             2             2       3      2
 
526
   ((b - 3) c  + (6 b - 2 b ) c + b  - 3 b ) (x + b)
 
527
 
 
528
                         1
 
529
 - ----------------------------------------------
 
530
             2
 
531
   ((b - 3) c  + (18 - 6 b) c + 9 b - 27) (x + 3)
 
532
(%i11) map ('factor, %);
 
533
              2
 
534
             c  - 4 c - b + 6                 c - 2
 
535
(%o11) - ------------------------- - ------------------------
 
536
                2        2                                  2
 
537
         (c - 3)  (c - b)  (x + c)   (c - 3) (c - b) (x + c)
 
538
 
 
539
                       b - 2                        1
 
540
            + ------------------------ - ------------------------
 
541
                             2                          2
 
542
              (b - 3) (c - b)  (x + b)   (b - 3) (c - 3)  (x + 3)
 
543
(%i12) ratsimp ((x^5 - 1)/(x - 1));
 
544
                       4    3    2
 
545
(%o12)                x  + x  + x  + x + 1
 
546
(%i13) subst (a, x, %);
 
547
                       4    3    2
 
548
(%o13)                a  + a  + a  + a + 1
 
549
(%i14) factor (%th(2), %);
 
550
                       2        3        3    2
 
551
(%o14)   (x - a) (x - a ) (x - a ) (x + a  + a  + a + 1)
 
552
(%i15) factor (1 + x^12);
 
553
                       4        8    4
 
554
(%o15)               (x  + 1) (x  - x  + 1)
 
555
(%i16) factor (1 + x^99);
 
556
                 2            6    3
 
557
(%o16) (x + 1) (x  - x + 1) (x  - x  + 1)
 
558
 
 
559
   10    9    8    7    6    5    4    3    2
 
560
 (x   - x  + x  - x  + x  - x  + x  - x  + x  - x + 1)
 
561
 
 
562
   20    19    17    16    14    13    11    10    9    7    6
 
563
 (x   + x   - x   - x   + x   + x   - x   - x   - x  + x  + x
 
564
 
 
565
    4    3            60    57    51    48    42    39    33
 
566
 - x  - x  + x + 1) (x   + x   - x   - x   + x   + x   - x
 
567
 
 
568
    30    27    21    18    12    9    3
 
569
 - x   - x   + x   + x   - x   - x  + x  + 1)
 
570
</pre></td></tr></table>
 
571
</dd></dl>
 
572
 
 
573
<dl>
 
574
<dt><u>Option variable:</u> <b>factorflag</b>
 
575
<a name="IDX396"></a>
 
576
</dt>
 
577
<dd><p>Default value: <code>false</code>
 
578
</p>
 
579
<p>When <code>factorflag</code> is <code>false</code>, suppresses the factoring of
 
580
integer factors of rational expressions.
 
581
</p>
 
582
</dd></dl>
 
583
 
 
584
<dl>
 
585
<dt><u>Function:</u> <b>factorout</b><i> (<var>expr</var>, <var>x_1</var>, <var>x_2</var>, ...)</i>
 
586
<a name="IDX397"></a>
 
587
</dt>
 
588
<dd><p>Rearranges the sum <var>expr</var> into a sum of
 
589
terms of the form <code>f (<var>x_1</var>, <var>x_2</var>, ...)*g</code> where <code>g</code> is a product of
 
590
expressions not containing any <var>x_i</var> and <code>f</code> is factored.
 
591
</p>
 
592
</dd></dl>
 
593
 
 
594
<dl>
 
595
<dt><u>Function:</u> <b>factorsum</b><i> (<var>expr</var>)</i>
 
596
<a name="IDX398"></a>
 
597
</dt>
 
598
<dd><p>Tries to group terms in factors of <var>expr</var> which are sums
 
599
into groups of terms such that their sum is factorable.  <code>factorsum</code> can
 
600
recover the result of <code>expand ((x + y)^2 + (z + w)^2)</code> but it can't recover
 
601
<code>expand ((x + 1)^2 + (x + y)^2)</code> because the terms have variables in common.
 
602
</p>
 
603
<p>Example:
 
604
</p>
 
605
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) expand ((x + 1)*((u + v)^2 + a*(w + z)^2));
 
606
           2      2                            2      2
 
607
(%o1) a x z  + a z  + 2 a w x z + 2 a w z + a w  x + v  x
 
608
 
 
609
                                     2        2    2            2
 
610
                        + 2 u v x + u  x + a w  + v  + 2 u v + u
 
611
(%i2) factorsum (%);
 
612
                                   2          2
 
613
(%o2)            (x + 1) (a (z + w)  + (v + u) )
 
614
</pre></td></tr></table>
 
615
</dd></dl>
 
616
 
 
617
<dl>
 
618
<dt><u>Function:</u> <b>fasttimes</b><i> (<var>p_1</var>, <var>p_2</var>)</i>
 
619
<a name="IDX399"></a>
 
620
</dt>
 
621
<dd><p>Returns the product of the polynomials <var>p_1</var> and <var>p_2</var> by using a
 
622
special algorithm for multiplication of polynomials.  <code>p_1</code> and <code>p_2</code> should be
 
623
multivariate, dense, and nearly the same size.  Classical
 
624
multiplication is of order <code>n_1 n_2</code> where
 
625
<code>n_1</code> is the degree of <code>p_1</code>
 
626
and <code>n_2</code> is the degree of <code>p_2</code>.
 
627
<code>fasttimes</code> is of order <code>max (n_1, n_2)^1.585</code>.
 
628
</p>
 
629
</dd></dl>
 
630
 
 
631
<dl>
 
632
<dt><u>Function:</u> <b>fullratsimp</b><i> (<var>expr</var>)</i>
 
633
<a name="IDX400"></a>
 
634
</dt>
 
635
<dd><p><code>fullratsimp</code> repeatedly
 
636
applies <code>ratsimp</code> followed by non-rational simplification to an
 
637
expression until no further change occurs,
 
638
and returns the result.
 
639
</p>
 
640
<p>When non-rational expressions are involved, one call
 
641
to <code>ratsimp</code> followed as is usual by non-rational (&quot;general&quot;)
 
642
simplification may not be sufficient to return a simplified result.
 
643
Sometimes, more than one such call may be necessary.
 
644
<code>fullratsimp</code> makes this process convenient.
 
645
</p>
 
646
<p><code>fullratsimp (<var>expr</var>, <var>x_1</var>, ..., <var>x_n</var>)</code> takes one or more arguments similar 
 
647
to <code>ratsimp</code> and <code>rat</code>.
 
648
</p>
 
649
<p>Example:
 
650
</p>
 
651
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) expr: (x^(a/2) + 1)^2*(x^(a/2) - 1)^2/(x^a - 1);
 
652
                       a/2     2   a/2     2
 
653
                     (x    - 1)  (x    + 1)
 
654
(%o1)                -----------------------
 
655
                              a
 
656
                             x  - 1
 
657
(%i2) ratsimp (expr);
 
658
                          2 a      a
 
659
                         x    - 2 x  + 1
 
660
(%o2)                    ---------------
 
661
                              a
 
662
                             x  - 1
 
663
(%i3) fullratsimp (expr);
 
664
                              a
 
665
(%o3)                        x  - 1
 
666
(%i4) rat (expr);
 
667
                       a/2 4       a/2 2
 
668
                     (x   )  - 2 (x   )  + 1
 
669
(%o4)/R/             -----------------------
 
670
                              a
 
671
                             x  - 1
 
672
</pre></td></tr></table>
 
673
</dd></dl>
 
674
 
 
675
<dl>
 
676
<dt><u>Function:</u> <b>fullratsubst</b><i> (<var>a</var>, <var>b</var>, <var>c</var>)</i>
 
677
<a name="IDX401"></a>
 
678
</dt>
 
679
<dd><p>is the same as <code>ratsubst</code> except that it calls
 
680
itself recursively on its result until that result stops changing.
 
681
This function is useful when the replacement expression and the
 
682
replaced expression have one or more variables in common.
 
683
</p>
 
684
<p><code>fullratsubst</code> will also accept its arguments in the format of
 
685
<code>lratsubst</code>.  That is, the first argument may be a single substitution
 
686
equation or a list of such equations, while the second argument is the
 
687
expression being processed.
 
688
</p>
 
689
<p><code>load (&quot;lrats&quot;)</code> loads <code>fullratsubst</code> and <code>lratsubst</code>.
 
690
</p>
 
691
<p>Examples:
 
692
</p>
 
693
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) load (&quot;lrats&quot;)$
 
694
</pre></td></tr></table><ul>
 
695
<li>
 
696
<code>subst</code> can carry out multiple substitutions.
 
697
<code>lratsubst</code> is analogous to <code>subst</code>.
 
698
</li></ul>
 
699
<table><tr><td>&nbsp;</td><td><pre class="example">(%i2) subst ([a = b, c = d], a + c);
 
700
(%o2)                         d + b
 
701
(%i3) lratsubst ([a^2 = b, c^2 = d], (a + e)*c*(a + c));
 
702
(%o3)                (d + a c) e + a d + b c
 
703
</pre></td></tr></table><ul>
 
704
<li>
 
705
If only one substitution is desired, then a single
 
706
equation may be given as first argument.
 
707
</li></ul>
 
708
<table><tr><td>&nbsp;</td><td><pre class="example">(%i4) lratsubst (a^2 = b, a^3);
 
709
(%o4)                          a b
 
710
</pre></td></tr></table><ul>
 
711
<li>
 
712
<code>fullratsubst</code> is equivalent to <code>ratsubst</code>
 
713
except that it recurses until its result stops changing.
 
714
</li></ul>
 
715
<table><tr><td>&nbsp;</td><td><pre class="example">(%i5) ratsubst (b*a, a^2, a^3);
 
716
                               2
 
717
(%o5)                         a  b
 
718
(%i6) fullratsubst (b*a, a^2, a^3);
 
719
                                 2
 
720
(%o6)                         a b
 
721
</pre></td></tr></table><ul>
 
722
<li>
 
723
<code>fullratsubst</code> also accepts a list of equations or a single
 
724
equation as first argument.
 
725
</li></ul>
 
726
<table><tr><td>&nbsp;</td><td><pre class="example">(%i7) fullratsubst ([a^2 = b, b^2 = c, c^2 = a], a^3*b*c);
 
727
(%o7)                           b
 
728
(%i8) fullratsubst (a^2 = b*a, a^3);
 
729
                                 2
 
730
(%o8)                         a b
 
731
</pre></td></tr></table><ul>
 
732
<li>
 
733
<code>fullratsubst</code> may cause an indefinite recursion.
 
734
</li></ul>
 
735
<table><tr><td>&nbsp;</td><td><pre class="example">(%i9) errcatch (fullratsubst (b*a^2, a^2, a^3));
 
736
 
 
737
*** - Lisp stack overflow. RESET
 
738
</pre></td></tr></table>
 
739
</dd></dl>
 
740
 
 
741
<dl>
 
742
<dt><u>Function:</u> <b>gcd</b><i> (<var>p_1</var>, <var>p_2</var>, <var>x_1</var>, ...)</i>
 
743
<a name="IDX402"></a>
 
744
</dt>
 
745
<dd><p>Returns the greatest common divisor of <var>p_1</var> and <var>p_2</var>.
 
746
The flag <code>gcd</code> determines which algorithm is employed.
 
747
Setting <code>gcd</code> to <code>ez</code>, <code>subres</code>, <code>red</code>, or <code>spmod</code> selects the <code>ezgcd</code>,
 
748
subresultant <code>prs</code>, reduced, or modular algorithm,
 
749
respectively.  If <code>gcd</code> <code>false</code> then <code>gcd (<var>p_1</var>, <var>p_2</var>, <var>x</var>)</code> always returns 1
 
750
for all <var>x</var>.  Many functions (e.g.  <code>ratsimp</code>, <code>factor</code>, etc.) cause gcd's
 
751
to be taken implicitly.  For homogeneous polynomials it is recommended
 
752
that <code>gcd</code> equal to <code>subres</code> be used.  To take the gcd when an algebraic is
 
753
present, e.g., <code>gcd (<var>x</var>^2 - 2*sqrt(2)*<var>x</var> + 2, <var>x</var> - sqrt(2))</code>, <code>algebraic</code> must be
 
754
<code>true</code> and <code>gcd</code> must not be <code>ez</code>.  <code>subres</code> is a new algorithm, and people
 
755
who have been using the <code>red</code> setting should probably change it to
 
756
<code>subres</code>.
 
757
</p>
 
758
<p>The <code>gcd</code> flag, default: <code>subres</code>, if <code>false</code> will also prevent the greatest
 
759
common divisor from being taken when expressions are converted to canonical rational expression (CRE)
 
760
form.  This will sometimes speed the calculation if gcds are not
 
761
required.
 
762
</p>
 
763
</dd></dl>
 
764
 
 
765
<dl>
 
766
<dt><u>Function:</u> <b>gcdex</b><i> (<var>f</var>, <var>g</var>)</i>
 
767
<a name="IDX403"></a>
 
768
</dt>
 
769
<dt><u>Function:</u> <b>gcdex</b><i> (<var>f</var>, <var>g</var>, <var>x</var>)</i>
 
770
<a name="IDX404"></a>
 
771
</dt>
 
772
<dd><p>Returns a list <code>[<var>a</var>, <var>b</var>, <var>u</var>]</code>
 
773
where <var>u</var> is the greatest common divisor (gcd) of <var>f</var> and <var>g</var>,
 
774
and <var>u</var> is equal to <code><var>a</var> <var>f</var> + <var>b</var> <var>g</var></code>.
 
775
The arguments <var>f</var> and <var>g</var> should be univariate polynomials,
 
776
or else polynomials in <var>x</var> a supplied <b>main</b> variable   
 
777
since we need to be in a principal ideal domain for this to work.
 
778
The gcd means the gcd regarding <var>f</var> and <var>g</var> as univariate polynomials with coefficients
 
779
being rational functions in the other variables.
 
780
</p>
 
781
<p><code>gcdex</code> implements the Euclidean algorithm,
 
782
where we have a sequence
 
783
of <code>L[i]: [a[i], b[i], r[i]]</code> which are all perpendicular
 
784
to <code>[f, g, -1]</code> and the next one is built as
 
785
if <code>q = quotient(r[i]/r[i+1])</code> then <code>L[i+2]: L[i] - q L[i+1]</code>, and it
 
786
terminates at <code>L[i+1]</code> when the remainder <code>r[i+2]</code> is zero.
 
787
</p>
 
788
 
 
789
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) gcdex (x^2 + 1, x^3 + 4);
 
790
                       2
 
791
                      x  + 4 x - 1  x + 4
 
792
(%o1)/R/           [- ------------, -----, 1]
 
793
                           17        17
 
794
(%i2) % . [x^2 + 1, x^3 + 4, -1];
 
795
(%o2)/R/                        0
 
796
</pre></td></tr></table>
 
797
<p>Note that the gcd in the following is <code>1</code>
 
798
since we work in <code>k(y)[x]</code>, not the  <code>y+1</code> we would expect in <code>k[y, x]</code>.
 
799
</p>
 
800
 
 
801
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) gcdex (x*(y + 1), y^2 - 1, x);
 
802
                               1
 
803
(%o1)/R/                 [0, ------, 1]
 
804
                              2
 
805
                             y  - 1
 
806
</pre></td></tr></table>
 
807
</dd></dl>
 
808
 
 
809
 
 
810
<dl>
 
811
<dt><u>Function:</u> <b>gcfactor</b><i> (<var>n</var>)</i>
 
812
<a name="IDX405"></a>
 
813
</dt>
 
814
<dd><p>Factors the Gaussian integer <var>n</var> over the Gaussian integers, i.e.,
 
815
numbers of the form <code><var>a</var> + <var>b</var> <code>%i</code></code> where <var>a</var> and <var>b</var> are rational integers
 
816
(i.e.,  ordinary integers).  Factors are normalized by making <var>a</var> and <var>b</var>
 
817
non-negative.
 
818
</p>
 
819
</dd></dl>
 
820
 
 
821
<dl>
 
822
<dt><u>Function:</u> <b>gfactor</b><i> (<var>expr</var>)</i>
 
823
<a name="IDX406"></a>
 
824
</dt>
 
825
<dd><p>Factors the polynomial <var>expr</var> over the Gaussian integers
 
826
(that is, the integers with the imaginary unit <code>%i</code> adjoined).
 
827
This is like <code>factor (<var>expr</var>, <var>a</var>^2+1)</code> where <var>a</var> is <code>%i</code>.
 
828
</p>
 
829
<p>Example:
 
830
</p>
 
831
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) gfactor (x^4 - 1);
 
832
(%o1)           (x - 1) (x + 1) (x - %i) (x + %i)
 
833
</pre></td></tr></table>
 
834
</dd></dl>
 
835
 
 
836
<dl>
 
837
<dt><u>Function:</u> <b>gfactorsum</b><i> (<var>expr</var>)</i>
 
838
<a name="IDX407"></a>
 
839
</dt>
 
840
<dd><p>is similar to <code>factorsum</code> but applies <code>gfactor</code> instead
 
841
of <code>factor</code>.
 
842
</p>
 
843
</dd></dl>
 
844
 
 
845
<dl>
 
846
<dt><u>Function:</u> <b>hipow</b><i> (<var>expr</var>, <var>x</var>)</i>
 
847
<a name="IDX408"></a>
 
848
</dt>
 
849
<dd><p>Returns the highest explicit exponent of <var>x</var> in <var>expr</var>.
 
850
<var>x</var> may be a variable or a general expression.
 
851
If <var>x</var> does not appear in <var>expr</var>,
 
852
<code>hipow</code> returns <code>0</code>.
 
853
</p>
 
854
<p><code>hipow</code> does not consider expressions equivalent to <code>expr</code>.
 
855
In particular, <code>hipow</code> does not expand <code>expr</code>,
 
856
so <code>hipow (<var>expr</var>, <var>x</var>)</code> and <code>hipow (expand (<var>expr</var>, <var>x</var>))</code>
 
857
may yield different results.
 
858
</p>
 
859
<p>Examples:
 
860
</p>
 
861
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) hipow (y^3 * x^2 + x * y^4, x);
 
862
(%o1)                           2
 
863
(%i2) hipow ((x + y)^5, x);
 
864
(%o2)                           1
 
865
(%i3) hipow (expand ((x + y)^5), x);
 
866
(%o3)                           5
 
867
(%i4) hipow ((x + y)^5, x + y);
 
868
(%o4)                           5
 
869
(%i5) hipow (expand ((x + y)^5), x + y);
 
870
(%o5)                           0
 
871
</pre></td></tr></table>
 
872
</dd></dl>
 
873
 
 
874
<dl>
 
875
<dt><u>Option variable:</u> <b>intfaclim</b>
 
876
<a name="IDX409"></a>
 
877
</dt>
 
878
<dd><p>Default value: true
 
879
</p>
 
880
<p>If <code>true</code>, maxima will give up factorization of
 
881
integers if no factor is found after trial divisions and Pollard's rho
 
882
method and factorization will not be complete.
 
883
</p>
 
884
<p>When <code>intfaclim</code> is <code>false</code> (this is the case when the user
 
885
calls <code>factor</code> explicitly), complete factorization will be
 
886
attempted.  <code>intfaclim</code> is set to <code>false</code> when factors are
 
887
computed in <code>divisors</code>, <code>divsum</code> and <code>totient</code>.
 
888
</p>
 
889
<p>Internal calls to <code>factor</code> respect the user-specified value of
 
890
<code>intfaclim</code>.  Setting <code>intfaclim</code> to <code>true</code> may reduce
 
891
the time spent factoring large integers.
 
892
</p>
 
893
</dd></dl>
 
894
 
 
895
<dl>
 
896
<dt><u>Option variable:</u> <b>keepfloat</b>
 
897
<a name="IDX410"></a>
 
898
</dt>
 
899
<dd><p>Default value: <code>false</code>
 
900
</p>
 
901
<p>When <code>keepfloat</code> is <code>true</code>, prevents floating
 
902
point numbers from being rationalized when expressions which contain
 
903
them are converted to canonical rational expression (CRE) form.
 
904
</p>
 
905
</dd></dl>
 
906
 
 
907
<dl>
 
908
<dt><u>Function:</u> <b>lratsubst</b><i> (<var>L</var>, <var>expr</var>)</i>
 
909
<a name="IDX411"></a>
 
910
</dt>
 
911
<dd><p>is analogous to <code>subst (<var>L</var>, <var>expr</var>)</code>
 
912
except that it uses <code>ratsubst</code> instead of <code>subst</code>.
 
913
</p>
 
914
<p>The first argument of
 
915
<code>lratsubst</code> is an equation or a list of equations identical in
 
916
format to that accepted by <code>subst</code>.  The
 
917
substitutions are made in the order given by the list of equations,
 
918
that is, from left to right.
 
919
</p>
 
920
<p><code>load (&quot;lrats&quot;)</code> loads <code>fullratsubst</code> and <code>lratsubst</code>.
 
921
</p>
 
922
<p>Examples:
 
923
</p>
 
924
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) load (&quot;lrats&quot;)$
 
925
</pre></td></tr></table><ul>
 
926
<li>
 
927
<code>subst</code> can carry out multiple substitutions.
 
928
<code>lratsubst</code> is analogous to <code>subst</code>.
 
929
</li></ul>
 
930
<table><tr><td>&nbsp;</td><td><pre class="example">(%i2) subst ([a = b, c = d], a + c);
 
931
(%o2)                         d + b
 
932
(%i3) lratsubst ([a^2 = b, c^2 = d], (a + e)*c*(a + c));
 
933
(%o3)                (d + a c) e + a d + b c
 
934
</pre></td></tr></table><ul>
 
935
<li>
 
936
If only one substitution is desired, then a single
 
937
equation may be given as first argument.
 
938
</li></ul>
 
939
<table><tr><td>&nbsp;</td><td><pre class="example">(%i4) lratsubst (a^2 = b, a^3);
 
940
(%o4)                          a b
 
941
</pre></td></tr></table>
 
942
</dd></dl>
 
943
 
 
944
<dl>
 
945
<dt><u>Option variable:</u> <b>modulus</b>
 
946
<a name="IDX412"></a>
 
947
</dt>
 
948
<dd><p>Default value: <code>false</code>
 
949
</p>
 
950
<p>When <code>modulus</code> is a positive number <var>p</var>,
 
951
operations on rational numbers (as returned by <code>rat</code> and related functions)
 
952
are carried out modulo <var>p</var>,
 
953
using the so-called &quot;balanced&quot; modulus system
 
954
in which <code><var>n</var> modulo <var>p</var></code> is defined as 
 
955
an integer <var>k</var> in <code>[-(<var>p</var>-1)/2, ..., 0, ..., (<var>p</var>-1)/2]</code>
 
956
when <var>p</var> is odd, or <code>[-(<var>p</var>/2 - 1), ..., 0, ...., <var>p</var>/2]</code> when <var>p</var> is even,
 
957
such that <code><var>a</var> <var>p</var> + <var>k</var></code> equals <var>n</var> for some integer <var>a</var>.
 
958
</p>
 
959
<p>If <var>expr</var> is already in canonical rational expression (CRE) form when <code>modulus</code> is reset,
 
960
then you may need to re-rat <var>expr</var>, e.g., <code>expr: rat (ratdisrep (expr))</code>,
 
961
in order to get correct results.
 
962
</p>
 
963
<p>Typically <code>modulus</code> is set to a prime number.
 
964
If <code>modulus</code> is set to a positive non-prime integer,
 
965
this setting is accepted, but a warning message is displayed.
 
966
Maxima will allow zero or a negative integer to be assigned to <code>modulus</code>,
 
967
although it is not clear if that has any useful consequences.
 
968
</p>
 
969
</dd></dl>
 
970
 
 
971
 
 
972
<dl>
 
973
<dt><u>Function:</u> <b>num</b><i> (<var>expr</var>)</i>
 
974
<a name="IDX413"></a>
 
975
</dt>
 
976
<dd><p>Returns the numerator of <var>expr</var> if it is a ratio.
 
977
If <var>expr</var> is not a ratio, <var>expr</var> is returned.
 
978
</p>
 
979
<p><code>num</code> evaluates its argument.
 
980
</p>
 
981
</dd></dl>
 
982
 
 
983
<dl>
 
984
<dt><u>Function:</u> <b>polydecomp</b><i> (<var>p</var>, <var>x</var>)</i>
 
985
<a name="IDX414"></a>
 
986
</dt>
 
987
<dd><p>Decomposes the polynomial <var>p</var> in the variable <var>x</var>
 
988
into the functional composition of polynomials in <var>x</var>.
 
989
<code>polydecomp</code> returns a list <code>[<var>p_1</var>, ..., <var>p_n</var>]</code> such that
 
990
</p>
 
991
<table><tr><td>&nbsp;</td><td><pre class="example">lambda ([x], p_1) (lambda ([x], p_2) (... (lambda ([x], p_n) (x)) ...))
 
992
</pre></td></tr></table>
 
993
<p>is equal to <var>p</var>.
 
994
The degree of <var>p_i</var> is greater than 1 for <var>i</var> less than <var>n</var>.
 
995
</p>
 
996
<p>Such a decomposition is not unique.
 
997
</p>
 
998
<p>Examples:
 
999
</p>
 
1000
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) polydecomp (x^210, x);
 
1001
                          7   5   3   2
 
1002
(%o1)                   [x , x , x , x ]
 
1003
(%i2) p : expand (subst (x^3 - x - 1, x, x^2 - a));
 
1004
                6      4      3    2
 
1005
(%o2)          x  - 2 x  - 2 x  + x  + 2 x - a + 1
 
1006
(%i3) polydecomp (p, x);
 
1007
                        2       3
 
1008
(%o3)                 [x  - a, x  - x - 1]
 
1009
</pre></td></tr></table>
 
1010
<p>The following function composes <code>L = [e_1, ..., e_n]</code> as functions in <code>x</code>;
 
1011
it is the inverse of polydecomp:
 
1012
</p>
 
1013
<table><tr><td>&nbsp;</td><td><pre class="example">compose (L, x) :=
 
1014
  block ([r : x], for e in L do r : subst (e, x, r), r) $
 
1015
</pre></td></tr></table>
 
1016
<p>Re-express above example using <code>compose</code>:
 
1017
</p>
 
1018
<table><tr><td>&nbsp;</td><td><pre class="example">(%i3) polydecomp (compose ([x^2 - a, x^3 - x - 1], x), x);
 
1019
                        2       3
 
1020
(%o3)                 [x  - a, x  - x - 1]
 
1021
</pre></td></tr></table>
 
1022
<p>Note that though <code>compose (polydecomp (<var>p</var>, <var>x</var>), <var>x</var>)</code>
 
1023
always returns <var>p</var> (unexpanded),
 
1024
<code>polydecomp (compose ([<var>p_1</var>, ..., <var>p_n</var>], <var>x</var>), <var>x</var>)</code> does <i>not</i>
 
1025
necessarily return <code>[<var>p_1</var>, ..., <var>p_n</var>]</code>:
 
1026
</p>
 
1027
<table><tr><td>&nbsp;</td><td><pre class="example">(%i4) polydecomp (compose ([x^2 + 2*x + 3, x^2], x), x);
 
1028
                          2       2
 
1029
(%o4)                   [x  + 2, x  + 1]
 
1030
(%i5) polydecomp (compose ([x^2 + x + 1, x^2 + x + 1], x), x);
 
1031
                      2       2
 
1032
                     x  + 3  x  + 5
 
1033
(%o5)               [------, ------, 2 x + 1]
 
1034
                       4       2
 
1035
</pre></td></tr></table>
 
1036
</dd></dl>
 
1037
 
 
1038
<dl>
 
1039
<dt><u>Function:</u> <b>quotient</b><i> (<var>p_1</var>, <var>p_2</var>)</i>
 
1040
<a name="IDX415"></a>
 
1041
</dt>
 
1042
<dt><u>Function:</u> <b>quotient</b><i> (<var>p_1</var>, <var>p_2</var>, <var>x_1</var>, ..., <var>x_n</var>)</i>
 
1043
<a name="IDX416"></a>
 
1044
</dt>
 
1045
<dd><p>Returns the polynomial <var>p_1</var> divided by the polynomial <var>p_2</var>.
 
1046
The arguments <var>x_1</var>, ..., <var>x_n</var> are interpreted as in <code>ratvars</code>.
 
1047
</p>
 
1048
<p><code>quotient</code> returns the first element of the two-element list returned by <code>divide</code>.
 
1049
</p>
 
1050
</dd></dl>
 
1051
 
 
1052
<dl>
 
1053
<dt><u>Function:</u> <b>rat</b><i> (<var>expr</var>)</i>
 
1054
<a name="IDX417"></a>
 
1055
</dt>
 
1056
<dt><u>Function:</u> <b>rat</b><i> (<var>expr</var>, <var>x_1</var>, ..., <var>x_n</var>)</i>
 
1057
<a name="IDX418"></a>
 
1058
</dt>
 
1059
<dd><p>Converts <var>expr</var> to canonical rational expression (CRE) form by expanding and
 
1060
combining all terms over a common denominator and cancelling out the
 
1061
greatest common divisor of the numerator and denominator, as well as
 
1062
converting floating point numbers to rational numbers within a
 
1063
tolerance of <code>ratepsilon</code>.
 
1064
The variables are ordered according
 
1065
to the <var>x_1</var>, ..., <var>x_n</var>, if specified, as in <code>ratvars</code>.
 
1066
</p>
 
1067
<p><code>rat</code> does not generally simplify functions other than
 
1068
addition <code>+</code>, subtraction <code>-</code>, multiplication <code>*</code>, division <code>/</code>, and
 
1069
exponentiation to an integer power,
 
1070
whereas <code>ratsimp</code> does handle those cases.
 
1071
Note that atoms (numbers and variables) in CRE form are not the
 
1072
same as they are in the general form.
 
1073
For example, <code>rat(x)- x</code> yields 
 
1074
<code>rat(0)</code> which has a different internal representation than 0.
 
1075
</p>
 
1076
<p>When <code>ratfac</code> is <code>true</code>, <code>rat</code> yields a partially factored form for CRE.
 
1077
During rational operations the expression is
 
1078
maintained as fully factored as possible without an actual call to the
 
1079
factor package.  This should always save space and may save some time
 
1080
in some computations.  The numerator and denominator are still made
 
1081
relatively prime
 
1082
(e.g.  <code>rat ((x^2 - 1)^4/(x + 1)^2)</code> yields <code>(x - 1)^4 (x + 1)^2)</code>,
 
1083
but the factors within each part may not be relatively prime.
 
1084
</p>
 
1085
<p><code>ratprint</code> if <code>false</code> suppresses the printout of the message
 
1086
informing the user of the conversion of floating point numbers to
 
1087
rational numbers.
 
1088
</p>
 
1089
<p><code>keepfloat</code> if <code>true</code> prevents floating point numbers from being
 
1090
converted to rational numbers.
 
1091
</p>
 
1092
<p>See also <code>ratexpand</code> and  <code>ratsimp</code>.
 
1093
</p>
 
1094
<p>Examples:
 
1095
</p>
 
1096
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) ((x - 2*y)^4/(x^2 - 4*y^2)^2 + 1)*(y + a)*(2*y + x) /(4*y^2 + x^2);
 
1097
                                           4
 
1098
                                  (x - 2 y)
 
1099
              (y + a) (2 y + x) (------------ + 1)
 
1100
                                   2      2 2
 
1101
                                 (x  - 4 y )
 
1102
(%o1)         ------------------------------------
 
1103
                              2    2
 
1104
                           4 y  + x
 
1105
(%i2) rat (%, y, a, x);
 
1106
                            2 a + 2 y
 
1107
(%o2)/R/                    ---------
 
1108
                             x + 2 y
 
1109
</pre></td></tr></table>
 
1110
</dd></dl>
 
1111
 
 
1112
<dl>
 
1113
<dt><u>Option variable:</u> <b>ratalgdenom</b>
 
1114
<a name="IDX419"></a>
 
1115
</dt>
 
1116
<dd><p>Default value: <code>true</code>
 
1117
</p>
 
1118
<p>When <code>ratalgdenom</code> is <code>true</code>, allows rationalization of
 
1119
denominators with respect to radicals to take effect.
 
1120
<code>ratalgdenom</code> has an effect only when canonical rational expressions (CRE) are used in algebraic mode.
 
1121
</p>
 
1122
</dd></dl>
 
1123
 
 
1124
<dl>
 
1125
<dt><u>Function:</u> <b>ratcoef</b><i> (<var>expr</var>, <var>x</var>, <var>n</var>)</i>
 
1126
<a name="IDX420"></a>
 
1127
</dt>
 
1128
<dt><u>Function:</u> <b>ratcoef</b><i> (<var>expr</var>, <var>x</var>)</i>
 
1129
<a name="IDX421"></a>
 
1130
</dt>
 
1131
<dd><p>Returns the coefficient of the expression <code><var>x</var>^<var>n</var></code>
 
1132
in the expression <var>expr</var>.
 
1133
If omitted, <var>n</var> is assumed to be 1.
 
1134
</p>
 
1135
<p>The return value is free
 
1136
(except possibly in a non-rational sense) of the variables in <var>x</var>.
 
1137
If no coefficient of this type exists, 0 is returned.
 
1138
</p>
 
1139
<p><code>ratcoef</code>
 
1140
expands and rationally simplifies its first argument and thus it may
 
1141
produce answers different from those of <code>coeff</code> which is purely
 
1142
syntactic.
 
1143
Thus <code>ratcoef ((x + 1)/y + x, x)</code> returns <code>(y + 1)/y</code> whereas <code>coeff</code> returns 1.
 
1144
</p>
 
1145
<p><code>ratcoef (<var>expr</var>, <var>x</var>, 0)</code>, viewing <var>expr</var> as a sum,
 
1146
returns a sum of those terms which do not contain <var>x</var>.
 
1147
Therefore if <var>x</var> occurs to any negative powers, <code>ratcoef</code> should not be used.
 
1148
</p>
 
1149
<p>Since <var>expr</var> is rationally
 
1150
simplified before it is examined, coefficients may not appear quite
 
1151
the way they were envisioned.
 
1152
</p>
 
1153
<p>Example:
 
1154
</p>
 
1155
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) s: a*x + b*x + 5$
 
1156
(%i2) ratcoef (s, a + b);
 
1157
(%o2)                           x
 
1158
</pre></td></tr></table>
 
1159
</dd></dl>
 
1160
 
 
1161
<dl>
 
1162
<dt><u>Function:</u> <b>ratdenom</b><i> (<var>expr</var>)</i>
 
1163
<a name="IDX422"></a>
 
1164
</dt>
 
1165
<dd><p>Returns the denominator of <var>expr</var>,
 
1166
after coercing <var>expr</var> to a canonical rational expression (CRE).
 
1167
The return value is a CRE.
 
1168
</p>
 
1169
<p><var>expr</var> is coerced to a CRE by <code>rat</code>
 
1170
if it is not already a CRE.
 
1171
This conversion may change the form of <var>expr</var> by putting all terms
 
1172
over a common denominator.
 
1173
</p>
 
1174
<p><code>denom</code> is similar, but returns an ordinary expression instead of a CRE.
 
1175
Also, <code>denom</code> does not attempt to place all terms over a common denominator,
 
1176
and thus some expressions which are considered ratios by <code>ratdenom</code>
 
1177
are not considered ratios by <code>denom</code>.
 
1178
</p>
 
1179
</dd></dl>
 
1180
 
 
1181
<dl>
 
1182
<dt><u>Option variable:</u> <b>ratdenomdivide</b>
 
1183
<a name="IDX423"></a>
 
1184
</dt>
 
1185
<dd><p>Default value: <code>true</code>
 
1186
</p>
 
1187
<p>When <code>ratdenomdivide</code> is <code>true</code>,
 
1188
<code>ratexpand</code> expands a ratio in which the numerator is a sum 
 
1189
into a sum of ratios,
 
1190
all having a common denominator.
 
1191
Otherwise, <code>ratexpand</code> collapses a sum of ratios into a single ratio,
 
1192
the numerator of which is the sum of the numerators of each ratio.
 
1193
</p>
 
1194
<p>Examples:
 
1195
</p>
 
1196
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) expr: (x^2 + x + 1)/(y^2 + 7);
 
1197
                            2
 
1198
                           x  + x + 1
 
1199
(%o1)                      ----------
 
1200
                              2
 
1201
                             y  + 7
 
1202
(%i2) ratdenomdivide: true$
 
1203
(%i3) ratexpand (expr);
 
1204
                       2
 
1205
                      x        x        1
 
1206
(%o3)               ------ + ------ + ------
 
1207
                     2        2        2
 
1208
                    y  + 7   y  + 7   y  + 7
 
1209
(%i4) ratdenomdivide: false$
 
1210
(%i5) ratexpand (expr);
 
1211
                            2
 
1212
                           x  + x + 1
 
1213
(%o5)                      ----------
 
1214
                              2
 
1215
                             y  + 7
 
1216
(%i6) expr2: a^2/(b^2 + 3) + b/(b^2 + 3);
 
1217
                                     2
 
1218
                           b        a
 
1219
(%o6)                    ------ + ------
 
1220
                          2        2
 
1221
                         b  + 3   b  + 3
 
1222
(%i7) ratexpand (expr2);
 
1223
                                  2
 
1224
                             b + a
 
1225
(%o7)                        ------
 
1226
                              2
 
1227
                             b  + 3
 
1228
</pre></td></tr></table>
 
1229
</dd></dl>
 
1230
 
 
1231
<dl>
 
1232
<dt><u>Function:</u> <b>ratdiff</b><i> (<var>expr</var>, <var>x</var>)</i>
 
1233
<a name="IDX424"></a>
 
1234
</dt>
 
1235
<dd><p>Differentiates the rational expression <var>expr</var> with respect to <var>x</var>.
 
1236
<var>expr</var> must be a ratio of polynomials or a polynomial in <var>x</var>.
 
1237
The argument <var>x</var> may be a variable or a subexpression of <var>expr</var>.
 
1238
</p>
 
1239
<p>The result is equivalent to <code>diff</code>, although perhaps in a different form.
 
1240
<code>ratdiff</code> may be faster than <code>diff</code>, for rational expressions.
 
1241
</p>
 
1242
<p><code>ratdiff</code> returns a canonical rational expression (CRE) if <code>expr</code> is a CRE.
 
1243
Otherwise, <code>ratdiff</code> returns a general expression.
 
1244
</p>
 
1245
<p><code>ratdiff</code> considers only the dependence of <var>expr</var> on <var>x</var>,
 
1246
and ignores any dependencies established by <code>depends</code>.
 
1247
</p>
 
1248
 
 
1249
<p>Example:
 
1250
</p>
 
1251
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) expr: (4*x^3 + 10*x - 11)/(x^5 + 5);
 
1252
                           3
 
1253
                        4 x  + 10 x - 11
 
1254
(%o1)                   ----------------
 
1255
                              5
 
1256
                             x  + 5
 
1257
(%i2) ratdiff (expr, x);
 
1258
                    7       5       4       2
 
1259
                 8 x  + 40 x  - 55 x  - 60 x  - 50
 
1260
(%o2)          - ---------------------------------
 
1261
                          10       5
 
1262
                         x   + 10 x  + 25
 
1263
(%i3) expr: f(x)^3 - f(x)^2 + 7;
 
1264
                         3       2
 
1265
(%o3)                   f (x) - f (x) + 7
 
1266
(%i4) ratdiff (expr, f(x));
 
1267
                           2
 
1268
(%o4)                   3 f (x) - 2 f(x)
 
1269
(%i5) expr: (a + b)^3 + (a + b)^2;
 
1270
                              3          2
 
1271
(%o5)                  (b + a)  + (b + a)
 
1272
(%i6) ratdiff (expr, a + b);
 
1273
                    2                    2
 
1274
(%o6)            3 b  + (6 a + 2) b + 3 a  + 2 a
 
1275
</pre></td></tr></table>
 
1276
</dd></dl>
 
1277
 
 
1278
<dl>
 
1279
<dt><u>Function:</u> <b>ratdisrep</b><i> (<var>expr</var>)</i>
 
1280
<a name="IDX425"></a>
 
1281
</dt>
 
1282
<dd><p>Returns its argument as a general expression.
 
1283
If <var>expr</var> is a general expression, it is returned unchanged.
 
1284
</p>
 
1285
<p>Typically <code>ratdisrep</code> is called to convert a canonical rational expression (CRE)
 
1286
into a general expression.
 
1287
This is sometimes convenient if one wishes to stop the &quot;contagion&quot;, or
 
1288
use rational functions in non-rational contexts.
 
1289
</p>
 
1290
<p>See also <code>totaldisrep</code>.
 
1291
</p>
 
1292
</dd></dl>
 
1293
 
 
1294
<dl>
 
1295
<dt><u>Option variable:</u> <b>ratepsilon</b>
 
1296
<a name="IDX426"></a>
 
1297
</dt>
 
1298
<dd><p>Default value: 2.0e-8
 
1299
</p>
 
1300
<p><code>ratepsilon</code> is the tolerance used in the conversion
 
1301
of floating point numbers to rational numbers.
 
1302
</p>
 
1303
</dd></dl>
 
1304
 
 
1305
<dl>
 
1306
<dt><u>Function:</u> <b>ratexpand</b><i> (<var>expr</var>)</i>
 
1307
<a name="IDX427"></a>
 
1308
</dt>
 
1309
<dt><u>Option variable:</u> <b>ratexpand</b>
 
1310
<a name="IDX428"></a>
 
1311
</dt>
 
1312
<dd><p>Expands <var>expr</var> by multiplying out products of sums and
 
1313
exponentiated sums, combining fractions over a common denominator,
 
1314
cancelling the greatest common divisor of the numerator and
 
1315
denominator, then splitting the numerator (if a sum) into its
 
1316
respective terms divided by the denominator.
 
1317
</p>
 
1318
<p>The return value of <code>ratexpand</code> is a general expression,
 
1319
even if <var>expr</var> is a canonical rational expression (CRE).
 
1320
</p>
 
1321
<p>The switch <code>ratexpand</code> if <code>true</code> will cause CRE
 
1322
expressions to be fully expanded when they are converted back to
 
1323
general form or displayed, while if it is <code>false</code> then they will be put
 
1324
into a recursive form.
 
1325
See also <code>ratsimp</code>.
 
1326
</p>
 
1327
<p>When <code>ratdenomdivide</code> is <code>true</code>,
 
1328
<code>ratexpand</code> expands a ratio in which the numerator is a sum 
 
1329
into a sum of ratios,
 
1330
all having a common denominator.
 
1331
Otherwise, <code>ratexpand</code> collapses a sum of ratios into a single ratio,
 
1332
the numerator of which is the sum of the numerators of each ratio.
 
1333
</p>
 
1334
<p>When <code>keepfloat</code> is <code>true</code>, prevents floating
 
1335
point numbers from being rationalized when expressions which contain
 
1336
them are converted to canonical rational expression (CRE) form.
 
1337
</p>
 
1338
<p>Examples:
 
1339
</p>
 
1340
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) ratexpand ((2*x - 3*y)^3);
 
1341
                     3         2       2        3
 
1342
(%o1)          - 27 y  + 54 x y  - 36 x  y + 8 x
 
1343
(%i2) expr: (x - 1)/(x + 1)^2 + 1/(x - 1);
 
1344
                         x - 1       1
 
1345
(%o2)                   -------- + -----
 
1346
                               2   x - 1
 
1347
                        (x + 1)
 
1348
(%i3) expand (expr);
 
1349
                    x              1           1
 
1350
(%o3)          ------------ - ------------ + -----
 
1351
                2              2             x - 1
 
1352
               x  + 2 x + 1   x  + 2 x + 1
 
1353
(%i4) ratexpand (expr);
 
1354
                        2
 
1355
                     2 x                 2
 
1356
(%o4)           --------------- + ---------------
 
1357
                 3    2            3    2
 
1358
                x  + x  - x - 1   x  + x  - x - 1
 
1359
</pre></td></tr></table>
 
1360
</dd></dl>
 
1361
 
 
1362
<dl>
 
1363
<dt><u>Option variable:</u> <b>ratfac</b>
 
1364
<a name="IDX429"></a>
 
1365
</dt>
 
1366
<dd><p>Default value: <code>false</code>
 
1367
</p>
 
1368
<p>When <code>ratfac</code> is <code>true</code>,
 
1369
canonical rational expressions (CRE) are manipulated in a partially factored form.
 
1370
</p>
 
1371
<p>During rational operations the
 
1372
expression is maintained as fully factored as possible without calling <code>factor</code>.
 
1373
This should always save space and may save time in some computations.
 
1374
The numerator and denominator are made relatively prime, for example
 
1375
<code>rat ((x^2 - 1)^4/(x + 1)^2)</code> yields <code>(x - 1)^4 (x + 1)^2)</code>,
 
1376
but the factors within each part may not be relatively prime.
 
1377
</p>
 
1378
<p>In the <code>ctensr</code> (Component Tensor Manipulation) package,
 
1379
Ricci, Einstein, Riemann, and Weyl tensors and the scalar curvature 
 
1380
are factored automatically when <code>ratfac</code> is <code>true</code>.
 
1381
<i><code>ratfac</code> should only be
 
1382
set for cases where the tensorial components are known to consist of
 
1383
few terms.</i>
 
1384
</p>
 
1385
<p>The <code>ratfac</code> and <code>ratweight</code> schemes are incompatible and may not
 
1386
both be used at the same time.
 
1387
</p>
 
1388
</dd></dl>
 
1389
 
 
1390
<dl>
 
1391
<dt><u>Function:</u> <b>ratnumer</b><i> (<var>expr</var>)</i>
 
1392
<a name="IDX430"></a>
 
1393
</dt>
 
1394
<dd><p>Returns the numerator of <var>expr</var>,
 
1395
after coercing <var>expr</var> to a canonical rational expression (CRE).
 
1396
The return value is a CRE.
 
1397
</p>
 
1398
<p><var>expr</var> is coerced to a CRE by <code>rat</code>
 
1399
if it is not already a CRE.
 
1400
This conversion may change the form of <var>expr</var> by putting all terms
 
1401
over a common denominator.
 
1402
</p>
 
1403
<p><code>num</code> is similar, but returns an ordinary expression instead of a CRE.
 
1404
Also, <code>num</code> does not attempt to place all terms over a common denominator,
 
1405
and thus some expressions which are considered ratios by <code>ratnumer</code>
 
1406
are not considered ratios by <code>num</code>.
 
1407
</p>
 
1408
</dd></dl>
 
1409
 
 
1410
<dl>
 
1411
<dt><u>Function:</u> <b>ratnump</b><i> (<var>expr</var>)</i>
 
1412
<a name="IDX431"></a>
 
1413
</dt>
 
1414
<dd><p>Returns <code>true</code> if <var>expr</var> is a literal integer or ratio of literal integers,
 
1415
otherwise <code>false</code>.
 
1416
</p>
 
1417
</dd></dl>
 
1418
 
 
1419
<dl>
 
1420
<dt><u>Function:</u> <b>ratp</b><i> (<var>expr</var>)</i>
 
1421
<a name="IDX432"></a>
 
1422
</dt>
 
1423
<dd><p>Returns <code>true</code> if <var>expr</var> is a canonical rational expression (CRE) or extended CRE,
 
1424
otherwise <code>false</code>.
 
1425
</p>
 
1426
<p>CRE are created by <code>rat</code> and related functions.
 
1427
Extended CRE are created by <code>taylor</code> and related functions.
 
1428
</p>
 
1429
</dd></dl>
 
1430
 
 
1431
<dl>
 
1432
<dt><u>Option variable:</u> <b>ratprint</b>
 
1433
<a name="IDX433"></a>
 
1434
</dt>
 
1435
<dd><p>Default value: <code>true</code>
 
1436
</p>
 
1437
<p>When <code>ratprint</code> is <code>true</code>,
 
1438
a message informing the user of the conversion of floating point numbers
 
1439
to rational numbers is displayed.
 
1440
</p>
 
1441
</dd></dl>
 
1442
 
 
1443
<dl>
 
1444
<dt><u>Function:</u> <b>ratsimp</b><i> (<var>expr</var>)</i>
 
1445
<a name="IDX434"></a>
 
1446
</dt>
 
1447
<dt><u>Function:</u> <b>ratsimp</b><i> (<var>expr</var>, <var>x_1</var>, ..., <var>x_n</var>)</i>
 
1448
<a name="IDX435"></a>
 
1449
</dt>
 
1450
<dd><p>Simplifies the expression <var>expr</var> and all of its subexpressions,
 
1451
including the arguments to non-rational functions.
 
1452
The result is returned as the quotient of two polynomials in a recursive form,
 
1453
that is, the coefficients of the main variable are polynomials in the other variables.
 
1454
Variables may include non-rational functions (e.g., <code>sin (x^2 + 1)</code>)
 
1455
and the arguments to any such functions are also rationally simplified.
 
1456
</p>
 
1457
<p><code>ratsimp (<var>expr</var>, <var>x_1</var>, ..., <var>x_n</var>)</code>
 
1458
enables rational simplification with the
 
1459
specification of variable ordering as in <code>ratvars</code>.
 
1460
</p>
 
1461
<p>When <code>ratsimpexpons</code> is <code>true</code>,
 
1462
<code>ratsimp</code> is applied to the exponents of expressions during simplification.
 
1463
</p>
 
1464
<p>See also <code>ratexpand</code>.
 
1465
Note that <code>ratsimp</code> is affected by some of the
 
1466
flags which affect <code>ratexpand</code>.
 
1467
</p>
 
1468
<p>Examples:
 
1469
</p>
 
1470
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) sin (x/(x^2 + x)) = exp ((log(x) + 1)^2 - log(x)^2);
 
1471
                                         2      2
 
1472
                   x         (log(x) + 1)  - log (x)
 
1473
(%o1)        sin(------) = %e
 
1474
                  2
 
1475
                 x  + x
 
1476
(%i2) ratsimp (%);
 
1477
                             1          2
 
1478
(%o2)                  sin(-----) = %e x
 
1479
                           x + 1
 
1480
(%i3) ((x - 1)^(3/2) - (x + 1)*sqrt(x - 1))/sqrt((x - 1)*(x + 1));
 
1481
                       3/2
 
1482
                (x - 1)    - sqrt(x - 1) (x + 1)
 
1483
(%o3)           --------------------------------
 
1484
                     sqrt((x - 1) (x + 1))
 
1485
(%i4) ratsimp (%);
 
1486
                           2 sqrt(x - 1)
 
1487
(%o4)                    - -------------
 
1488
                                 2
 
1489
                           sqrt(x  - 1)
 
1490
(%i5) x^(a + 1/a), ratsimpexpons: true;
 
1491
                               2
 
1492
                              a  + 1
 
1493
                              ------
 
1494
                                a
 
1495
(%o5)                        x
 
1496
</pre></td></tr></table>
 
1497
</dd></dl>
 
1498
 
 
1499
<dl>
 
1500
<dt><u>Option variable:</u> <b>ratsimpexpons</b>
 
1501
<a name="IDX436"></a>
 
1502
</dt>
 
1503
<dd><p>Default value: <code>false</code>
 
1504
</p>
 
1505
<p>When <code>ratsimpexpons</code> is <code>true</code>,
 
1506
<code>ratsimp</code> is applied to the exponents of expressions during simplification.
 
1507
</p>
 
1508
</dd></dl>
 
1509
 
 
1510
<dl>
 
1511
<dt><u>Function:</u> <b>ratsubst</b><i> (<var>a</var>, <var>b</var>, <var>c</var>)</i>
 
1512
<a name="IDX437"></a>
 
1513
</dt>
 
1514
<dd><p>Substitutes <var>a</var> for <var>b</var> in <var>c</var> and returns the resulting expression.
 
1515
<var>b</var> may be a sum, product, power, etc.
 
1516
</p>
 
1517
<p><code>ratsubst</code> knows something of the meaning of expressions
 
1518
whereas <code>subst</code> does a purely syntactic substitution.
 
1519
Thus <code>subst (a, x + y, x + y + z)</code> returns <code>x + y + z</code>
 
1520
whereas <code>ratsubst</code> returns <code>z + a</code>.
 
1521
</p>
 
1522
<p>When <code>radsubstflag</code> is <code>true</code>,
 
1523
<code>ratsubst</code> makes substitutions for radicals in expressions
 
1524
which don't explicitly contain them.
 
1525
</p>
 
1526
<p>Examples:
 
1527
</p>
 
1528
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) ratsubst (a, x*y^2, x^4*y^3 + x^4*y^8);
 
1529
                              3      4
 
1530
(%o1)                      a x  y + a
 
1531
(%i2) cos(x)^4 + cos(x)^3 + cos(x)^2 + cos(x) + 1;
 
1532
               4         3         2
 
1533
(%o2)       cos (x) + cos (x) + cos (x) + cos(x) + 1
 
1534
(%i3) ratsubst (1 - sin(x)^2, cos(x)^2, %);
 
1535
            4           2                     2
 
1536
(%o3)    sin (x) - 3 sin (x) + cos(x) (2 - sin (x)) + 3
 
1537
(%i4) ratsubst (1 - cos(x)^2, sin(x)^2, sin(x)^4);
 
1538
                        4           2
 
1539
(%o4)                cos (x) - 2 cos (x) + 1
 
1540
(%i5) radsubstflag: false$
 
1541
(%i6) ratsubst (u, sqrt(x), x);
 
1542
(%o6)                           x
 
1543
(%i7) radsubstflag: true$
 
1544
(%i8) ratsubst (u, sqrt(x), x);
 
1545
                                2
 
1546
(%o8)                          u
 
1547
</pre></td></tr></table>
 
1548
</dd></dl>
 
1549
 
 
1550
<dl>
 
1551
<dt><u>Function:</u> <b>ratvars</b><i> (<var>x_1</var>, ..., <var>x_n</var>)</i>
 
1552
<a name="IDX438"></a>
 
1553
</dt>
 
1554
<dt><u>Function:</u> <b>ratvars</b><i> ()</i>
 
1555
<a name="IDX439"></a>
 
1556
</dt>
 
1557
<dt><u>System variable:</u> <b>ratvars</b>
 
1558
<a name="IDX440"></a>
 
1559
</dt>
 
1560
<dd><p>Declares main variables <var>x_1</var>, ..., <var>x_n</var> for rational expressions.
 
1561
<var>x_n</var>, if present in a rational expression, is considered the main variable.
 
1562
Otherwise, <var>x_[n-1]</var> is considered the main variable if present,
 
1563
and so on through the preceding variables to <var>x_1</var>,
 
1564
which is considered the main variable only if none of the succeeding variables are present.
 
1565
</p>
 
1566
<p>If a variable in a rational expression is not present in the <code>ratvars</code> list,
 
1567
it is given a lower priority than <var>x_1</var>.
 
1568
</p>
 
1569
<p>The arguments to <code>ratvars</code> can be either variables or non-rational functions
 
1570
such as <code>sin(x)</code>.
 
1571
</p>
 
1572
<p>The variable <code>ratvars</code> is a list of the arguments of 
 
1573
the function <code>ratvars</code> when it was called most recently.
 
1574
Each call to the function <code>ratvars</code> resets the list.
 
1575
<code>ratvars ()</code> clears the list.
 
1576
</p>
 
1577
</dd></dl>
 
1578
 
 
1579
<dl>
 
1580
<dt><u>Function:</u> <b>ratweight</b><i> (<var>x_1</var>, <var>w_1</var>, ..., <var>x_n</var>, <var>w_n</var>)</i>
 
1581
<a name="IDX441"></a>
 
1582
</dt>
 
1583
<dt><u>Function:</u> <b>ratweight</b><i> ()</i>
 
1584
<a name="IDX442"></a>
 
1585
</dt>
 
1586
<dd><p>Assigns a weight <var>w_i</var> to the variable <var>x_i</var>.
 
1587
This causes a term to be replaced by 0 if its weight exceeds the
 
1588
value of the variable <code>ratwtlvl</code> (default yields no truncation).
 
1589
The weight of a term is the sum of the products of the
 
1590
weight of a variable in the term times its power.
 
1591
For example, the weight of <code>3 x_1^2 x_2</code> is <code>2 w_1 + w_2</code>.
 
1592
Truncation according to <code>ratwtlvl</code> is carried out only when multiplying
 
1593
or exponentiating canonical rational expressions (CRE).
 
1594
</p>
 
1595
<p><code>ratweight ()</code> returns the cumulative list of weight assignments.
 
1596
</p>
 
1597
<p>Note: The <code>ratfac</code> and <code>ratweight</code> schemes are incompatible and may not
 
1598
both be used at the same time.
 
1599
</p>
 
1600
<p>Examples:
 
1601
</p>
 
1602
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) ratweight (a, 1, b, 1);
 
1603
(%o1)                     [a, 1, b, 1]
 
1604
(%i2) expr1: rat(a + b + 1)$
 
1605
(%i3) expr1^2;
 
1606
                  2                  2
 
1607
(%o3)/R/         b  + (2 a + 2) b + a  + 2 a + 1
 
1608
(%i4) ratwtlvl: 1$
 
1609
(%i5) expr1^2;
 
1610
(%o5)/R/                  2 b + 2 a + 1
 
1611
</pre></td></tr></table>
 
1612
</dd></dl>
 
1613
 
 
1614
<dl>
 
1615
<dt><u>System variable:</u> <b>ratweights</b>
 
1616
<a name="IDX443"></a>
 
1617
</dt>
 
1618
<dd><p>Default value: <code>[]</code>
 
1619
</p>
 
1620
<p><code>ratweights</code> is the list of weights assigned by <code>ratweight</code>.
 
1621
The list is cumulative:
 
1622
each call to <code>ratweight</code> places additional items in the list.
 
1623
</p>
 
1624
<p><code>kill (ratweights)</code> and <code>save (ratweights)</code> both work as expected.
 
1625
</p>
 
1626
</dd></dl>
 
1627
 
 
1628
<dl>
 
1629
<dt><u>Option variable:</u> <b>ratwtlvl</b>
 
1630
<a name="IDX444"></a>
 
1631
</dt>
 
1632
<dd><p>Default value: <code>false</code>
 
1633
</p>
 
1634
<p><code>ratwtlvl</code> is used in combination with the <code>ratweight</code>
 
1635
function to control the truncation of canonical rational expressions (CRE).
 
1636
For the default value of <code>false</code>, no truncation occurs.
 
1637
</p>
 
1638
</dd></dl>
 
1639
 
 
1640
<dl>
 
1641
<dt><u>Function:</u> <b>remainder</b><i> (<var>p_1</var>, <var>p_2</var>)</i>
 
1642
<a name="IDX445"></a>
 
1643
</dt>
 
1644
<dt><u>Function:</u> <b>remainder</b><i> (<var>p_1</var>, <var>p_2</var>, <var>x_1</var>, ..., <var>x_n</var>)</i>
 
1645
<a name="IDX446"></a>
 
1646
</dt>
 
1647
<dd><p>Returns the remainder of the polynomial <var>p_1</var> divided by the polynomial <var>p_2</var>.
 
1648
The arguments <var>x_1</var>, ..., <var>x_n</var> are interpreted as in <code>ratvars</code>.
 
1649
</p>
 
1650
<p><code>remainder</code> returns the second element
 
1651
of the two-element list returned by <code>divide</code>.
 
1652
</p>
 
1653
</dd></dl>
 
1654
 
 
1655
<dl>
 
1656
<dt><u>Function:</u> <b>resultant</b><i> (<var>p_1</var>, <var>p_2</var>, <var>x</var>)</i>
 
1657
<a name="IDX447"></a>
 
1658
</dt>
 
1659
<dt><u>Variable:</u> <b>resultant</b>
 
1660
<a name="IDX448"></a>
 
1661
</dt>
 
1662
<dd><p>Computes the resultant of the two polynomials <var>p_1</var> and <var>p_2</var>,
 
1663
eliminating the variable <var>x</var>.
 
1664
The resultant is a determinant of the coefficients of <var>x</var>
 
1665
in <var>p_1</var> and <var>p_2</var>,
 
1666
which equals zero
 
1667
if and only if <var>p_1</var> and <var>p_2</var> have a non-constant factor in common.
 
1668
</p>
 
1669
<p>If <var>p_1</var> or <var>p_2</var> can be factored,
 
1670
it may be desirable to call <code>factor</code> before calling <code>resultant</code>.
 
1671
</p>
 
1672
<p>The variable <code>resultant</code> controls which algorithm will be used to compute
 
1673
the resultant.
 
1674
<code>subres</code> for subresultant prs,
 
1675
<code>mod</code> for modular resultant algorithm,
 
1676
and <code>red</code> for reduced prs.
 
1677
On most problems <code>subres</code> should be best.
 
1678
On some large degree univariate or bivariate problems <code>mod</code> may be better.
 
1679
</p>
 
1680
<p>The function <code>bezout</code> takes the same arguments as <code>resultant</code> and returns
 
1681
a matrix.  The determinant of the return value is the desired resultant.
 
1682
</p>
 
1683
</dd></dl>
 
1684
 
 
1685
<dl>
 
1686
<dt><u>Option variable:</u> <b>savefactors</b>
 
1687
<a name="IDX449"></a>
 
1688
</dt>
 
1689
<dd><p>Default value: <code>false</code>
 
1690
</p>
 
1691
<p>When <code>savefactors</code> is <code>true</code>, causes the factors of an
 
1692
expression which is a product of factors to be saved by certain
 
1693
functions in order to speed up later factorizations of expressions
 
1694
containing some of the same factors.
 
1695
</p>
 
1696
</dd></dl>
 
1697
 
 
1698
<dl>
 
1699
<dt><u>Function:</u> <b>sqfr</b><i> (<var>expr</var>)</i>
 
1700
<a name="IDX450"></a>
 
1701
</dt>
 
1702
<dd><p>is similar to <code>factor</code> except that the polynomial factors are &quot;square-free.&quot;
 
1703
That is, they have factors only of degree one.
 
1704
This algorithm, which is also used by the first stage of <code>factor</code>, utilizes
 
1705
the fact that a polynomial has in common with its n'th derivative all
 
1706
its factors of degree greater than n.  Thus by taking greatest common divisors
 
1707
with the polynomial of
 
1708
the derivatives with respect to each variable in the polynomial, all
 
1709
factors of degree greater than 1 can be found.
 
1710
</p>
 
1711
<p>Example:
 
1712
</p>
 
1713
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) sqfr (4*x^4 + 4*x^3 - 3*x^2 - 4*x - 1);
 
1714
                                2   2
 
1715
(%o1)                  (2 x + 1)  (x  - 1)
 
1716
</pre></td></tr></table>
 
1717
</dd></dl>
 
1718
 
 
1719
<dl>
 
1720
<dt><u>Function:</u> <b>tellrat</b><i> (<var>p_1</var>, ..., <var>p_n</var>)</i>
 
1721
<a name="IDX451"></a>
 
1722
</dt>
 
1723
<dt><u>Function:</u> <b>tellrat</b><i> ()</i>
 
1724
<a name="IDX452"></a>
 
1725
</dt>
 
1726
<dd><p>Adds to the ring of algebraic integers known to Maxima
 
1727
the elements which are the solutions of the polynomials <var>p_1</var>, ..., <var>p_n</var>.
 
1728
Each argument <var>p_i</var> is a polynomial with integer coefficients.
 
1729
</p>
 
1730
<p><code>tellrat (<var>x</var>)</code> effectively means substitute 0 for <var>x</var> in rational
 
1731
functions.
 
1732
</p>
 
1733
<p><code>tellrat ()</code> returns a list of the current substitutions.
 
1734
</p>
 
1735
<p><code>algebraic</code> must be set to <code>true</code> in order for the simplification of
 
1736
algebraic integers to take effect.
 
1737
</p>
 
1738
<p>Maxima initially knows about the imaginary unit <code>%i</code>
 
1739
and all roots of integers.
 
1740
</p>
 
1741
<p>There is a command <code>untellrat</code> which takes kernels and
 
1742
removes <code>tellrat</code> properties.
 
1743
</p>
 
1744
<p>When <code>tellrat</code>'ing a multivariate
 
1745
polynomial, e.g., <code>tellrat (x^2 - y^2)</code>, there would be an ambiguity as to
 
1746
whether to substitute <code><var>y</var>^2</code> for <code><var>x</var>^2</code>
 
1747
or vice versa.  
 
1748
Maxima picks a particular ordering, but if the user wants to specify which, e.g.
 
1749
<code>tellrat (y^2 = x^2)</code> provides a syntax which says replace
 
1750
<code><var>y</var>^2</code> by <code><var>x</var>^2</code>.
 
1751
</p>
 
1752
 
 
1753
<p>Examples:
 
1754
</p>
 
1755
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) 10*(%i + 1)/(%i + 3^(1/3));
 
1756
                           10 (%i + 1)
 
1757
(%o1)                      -----------
 
1758
                                  1/3
 
1759
                            %i + 3
 
1760
(%i2) ev (ratdisrep (rat(%)), algebraic);
 
1761
             2/3      1/3              2/3      1/3
 
1762
(%o2)    (4 3    - 2 3    - 4) %i + 2 3    + 4 3    - 2
 
1763
(%i3) tellrat (1 + a + a^2);
 
1764
                            2
 
1765
(%o3)                     [a  + a + 1]
 
1766
(%i4) 1/(a*sqrt(2) - 1) + a/(sqrt(3) + sqrt(2));
 
1767
                      1                 a
 
1768
(%o4)           ------------- + -----------------
 
1769
                sqrt(2) a - 1   sqrt(3) + sqrt(2)
 
1770
(%i5) ev (ratdisrep (rat(%)), algebraic);
 
1771
         (7 sqrt(3) - 10 sqrt(2) + 2) a - 2 sqrt(2) - 1
 
1772
(%o5)    ----------------------------------------------
 
1773
                               7
 
1774
(%i6) tellrat (y^2 = x^2);
 
1775
                        2    2   2
 
1776
(%o6)                 [y  - x , a  + a + 1]
 
1777
</pre></td></tr></table>
 
1778
</dd></dl>
 
1779
 
 
1780
<dl>
 
1781
<dt><u>Function:</u> <b>totaldisrep</b><i> (<var>expr</var>)</i>
 
1782
<a name="IDX453"></a>
 
1783
</dt>
 
1784
<dd><p>Converts every subexpression of <var>expr</var> from canonical rational expressions (CRE) to
 
1785
general form and returns the result.
 
1786
If <var>expr</var> is itself in CRE form then <code>totaldisrep</code> is identical to
 
1787
<code>ratdisrep</code>.
 
1788
</p>
 
1789
<p><code>totaldisrep</code> may be useful for
 
1790
ratdisrepping expressions such as equations, lists, matrices, etc., which
 
1791
have some subexpressions in CRE form.
 
1792
</p>
 
1793
</dd></dl>
 
1794
 
 
1795
<dl>
 
1796
<dt><u>Function:</u> <b>untellrat</b><i> (<var>x_1</var>, ..., <var>x_n</var>)</i>
 
1797
<a name="IDX454"></a>
 
1798
</dt>
 
1799
<dd><p>Removes <code>tellrat</code> properties from <var>x_1</var>, ..., <var>x_n</var>.
 
1800
</p>
 
1801
</dd></dl>
 
1802
 
 
1803
<hr size="6">
 
1804
<table cellpadding="1" cellspacing="1" border="0">
 
1805
<tr><td valign="middle" align="left">[<a href="#SEC44" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
 
1806
<td valign="middle" align="left">[<a href="maxima_13.html#SEC47" title="Next chapter"> &gt;&gt; </a>]</td>
 
1807
<td valign="middle" align="left"> &nbsp; </td>
 
1808
<td valign="middle" align="left"> &nbsp; </td>
 
1809
<td valign="middle" align="left"> &nbsp; </td>
 
1810
<td valign="middle" align="left"> &nbsp; </td>
 
1811
<td valign="middle" align="left"> &nbsp; </td>
 
1812
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
 
1813
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
 
1814
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
 
1815
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
 
1816
</tr></table>
 
1817
<p>
 
1818
 <font size="-1">
 
1819
  This document was generated by <em>Robert Dodier</em> on <em>September, 20 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 
1820
 </font>
 
1821
 <br>
 
1822
 
 
1823
</p>
 
1824
</body>
 
1825
</html>