Re: Radical conjugates
- To: mathgroup at smc.vnet.net
- Subject: [mg129696] Re: Radical conjugates
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Mon, 4 Feb 2013 22:24:23 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20130204062157.5F2466891@smc.vnet.net>
Clear[radicalConjugate1, radicalConjugate2] radicalConjugate1[x_] := Module[{c}, c = Cases[x, Power[_]]; If[Length[c] > 0, x /. c[[1]] -> -c[[1]], x]] radicalConjugate2[n_] := n /. (y_.*Sqrt[z_] + x_. -> x - y*Sqrt[z]); testData = {a + b Sqrt[c], a Sqrt[b] + c Sqrt[d], c Sqrt[d] + a Sqrt[b], a Sqrt[b]}; radicalConjugate1 /@ testData {-a + b Sqrt[c], -a Sqrt[b] + c Sqrt[d], -a Sqrt[b] + c Sqrt[d], -a Sqrt[b]} radicalConjugate2 /@ testData {a - b Sqrt[c], -a Sqrt[b] + c Sqrt[d], -a Sqrt[b] + c Sqrt[d], -a Sqrt[b]} Note the difference in the handling of the first test case. Bob Hanlon On Mon, Feb 4, 2013 at 1:21 AM, Francisco Javier Garc=EDa Capit=E1n <garciacapitan at gmail.com> wrote: > > Hello, I wanted a function that takes a numerical expression of the form > > a + b Sqrt[c] > > or > > a Sqrt[b] + c Sqrt[d] > > and returns its conjugate, namely a - b Sqrt[c] and (a Sqrt[b] - c > Sqrt[d]) respectively. > > I wrote > > RadicalConjugate[x_] := Module[{c}, > c = Cases[x, Power[_]]; > If[Length[c] > 0, x /. c[[1]] -> -c[[1]], x] > ] > > and it seems that it works. Anyway, do you have a different approach? > > Thank you. > > -- > --- > Francisco Javier Garc=EDa Capit=E1n > http://garciacapitan.99on.com > >
- References:
- Radical conjugates
- From: Francisco Javier García Capitán <garciacapitan@gmail.com>
- Radical conjugates