Thread: Excel Math Bug
View Single Post
  #38   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Excel Math Bug

Hi Fred. I think it's just one of those things one must be aware of.
That's all. All programs are different. Whenever a formula starts with a
"-", it always triggers in my mind that () are probably needed.

It's hard to compare both programs when they are so different. (After all,
mm has a few pages of "Operator precedence's." This is off topic I know,
but the reason mm does -5^2 correctly is that "Times" (or multiplication)
has lower precedence that Power. This is different then what we think of
when using Excel and "Negation." For discussion only, here is a complex
number problem: -(3 + 4*I)^2. The term "Negation" wouldn't make sense
here. Excel is not set up to do this type of problem, so that is why it's
not fair to compare the two programs. Here's one way to do it in Excel:

=IMPRODUCT(-1,IMPOWER( COMPLEX(3,4),2))

Returns:
7-24i

(now you see why Times is used and not a "negation")

Which checks:
-(3 + 4*I)^2
7 - 24*I

For curiosity, we put a hold on the evaluation:
HoldForm[-(3 + 4*I)^2]

Times[-1, Power[Plus[3, Times[4, \[ImaginaryI]]], 2]]

We see that we needed to do something very similar in Excel to get the same
answer. :)

Anyway, off topic I know. Just some thoughts. :)

Dana DeLouis



"fred" wrote in message
...
Do any of you SCI.MATH whizes want to weigh in on this?

MS Excel calculates "=-5^2" as 25, not as -25.
This is because 'negation' is handled first in Excel. (!?)
If you put a zero in the equation,
as in "=0-5^2", your answer changes to -25.

Is this in line with standard math rules?
Is negation different than subtraction?

I'm getting a lot of comments in the Excel NG
basically saying that "it's in the help section, so too bad".

I've had lots of math and as far as I know
negation and subtraction are the same thing.




"JE McGimpsey" wrote in message
...
That's clearly explained in the XL Help topic "The order in which
Microsoft Excel performs operations in formulas".

In all the math I've ever done, from grade school on, negation and
subtraction have been separate operations (often, but not always, using
separate symbols, such as a hyphen for negation and an n-dash for
subtraction), so that -5^2 has always been interpreted to equal 25.

Personally, I'd take it up with your consultant, assuming that he/she
was working on the Excel model. That problem should have been a piece of
cake for someone with even moderate expertise to identify, from the sign
change alone! There's no way you should have to pay for 20 hours of
troubleshooting (at my rates, at least).

In article ,
"fred" wrote:

I did in another sub-thread. Dana was familiar with it already.

If you lead off with a negative sign it uses the negative value inside

the
exponentiation.
So, instead of =-5^2 equalling -25 it equals 25.
but, =0-5^2 is calculated correctly as -25 even though it's

mathematically
the same.