[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |

In 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
`load`

commands in ‘`$HOME/.asirrc`’.

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 `simpalg()`

function for simplification of algebraic numbers
by defining polynomials.

[49] T=A0^2+1; (#0^2+1) [50] simpalg(T); 0

Function `simpalg()`

simplifies algebraic numbers which have
the same structures as rational expressions in their appearances.

[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 `simpalg()`

, which attempted to simplify
an algebraic number expression of which the denominator is 0.

Function `simpalg()`

also can take a polynomial as its argument
and simplifies algebraic numbers in its coefficients.

[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 `simpalg()`

.
You may sometimes feel needs to convert **root**’s into indeterminates,
especially when you are working for norm computation in algorithms for
algebraic factorization.
Function `algptorat()`

is used for such cases.

[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 `algptorat()`

converts **root**’s, `#`

,
in polynomials and numbers into its associated indeterminates,
`n``t#`

. As was already mentioned those indeterminates cannot
be directly input in their immediate form.
The restriction is adopted to avoid the confusion that might happen
if the user could input such internally generatable indeterminates.
`n`

The associated indeterminate to a **root** is reversely converted
into the **root** by `rattoalgp()`

function.

[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 `rattoalgp()`

takes as the second argument
a list consisting of **root**’s that you want to convert,
and converts them successively from the left.
This example shows that apparent difference of the results due to
the order of such conversion will vanish by simplification yielding
the same result.
Functions `algptorat()`

and `rattoalgp()`

can be conveniently
used for your own simplification.

[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |

This document was generated on *February 24, 2018* using *texi2html 5.0*.