Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13387

Re: Radical conjugates

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Radical conjugates
Date Tue, 5 Feb 2013 03:23:41 +0000 (UTC)
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <keptvt$dhm$1@smc.vnet.net> (permalink)
References <20130204062157.5F2466891@smc.vnet.net>
Lines 58
Organization Time-Warner Telecom
NNTP-Posting-Date 05 Feb 2013 03:26:47 GMT
NNTP-Posting-Host 2ff11756.news.twtelecom.net
X-Trace DXC=bA`7jHHOD5jnJ]SQJ40F_gC_A=>8kQj6m9BHNOcEA\@ii`?:OBN9I@oEFiONJ7[Gof@@^nbd4^^C`
X-Complaints-To abuse@twtelecom.net
Xref csiph.com comp.soft-sys.math.mathematica:13387

Show key headers only | View raw


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@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
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Radical conjugates Bob Hanlon <hanlonr357@gmail.com> - 2013-02-05 03:23 +0000

csiph-web