Rationalize denominators and denest square roots
Source:R/simplify-radsimp.R, R/simplify.R
radsimp.Rdradsimp() removes square roots from denominators as SymPy's
radsimp(): at most max_terms radical terms are handled, and with
symbolic = FALSE denominators with symbols are left alone.
rad_rationalize(num, den) rationalizes num/den and returns the new
numerator and denominator. collect_sqrt() collects terms with common
square roots. split_surds() splits a sum of surds by their gcd.
sqrtdenest() rewrites sqrt(a + b*sqrt(c)) as a sum of square roots
when possible.
Usage
radsimp(e, symbolic = TRUE, max_terms = 4L)
rad_rationalize(num, den)
split_surds(expr)
collect_sqrt(expr, evaluate = TRUE)
sqrtdenest(e, max_iter = 3L)Arguments
- e, expr
An expression.
- symbolic
Also handle denominators with symbols.
- max_terms
The largest number of radical terms handled.
- num, den
Numerator and denominator.
- evaluate
For
collect_sqrt():FALSEreturns the terms and the number of radical terms instead of the sum.- max_iter
For
sqrtdenest(): the largest number of denesting passes.