MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Forcing surds into the numerator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64680] Re: [mg64656] Forcing surds into the numerator
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sun, 26 Feb 2006 05:08:02 -0500 (EST)
  • References: <200602250753.CAA13968@smc.vnet.net> <9761453B-CD02-4FFD-BA7E-C011DA040EFF@mimuw.edu.pl>
  • Sender: owner-wri-mathgroup at wolfram.com

I forgot of course to add that my second function  
RationalizeDenominator2 will only work if you load in the package

<< Algebra`PolynomialExtendedGCD`

Also, I should add that the reason why RationalizeDenominator1[Sin[Pi/ 
12]] returns an answer with Sqrt[2] in the denominator is precisely  
the fact that Mathematica will always convert Sqrt[2]/2 to 1/Sqrt[2].

Andrzej Kozlowski


On 25 Feb 2006, at 18:46, Andrzej Kozlowski wrote:

>
> On 25 Feb 2006, at 08:53, Tony King wrote:
>
>> Does anyone know how I can force Mathematica to display surds in the
>> numerator of an expression, or a function that can be applied to  
>> do the job?
>>
>> For example, FullSimplify[1/(3+Sqrt[2])] returns itself and not 1/7
>> (3-root2)
>>
>> Similarly, Sin[Pi/12] returns (-1+root3)/(2root2) and not 1/4  
>> (root6-root2)
>>
>> Many thanks
>>
>> Tony
>>
>
> I answered this question in 1999, so below I am just copying the  
> functions I defined in that post without any further thinking about  
> it.
>
>
> You can do it with FullSimplify and a suitably chosen complexity  
> function that will penalise the presence of radicals in the  
> denominator. Here is such a function:
>
> RationalizeDenominator1[expr_] :=
>
>   FullSimplify[expr, ComplexityFunction ->
>     (
>       Count[#, _?
>         (MatchQ[Denominator[#], Power[_, _Rational] _. + _.] &),
>         {0, Infinity}
>       ] + If[FreeQ[#, Root], 0, 1] &
>     )
>   ]
>
> This will work on your first example:
>
>
> RationalizeDenominator1[1/(3 + Sqrt[2])]
>
>
> (1/7)*(3 - Sqrt[2])
>
> but not quite on yours second
>
> In[14]:=
> RationalizeDenominator1[Sin[Pi/12]]
>
> Out[14]=
> (-1 + Sqrt[3])/(2*Sqrt[2])
>
>
> To deal with such and more complicated cases I wrote a function  
> that will remove radicals from the denominator. It has quite clumsy  
> interface so one has to specify the root you want to remove but it  
> is not difficult to make a function that will remove all radicals.   
> Here is the function:
>
> RationalizeDenominator2[f_, a_] :=
>   Module[{t,
>      MinimalPoly}, MinimalPoly[x_, t_] := RootReduce[
>       x][[1]][t]; MinimalPoly[Sqrt[b_], t_] := t^2 - b;
>     Numerator[f]*
>           PolynomialExtendedGCD[Denominator[f] /. {a -> t},
>               MinimalPoly[a, t]][[2, 1]] /. t -> a // Expand]
>
>
> To use it you have to specify which radical in the denominator you  
> want move to the numerator:
>
>
> RationalizeDenominator2[1/(3 + Sqrt[2]), Sqrt[2]]
>
>
> 3/7 - Sqrt[2]/7
>
>
>
> RationalizeDenominator2[RationalizeDenominator2[Sin[Pi/12], Sqrt 
> [3]], Sqrt[2]]
>
>
> Sqrt[3/2]/2 - 1/(2*Sqrt[2])
>
>
> with complicated expressions RationalizeDenominator1 and  
> RationalizeDenominator2 will give you different answers:
>
>
> expr = (3 - Sqrt[5])/(1 + 5^(1/7));
>
>
> RationalizeDenominator1[expr]
>
>
> (-(-3 + Sqrt[5]))*Root[6*#1^7 - 7*#1^6 + 21*#1^5 - 35*#1^4 +  
> 35*#1^3 - 21*#1^2 + 7*#1 -
>      1 & , 1]
>
>
> RationalizeDenominator2[expr, 5^(1/7)]
>
>
> 1/2 - (5*5^(1/14))/6 - 5^(1/7)/2 + (5*5^(3/14))/6 + 5^(2/7)/2 -  
> (5*5^(5/14))/6 -
>   5^(3/7)/2 - Sqrt[5]/6 + 5^(4/7)/2 + 5^(9/14)/6 - 5^(5/7)/2 - 5^ 
> (11/14)/6 +
>   5^(6/7)/2 + 5^(13/14)/6
>
>
> Note also, however, that Mathematica will always do this:
>
>
> Sqrt[2]/2
>
>
> 1/Sqrt[2]
>
> which means that no matter what you do if Mathematica encounters  
> something like the above you will get square roots in the  
> denominator. There is no way of preventing this without using Hold.
>
>
> Andrzej Kozlowski
>
>
>
>
>


  • Prev by Date: Re: Forcing surds into the numerator
  • Next by Date: Re: Multivariable Limits
  • Previous by thread: Re: Forcing surds into the numerator
  • Next by thread: Re: Re: Forcing surds into the numerator