|
Go to the first, previous, next, last section, table of contents.
Operations over algebraic numbersIn the previous section, we explained about the representation of algebraic numbers and their defining method. Here, we describe operations on algebraic numbers. Only a few functions are built-in, and almost all functions are provided as user defined functions. The file containing their definitions is `sp', and it is placed under the same directory as `gr' is placed, i.e., the standard library directory of Asir. [0] load("gr")$ [1] load("sp")$
Or if you always need them, it is more convenient to include the
Like the other numbers, algebraic numbers can get arithmetic operations applied. Simplification, however, by defining polynomials are not automatically performed. It is left to users to simplify their expressions. A fatal error shall result if the denominator expression will be simplified to 0. Therefore, be careful enough when you will create and deal with algebraic numbers which may denominators in their expressions.
Use [49] T=A0^2+1; (#0^2+1) [50] simpalg(T); 0
Function [39] A0=newalg(x^2+1); (#0) [40] T=(A0^2+A0+1)/(A0+3); ((#0^2+#0+1)/(#0+3)) [41] simpalg(T); (3/10*#0+1/10) [42] T=1/(A0^2+1); ((1)/(#0^2+1)) [43] simpalg(T); div : division by 0 stopped in invalgp at line 258 in file "/usr/local/lib/asir/sp" 258 return 1/A; (debug)
This example shows an error caused by zero division in the course of
program execution of
Function [43] simpalg(1/A0*x+1/(A0+1)); (-#0)*x+(-1/2*#0+1/2)
Thus, you can operate in polynomials which contain algebraic numbers
as you do usually in ordinary polynomials,
except for proper simplification by [83] A0=newalg(x^2+1); (#0) [84] A1=newalg(x^3+A0*x+A0); (#1) [85] T=(2*A0+A1*A0+A1^2)*x+(1+A1)/(2+A0); (#1^2+#0*#1+2*#0)*x+((#1+1)/(#0+2)) [86] S=algptorat(T); (((t#0+2)*t#1^2+(t#0^2+2*t#0)*t#1+2*t#0^2+4*t#0)*x+t#1+1)/(t#0+2) [87] algptorat(coef(T,1)); t#1^2+t#0*t#1+2*t#0
As you see by the example,
function
The associated indeterminate to a root is reversely converted
into the root by [88] rattoalgp(S,[alg(0)]); (((#0+2)/(#0+2))*t#1^2+((#0^2+2*#0)/(#0+2))*t#1+((2*#0^2+4*#0)/(#0+2)))*x +((1)/(#0+2))*t#1+((1)/(#0+2)) [89] rattoalgp(S,[alg(0),alg(1)]); (((#0^3+6*#0^2+12*#0+8)*#1^2+(#0^4+6*#0^3+12*#0^2+8*#0)*#1+2*#0^4+12*#0^3 +24*#0^2+16*#0)/(#0^3+6*#0^2+12*#0+8))*x+(((#0+2)*#1+#0+2)/(#0^2+4*#0+4)) [90] rattoalgp(S,[alg(1),alg(0)]); (((#0+2)*#1^2+(#0^2+2*#0)*#1+2*#0^2+4*#0)/(#0+2))*x+((#1+1)/(#0+2)) [91] simpalg(@89); (#1^2+#0*#1+2*#0)*x+((-1/5*#0+2/5)*#1-1/5*#0+2/5) [92] simpalg(@90); (#1^2+#0*#1+2*#0)*x+((-1/5*#0+2/5)*#1-1/5*#0+2/5)
Function Go to the first, previous, next, last section, table of contents. |