wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> microsoft >> Microsoft Algebra Question
(Message started by: SWF on Apr 2nd, 2004, 5:14pm)

Title: Microsoft Algebra Question
Post by SWF on Apr 2nd, 2004, 5:14pm
Simplify the following algebraic expression:

              - x2 - x2

You are strongly encouraged to check your answer with Microsoft Excel and the spreadsheet in Microsoft Works.

Title: Re: Microsoft Algebra Question
Post by Cathos on Apr 2nd, 2004, 9:28pm
Is the answer not [hide]Zero[/hide]?

Title: Re: Microsoft Algebra Question
Post by BNC on Apr 4th, 2004, 1:45am
The really interesting question (IMHO) is why, o why doesn't M$ change it, when they know it's wrong (http://support.microsoft.com/support/kb/articles/q132/6/86.asp).

Title: Re: Microsoft Algebra Question
Post by Cathos on Apr 4th, 2004, 7:18pm
That is the answer right?  I plugged it into Excel, and I checked it with a calculator, and I got that answer.  Am I missing something? (I never got very far in math, but I thought I understood algebra)
???

Title: Re: Microsoft Algebra Question
Post by BNC on Apr 5th, 2004, 1:20am
The question is if you do unary operations before or after power operations.

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 5th, 2004, 4:12pm
By convention in mathematics, exponentiation gets the highest priority on its base side, ahead of all other operations. For some reason, the programmers at MS decided to violate this and make negation (unary minus) a higher priority operation, even though they left binary minus at a lower priority. I would be very much interested to hear why. Apparently from the remarks on the linked page, it was intentional (or at least, they are pretending it was).

Cathos: To the rest of the world other than Microsoft,

- x2 - x2 = - (x2) - (x2) = -2x2

To Microsoft,

- x2 - x2 = (-x)2 - (x2) = x2 - x2 = 0.

Title: Re: Microsoft Algebra Question
Post by Cathos on Apr 5th, 2004, 8:38pm
Wow, I must be really rusty with my Algebra, 'cause I got 0 with a calculator too...  See, this is why I don't venture past the Easy and What am I forums.

Title: Re: Microsoft Algebra Question
Post by SWF on Apr 5th, 2004, 9:41pm
Cathos, do you by any chance work for Microsoft?

This is something I ran across for using Excel to try to compute exp(-x^2). But BNC's link shows MS is well aware of it. At first I though MS was just trying to dictate their own idea of precedence on the rest of the world. However, my version the Microsoft Works spreadsheet does it correctly, so it does not give the same answer as Excel.

Title: Re: Microsoft Algebra Question
Post by Cathos on Apr 5th, 2004, 10:28pm
Funny, SWF.  I don't work in the computer biz at all - just a hobby of mine since the old C64 (ahh, the nostalgia...)  Well, I did get the right answer when I tried again, which means I'm smart enough to work a calculator at least half the time.  8)

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 6th, 2004, 4:58pm
My first personal computer was a Commodore 128. I loved that thing! I believe I had more fun playing games on it than I have ever had since.

For those of you who are too young, that "64" and "128" refer to how many kilobytes of memory the machines had. And this memory total included both the ROM operating system (8 or 16 K - I don't remember) and RAM.

Title: Re: Microsoft Algebra Question
Post by kellys on Apr 6th, 2004, 5:12pm
Really?  It wasn't called the Commodore 64 because it had 64 bit 3-D graphics?  How lame.  :)

Title: Re: Microsoft Algebra Question
Post by Sir Col on Apr 6th, 2004, 5:23pm
Nice one, kellys! ;D

Did you have Sinclair computers in America? My first tinkering with a home computer was with a Sinclair ZX80 (1K RAM), but the first one I owned was an Oric-1 (with a massive 16K RAM). I then progressed to a BBC 32K Microcomputer. Cor! the good old days. *nostalgic swoon*

For anyone interested, I found this webpage that has an archive of adverts for some of these dinosaurs (http://www.binarydinosaurs.co.uk/Museum/Adverts/adverts.php).

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 6th, 2004, 6:08pm
****** WARNING *******
GEEZER REMINENCES AHEAD
****** WARNING *******


The first personal computer I ever encountered was a TRS-80 that my high school got in 1978. The amazing device had a whole 16K of memory (my school splurged and got the expensive one - there was also an 8K model). Its graphics was alas slightly short of the 64bit 3-D standard. It had a 24 row by 40 column text screen, but by using its graphical extension of ASCII, you could subdivide each character space into 4 parts, giving you a whopping 3840 "pixel" resolution!

I used to graph polar equations of the form r = A+ Bsin([theta]/N) that way. It was loads of fun trying to figure out what the graph really looked like from what I saw on the screen. I also remember once calculating how much memory it would take to assign a byte to every actual pixel on the screen (the monitor itself was low resolution by today's standards) and deciding that even with the pace of improvements at the the time, it was unrealistic to ever expect this much memory to become widely available in my lifetime (it actually took about 5-10 years).

For obvious reasons (well - obvious to those who know my true name), I was tempted to buy a Sinclair computer. But Commodore had a much superior machine in my price range, so I ended up getting the C128 instead. Long before I could even think of buying more than one computer, Sinclair was gone.

Title: Re: Microsoft Algebra Question
Post by Cathos on Apr 6th, 2004, 7:00pm
Oh dear, look what I've started - an "I remember the good ol' days" fest.

Mine was actually a hybrid 64/128, but I always used the 64 mode, cause the 128 was too sophisticated for me at the time (I'm a little younger than you, Icarus  ;) )  How I miss the old Basic...

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 6th, 2004, 7:43pm
C128 were all hybrids. All the software support was for the 64, so I almost never used the added 128 capabilities either. The extra memory was only available by memory paging, if I recall. You could run the cpu at 2 MHz instead of the 1MHz of 64 mode, but again, no commercial programs ever made use of it, and my own were never sophisticated enough for the difference to be useful. The most intriguing thing about the C128 was that it actually had 2 processors. You could run it with the default processor (an 8086, if I recall), but it also had a Z80 processor that you could switch to. The problem though was that all there was for a Z80 operating system was an assembler on the 8086 side. So you if you wanted to use the Z80, you had to write an assembly program and compile it on the 8086 side, then switch to the Z80 to execute it. More trouble than it was ever worth. I'm sure that very few of those Z80 processors were ever used. Mine only saw a few token attempts.

Title: Re: Microsoft Algebra Question
Post by Sir Col on Apr 7th, 2004, 3:07am
Disclaimer: Yet more reminiscing...


We were rather fortunate when I was at school as our Computer Studies teacher had connections with Liverpool University (near where I grew up), and when I was 13 years old he took a select group of us to visit their Computing department. We had the opportunity to spend two days playing on a VAX minicomputer!

I remember getting myself into trouble though. Each user was allocated a humble amount of memory, and I discovered how to "peek" and "poke"; it was possible to access your memory space byte-by-byte. The sneaky part was that there was no check for the address you accessed, so it was possible to view and amend other users' data. I don't remember much about the system, but I think that the architecture was based on job sharing, which meant that most tasks, like printing, were queued (and open to modification if you found the correct address). The messages that some of my classmates sent to the printer were disgraceful!  ::)

Title: Re: Microsoft Algebra Question
Post by SWF on Apr 7th, 2004, 5:37pm
My school acquired an obsolete computer from some buisness, and we used to write programs on computer cards and feed them into a card reader. Programs would run and print out on a teletype (no monitor). Interactive editing of the program could not be saved except by printing a text copy. The front of the computer had a row of lights with a switch under each that corresponded to the state of bits of information. A later upgrade came with a hexadecimal keypad allowing 4 bits of information to be entered at the touch of a single button. It was a real treat when we acquired a teletype that could save interactive work by punching holes on a long strand of yellow paper tape.

That would have been around 1975 when I was 12. Every computer from then until my recent experience with Excel has computed -x^2-x^2 as -2*x^2.

What is the point of having Excel treat -x^y as (-x)^y ? If y is not an integer, the result is not a real number; if y is an even integer, the negative sign is irrelevant; if y is an odd integer, the Microsoft version equals what would be obtained with the usual interpretation, -(x^y).

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 7th, 2004, 7:12pm
SWF - The point is that Microsoft products do not have bugs, only features! (http://www.ubersoft.net/d/19960429.html)

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 17th, 2004, 9:29am
It appears that Microsoft is not alone in this curious behavior.

I looked up some documentation on the REXX scripting language for some stuff at work yesterday, and discovered that REXX (which I believe IBM came up with) does the same thing.

Title: Re: Microsoft Algebra Question
Post by who_cares on Apr 22nd, 2004, 7:34pm
Hi,
Does times sorting work for anyone in Mic$ excel. I tried putting in dates in the format "01.30 PM", .... "02.00 AM" and instead of making the AM timings after PM it just sorted by numbers like "01.30 PM" comes before "02.00 AM"....


Title: Re: Microsoft Algebra Question
Post by who_cares on Apr 22nd, 2004, 7:35pm
I am sorry, I meant ideally, it should put AM timings before PM timings ( I think I should register :-(   )

Title: Re: Microsoft Algebra Question
Post by John_Gaughan on Apr 22nd, 2004, 7:53pm
Excel does know how to sort dates, better than it knows Algebra ;-)

Try formatting the cell as a date. Go to cell properties and change it there. That instructs Excel on the cell contents. Right now it probably looks like a literal string, no interpretation.

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 23rd, 2004, 4:03pm
Yes, Excel stores all dates and times as raw numbers giving the number of days since "the epoch" (12 AM Jan 1 1970, GMT if I recall correctly), but if your cells are formatted as text, then Excel does not recognize it as a date, and simply sorting it as a string. If you reformat the cells as dates, it will convert them internally, and sort them numerically.

Also, be sure to check that the cell contents do not start with a " ' ". To do this select a cell and look at what is written in the data entry line, not what is displayed in the cell. Excel interprets a leading single quote as indicating the contents of this cell are a text string, regardless of the cell's formatting. When it displays the contents though, it suppresses the leading single quote. So the only way to tell it is there is in the data entry line. If you have these quotes, you will need to delete them before Excel will convert the times into its internal format.

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 23rd, 2004, 8:01pm
I think I've figured out why Excel and REXX do this (unary -) before exponentiation bit.

The exponential operator (^ for Excel, ** for REXX) is implemented as an ordinary binary operator. As such, it has the same precedence on both sides. Therefore they had a choice: either unary - takes precedence over exponentiation, so -2^2 = -4, or exponentiation has precedence over unary -, in which case, 2^-2 = -4. Given a choice between only these two possibilities, they did the right thing by making unary - come first. As bad as -2^2 = -4 is, 2^-2 = -4 is worse!

It's still laziness, though. They just need to set up the ability for a binary operator to have different precedence on the left than on the right (so ^ has lesser precedence than unary - on the right, but has greater precedence on the left). Other languages and applications have accomplished it.

Title: Re: Microsoft Algebra Question
Post by grimbal on Apr 30th, 2004, 1:45am
I can understand that they don't fix it.  They risk breaking thousands of perfectly well-working spreadsheets that accepted that as a feature.  They could be sued for doing that.

Title: Re: Microsoft Algebra Question
Post by farsed on Mar 2nd, 2005, 12:23am
the solution is this -x^2 == x^2 == -x * -x and thats why the left part is x^2 - x^2 = 0

Title: Re: Microsoft Algebra Question
Post by Icarus on Mar 2nd, 2005, 4:24pm
Not by standard conventions of mathematics: exponentiation has precedence over - (both unary and binary):

-x2 = -(x2) = -(x * x), AND NOT (-x)2 = (-x * -x).

Unfortunately, certain languages, including VBasic which Excel uses, have chosen to give unary - precedence over exponentiation, contrary to long established conventions. The whole point of this thread was to point out this dastardly practice.

Title: Re: Microsoft Algebra Question
Post by TheGodfather234 on Mar 30th, 2005, 7:23pm
-x^4

Title: Re: Microsoft Algebra Question
Post by towr on Mar 30th, 2005, 11:01pm

on 03/30/05 at 19:23:37, TheGodfather234 wrote:
-x^4

Only if x=0  ;D

Title: Re: Microsoft Algebra Question
Post by SWF on Apr 5th, 2005, 5:45pm
Take a look at the attached Excel file. Cells A1 and B1 contain the same formula (-2^2), but give different results for the computation (-4 and +4). Why is this? Should I just be satisfied that least one of them is correct this time.

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 5th, 2005, 7:39pm
Now that is truly messed up! How did you manage to accomplish this? If I do any manipulation of the correct formula, it reverts back to the incorrect value, even if I undo the change I made, or the change is not a real change at all (replacing "2" with "2") before pressing "enter". However, I can copy the cell and paste it and still get -4. This holds even if I paste just the formula, not the value.

I would suggest telling MS about it, except that if they did anything, they would surely go the wrong way and have it =4 at all times.

Title: Re: Microsoft Algebra Question
Post by SWF on Apr 12th, 2005, 7:28pm
I was using the Linux spreadsheet, Gnumeric (which does arithmetic correctly), and wondered what would happen if saved to Excel format. From Gnumeric I put the formula -2^2 in cell A1, saved as Excel format. Then opened the file in Excel. The formula looked the same as before and even gave the correct answer of -4.  Then I typed the same formula in cell B1, which Excel computes incorrectly.

When that file is saved from Excel, and reopened in Gnumeric, the values for the two cells are -4 and +4, but Gnumeric has corrected the formula in B1 with parentheses:  (-2)^2.

The spreadsheet in "Open Office" which is meant to be compatible with MS Office does exponents the Microsoft way.  Evidently compatiblity with MS was the objective with Open Office, and common sense took precedence with Gnumeric.

Title: Re: Microsoft Algebra Question
Post by Icarus on Apr 13th, 2005, 3:55pm
That explains it. Excel (and probably other spreadsheets) includes both the formula and the current value in their cell objects. This saves on the amount of calculation the spreadsheet has to do. The value is only recalculated when the cell formula or one of formula's referenced cells is changed.

Since you had a sane spreadsheet  program calculate the value, it was correct, and since Excel did not know the spreadsheet had been created by a sane program, it didn't realize it needed to recalculate for continue attempting to fool the masses.

Title: Re: Microsoft Algebra Question
Post by SWF on Apr 13th, 2005, 7:19pm
In Excel, there is a "Formula Auditing" option which can be picked from the Tools drop down menu. Using that shows the formula in cell A1 is stored as if operations are done in the standard order, while cell B1 is stored as if done with Microsoft math. So I don't think Excel is saving a computed result. I believe the formula is translated from the typed text and stored in some other format in Excel, and that is what gets preserved. I will try testing it by using a formula referring to cells and then change values in the referenced cells.

If you write -x^y for a formula in a Visual Basic macro, it does the operations in the standard order and therefore gives a different result from the same formula placed in an Excel cell.

Title: Re: Microsoft Algebra Question
Post by SWF on Jul 6th, 2005, 5:43pm
Here is another Excel alert:

Today, I noticed that Excel uses the arguments of the atan2() function in an order different from commonly used by computer languages. Most (all?) languages that have the atan2() function use the arguments in the order atan(y,x), but Excel has them reversed as atan2(x,y).

Title: Re: Microsoft Algebra Question
Post by paul schmitz on Jul 6th, 2005, 11:05pm
i know that almost all calculators translate -x^2 as -(x^2) and frankly i think it's really annoying.  when i write algebra, i use the negative "-" symbol as the highest priority.  most calculating systems use "-" to abbreviate *-1, which gives it the same priority as multiplication.  it's weird that MS does it differently from everything else, but if i had to choose i think it's more logical to do it their way.  of course, since everything else does differently, it's wrong to do it like that.
more often that i'd like, i've hastily plugged in a "-" without the appropriate parenthensis' and i've gotten a wrong answer.

Title: Re: Microsoft Algebra Question
Post by towr on Jul 7th, 2005, 1:11am
Yes, really annoying when programs follow mathematical convention..

Title: Re: Microsoft Algebra Question
Post by River_Phoenix on Jul 7th, 2005, 6:21am
paul, what about something written as:

x^3   -   2x^2    +   4

Should that second term be the same as (-2x)^2?



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board