[385280]: htdocs / docs / original / maxima_11.html Maximize Restore History

Download this file

maxima_11.html    1136 lines (1010 with data), 38.1 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52
from maxima.texi on 11 April 2003 -->
<TITLE>Maxima Manual - Polynomials</TITLE>
<link href="maxima_12.html" rel=Next>
<link href="maxima_10.html" rel=Previous>
<link href="maxima_toc.html" rel=ToC>
</HEAD>
<BODY>
<p>Go to the <A HREF="maxima_1.html">first</A>, <A HREF="maxima_10.html">previous</A>, <A HREF="maxima_12.html">next</A>, <A HREF="maxima_42.html">last</A> section, <A HREF="maxima_toc.html">table of contents</A>.
<P><HR><P>
<H1><A NAME="SEC38" HREF="maxima_toc.html#TOC38">Polynomials</A></H1>
<H2><A NAME="SEC39" HREF="maxima_toc.html#TOC39">Introduction to Polynomials</A></H2>
<P>
Polynomials are stored in maxima either in General Form or as
Cannonical Rational Expressions (CRE) form. The latter is a standard
form, and is used internally by operations such as factor, ratsimp, and
so on.
</P>
<P>
Canonical Rational Expressions constitute a kind of representation
which is especially suitable for expanded polynomials and rational
functions (as well as for partially factored polynomials and rational
functions when RATFAC[FALSE] is set to TRUE). In this CRE form an
ordering of variables (from most to least main) is assumed for each
expression. Polynomials are represented recursively by a list
consisting of the main variable followed by a series of pairs of
expressions, one for each term of the polynomial. The first member of
each pair is the exponent of the main variable in that term and the
second member is the coefficient of that term which could be a number or
a polynomial in another variable again represented in this form. Thus
the principal part of the CRE form of 3*X^2-1 is (X 2 3 0 -1) and that
of 2*X*Y+X-3 is (Y 1 (X 1 2) 0 (X 1 1 0 -3)) assuming Y is the main
variable, and is (X 1 (Y 1 2 0 1) 0 -3) assuming X is the main
variable. "Main"-ness is usually determined by reverse alphabetical
order. The "variables" of a CRE expression needn't be atomic. In fact
any subexpression whose main operator is not + - * / or ^ with integer
power will be considered a "variable" of the expression (in CRE form) in
which it occurs. For example the CRE variables of the expression
X+SIN(X+1)+2*SQRT(X)+1 are X, SQRT(X), and SIN(X+1). If the user does
not specify an ordering of variables by using the RATVARS function
MACSYMA will choose an alphabetic one. In general, CRE's represent
rational expressions, that is, ratios of polynomials, where the
numerator and denominator have no common factors, and the denominator is
positive. The internal form is essentially a pair of polynomials (the
numerator and denominator) preceded by the variable ordering list. If
an expression to be displayed is in CRE form or if it contains any
subexpressions in CRE form, the symbol /R/ will follow the line label.
See the RAT function for converting an expression to CRE form. An
extended CRE form is used for the representation of Taylor series. The
notion of a rational expression is extended so that the exponents of the
variables can be positive or negative rational numbers rather than just
positive integers and the coefficients can themselves be rational
expressions as described above rather than just polynomials. These are
represented internally by a recursive polynomial form which is similar
to and is a generalization of CRE form, but carries additional
information such as the degree of truncation. As with CRE form, the
symbol /T/ follows the line label of such expressions.
</P>
<H2><A NAME="SEC40" HREF="maxima_toc.html#TOC40">Definitions for Polynomials</A></H2>
<P>
<DL>
<DT><U>Variable:</U> <B>ALGEBRAIC</B>
<DD><A NAME="IDX318"></A>
default: [FALSE] must be set to TRUE in order for the
simplification of algebraic integers to take effect.
</DL>
</P>
<P>
<DL>
<DT><U>Variable:</U> <B>BERLEFACT</B>
<DD><A NAME="IDX319"></A>
default: [TRUE] if FALSE then the Kronecker factoring
algorithm will be used otherwise the Berlekamp algorithm, which is the
default, will be used.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>BEZOUT</B> <I>(p1, p2, var)</I>
<DD><A NAME="IDX320"></A>
an alternative to the RESULTANT command. It
returns a matrix. DETERMINANT of this matrix is the desired resultant.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>BOTHCOEF</B> <I>(exp, var)</I>
<DD><A NAME="IDX321"></A>
returns a list whose first member is the
coefficient of var in exp (as found by RATCOEF if exp is in CRE form
otherwise by COEFF) and whose second member is the remaining part of
exp. That is, [A,B] where exp=A*var+B.
<PRE>
(C1) ISLINEAR(EXP,VAR):=BLOCK([C],
C:BOTHCOEF(RAT(EXP,VAR),VAR),
IS(FREEOF(VAR,C) AND C[1]#0))$
(C2) ISLINEAR((R**2-(X-R)**2)/X,X);
(D2) TRUE
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>COEFF</B> <I>(exp, v, n)</I>
<DD><A NAME="IDX322"></A>
obtains the coefficient of v**n in exp. n may be
omitted if it is 1. v may be an atom, or complete subexpression of
exp e.g., X, SIN(X), A[I+1], X+Y, etc. (In the last case the
expression (X+Y) should occur in exp). Sometimes it may be necessary
to expand or factor exp in order to make v^n explicit. This is not
done automatically by COEFF.
<PRE>
(C1) COEFF(2*A*TAN(X)+TAN(X)+B=5*TAN(X)+3,TAN(X));
(D1) 2 A + 1 = 5
(C2) COEFF(Y+X*%E**X+1,X,0);
(D2) Y + 1
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>COMBINE</B> <I>(exp)</I>
<DD><A NAME="IDX323"></A>
simplifies the sum exp by combining terms with the same
denominator into a single term.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>CONTENT</B> <I>(p1, var1, ..., varn)</I>
<DD><A NAME="IDX324"></A>
returns a list whose first element is
the greatest common divisor of the coefficients of the terms of the
polynomial p1 in the variable varn (this is the content) and whose
second element is the polynomial p1 divided by the content.
<PRE>
(C1) CONTENT(2*X*Y+4*X**2*Y**2,Y);
(D1) [2*X, 2*X*Y**2+Y].
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>DENOM</B> <I>(exp)</I>
<DD><A NAME="IDX325"></A>
returns the denominator of the rational expression exp.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>DIVIDE</B> <I>(p1, p2, var1, ..., varn)</I>
<DD><A NAME="IDX326"></A>
computes the quotient and remainder
of the polynomial p1 divided by the polynomial p2, in a main
polynomial variable, varn. The other variables are as in the RATVARS
function. The result is a list whose first element is the quotient
and whose second element is the remainder.
<PRE>
(C1) DIVIDE(X+Y,X-Y,X);
(D1) [1, 2 Y]
(C2) DIVIDE(X+Y,X-Y);
(D2) [ - 1, 2 X]
</PRE>
<P>
(Note that Y is the main variable in C2)
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>ELIMINATE</B> <I>([eq1,eq2,...,eqn],[v1,v2,...,vk])</I>
<DD><A NAME="IDX327"></A>
eliminates variables from
equations (or expressions assumed equal to zero) by taking successive
resultants. This returns a list of n-k expressions with the k
variables v1,...,vk eliminated. First v1 is eliminated yielding n-1
expressions, then v2 is, etc. If k=n then a single expression in a
list is returned free of the variables v1,...,vk. In this case SOLVE
is called to solve the last resultant for the last variable.
Example:
<PRE>
(C1) EXP1:2*X^2+Y*X+Z;
2
(D1) Z + X Y + 2 X
(C2) EXP2:3*X+5*Y-Z-1;
(D2) - Z + 5 Y + 3 X - 1
(C3) EXP3:Z^2+X-Y^2+5;
2 2
(D3) Z - Y + X + 5
(C4) ELIMINATE([EXP3,EXP2,EXP1],[Y,Z]);
8 7 6 5 4
(D3) [7425 X - 1170 X + 1299 X + 12076 X + 22887 X
3 2
- 5154 X - 1291 X + 7688 X + 15376]
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>EZGCD</B> <I>(p1, p2, ...)</I>
<DD><A NAME="IDX328"></A>
gives a list whose first element is the g.c.d of
the polynomials p1,p2,... and whose remaining elements are the
polynomials divided by the g.c.d. This always uses the EZGCD
algorithm.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>FACEXPAND</B>
<DD><A NAME="IDX329"></A>
default: [TRUE] controls whether the irreducible factors
returned by FACTOR are in expanded (the default) or recursive (normal
CRE) form.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FACTCOMB</B> <I>(exp)</I>
<DD><A NAME="IDX330"></A>
tries to combine the coefficients of factorials in exp
with the factorials themselves by converting, for example, (N+1)*N!
into (N+1)!.
SUMSPLITFACT[TRUE] if set to FALSE will cause MINFACTORIAL to be
applied after a FACTCOMB.
<PRE>
(C1) (N+1)^B*N!^B;
B B
(D1) (N + 1) N!
(C2) FACTCOMB(%);
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FACTOR</B> <I>(exp)</I>
<DD><A NAME="IDX331"></A>
factors the expression exp, containing any number of
variables or functions, into factors irreducible over the integers.
FACTOR(exp, p) factors exp over the field of integers with an element
adjoined whose minimum polynomial is p.
FACTORFLAG[FALSE] if FALSE suppresses the factoring of integer factors
of rational expressions.
DONTFACTOR may be set to a list of variables with respect to which
factoring is not to occur. (It is initially empty). Factoring also
will not take place with respect to any variables which are less
important (using the variable ordering assumed for CRE form) than
those on the DONTFACTOR list.
SAVEFACTORS[FALSE] if TRUE causes the factors of an expression which
is a product of factors to be saved by certain functions in order to
speed up later factorizations of expressions containing some of the
same factors.
BERLEFACT[TRUE] if FALSE then the Kronecker factoring algorithm will
be used otherwise the Berlekamp algorithm, which is the default, will
be used.
INTFACLIM[1000] is the largest divisor which will be tried when
factoring a bignum integer. If set to FALSE (this is the case when
the user calls FACTOR explicitly), or if the integer is a fixnum (i.e.
fits in one machine word), complete factorization of the integer will
be attempted. The user's setting of INTFACLIM is used for internal
calls to FACTOR. Thus, INTFACLIM may be reset to prevent MACSYMA from
taking an inordinately long time factoring large integers.
NEWFAC[FALSE] may be set to true to use the new factoring routines.
Do EXAMPLE(FACTOR); for examples.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>FACTORFLAG</B>
<DD><A NAME="IDX332"></A>
default: [FALSE] if FALSE suppresses the factoring of
integer factors of rational expressions.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FACTOROUT</B> <I>(exp,var1,var2,...)</I>
<DD><A NAME="IDX333"></A>
rearranges the sum exp into a sum of
terms of the form f(var1,var2,...)*g where g is a product of
expressions not containing the vari's and f is factored.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FACTORSUM</B> <I>(exp)</I>
<DD><A NAME="IDX334"></A>
tries to group terms in factors of exp which are sums
into groups of terms such that their sum is factorable. It can
recover the result of EXPAND((X+Y)^2+(Z+W)^2) but it can't recover
EXPAND((X+1)^2+(X+Y)^2) because the terms have variables in common.
<PRE>
(C1) (X+1)*((U+V)^2+A*(W+Z)^2),EXPAND;
2 2 2 2
(D1) A X Z + A Z + 2 A W X Z + 2 A W Z + A W X + V X
2 2 2 2
+ 2 U V X + U X + A W + V + 2 U V + U
(C2) FACTORSUM(%);
2 2
(D2) (X + 1) (A (Z + W) + (V + U) )
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FASTTIMES</B> <I>(p1, p2)</I>
<DD><A NAME="IDX335"></A>
multiplies the polynomials p1 and p2 by using a
special algorithm for multiplication of polynomials. They should be
multivariate, dense, and nearly the same size. Classical
multiplication is of order N*M where N and M are the degrees.
FASTTIMES is of order MAX(N,M)**1.585.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FULLRATSIMP</B> <I>(exp)</I>
<DD><A NAME="IDX336"></A>
When non-rational expressions are involved, one call
to RATSIMP followed as is usual by non-rational ("general")
simplification may not be sufficient to return a simplified result.
Sometimes, more than one such call may be necessary. The command
FULLRATSIMP makes this process convenient. FULLRATSIMP repeatedly
applies RATSIMP followed by non-rational simplification to an
expression until no further change occurs. For example, consider
For the expression EXP: (X^(A/2)+1)^2*(X^(A/2)-1)^2/(X^A-1) .
RATSIMP(EXP); gives (X^(2*A)-2*X^A+1)/(X^A-1) .
FULLRATSIMP(EXP); gives X^A-1 . The problem may be seen by looking at
RAT(EXP); which gives ((X^(A/2))^4-2*(X^(A/2))^2+1)/(X^A-1) .
FULLRATSIMP(exp,var1,...,varn) takes one or more arguments similar
to RATSIMP and RAT.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>FULLRATSUBST</B> <I>(a,b,c)</I>
<DD><A NAME="IDX337"></A>
is the same as RATSUBST except that it calls
itself recursively on its result until that result stops changing.
This function is useful when the replacement expression and the
replaced expression have one or more variables in common.
FULLRATSUBST will also accept its arguments in the format of
LRATSUBST. That is, the first argument may be a single substitution
equation or a list of such equations, while the second argument is the
expression being processed. There is a demo available by
DEMO("lrats.dem"); .
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>GCD</B> <I>(p1, p2, var1, ...)</I>
<DD><A NAME="IDX338"></A>
computes the greatest common divisor of p1 and
p2. The flag GCD[SPMOD] determines which algorithm is employed.
Setting GCD to EZ, EEZ, SUBRES, RED, or SPMOD selects the EZGCD, New
EEZ GCD, subresultant PRS, reduced, or modular algorithm,
respectively. If GCD:FALSE then GCD(p1,p2,var) will always return 1
for all var. Many functions (e.g. RATSIMP, FACTOR, etc.) cause gcd's
to be taken implicitly. For homogeneous polynomials it is recommended
that GCD:SUBRES be used. To take the gcd when an algebraic is
present, e.g. GCD(X^2-2*SQRT(2)*X+2,X-SQRT(2)); , ALGEBRAIC must be
TRUE and GCD must not be EZ. SUBRES is a new algorithm, and people
who have been using the RED setting should probably change it to
SUBRES.
The GCD flag, default: [SPMOD], if FALSE will also prevent the greatest
common divisor from being taken when expressions are converted to CRE
form. This will sometimes speed the calculation if gcds are not
required.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>GCDEX</B> <I>(f,g)</I>
<DD><A NAME="IDX339"></A>
<DT><U>Function:</U> <B>GCDEX</B> <I>(f,g,var)</I>
<DD><A NAME="IDX340"></A>
returns a list containing [a,b,u] where u is the gcd of f and g,
and u = a*f + b*g. The arguments f and g should b univariate polynomials,
or else polynomials in VAR a supplied <B>main</B> variable
since we need to be in a principal ideal domain for this to work. The
gcd means the gcd regarding f and g as univariate polynomials with coefficients
being rational functions in the other variables.
</P>
<P>
The
algorithm is simply the euclidean algorithm, where we have a sequence
of <CODE>lis[i]:[a[i],b[i],r[i]] ..</CODE> which are all perpendicular
to <CODE>[f,g,-1]</CODE> and the next one is built as
if <CODE>q = quotient(r[i]/r[i+1])</CODE> then <CODE>lis[i+2]:lis[i]-q*lis[i+1]</CODE>, and it
terminates at <CODE>lis[i+1]</CODE> when the remainder <CODE>r[i+2]</CODE> is zero.
<PRE>
(C1) gcdex(x^2+1,x^3+4);
2
x + 4 x - 1 x + 4
(D1)/R/ [- ------------, -----, 1]
17 17
(C2) d1.[x^2+1,x^3+4,-1];
(D2) 0
</PRE>
<P>
note that the gcd in the following is <CODE>1</CODE>
since we work in <CODE>k(y)[x]</CODE>, not the <CODE>y+1</CODE> we would expect in <CODE>k[y,x] </CODE>
</P>
<PRE>
(C4) gcdex(x*(y+1),y^2-1,x);
1
(D4) [0, ------, 1]
2
y - 1
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>GCFACTOR</B> <I>(n)</I>
<DD><A NAME="IDX341"></A>
factors the gaussian integer n over the gaussians, i.e.
numbers of the form a + b i where a and b are rational integers (i.e.
ordinary integers). Factors are normalized by making a and b
non-negative.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>GFACTOR</B> <I>(exp)</I>
<DD><A NAME="IDX342"></A>
factors the polynomial exp over the Gaussian integers
(i. e. with SQRT(-1) = %I adjoined). This is like
FACTOR(exp,A**2+1) where A is %I.
<PRE>
(C1) GFACTOR(X**4-1);
(D1) (X - 1) (X + 1) (X + %I) (X - %I)
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>GFACTORSUM</B> <I>(exp)</I>
<DD><A NAME="IDX343"></A>
is similar to FACTORSUM but applies GFACTOR instead
of FACTOR.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>HIPOW</B> <I>(exp, v)</I>
<DD><A NAME="IDX344"></A>
the highest explicit exponent of v in exp. Sometimes
it may be necessary to expand exp since this is not done automatically
by HIPOW. Thus HIPOW(Y**3*X**2+X*Y**4,X) is 2.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>INTFACLIM</B>
<DD><A NAME="IDX345"></A>
default: [1000] is the largest divisor which will be tried
when factoring a bignum integer. If set to FALSE (this is the case
when the user calls FACTOR explicitly), or if the integer is a fixnum
(i.e. fits in one machine word), complete factorization of the integer
will be attempted. The user's setting of INTFACLIM is used for
internal calls to FACTOR. Thus, INTFACLIM may be reset to prevent
MACSYMA from taking an inordinately long time factoring large
integers.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>KEEPFLOAT</B>
<DD><A NAME="IDX346"></A>
default: [FALSE] - if set to TRUE will prevent floating
point numbers from being rationalized when expressions which contain
them are converted to CRE form.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>LRATSUBST</B> <I>(list,exp)</I>
<DD><A NAME="IDX347"></A>
is analogous to SUBST(list_of_equations,exp)
except that it uses RATSUBST instead of SUBST. The first argument of
LRATSUBST must be an equation or a list of equations identical in
format to that accepted by SUBST (see DESCRIBE(SUBST);). The
substitutions are made in the order given by the list of equations,
that is, from left to right. A demo is available by doing
DEMO("lrats.dem"); .
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>MODULUS</B>
<DD><A NAME="IDX348"></A>
default: [FALSE] - if set to a positive prime p, then all
arithmetic in the rational function routines will be done modulo p.
That is all integers will be reduced to less than p/2 in absolute
value (if p=2 then all integers are reduced to 1 or 0). This is the
so called "balanced" modulus system, e.g. N MOD 5 = -2, -1, 0, 1, or
2. Warning: If EXP is already in CRE form when you reset MODULUS,
then you may need to re-rat EXP, e.g. EXP:RAT(RATDISREP(EXP)), in
order to get correct results. (If MODULUS is set to a positive
non-prime integer, this setting will be accepted, but a warning will
be given.)
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>NEWFAC</B>
<DD><A NAME="IDX349"></A>
default: [FALSE], if TRUE then FACTOR will use the new factoring
routines.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>NUM</B> <I>(exp)</I>
<DD><A NAME="IDX350"></A>
obtains the numerator, exp1, of the rational expression
exp = exp1/exp2.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>QUOTIENT</B> <I>(p1, p2, var1, ...)</I>
<DD><A NAME="IDX351"></A>
computes the quotient of the polynomial
p1 divided by the polynomial p2.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RAT</B> <I>(exp, v1, ..., vn)</I>
<DD><A NAME="IDX352"></A>
converts exp to CRE form by expanding and
combining all terms over a common denominator and cancelling out the
greatest common divisor of the numerator and denominator as well as
converting floating point numbers to rational numbers within a
tolerance of RATEPSILON[2.0E-8]. The variables are ordered according
to the v1,...,vn as in RATVARS, if these are specified. RAT does not
generally simplify functions other than + , - , * , / , and
exponentiation to an integer power whereas RATSIMP does handle these
cases. Note that atoms (numbers and names) in CRE form are not the
same as they are in the general form. Thus RAT(X)- X results in
RAT(0) which has a different internal representation than 0.
RATFAC[FALSE] when TRUE invokes a partially factored form for CRE
rational expressions. During rational operations the expression is
maintained as fully factored as possible without an actual call to the
factor package. This should always save space and may save some time
in some computations. The numerator and denominator are still made
relatively prime (e.g. RAT((X^2 -1)^4/(X+1)^2); yields
(X-1)^4*(X+1)^2), but the factors within each part may not be
relatively prime.
RATPRINT[TRUE] if FALSE suppresses the printout of the message
informing the user of the conversion of floating point numbers to
rational numbers.
KEEPFLOAT[FALSE] if TRUE prevents floating point numbers from being
converted to rational numbers.
(Also see the RATEXPAND and RATSIMP functions.)
<PRE>
(C1) ((X-2*Y)**4/(X**2-4*Y**2)**2+1)*(Y+A)*(2*Y+X)
/(4*Y**2+X**2);
4
(X - 2 Y)
(Y + A) (2 Y + X) (------------ + 1)
2 2 2
(X - 4 Y )
(D1) ------------------------------------
2 2
4 Y + X
(C2) RAT(%,Y,A,X);
2 A + 2 Y
(D2)/R/ ---------
X + 2 Y
</PRE>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATALGDENOM</B>
<DD><A NAME="IDX353"></A>
default: [TRUE] - if TRUE allows rationalization of
denominators wrt. radicals to take effect. To do this one must use
CRE form in algebraic mode.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATCOEF</B> <I>(exp, v, n)</I>
<DD><A NAME="IDX354"></A>
returns the coefficient, C, of the expression v**n
in the expression exp. n may be omitted if it is 1. C will be free
(except possibly in a non-rational sense) of the variables in v. If
no coefficient of this type exists, zero will be returned. RATCOEF
expands and rationally simplifies its first argument and thus it may
produce answers different from those of COEFF which is purely
syntactic. Thus RATCOEF((X+1)/Y+X,X) returns (Y+1)/Y whereas COEFF
returns 1. RATCOEF(exp,v,0), viewing exp as a sum, gives a sum of
those terms which do not contain v. Therefore if v occurs to any
negative powers, RATCOEF should not be used. Since exp is rationally
simplified before it is examined, coefficients may not appear quite
the way they were envisioned.
<PRE>
(C1) S:A*X+B*X+5$
(C2) RATCOEF(S,A+B);
(D2) X
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATDENOM</B> <I>(exp)</I>
<DD><A NAME="IDX355"></A>
obtains the denominator of the rational expression exp.
If exp is in general form then the DENOM function should be used
instead, unless one wishes to get a CRE result.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATDENOMDIVIDE</B>
<DD><A NAME="IDX356"></A>
default: [TRUE] - if FALSE will stop the splitting up
of the terms of the numerator of RATEXPANDed expressions from
occurring.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATDIFF</B> <I>(exp, var)</I>
<DD><A NAME="IDX357"></A>
differentiates the rational expression exp (which
must be a ratio of polynomials or a polynomial in the variable var)
with respect to var. For rational expressions this is much faster
than DIFF. The result is left in CRE form. However, RATDIFF should
not be used on factored CRE forms; use DIFF instead for such
expressions.
<PRE>
(C1) (4*X**3+10*X-11)/(X**5+5);
3
4 X + 10 X - 11
(D1) ----------------
5
X
(C2) MODULUS:3$
(C3) MOD(D1);
2
X + X - 1
(D3) --------------------
4 3 2
X + X + X + X + 1
(C4) RATDIFF(D1,X);
5 4 3
X - X - X + X - 1
(D4) ------------------------------
8 7 5 4 3
X - X + X - X + X - X + 1
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATDISREP</B> <I>(exp)</I>
<DD><A NAME="IDX358"></A>
changes its argument from CRE form to general form.
This is sometimes convenient if one wishes to stop the "contagion", or
use rational functions in non-rational contexts. Most CRE functions
will work on either CRE or non-CRE expressions, but the answers may
take different forms. If RATDISREP is given a non-CRE for an
argument, it returns its argument unchanged. See also TOTALDISREP.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATEPSILON</B>
<DD><A NAME="IDX359"></A>
default: [2.0E-8] - the tolerance used in the conversion
of floating point numbers to rational numbers.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATEXPAND</B> <I>(exp)</I>
<DD><A NAME="IDX360"></A>
expands exp by multiplying out products of sums and
exponentiated sums, combining fractions over a common denominator,
cancelling the greatest common divisor of the numerator and
denominator, then splitting the numerator (if a sum) into its
respective terms divided by the denominator. This is accomplished by
converting exp to CRE form and then back to general form.
The switch RATEXPAND, default: [FALSE], if TRUE will cause CRE
expressions to be fully expanded when they are converted back to
general form or displayed, while if it is FALSE then they will be put
into a recursive form. (see RATSIMP)
RATDENOMDIVIDE[TRUE] - if FALSE will stop the splitting up of the
terms of the numerator of RATEXPANDed expressions from occurring.
KEEPFLOAT[FALSE] if set to TRUE will prevent floating point numbers
from being rationalized when expressions which contain them are
converted to CRE form.
<PRE>
(C1) RATEXPAND((2*X-3*Y)**3);
3 2 2 3
(D1) - 27 Y + 54 X Y - 36 X Y + 8 X
(C2) (X-1)/(X+1)**2+1/(X-1);
X - 1 1
(D2) -------- + -----
2 X - 1
(X + 1)
(C3) EXPAND(D2);
X 1 1
(D3) ------------ - ------------ + -----
2 2 X - 1
X + 2 X + 1 X + 2 X + 1
(C4) RATEXPAND(D2);
2
2 X 2
(D4) --------------- + ---------------
3 2 3 2
X + X - X - 1 X + X - X - 1
</PRE>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATFAC</B>
<DD><A NAME="IDX361"></A>
default: [FALSE] - when TRUE invokes a partially factored form
for CRE rational expressions. During rational operations the
expression is maintained as fully factored as possible without an
actual call to the factor package. This should always save space and
may save some time in some computations. The numerator and
denominator are still made relatively prime, for example
RAT((X^2 -1)^4/(X+1)^2); yields (X-1)^4*(X+1)^2),
but the factors within each part may not be relatively prime.
In the CTENSR (Component Tensor Manipulation) Package, if RATFAC is
TRUE, it causes the Ricci, Einstein, Riemann, and Weyl tensors and the
Scalar Curvature to be factored automatically. ** This should only be
set for cases where the tensorial components are known to consist of
few terms **.
Note: The RATFAC and RATWEIGHT schemes are incompatible and may not
both be used at the same time.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATNUMER</B> <I>(exp)</I>
<DD><A NAME="IDX362"></A>
obtains the numerator of the rational expression exp.
If exp is in general form then the NUM function should be used
instead, unless one wishes to get a CRE result.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATNUMP</B> <I>(exp)</I>
<DD><A NAME="IDX363"></A>
is TRUE if exp is a rational number (includes integers)
else FALSE.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATP</B> <I>(exp)</I>
<DD><A NAME="IDX364"></A>
is TRUE if exp is in CRE or extended CRE form else FALSE.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATPRINT</B>
<DD><A NAME="IDX365"></A>
default: [TRUE] - if FALSE suppresses the printout of the
message informing the user of the conversion of floating point numbers
to rational numbers.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATSIMP</B> <I>(exp)</I>
<DD><A NAME="IDX366"></A>
rationally" simplifies (similar to RATEXPAND) the
expression exp and all of its subexpressions including the arguments
to non- rational functions. The result is returned as the quotient of
two polynomials in a recursive form, i.e. the coefficients of the
main variable are polynomials in the other variables. Variables may,
as in RATEXPAND, include non-rational functions (e.g. SIN(X**2+1) )
but with RATSIMP, the arguments to non-rational functions are
rationally simplified. Note that RATSIMP is affected by some of the
variables which affect RATEXPAND.
RATSIMP(exp,v1,v2,...,vn) - enables rational simplification with the
specification of variable ordering as in RATVARS.
RATSIMPEXPONS[FALSE] - if TRUE will cause exponents of expressions to
be RATSIMPed automatically during simplification.
<PRE>
(C1) SIN(X/(X^2+X))=%E^((LOG(X)+1)**2-LOG(X)**2);
2 2
X (LOG(X) + 1) - LOG (X)
(D1) SIN(------) = %E
2
X + X
(C2) RATSIMP(%);
1 2
(D2) SIN(-----) = %E X
X + 1
(C3) ((X-1)**(3/2)-(X+1)*SQRT(X-1))/SQRT((X-1)*(X+1));
3/2
(X - 1) - SQRT(X - 1) (X + 1)
(D3) --------------------------------
SQRT(X - 1) SQRT(X + 1)
(C4) RATSIMP(%);
2
(D4) - -----------
SQRT(X + 1)
(C5) X**(A+1/A),RATSIMPEXPONS:TRUE;
2
A + 1
------
A
(D5) X
</PRE>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATSIMPEXPONS</B>
<DD><A NAME="IDX367"></A>
default: [FALSE] - if TRUE will cause exponents of
expressions to be RATSIMPed automatically during simplification.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATSUBST</B> <I>(a, b, c)</I>
<DD><A NAME="IDX368"></A>
substitutes a for b in c. b may be a sum, product,
power, etc. RATSUBST knows something of the meaning of expressions
whereas SUBST does a purely syntactic substitution. Thus
SUBST(A,X+Y,X+Y+Z) returns X+Y+Z whereas RATSUBST would return Z+A.
RADSUBSTFLAG[FALSE] if TRUE permits RATSUBST to make substitutions
like U for SQRT(X) in X.
Do EXAMPLE(RATSUBST); for examples.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATVARS</B> <I>(var1, var2, ..., varn)</I>
<DD><A NAME="IDX369"></A>
forms its n arguments into a list in
which the rightmost variable varn will be the main variable of future
rational expressions in which it occurs, and the other variables will
follow in sequence. If a variable is missing from the RATVARS list,
it will be given lower priority than the leftmost variable var1. The
arguments to RATVARS can be either variables or non-rational functions
(e.g. SIN(X)). The variable RATVARS is a list of the arguments which
have been given to this function.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RATWEIGHT</B> <I>(v1, w1, ..., vn, wn)</I>
<DD><A NAME="IDX370"></A>
assigns a weight of wi to the variable
vi. This causes a term to be replaced by 0 if its weight exceeds the
value of the variable RATWTLVL [default is FALSE which means no
truncation]. The weight of a term is the sum of the products of the
weight of a variable in the term times its power. Thus the weight of
3*v1**2*v2 is 2*w1+w2. This truncation occurs only when multiplying
or exponentiating CRE forms of expressions.
<PRE>
(C5) RATWEIGHT(A,1,B,1);
(D5) [[B, 1], [A, 1]]
(C6) EXP1:RAT(A+B+1)$
(C7) %**2;
2 2
(D7)/R/ B + (2 A + 2) B + A + 2 A + 1
(C8) RATWTLVL:1$
(C9) EXP1**2;
(D9)/R/ 2 B + 2 A + 1
</PRE>
<P>
Note: The RATFAC and RATWEIGHT schemes are incompatible and may not
both be used at the same time.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATWEIGHTS</B>
<DD><A NAME="IDX371"></A>
- a list of weight assignments (set up by the RATWEIGHT
function), RATWEIGHTS; or RATWEIGHT(); will show you the list.
</P>
<PRE>
KILL(...,RATWEIGHTS)
</PRE>
<P>
and
<PRE>
SAVE(...,RATWEIGHTS);
</PRE>
<P>
both work.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATWEYL</B>
<DD><A NAME="IDX372"></A>
default: [] - one of the switches controlling the
simplification of components of the Weyl conformal tensor; if TRUE,
then the components will be rationally simplified; if FACRAT is TRUE
then the results will be factored as well.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>RATWTLVL</B>
<DD><A NAME="IDX373"></A>
default: [FALSE] - used in combination with the RATWEIGHT
function to control the truncation of rational (CRE form) expressions
(for the default value of FALSE, no truncation occurs).
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>REMAINDER</B> <I>(p1, p2, var1, ...)</I>
<DD><A NAME="IDX374"></A>
computes the remainder of the polynomial
p1 divided by the polynomial p2.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>RESULTANT</B> <I>(p1, p2, var)</I>
<DD><A NAME="IDX375"></A>
computes the resultant of the two polynomials
p1 and p2, eliminating the variable var. The resultant is a
determinant of the coefficients of var in p1 and p2 which equals zero
if and only if p1 and p2 have a non-constant factor in common. If p1
or p2 can be factored, it may be desirable to call FACTOR before
calling RESULTANT.
RESULTANT[SUBRES] - controls which algorithm will be used to compute
the resultant. SUBRES for subresultant prs [the default], MOD for
modular resultant algorithm, and RED for reduced prs. On most
problems SUBRES should be best. On some large degree univariate or
bivariate problems MOD may be better. Another alternative is the
BEZOUT command which takes the same arguments as RESULTANT and returns
a matrix. DETERMINANT of this matrix is the desired resultant.
</P>
</DL>
<P>
<DL>
<DT><U>Variable:</U> <B>SAVEFACTORS</B>
<DD><A NAME="IDX376"></A>
default: [FALSE] - if TRUE causes the factors of an
expression which is a product of factors to be saved by certain
functions in order to speed up later factorizations of expressions
containing some of the same factors.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>SQFR</B> <I>(exp)</I>
<DD><A NAME="IDX377"></A>
is similar to FACTOR except that the polynomial factors are
"square-free." That is, they have factors only of degree one. This
algorithm, which is also used by the first stage of FACTOR, utilizes
the fact that a polynomial has in common with its nth derivative all
its factors of degree &#62; n. Thus by taking gcds with the polynomial of
the derivatives with respect to each variable in the polynomial, all
factors of degree &#62; 1 can be found.
<PRE>
(C1) SQFR(4*X**4+4*X**3-3*X**2-4*X-1);
2 2
(D1) (X - 1) (2 X + 1)
</PRE>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>TELLRAT</B> <I>(poly)</I>
<DD><A NAME="IDX378"></A>
adds to the ring of algebraic integers known to
MACSYMA, the element which is the solution of the polynomial with
integer coefficients. MACSYMA initially knows about %I and all roots
of integers. TELLRAT(X); means substitute 0 for X in rational
functions. There is a command UNTELLRAT which takes kernels and
removes TELLRAT properties. When TELLRATing a multivariate
polynomial, e.g. TELLRAT(X^2-Y^2);, there would be an ambiguity as to
whether to substitute Y^2 for X^2 or vice versa. The system will pick
a particular ordering, but if the user wants to specify which, e.g.
TELLRAT(Y^2=X^2); provides a syntax which says replace Y^2 by X^2.
TELLRAT and UNTELLRAT both can take any number of arguments, and
TELLRAT(); returns a list of the current substitutions. Note: When
you TELLRAT reducible polynomials, you want to be careful not to
attempt to rationalize a denominator with a zero divisor. E.g.
TELLRAT(W^3-1)$ ALGEBRAIC:TRUE$ RAT(1/(W^2-W)); will give "quotient by
zero". This error can be avoided by setting RATALGDENOM:FALSE$.
ALGEBRAIC[FALSE] must be set to TRUE in order for the simplification of
algebraic integers to take effect.
Do EXAMPLE(TELLRAT); for examples.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>TOTALDISREP</B> <I>(exp)</I>
<DD><A NAME="IDX379"></A>
converts every subexpression of exp from CRE to
general form. If exp is itself in CRE form then this is identical to
RATDISREP but if not then RATDISREP would return exp unchanged while
TOTALDISREP would "totally disrep" it. This is useful for
ratdisrepping expressions e.g., equations, lists, matrices, etc. which
have some subexpressions in CRE form.
</P>
</DL>
<P>
<DL>
<DT><U>Function:</U> <B>UNTELLRAT</B> <I>(x)</I>
<DD><A NAME="IDX380"></A>
takes kernels and removes TELLRAT properties.
</P>
</DL>
<P><HR><P>
<p>Go to the <A HREF="maxima_1.html">first</A>, <A HREF="maxima_10.html">previous</A>, <A HREF="maxima_12.html">next</A>, <A HREF="maxima_42.html">last</A> section, <A HREF="maxima_toc.html">table of contents</A>.
</BODY>
</HTML>