Module radical

This module provides radical constants. The module is responsible for the reduction rules that perform partial evaluation. The result can be also an integer or a rational. In case that some extra arguments is a radical, the rules delegate to the polynom and fraction methods since a rational can be easily also viewed as a polynom or fraction. The reciprocal of a radical constant is calculated with the help of a Swinnerton-Dyer polynomial.

Examples:
?- X is 1/(sqrt(3)+sqrt(2)).
X is -sqrt(2)+sqrt(3)
?- X is (2-A^2)/(sqrt(6)+sqrt(3)*A).
X is sqrt(2/3)-sqrt(1/3)*A

Because reciprocal is available the Gröbner Bases algorithm works with radical coefficients. The reduction rules are just predicates inside the radical module with a Python first argument for the method receiver. We provide reduction rules for basic arithmetic. Radical constants are modelled as arbitrary long square root sums but nesting of radicals is not yet supported. Special functions are currently not supported. Error handling is rudimentary.

The following radical constant predicates are defined:

-(P, Q):
The predicate succeeds in Q with the P negated.
+(P, Q, R):
The predicate succeeds in R with the sum of P and Q.
-(P, Q, R):
The predicate succeeds in R with P subtracted by Q.
*(P, Q, R):
The predicate succeeds in R with the product of P and Q.
/(P, Q, R):
The predicate succeeds in R with P divided by Q.
^(P, Q, R):
The predicate succeeds in R with P raised by Q.

Kommentare