2
$\begingroup$

Is there an easy way to all remove radicals from a denominator? I would like a function, say RemRadsFromDenom that, e.g., transforms $\frac{1-\sqrt{3}}{1+\sqrt{3}}$ to $-\frac{(1-\sqrt{3})^2}{2}$ and, e.g., $\frac{1+\sqrt{3}}{1-\sqrt{3}+\sqrt{5}}$ to $\frac{7 - 2 \sqrt{3} - \sqrt{5} + 2 \sqrt{15}}{11}$.

So when given a fraction containing radicals, I want ```RemRadsFromDenom`` to return an expression without any radicals in the denominator.

I feel there should be a built-in function to do this, but I haven't found anything in the documentation centre. There exits algorithms to achieve this result but before implementing those on my own I wondered if there isn't any built-in functionality that achieves the goal. This does seem like a standard thing that any CAS should be able to do.

All questions related to this one have answers that circumvent using such a function. Typically because some obvious simplification could be done, in which case FullSimplify could be used.

$\endgroup$
6
  • $\begingroup$ FullSimplify? $\endgroup$ May 2, 2023 at 15:29
  • $\begingroup$ FullSimplify doesn't guarantee that the denominator in the result has no radicals. $\endgroup$
    – Gert
    May 2, 2023 at 15:32
  • $\begingroup$ Please give an example problem where FullSimplify does not work. $\endgroup$ May 2, 2023 at 15:36
  • $\begingroup$ For example FullSimplify[(1 + Sqrt[3])/(1 - Sqrt[3] + Sqrt[5])]. It is important to note that one can make FullSimplify work for this case as well but I would like a function that works for any case and guarantees that the result has no radicals in the denominator. Since I don't know the inner workings of FullSimplify I can't assume it will always do this $\endgroup$
    – Gert
    May 2, 2023 at 15:39
  • $\begingroup$ so what do you want for example $\frac{1-\sqrt{3}+\sqrt{5}}{1+\sqrt{3}}$ to transform to? It is better to give more examples than just one so one gets better idea of what is it you want. For the example you gave, it is easy to do what you want. expr = (1 - Sqrt[3])/(1 + Sqrt[3]); num = Numerator[expr]; den = Denominator[expr]; expr = Simplify[num^2]/Simplify[num*den] but this will not work for all cases. $\endgroup$
    – Nasser
    May 2, 2023 at 15:40

1 Answer 1

2
$\begingroup$

You haven't really given a lot of test cases, so it is hard to properly test our solutions.

RemRadsFromDenom[expr_] := 
 FullSimplify[expr, 
  ComplexityFunction -> (LeafCount[#] + 
      1000 Count[Denominator@Together@#, 
        Sqrt[_] | Surd[_, _] | _^Rational[_, _] | Root[__], All] &)]

testCases = {
  (1 + Sqrt[3])/(1 - Sqrt[3] + Sqrt[5]), 
  (1 - Sqrt[3])/(1 + Sqrt[3]), 
  (1 - 5^(1/3))/(2 - 6^(1/3) + 7^(1/5))
 };

RemRadsFromDenom /@ testCases
(* {
    1/11 (-2 + 4 Sqrt[3] + 5 Sqrt[5] + Sqrt[15]),  
    -2 + Sqrt[3], 
    (-1 + 5^(1/3)) Root[1 + 30 # + 420 #^2 + ... + 2889720 #^14 + 1064823 #^15&, 1, 0]
   } 
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.