Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Radical conjugates
Replies: 1   Last Post: Feb 4, 2013 10:23 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Bob Hanlon

Posts: 890
Registered: 10/29/11
Re: Radical conjugates
Posted: Feb 4, 2013 10:23 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.