       Re: How to remove the "0." from "0. + 1.41774i"

• To: mathgroup at smc.vnet.net
• Subject: [mg131254] Re: How to remove the "0." from "0. + 1.41774i"
• From: Sseziwa Mukasa <mukasa at gmail.com>
• Date: Fri, 21 Jun 2013 06:01:10 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <20130620084452.627F569EF@smc.vnet.net> <58732FA6-FDFE-4100-8637-926219C678F6@gmail.com> <CAJxy_SqurCkArZaLNQDN+35u3YT8XjAL7g7wsL9cvnSOV9MLKg@mail.gmail.com>

```It's a precision issue,  the documentation on rationalize says:

Rationalize[x] yields x unchanged if there is no rational number close enough to x to satisfy the condition =E2=88=AA p/q - x =E2=88=AA < c/q^2, with c chosen to be 10^-4.
Rationalize[x, 0] converts any x to rational form.

So:

(Debug) In:= nuChop[t_] := Rationalize[Chop[t], 0];
A = {{-1.2, 1.5}, {-2.3, 1.2}};
eigval1 = Eigenvalues[A][]
nuChop[eigval1]
(Debug) Out= 2.77556*10^-17 + 1.41774 I
(Debug) Out= (116833629 I)/82408088

But I don't find (116833629 I)/82408088 more visually useful than 0. + 1.41774 I.

However here's another approach:

(Debug) In:= suppressMachinePrecisionZeros[Complex[a_, b_]] :=
SetPrecision[Chop[a], \$MachinePrecision] +
SetPrecision[Chop[b], \$MachinePrecision] I
(Debug) In:= suppressMachinePrecisionZeros /@ Eigenvalues[A]
(Debug) Out= {1.417744687875782 I, -1.417744687875782 I}

On Jun 20, 2013, at 8:15 AM, Mike Bayville <mike.bayville at gmail.com> wrote:

> Thanks, but Rationalize works in the manner you executed it; however, it does not work like this...
>
> In:= nuChop[t_] = Rationalize[t];
>               A = {{-1.2, 1.5}, {-2.3, 1.2}};
>               eigval1 = Eigenvalues[A][]
>               nuChop[eigval1]
>
> Out= 2.7755576*10^-17 + 1.4177447 I
>
> Out= 2.7755576*10^-17 + 1.4177447 I
>
>
> On Thu, Jun 20, 2013 at 7:54 AM, Sseziwa Mukasa <mukasa at gmail.com> wrote:
> (Debug) In:= Rationalize[0. + 1.41774 I]
> (Debug) Out= (70887 I)/50000
>
> That has it's own problems with respect to large values in the numerator or denominator.
>
> On Jun 20, 2013, at 4:44 AM, Mike Bayville <mike.bayville at gmail.com> wrote:
>
> > Can anyone suggest a built-in function for removing  the "0." from "0. + 1.41774i"?
> >
> > Thanks!
> >
> > Mike
> >
> > INPUT
> > A={{-1.2, 1.5}, {-2.3, 1.2}};
> > Clear[eigenvalue];
> > {eigenvalue, eigenvalue} = Chop[Eigenvalues[A]]
> > Chop[eigenvalue]
> > Chop[eigenvalue]
> >
> > OUTPUT
> > {0. + 1.41774i, 0. - 1.41774i}
> > 0. + 1.41774i
> > 0. - 1.41774i
> >
>
>

```

• Prev by Date: Re: Calculation of a not so simple integral
• Next by Date: Re: How to remove the "0." from "0. + 1.41774i"
• Previous by thread: Re: How to remove the "0." from "0. + 1.41774i"
• Next by thread: Re: How to remove the "0." from "0. + 1.41774i"