Re: Re: Forcing surds into the numerator

*To*: mathgroup at smc.vnet.net*Subject*: [mg64685] Re: [mg64680] Re: [mg64656] Forcing surds into the numerator*From*: "Kai Gauer" <kai.g.gauer at gmail.com>*Date*: Mon, 27 Feb 2006 00:18:33 -0500 (EST)*References*: <200602250753.CAA13968@smc.vnet.net> <9761453B-CD02-4FFD-BA7E-C011DA040EFF@mimuw.edu.pl> <200602261008.FAA22170@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Apparently, none of the 3 solutions seem to fully RationalizeDenominator for this particular example: x:=Sqrt[2]*Sqrt[(-(a*b*c) + a*f^2 + b*g^2 - 2*f*g*h + c*h^2)/ ((-(a*b) + h^2)*(-a - b + (-a + b)*Sqrt[1 + (4*h^2)/(a - b)^2]))] RationalizeDenominator1[x] - doesn't fully try all that it might be wanted to RationalizeDenominator2[x, Sqrt[(a - b)^2 + 4*h^2]] (** The 2nd argument is chosen in this form because it makes sense to eliminate the denomintator of the less-simplified Sqrt[1 + (4*h^2)/(a - b)^2] form **) - returns the warning: PolynomialExtendedGCD::"onevar": "PolynomialExtendedGCD is defined only for polynomials in one variable." (Mathematica 3.0) SurdFunction[x] - also doesn't tackle it successfully My particular functions also have the related quantity of x, call it y: y:=Sqrt[2]*Sqrt[(-(a*b*c) + a*f^2 + b*g^2 - 2*f*g*h + c*h^2)/ ((-(a*b) + h^2)*(-a - b + (a - b)*Sqrt[1 + (4*h^2)/(a - b)^2]))] Is there any way to have all the surd solutions return as a single list, but also for symbolic forms? Can I also instead attach a (-1)^k value term here to help pick up the sign changes of doing operations such as FullSimplify (usually k for my purposes will be an Integer type, expecting at least a factor of (-(a*b*c) + a*f^2 + b*g^2 - 2*f*g*h + c*h^2) above the -1) or have a return value in the form (<esc> +- <esc>), or (<esc> -+ <esc>) operators? I do not know how to define extra rules which will allow for Simplify, etc to recognize these in the same format as Plus, Minus. Certain TargetFunctions -> {Abs, Arg}, allow for tries with other functions, but seem to be limited for the forms which they can return. I do not necessarily need to keep the parity of the list returned (ie the list can be re-ordered if all the solutions are returned) as it more necessary in my application to run a Simplify on 4 values at a time and get 4 returns (with, in certain cases, possibly double-root solutions). Any ideas? Kai G. Gauer On 2/26/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > 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 > > > > > > > > > > > >

**References**:**Forcing surds into the numerator***From:*"Tony King" <mathstutoring@ntlworld.com>

**Re: Forcing surds into the numerator***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>