Previous in Forum: Need Infomation on a Standard Next in Forum: Designing Or Sizing A Single Phase (50 Hz) UPS System
Commentator

Join Date: Oct 2014
Posts: 82

# The Input of Complex Numbers

12/21/2014 7:50 PM

I need a general E.E./Computer Science answer to the following:

Why can't I enter sqrt(-9) as an input in my scientific calculator but can enter 3i as an input?

In addition, my nifty Sharp EL-520R 2-line scientific calculator will let me input 2+3i but will not let me enter 2+sqrt -9, its equivalent; it returns an error. . . Any electrical engineering or computer science answers will be appreciated.

/Silicon Valley Regards

Pathfinder Tags: complex numbers
Interested in this topic? By joining CR4 you can "subscribe" to

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, rate them!
Guru

Join Date: Mar 2007
Location: at the beach in Florida
Posts: 30962
#1

### Re: The input of complex numbers

12/21/2014 7:59 PM

Difference between negative [(-)] and minus [-]....?
Negative [(-)] is like an adjective. Minus [-] is like a verb.

__________________
Break a sweat everyday doing something you enjoy
Commentator

Join Date: Oct 2014
Posts: 82
#3

### Re: The input of complex numbers

12/21/2014 8:10 PM

I was careful to use negative, when inputting the sqrt -9; I get the error message whether I input 'negative' or 'minus'.

/Silicon Valley Regards

3
Guru

Join Date: May 2009
Location: Richland, WA, USA
Posts: 20964
#2

### Re: The input of complex numbers

12/21/2014 8:07 PM

Unless you arbitrarily define sqrt as positive, it is ambiguous. I.e., sqrt (-9) = +/- 3i.

__________________
In vino veritas; in cervisia carmen; in aqua E. coli.
Commentator

Join Date: Oct 2014
Posts: 82
#4

### Re: The input of complex numbers

12/21/2014 8:22 PM

That is very curious; maybe that's how the Sharp engineers thought when they wrote the software for it.

/Silicon Valley Regards

Guru

Join Date: Apr 2014
Posts: 1869
#5

### Re: The input of complex numbers

12/21/2014 8:44 PM

That's exactly the reason; i = +sqrt(-1) != sqrt(-1). Their error message could be more succinct, but they'd have to be mindreaders to know you're working with complex numbers (unless the calculator has an explicit Complex Mode).

Most users by far would be working in a Real Number context in which the square root of negative *anything* is an outright error, whereas in your context it is simply an ambiguity that cannot be resolved without knowledge of your context. That context is assumed when you use i (or j, if it is Truly an Engineering calculator) in a numeric expression, whereas it cannot be assumed when using the 'square-root' format.

Commentator

Join Date: Oct 2014
Posts: 82
#6

### Re: The input of complex numbers

12/21/2014 9:07 PM

But I must put my EL-520R in Complex Mode (all scientific calculators must be put in 'complex mode' before you can work with complex nos.), so the context is clear.

(The exception is the TI-36X Pro scientific calculator (not a grapher); it does complex number calculations on the same stack as the Real Number mode.

/Silicon Valley Regards

Guru

Join Date: Apr 2014
Posts: 1869
#8

### Re: The input of complex numbers

12/21/2014 9:32 PM

"... so the context is clear."

Not yet it isn't. How does it know which component - Real or Imaginary - you are computing? For all it knows you are incorrectly computing the Real part! It does not know (and cannot know) from that expression alone that you mean the Imaginary part. It simply hasn't enough information yet to assign the result to the proper component. Only you know that part for sure; it does not, and the way you tell it unambiguously is by using i as part of the numeric expression. That is the only way it can know for sure which part you mean.

Commentator

Join Date: Oct 2014
Posts: 82
#9

### Re: The input of complex numbers

12/21/2014 9:41 PM

Your point is well taken; thank you.

/Silicon Valley Regards

3
Guru

Join Date: Apr 2014
Posts: 1869
#10

### Re: The input of complex numbers

12/21/2014 9:46 PM

This is one of those examples where computers (in the broadest machine sense) cannot tolerate ambiguity - at all - and why explicitly-defined computer languages are necessary. Even with these there are plenty of opportunities for ambiguity to creep in.

Unfortunately this leaves you with more work on your hands, as you must manually factor-out the real coefficient from inside the square-root, leaving only the sqrt(-1) and changing that to i. It won't do this for you because, as was mentioned earlier, sqrt(-1) has two roots: +sqrt(-1) and -sqrt(-1) and so how does it know which root, +i or -i, you intend? It doesn't; you have to tell it.

Computers are truly mindless.

Commentator

Join Date: Oct 2014
Posts: 82
#11

### Re: The input of complex numbers

12/21/2014 10:05 PM

Yes it was. . . . I have two Sharp models; the EL-520R and the EL-506R; both are only 5-1/2-inches tall and both do complex numbers, differentiation and definite integrals; so powerful for small hand-held calculators. The biggest difference is that the EL-506R has power-off memory protection; when it auto-powers off it saves all calculations you were working on in memory when you power it back on.

They are long-discontinued models and oddly the only place I can find brand new ones is with European resellers (the cost of shipping equals the cost of the calculator).

/Silicon Valley Regards

Guru

Join Date: Apr 2014
Posts: 1869
#13

### Re: The input of complex numbers

12/21/2014 10:14 PM

I really miss my old HP-33e (I drooled over the '65 but it was way beyond my uni-student's budget). The '33e had only 49 program steps but RPN made for very efficient use of every step. In 49 steps I could perform selected integrations. They took for-bluddy-ever to compute but, still, I could do them on that calculator with its limited program memory.

As a test I numerically integrated the area under the Bell curve out to eight standard deviations on either side and the answer was (to the precision of the calculator) 1.000...

The integration took six hours.

Commentator

Join Date: Oct 2014
Posts: 82
#34

### Re: The input of complex numbers

12/23/2014 8:58 PM

It's mystifying to me why both HP and TI sell various numbers of elegant hand held Business calculators but don't have the same interest in scientific calculators.

For example you can still buy the HP 33 and 35, but TI only has only one decent scientific, the TI 36X Pro. But it falls short as compared to HP's two scientific calculators (graphers are too menu intensive and too large so I prefer the scientifics). . . . But both companies have several Business calcs on the market; it's as if they both think everyone is a CPA and engineers matter far less; odd.

My brother-in-law showed me an HP emulator on his phone but I prefer the tactile feel of buttons.

/Silicon Valley Regards

2
Guru

Join Date: Oct 2013
Location: Illinois, 7 county region (The 'blue dot' that drags the rest of the 'red state' around during presidential elections.)
Posts: 3688
#32

### Re: The input of complex numbers

12/23/2014 9:49 AM

GA for that.

What a lot of students (and professionals) forget is WHY those numbers are called 'complex.' The two components (real and imaginary) are separate number lines, so you have to work on each half independently then put them back together to find the result.

Computers, being literally as dumb as a box of rocks(1) need everything spelled out for them before they can crunch the numbers.If you were making an X-Y scatter diagram on a spreadsheet and put the Y values into the X column, do you think the computer will give you a meaningful result? Complex numbers are the same way, the X is the real component, the Y is the imaginary.

Also computers and calculators are typically programmed to return an error when dividing by zero or trying to find the square root of a negative number, because the solution is more complex than a rock can understand. For division by zero, there are three possibilities:

1. If the formula is X/(X+Y) where X is the sample count of interest and (X+Y) is the total count, (used to find the pass/fail ratio of a quality inspection, for example) when the total is zero, the pass/fail ratio would be zero by definition.
2. If you are looking at 'boundary dimensions' (such as for a selection window on a graphics program, a window of 0x0 units would have an aspect ratio of 1:1, which would appear to be handles as 0/0=1.
3. If you are looking at an equation of A/X looking for the limits as X approaches zero, you would say that A/X approaches infinity.

This all requires more brain cells than ANY computer possesses (2), so the programmer has to look at what is happening and tell the computer 'IF X = 0 THEN spit out this result, ELSE perform this division.'

Square roots of negative numbers have the ambiguity of being either positive or negative. i = sqrt(-1) by definition, but that is only half the answer, -i can also be considered the square root of -1, since both i2 and -i2 = -1.

I might be wrong about that last statement (It's been a while since I've had to work with complex or imaginary numbers) but that just proves my point, if a human, who has reason and common sense, can get confused about square roots of negative numbers, a dumb machine that can only do exactly what it is told to do (which may not be what the teller MEANT it to do) does not even have the proverbial snowball's chance in Hades(3) of figuring things out.

Notes:

1. Since they are made from silicon, they ARE 'a box of rocks' in a manner of speaking.
2. See 'dumb as a box of rocks' comment above.
3. Sometimes I wish for the simpler era where the 'politically incorrect' versions of statements were allowed, I tended to turn that phrase as "... has two chances, a snowball's and a [REDACTED]'s." It still jumps into my head at the wrong times. A well, perhaps the later generations will grow up never learning those 'impolite' phrases, or, as Uhura said to Lincoln in that Star Trek episode, They'll "...learn to not fear words."
__________________
( The opinions espressed in this post may not reflect the true opinions of the poster, and may not reflect commonly accepted versions of reality. ) (If you are wondering: yes, I DO hope to live to be as old as my jokes.)
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#16

### Re: The input of complex numbers

12/22/2014 9:20 AM

Maybe you understand #8 but sorry, I don't. I'd suggest you try Mathcad. It handles complex numbers as readily as real ones, including symbolic calculation as well as numerical. If you type i it knows you're doing complex calcs. If you mean i you enter i, if you mean -i you enter -i, and it knows the difference. In case of sqrt it assumes positive. For symbolic calc you have to choose complex from the menu, for numerical you just hit = in the usual way.

Eg it gives (symbolically) √i = (1 + i)/√2. Checking by squaring the answer gives back i (as you'd expect!), and also (-(1 + i)/√2)2 = i.

And √(-i) = (1 - i)/√2.

__________________
Give masochists a fair crack of the whip
Commentator

Join Date: Oct 2014
Posts: 82
#18

### Re: The input of complex numbers

12/22/2014 1:44 PM

Happily, I typed in your (1 + i)/√2 and hit the 'x-squared' key on my small Sharp two-line scientific calculator, --and it quickly returned i as we would expect.

I love my powerful little Sharp EL-520R . . .

/Silicon Valley Regards

Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#20

### Re: The input of complex numbers

12/22/2014 1:58 PM

That's good! Does it give you (1 + i)/√2 (or something equivalent) when you try to evaluate √i ?

__________________
Give masochists a fair crack of the whip
Commentator

Join Date: Oct 2014
Posts: 82
#21

### Re: The input of complex numbers

12/22/2014 2:16 PM

That's curious, my EL-520R returns an error; it returns "Error 2" defined as:

Calculation error (Error 2):

• The absolute value of an intermediate or final calculation result equals or exceeds 10^100
• An attempt was made to divide by 0
• The calculation ranges were exceeded while performing calculations

/Silicon Valley Regards

Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#22

### Re: The input of complex numbers

12/22/2014 2:28 PM

That's interesting.

Have you tried to find eg √(4*i) ? I'd be surprised if it works if it won't do √i but you never know.

Or √(3 + 4*i) ? Or ln(-1) ? should give i*pi.

__________________
Give masochists a fair crack of the whip
Commentator

Join Date: Oct 2014
Posts: 82
#23

### Re: The input of complex numbers

12/22/2014 2:56 PM

Paradoxically, my scientific calculator will not take the sqrt of (4*i), or, will not allow me to raise it to a fractional power (like 1/2, or even to 0.5), it returns Error 2 . . . . but it will raise it to a whole number power.

√(3 + 4*i) returned an Error 2 also, but it will raise it to a whole number power.

ln(-1) also returns Error 2.

/Silicon Valley Regards

Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#24

### Re: The input of complex numbers

12/22/2014 3:21 PM

OK thanks. I still recommend Mathcad, it will do all that with no problem at all (and a lot more besides )

__________________
Give masochists a fair crack of the whip
Power-User

Join Date: Jul 2007
Location: Cleveland, OH
Posts: 445
#29

### Re: The input of complex numbers

12/23/2014 1:07 AM

I love Mathcad. Unfortunately, since Parametric Technologies bought it, the low-cost version has vanished. I can't afford the current version.

Or have they woken up and brought it back? I paid a little over \$100 for mine.

__________________
"Just a little off the top" - Marie Antoinette
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#31

### Re: The input of complex numbers

12/23/2014 6:13 AM

I didn't know Mathcad had been sold. I'm a great fan too. I've had mine for years but I'm not saying how I got it! I'm on version 14 which I guess is far from the latest. I didn't think later ones were always an improvement on previous, eg editing formulas got trickier, but I wouldn't be without it.

It would be nice to think there was a budget version that Joe Public might buy, but I don't know.

__________________
Give masochists a fair crack of the whip
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#25

### Re: The input of complex numbers

12/22/2014 3:36 PM

Another thought - does your calculator do ei*pi = -1 ?

__________________
Give masochists a fair crack of the whip
Commentator

Join Date: Oct 2014
Posts: 82
#26

### Re: The input of complex numbers

12/22/2014 4:04 PM

e^i*pi on my Sharp also returns Error 2.

It's a beautiful thing that the complex exponential function e^i*pi is simply a point on the Real x-axis.

/Silicon Valley Regards

Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#27

### Re: The input of complex numbers

12/22/2014 4:32 PM

It is, and the equation ei*pi + 1 = 0 incorporates zero, the real unit 1, the imaginary unit i, and the two best known transcendental numbers e and pi. Fascinating if you like that kind of thing.

Be interesting to know if other calculators which claim complex capability do any better.

__________________
Give masochists a fair crack of the whip
Commentator

Join Date: Oct 2012
Location: USA
Posts: 95
#28

### Re: The input of complex numbers

12/22/2014 11:04 PM

Euler Identity

I have that one as a sticky note on my desktop monitor.It is awesome how math works.

__________________
If you can't explain it simply, you don't understand it well enough. AE
Off Topic (Score 5)
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#30

### Re: The input of complex numbers

12/23/2014 5:53 AM

Yes, the full thing (as I'm sure you know) is

ei*x = cos(x) + i*sin(x)

It's one of the most surprising results in maths. e, i and trig functions come from 3 different areas of the subject, yet it turns out they have this connection. I can still remember the spooky feeling I had when I first came across this, over 50 years ago.

__________________
Give masochists a fair crack of the whip
Off Topic (Score 5)
2
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#15

### Re: The input of complex numbers

12/22/2014 8:44 AM

But that also applies to sqrt of positive numbers. Calculators assume the positive root. If user wants to use the negative root, he has to do a different calculation. In principle the same approach could apply to sqrt of negative numbers as far as I can tell.

__________________
Give masochists a fair crack of the whip
Guru

Join Date: May 2007
Location: NYC metropolitan area.
Posts: 3231
#17

### Re: The input of complex numbers

12/22/2014 1:10 PM

No it can't, the sqrt of any negative number is undefined in "ordinary" math since there is no pair of identical numbers that when multiplied together will equal a negative number. That type of math only exists in the world of complex numbers, and the calculators designed to handle them.

__________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.” Ben Franklin.
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#19

### Re: The input of complex numbers

12/22/2014 1:55 PM

My #15 was a reply to #2. I wasn't commenting on #8.

We've established that we're discussing calculators that can handle complex numbers, or we wouldn't have got this far. It's just that the ones OP is using don't seem to handle them the way he'd like.

Also the point about sqrt having +/- values is true for complex numbers as well as real ones, as mentioned in #16.

__________________
Give masochists a fair crack of the whip
Guru

Join Date: Sep 2009
Posts: 1032
#7

### Re: The Input of Complex Numbers

12/21/2014 9:18 PM

In real number world, sqrt of a (positive) number IS by definition the positive root. Not aware of a corresponding arrangement in complex numbers world, let alone that the meaning of "positive" is not identical, it is extended. S.M.

__________________
Life is complex. It has a real part and an imaginary part.
Guru

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 14331
#33

### Re: The Input of Complex Numbers

12/23/2014 10:56 AM

There are quadratic equations where the negative square root of the term is the one that makes logical sense, and it the selected answer in that case, but many times is is also the postive square root of the term that matters.

For myself pi r≠[], because cornbread r square, pi is round. That takes some heavy cipherin'.

I just check my "realcalc" app on my Android device, it does not have a provision for complex numbers. Fortunately, there is still Excel spreadsheets, and all the tricks that one can play on them.

__________________
If it ain't broke, don't fix it. Just build a better one.
Guru

Join Date: May 2007
Location: NYC metropolitan area.
Posts: 3231
#12

### Re: The Input of Complex Numbers

12/21/2014 10:09 PM

Scientific calculators take an input, perform an operation on that input, and provide an output. Notice the emphasis on a single input/operation/output. In CS terms, Sqrt() is a unary operator; i.e., it accepts a single input and provides a single output.

More sophisticated calculators like the TI-89 etc. are solvers, they provide a solution, which could be unary, binary, or a series of data points. They are preprogrammed to be context sensitive, so that when they see the command sqrt(-1) they will perform complex math and return both roots when so directed by the user.

__________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.” Ben Franklin.
Commentator

Join Date: Oct 2014
Posts: 82
#14

### Re: The Input of Complex Numbers

12/21/2014 10:51 PM

Unary; I've seen that term before somewhere a long time ago, now I know what it really means to me.

That's a terrific video.

I can perform that same TI-89 calculation 5i(3-2i)^2 with fewer input steps on my two-line Sharp scientific calculator. Also, you don't always need a graphing calculator to have a solver feature; there are newer Sharp, Casio and TI scientific calculators that have solvers, too.

/Silicon Valley Regards

Participant

Join Date: Jan 2015
Posts: 3
#36

### Re: The Input of Complex Numbers

01/09/2015 1:44 AM

Complex numbers consist of two separate parts: a real part and an imaginary part.

Off Topic (Score 5)
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#37

### Re: The Input of Complex Numbers

01/09/2015 8:38 AM

I think most of us knew that .

But following on from James S in #33, there's quite a bit on complex numbers in Excel. If anybody doesn't know, type complex in the formula Search box and you get various functions, including division (which obviously covers reciprocals), sqrt, ln etc. One thing slightly irritating, it gives results to 14 places of decimals, and there's no way I can find to edit, even via right-click/format cells/number. Who needs that, we're engineers for chrissake!

__________________
Give masochists a fair crack of the whip
Off Topic (Score 5)
Commentator

Join Date: Oct 2014
Posts: 82
#38

### Re: The Input of Complex Numbers

01/11/2015 10:25 PM

Codemaster I may open Excel to check it out, but my real interest is a handheld scientific calculator (like the early HPs, the early TI-35X) with complex number support and polynomial solvers.

My small two-line Sharp scientific, only 6" tall, can do both; it certainly has shortcomings, but at least I can run simple checks on things because it has those two important features. Indeed, I can perform operations on two complex numbers in two different forms, for example: (3+4i) / (5, 60deg). That is so beautiful.

Alas, Sharp no longer makes these small compact scientific models.

I queried someone on another forum and asked him if the discontinued TI-35X (an elegant little powerhouse) which he once had, had a modern two-line LCD screen, would he still prefer it over the modern TI-36X Pro scientific calculator; he replied that he would still prefer the 35X over the 36X Pro.

The scientific calculator market has fallen on hard times.

/Silicon Valley Regards

Guru

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 14331
#39

### Re: The Input of Complex Numbers

01/12/2015 11:07 AM
 Here is Excel stuff input1 17+2i input 2 2+3i input 3 5+5i improduct(input1, input2, input3) -135+415i imln(E14) 6.07857248595337+1.88530063121164i imconjugate(G14) 6.07857248595337-1.88530063121164i improduct(G14,G16) 40.5034019370363 "13 decimal places, not sought" Bitmap sqrt 6.364 squared 40.503 "correct format" round(imaginary(G14), 2) 1.89 "correct format" round(imreal(G14),2) 6.08 "correct format" G23^2 +G24^2 40.539 "correct format" -3.572 complex(G24,G23) 6.08+1.89i
__________________
If it ain't broke, don't fix it. Just build a better one.
Off Topic (Score 6)
Guru

Join Date: Jul 2005
Location: Stoke-on-Trent, UK
Posts: 4320
#40

### Re: The Input of Complex Numbers

01/12/2015 2:27 PM

OK, I see how it can be done. But it seems quite a performance just to round a number down

__________________
Give masochists a fair crack of the whip
Off Topic (Score 5)
Guru

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 14331
#41

### Re: The Input of Complex Numbers

01/12/2015 3:11 PM

no duh. It almost hurts to have to go that far just for a properly formatted answer.

Obviously, I could have cleaned that up somewhat.

__________________
If it ain't broke, don't fix it. Just build a better one.
Off Topic (Score 5)
Anonymous Poster #1
#35

### Best Engineering College in UP

12/29/2014 4:51 AM

Engineering & Technology, we believe that innovation should lead to real benefits in the world outside.

Best Engineering College in UP

Off Topic (Score 3)
Interested in this topic? By joining CR4 you can "subscribe" to