Re: How to remove the "0." from "0. + 1.41774i" [Revised]
- To: mathgroup at smc.vnet.net
- Subject: [mg131259] Re: How to remove the "0." from "0. + 1.41774i" [Revised]
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sat, 22 Jun 2013 03:32:08 -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: <kpucst$9f7$1@smc.vnet.net> <20130621095850.7C9AB69ED@smc.vnet.net>
Unless you'd be satisfied to have just a display form with no "0." included, e.g., as a string, I don't see how you can do what you ask. You might be tempted to try something like: imchop[z_] := Which[z \[Element] Reals, z, Head[z] == Complex && Re[z] != 0, z, Head[z] == Complex && Re[z] == 0, Im[z] I] But it won't handle the case at issue, e.g.: imchop[0. + 1.41774 I] 0. + 1.41774 I And the reason is that after extracting the imaginary part 1.41774 and multiplying by I, you have a number whose FullForm is Complex[0.`, 1.417741] and hence will display as the very same 0. + 1.41774 I. > I have some to realize that I failed to describe the context of my request. > > I am hope to identify or create a function, e.g., mikechop[t_], such that the argument could be a real or complex number, and if it is a complex number such as: > > 0. + 1.41774i > > or > > 1.2313 x 10^(-16) + 1.41774i > > the output will be: > > 1.41774i > > otherwise it will be the real or complex number that was input. > > This is for inclusion in code that I write. > > Sorry for not properly describing the end use. > > Humbly, > > Mike > > > > > > On Thursday, June 20, 2013 4:01:33 AM UTC-4, Mike Bayville 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[1], eigenvalue[2]} = Chop[Eigenvalues[A]] >> >> Chop[eigenvalue[1]] >> >> Chop[eigenvalue[2]] >> >> >> >> OUTPUT >> >> {0. + 1.41774i, 0. - 1.41774i} >> >> 0. + 1.41774i >> >> 0. - 1.41774i --- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2838 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- Follow-Ups:
- Re: How to remove the "0." from "0. + 1.41774i" [Revised]
- From: Fred Simons <f.h.simons@tue.nl>
- Re: How to remove the "0." from "0. + 1.41774i" [Revised]
- References:
- How to remove the "0." from "0. + 1.41774i" [Revised]
- From: Mike Bayville <mike.bayville@gmail.com>
- How to remove the "0." from "0. + 1.41774i" [Revised]