MathGroup Archive 1999

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

Search the Archive

Re: Rationalizing the denominator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18671] Re: [mg18633] Rationalizing the denominator
  • From: "Tomas Garza" <tgarza at mail.internet.com.mx>
  • Date: Thu, 15 Jul 1999 01:45:55 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Drago Ganic [drago.ganic at in2.hr] wrote:

> How can I get
>
>     Sqrt[2]/2
>
> instead of
>
>     1/Sqrt[2]
>
> as a result for Sin[Pi/4].
>
> When it comes to complex numbers Mathematica never returns 1/I -
> she always
> returns -I.
> Why is the behaviour for irrationals different ?

Hi, Drago!

As often has been the advise in this group, look at FullForm:

In[1]:=
  1/Sqrt[2] // FullForm

Out[1]//FullForm=
Power[2, Rational[-1, 2]]

You can't expect Mathematica to go back from this to the "rational" form
Sqrt[x]/x. In fact, if you write Sqrt[x]/x you'll get 1/Sqrt[x]:

In[2]:=
Sqrt[x]/x
Out[2]=
1/Sqrt[x]

Of course, if you still want to "rationalize" 1/Sqrt[x] you may use a
transformation rule together with HoldForm:

In[3]:=
Sin[Pi/4] /.
  Power[x_, Rational[-1, 2]] ->
    HoldForm[Power[x, Rational[1, 2]]*Power[x, -1]]
Out[3]=
Sqrt[2]/2

which, from the point of view of Mathematica, is a waste of time since this
last expression, if released, will be always return 1/Sqrt[2] as shown in
In[2] above:

In[4]:=
ReleaseHold[%]
Out[4]=
1/Sqrt[2]

On the other hand,

In[5]:=
1/I // FullForm
Out[5]//FullForm=
Complex[0, -1]

which explains why 1/I returns -I. The behavior is consistent: internally,
Mathematica has no division.

Tomas Garza
Mexico City



  • Prev by Date: Re: Solving difficult integral a follow up
  • Next by Date: Re: [Q] Implementing identities as rules
  • Previous by thread: Re: Rationalizing the denominator
  • Next by thread: Re: Rationalizing the denominator