Search The Web

Today's Headlines

Sunday, February 28, 2010

A Satisfying Week

There were quite a few interesting developments last week. both at work and outside. Some of them, taken by themselves could be construed as upsetting and threatening, but overall, in the grand scheme of things, these developments seem to signal things turning around towards sanity in the long run.

At work, my team and I produced a detailed data flow diagram that showed our manager and director how and in what order different things had to happen for us to deliver results from the program we were writing. We made it clear that we could complete our program well within our deadline, but we were not sure that the support infrastructure existed to make the rest of the steps happen, on time, or even ever!

So, my manager and director called a meeting with our counterparts in the IT department to bring them up to speed on our requirements. The IT department had not given any thought to any of the stuff that had to happen apart from extracting some data from some enterprise databases. Even that process was well behind schedule according to their own admission.

When they saw our detailed flow diagram and the explanations of what needed to happen when and so on, their first reaction was quite predictable. They tried to weasel their way out of the whole mess by trying to imply that once they gave us the data it was entirely our responsibility to make sure the infrastructure and technical skill existed on our side to make the other stuff happen.

This was obviously absurd since our department does not have any hard-core IT skills, only mathematical modeling skills, and we rely on our IT department for making other stuff happen. But, in the past, my manager and director seemed willing to roll over and play dead, leaving us in the position of sticking to our deadline even though we did not have the knowledge or know-how to make half of the stuff in the flow chart happen.

For the first time, our director put our collective feet down, and told IT it was their responsibility to make things happen outside the actual modeling part. My week started looking up as soon as this happened. It looks likely that several positive developments will follow from this. Some of them may not appear positive at first glance, but taken together, my project's chances of success probably went up several-fold.

First of all, it is likely that the project timelines will be stretched out to accommodate the schedule IT comes up with for accomplishing stuff on the flow diagram that is outside our control. This may sound bad at first, but it is quite good. First of all, there was no way for us to keep to our timelines given that we had no skills to accomplish some of the steps in the flow diagram. It was a completely unreasonable and infeasible timeline. We would have gotten to our deadlines and had to report that half of what we needed to do was not done.

If IT actually decides to stretch the timeline by a couple of months, then it gives us all some breathing room. It also places responsibility for various steps with the groups that actually have the skills to accomplish the steps, so the project as a whole is likely to get completed according to the new timeline.

This should have been done a few months back. But it wasn't. There will probably be some gnashing of teeth and wringing of hands when the project timeline is pushed back because of this development. This separation of responsibilities should have been done a few months back. It probably would have resulted in some replanning, but we could have probably kept our published deadlines. But now, I doubt there is any alternative but to postpone our initial production delivery date. The positive development is that people have been forced to take their head out of the sand for the first time in several months!

Outside of work, I got into an argument about technology and standards with a couple of people who I thought knew what they were talking about. It turns out they did not, and I had to do a lot of research by myself, but the final outcome was that I disproved what they were trying to prove to me. It took some time on my part, but I learned a little more about technology, standards and the history of technology in the process. Another satisfying outcome overall!

My daughters start state-wide standard testing this coming Monday. The school has prepared them quite well for the test, and their work at home has been quite good too. I have no doubt they will do well on the tests. The school did something new this year: they sent the parents email asking them to write letters of encouragement to their kids so that they can read them just before they start working on the test. I think this is a very innovative idea that will bring out the best in the kids.

My wife and I sat down and wrote nice letters for our kids this week. The letters were sent to the school in envelopes just bearing the kids' names. I am sure they will be pleasantly surprised to read the letters when the sit down to begin their standard testing!

I continue to get visitors from new countries to my blog long after I have stopped holding out much hope of that happening! My new visitor for the week was from the former Yugoslav Republic of Macedonia. That makes visitors from 107 different countries to my blog!

In the blog this week, I put together a post on crosstab queries on Monday. On Tuesday, I published second part of my post on weird-looking computer mice. This was the mice that could not be accommodated in my earlier post because of the formatting snafus I talked about in last week's roundup. On Wednesday, I published a post on cubic equations and followed that up on Thursday with a humorous post on the differences between men and women as illustrated by a couple of old, but very good jokes. On Friday, I put together a post with some playful signs that bring a smile to your face. On Saturday, I summarized the technology argument I had with my friends into another post.

I also had a visitor to one of my earlier posts on Access (dealing with percentile values) post a comment asking for help with solving a related problem. The problem turned out to be somewhat challenging, but after spending a few hours trying various SQL tricks, I managed to solve the problem. Did I say this week was satisfying?!! My only disappointment was that the person who asked me the question seemed to have lost interest and moved on. At least he never posted back telling me whether my final solution worked for him/her or not. But, for the first time, I had a back and forth going on in the comments to one of my blog posts, and that by itself was satisfying to me.

Next week promises to be quite a busy one. At work, there promise to be more meetings, more presentations to put together, more spreadsheets to justify various things, etc. I probably have to participate in several hand-wringing sessions while things get adjusted to reflect new realities. Well, some things just can't be avoided I guess.

At home, the kids will be busy with their standards tests and the preparations that go with them. I probably have to sit with them in the evenings to make sure they don't have any last-minute doubts or problems with the material they are supposed to know and get tested on. At the end of next week, my kids are also supposed to participate in a singing program. They will be performing outside a group setting for the first time, so they are busy practicing for that, and I am sure they will be busy continuing their practice next week too.

My karate class is proceeding as usual. I am reviewing and practicing all my katas these days in addition to teaching the new students. I can feel my black belt test coming closer though I have no idea precisely when it is going to happen.

Now, it is time for me to get ready for the busy week ahead. I have my usual chores at the end of the weekend to take care of too. The weekends are never long enough, the week is never short enough!

Saturday, February 27, 2010

Somebody Has To Stand Up For The Big Guy!

This week something exciting happened in my life. No, don't worry, I did not get recruited by the CIA and given a license to kill, or anything like that! When I say something exciting, I mean it in a nerdy, geeky sort of way. I got involved in an email back-and-forth that had me becoming the unlikely online defender of tech behemoth, Microsoft.

Yes, yes, I know, it is cool to bash MS because they are big. It is cool to take potshots at them for all kinds of things because to do otherwise brands you as an MS apologist. But, sometimes, you just have to stand up for what is right, even if that means defending Microsoft, which is what I ended up doing.

It all started out simply enough. I was in email conversation with my friends A and B about something unrelated. A wanted to find out what would be a good character to use to designate a specific type of linkage between two entities in an input line that he was parsing for further processing. I suggested a "\" since "/" was already taken in this application. B jumped in with an objection, and it all got started with that. I have reproduced a bunch of emails below with some comments from me about the emails in italics.

----
From B:

I think that would just cause confusion. There are way too many people out
there (including many who should know better such as web site designers) who
thanks to Microsoft, don't even know there is a difference between a forward
slash and a backslash and use them interchangeably.
----
Notice the gratuitous swipe at Microsoft in a conversation that has absolutely nothing to do with that company!

----
From me:

Come on, B, blaming MS for the "/" versus "\" confusion is like blaming Apple for people who don't know the difference between right-clicking and left-clicking their mouse! :) There are stupid people, and then there are people who realize the difference between things that look close but are different, such as "/" and "\", right-click and left-click, etc. That is all there is to it, as far as I am concerned.
----
You would think that B would then agree, and leave it at that. But where would I get excitement in my life if that had happened? Instead he responds with this:

----
From B:

Really? Microsoft is who decided to use backslash as the separator in a
directory path for Windows when the rest of the world had already
standardized the forward slash for that purpose. If it hadn't been for
Microsoft's "we'll redefine the standard because we're big and we feel like
it" attitude, most people would have no clue that there even is a backslash.
----
So, B seems to be implying that somehow MS decided that "/" was an inconvenience in its quest for global hegemony, and therefore consciously decided to introduce "\" into the mix well after a standard was established. Obviously nothing could be farther from the truth. So, I wrote back the following:

----
From me:

By the same token, Apple took Xerox's original mouse design that had two or three mouse buttons and made it a single button for their Macintosh in 1984.

In any case, DOS was not even written by Microsoft, it was bought from Seattle Computer Products by MS for licensing to IBM with their newly designed computer (and it was based on CP/M. I am not familiar with CP/M, but it is quite probable that CP/M used "\" as the directory separator, so the use of "/" as directory separator was by no means standard when MS started using "\". At the time DOS was introduced in 1981, only Unix and its variants used "/" as the directory separator. DEC and VMS, the other dominant OS'es at that time did not).

Anyway, calling MS "big" at the time DOS was introduced is a wee bit of an exaggeration, methinks! "Unknown" or "tiny" would be better adjectives for them at that time. It is not as if MS decided in 2000 suddenly (when the adjective "big" actually makes sense to use with MS) to change the directory separator out of spite at the world. There are lots of things you can blame MS for, blaming them for the directory separator character in DOS is not just barking up the wrong tree, it is barking in the wrong neighborhood, as far as I am concerned. "/" was by no means a standard directory separator in 1981 when DOS came out, and even it if was, MS was not big enough to "redefine the standard because we're big and we feel like it". If anyone was to blame, it was IBM who had the clout and size to force MS to change the separator to "/" if they wanted to, but did not.

Nowadays, windows computers understand both "/" and "\" as directory separators (in fact there is practically no difference between the characters on a modern windows computer. You don't have to take my word for it, try it out on your windows computer if you don't believe me). In fact, it is an undocumented feature, but even the earliest versions of DOS were coded up to allow "/" as a directory separator, and "-" as an option-prefix. It was based on a little-known, undocumented system setting.

And calling Apple a defender of open standards is even more laughable. Apple computers still come with only one mouse button (no system setting option to make it two buttons. No customization at purchase time to make your apple laptop come with 2 mouse buttons decades after the rest of the world has standardized around 2 mouse buttons). It is OK for Apple to have a "we make cool-looking, outrageously expensive toys, and if we want our users to have only one mouse button, then that is what they will have, take it or leave it" attitude, but MS is not allowed to continue coding up their OS to use "\" as a directory separator purely for backwards compatibility even though it is not needed anymore. Make of that what you will. If anything, given the market share of windows-based computers in the world, I would say it is time for other OS'es to give up their antiquated "standards" and switch to "\" for the directory separator like they should have done years back!
----
Obviously, I could have just backed off my comment about Apple, and just concentrated on defending MS, but where would the fun be in that?!! B writes back and the fun really starts!

----
From B:

Why do you keep bringing up Apple? I have not said a word about Apple in
this discussion.

I do have strong feeelings on the the forward vs. back slash question
because I have run into websites run by people who think there is no life
outside Windows and IE and used backslashes in URLs. Apparently (at least at
the time), IE would silently correct those into forward slashes so the site
worked fine for him. Meanwhile, his view was that those of us using browsers
that did not perform this silent "correction" were the ones at fault for not
using "standard" IE. Since I had a critical business need to access this
site, it was a problem.
----
Ah, now I am at fault for bringing up Apple. Notice that there was no need to bring up MS, yet he did. But now that I have brought up his favorite cult, he is miffed about it!

----
From me:

And I never said a word about MS in this discussion before you brought it up either. And I had a user of one of my models once who kept messing up in our GUI by pressing the right mouse button instead of the left mouse button. Apparently, they were used to a computer whose mouse silently "corrected" all their clicks to left clicks whether they pressed the mouse with their index finger or pinky, and whether they pressed the left side of the mouse or the right. I just considered THEM stupid, not their computer or the company that manufactured it.

I understand that you have strong feelings about the confusion caused by "/" and "\", but why pin the blame on MS? If you don't like "\", you don't like "\". I fail to see why it translates to a dislike of MS. It is not as if they invented the character or decided to use it specifically to thwart some "standard". And what prevents other "advanced" web browsers from incorporating a similar silent "correction" given that many people are used to it? Why not blame them for not evolving with the times instead of blaming an historical accident on a convenient scapegoat that had nothing to do with it?
----
As you can see, I was starting to enjoy this discussion. I do strongly believe that MS had nothing to do with the introduction of "\" in DOS, and based on that belief, I was just stating the obvious. Unfortunately, the obvious is not very convenient to A and B who have a deep-rooted bias against Microsoft and would have no problems blaming it for nuclear warfare, world hunger and the AIDS epidemic if they could! At this point, A jumps into the argument.

----
From A:
> In any case, DOS was not even written by Microsoft, it was bought from
> Seattle Computer Products by MS for licensing to IBM with their newly
> designed computer (and it was based on CP/M. I am not familiar with
> CP/M, but it is quite probable that CP/M used "\" as the directory
> separator ...

I used to own a CP/M system: it didn't have subdirectories so there was
no concept of a directory separator.

> At the time DOS was introduced in 1981, only Unix and its variants
> used "/" as the directory separator. DEC and VMS, the other dominant
> OS'es at that time did not).

DEC was a company, not an OS. Aspects of several DEC OSes are apparent
in MS/DOS but not the backslash separator. RT-11 and RSTS/E (both PDP-11
OSes) didn't have subdirectories. TOPS-10 (PDP-10 / DECsystem-10) used
commas but the directory was syntactically separated from the filename::

dev:[proj,prog,dir]file.ext

The "proj,prog" component was the Project Programmer Number (PPN), each
piece an octal number.

VAX/VMS used a similar syntax but with periods instead of commas.

The use of "/" as the command-line option prefix was consistent across
all of the DEC OSes I used and I assume that's where MS/DOS got it.

So far as I know, Unix originated the idea of a unified pathname syntax
for subdirectories and filenames.

At least one other OS I worked on used ">" as the directory separator.

> Anyway, calling MS "big" at the time DOS was introduced is a wee bit of an
> exaggeration, methinks!

B didn't say that. He said MS was big at the time Windows was
introduced, which seems like a fair statement.

One could argue that early Windoze was just a hack on top of MS/DOS, and
thus couldn't readily change the syntax, and successive versions just
continued that tradition.

Where they really screwed up is allowing and perhaps encouraging "\" as
a separator in URLs, in direct contravention to an established standard.
----
All kinds of red herrings to confuse the issue. The directory separator in CP/M (whether one existed or not) is obviously irrelevant to our discussion. It was just a conjecture on my part that CP/M is where Seattle Computer Products might have gotten the directory separator in DOS. So is the distinction between DEC as a company and their operating systems. If you say MS uses "\" as a directory separator, any sane person would understand that what is meant is that MS's operating systems use "\", not the company MS, obviously.

Similarly, the size of MS in the age of windows is irrelevant. "\" was not introduced by MS with the advent of Windows, it has always been a part of Microsoft's operating systems since day 1.


I had already written it, but A rediscovers history by writing "One could argue that early Windoze was just a hack on top of MS/DOS, and thus couldn't readily change the syntax, and successive versions just continued that tradition." Duh!

In the meantime, B is itching to get back in the discussion, so he writes as follows:


----
From B:

> I understand that you have strong feelings about the confusion caused by "/"
> and "\", but why pin the blame on MS?

Because as far as I know, MS was the first to use "\" as a directory
separator in opposition to established use.
----
Again the "established use" argument. And he still refuses to acknowledge that MS did not introduce "\" as a directory separator even though I have provided him with enough evidence to the contrary!

----
From me:

> Because as far as I know, MS was the first to use "\" as a directory
> separator in opposition to established use.

Well, hopefully based on the messages in this exchange, you will start blaming Seattle Computer Products for this problem in the future! And as A mentioned in his message, only one OS (Unix) used "/" as a directory separator. Most others used a different character or did not have any concept of directory structure. So, I have no idea what "established use" you are referring to.
----
Obviously, I was getting tired of beating the dead horse that MS did not introduce "\" as a directory separator. And I was hoping to shut B up with this message. It mostly worked, as you will see.

But in the meantime, I also wrote a response to A as below:


----
From me:

> I used to own a CP/M system: it didn't have subdirectories so there was
> no concept of a directory separator.

That is a red herring, since, as I said, MS did not write DOS. Blaming them for the "\" separator is like blaming them for the QWERTY keyboard.

>> Anyway, calling MS "big" at the time DOS was introduced is a wee bit of an
>> exaggeration, methinks!

> B didn't say that. He said MS was big at the time Windows was
> introduced, which seems like a fair statement.

The use of "\" as a directory separator did not originate with Windows. So, why does MS's size at the time of Windows matter to this discussion? BTW, windows was introduced to the public in 1985 and calling MS big in 1985 is still a bit of an exaggeration too. And in any case, MS did not even introduce "\", so the whole point is moot.

> One could argue that early Windoze was just a hack on top of MS/DOS, and
> thus couldn't readily change the syntax, and successive versions just
> continued that tradition.

I already mentioned that the "\" was retained purely as a nod to backwards compatibility. Windows perfectly understands "/" as a directory separator and even DOS did.

> Where they really screwed up is allowing and perhaps encouraging "\" as
> a separator in URLs, in direct contravention to an established standard.

How does allowing something to be used in addition to the standard become a contravention of the standard? Does the standard specifically prohibit "\" as a separator? It is not as if they specifically forbade the use of the standard and allowed people to do things only their way. That is like saying modern browsers contravene standards by allowing and in fact encouraging users to type in "google.com" instead of "http://www.google.com".

Choices sometimes confuse people, but I would much rather have more choices than fewer, thank you very much.
----
Now, we are getting closer to the crux of the issue, in spite of all the detours this conversation has taken. The issue is the use of "\" in URL's and A and B's claims that this contravenes some "standard". Hence my specific question about what the standard says and whether there is a prohibition against "\" in URL's. Here is the response I got:

----
From A:

> That is a red herring, since, as I said, MS did not write DOS. Blaming
> them for the "\" separator is like blaming them for the QWERTY keyboard.

It's your red herring. I merely documented that CP/M was not, as you
suggested, the surce of the "\" separator.

>> Where they really screwed up is allowing and perhaps encouraging "\" as
>> a separator in URLs, in direct contravention to an established standard.
>
> How does allowing something to be used in addition to the standard
> become a contravention of the standard?

Allowing a non-standard syntax to be use is not a bad thing.
Encouraging it (by not correcting it and by publishing documents which
use it) is a bad thing.

> Does the standard pecifically prohibit "\" as a separator?

You can look at the standard as well as I can. Google "RFC URL format"
and look at RFC 1738, specifically

3.1. Common Internet Scheme Syntax

While the syntax for the rest of the URL may vary depending on the
particular scheme selected, URL schemes that involve the direct use
of an IP-based protocol to a specified host on the Internet use a
common syntax for the scheme-specific data:

//<user>:<password>@<host>:<port>/<url-path>

Some or all of the parts "<user>:<password>@", ":<password>",
":<port>", and "/<url-path>" may be excluded. The scheme specific
data start with a double slash "//" to indicate that it complies
with the common Internet scheme syntax. ...

The standard does not say "'/' or whatever other character you feel
like using" though it does not explicitly prohibit "\".

> Choices sometimes confuse people, but I would much rather have more
> choices than fewer, thank you very much.

There is an axiom in the world of implementing Internet protocols which
says that one should be liberal in what one accepts and conservative in
what one generates. By accepting "\" in URLs M$ was liberal in what
they accepted (at the cost of encouraging bad habits). By not
correcting the error in the URLs they generated and expecting others to
accomodate their mistake they failed to be conservative in what they
generate.
----
Notice that he does not want to give up on the irrelevancy of CP/M to the whole argument here!

Also notice the use of Windoze and M$. It is called name-calling, but I let it pass. And to hear him talk about M$ and Micro$oft and Windoze, Window$, etc., while defending the cult of Apple, you would be forgiven for thinking that Apple is run as a non-profit philanthropy by Mother Teresa herself!

In any case, he has cited a standard. Notice that he talks about the "/" before the <url-path> in the standard, but I thought the whole argument was what was permitted inside the URL path itself, not what comes before it. After all, it is not as if MS allows "http:\\" instead of "http://". The question of whether the standard prohibits the use of "\" inside the URL is cleverly avoided. It turns out that is for good reason. My research into the standards resulted in the email below:


----
From me:

OK, I took your suggestion and looked at the standard. Specifically, I was interested in what the standard had to say about <url-path> because that is what is under discussion here, not the use of "http://" or other parts of the URL. And this is what the standard has to say:

An HTTP URL takes the form:

http://<host>:<port>/<path>?<searchpart>


where <host> and <port> are as described in Section 3.1. If :<port>
is omitted, the port defaults to 80. No user name or password is
allowed. <path> is an HTTP selector, and <searchpart> is a query
string. The <path> is optional, as is the <searchpart> and its
preceding "?". If neither <path> nor <searchpart> is present, the "/"
may also be omitted.

Within the <path> and <searchpart> components, "/", ";", "?" are
reserved. The "/" character may be used within HTTP to designate a
hierarchical structure.

Note the use of the word "may" in the last sentence. The writers could just as easily have said "must", or "should" or "has to" instead of "may", but they specifically chose "may". To me, it is a clear indication that they wanted to suggest "/" as the directory separator, but they specifically did not want to impose it as a standard. I see no standards non-compliance if MS decided to use "\" to designate a hierarchical structure. After all, dos and windows users were already used to that character to designate a hierarchical structure, so why not?

You can shout at the writers of the standards for leaving the standards vague. Or you can shout at the unix-centric coders of your favorite browser for ignoring the hierarchical structure designator of the largest operating system in the world. But MS bears no blame in this entire fiasco as far as I am concerned. "\" is perfectly acceptable in URL's according to my reading of this standards document. The standards neither mandate "/" nor prohibit "\" as a hierarchical structure designator, so I don't know where one gets the idea that MS allowing the use of "\" in URL's is heretical.
----

I have not received a response to this email from B (or A) - for obvious reasons, I think!

It is easy for people to assume that whatever they are used to is a standard, and if someone comes up with a new way of doing something, it must be wrong and against the "standards". When it comes to the use of "\" as a directory separator in URL's, it turns out there is no standard and MS is completely within its rights to use "\" if it wants to. In fact they could use any character they choose to use as a directory separator because the standard does not specify any particular character.

In any case, A now feigns boredom, and writes back as follows:

----
From A:

I am done with this.
----
Of course he is! No acknowledgment that he was wrong about any of the points he raised. No apology for dragging MS into the argument with his juvenile, baseless, ad hominem attack on them. Now he is done with this! I wrote back:

----
From me:

No problem. At least I learned a lot from this discussion, the history of DOS, and the URL standards being the least of it.
----

But really, I meant what I wrote above. First of all, I thought A and B were unbiased. That turned out to be quite wrong.

Next, I assumed that they knew what they were talking about when it comes to the history of computers and operating systems. It turns out that was not true either. I had to do my own research to prove to myself and them that Microsoft did not come up with "\" as a directory separator by themselves.

More importantly, I assumed that they knew what they were talking about when it comes to http and the web. I have never done any web development while these two have their own websites and what-not. And, in the past, when they said MS went against standards, I might have stayed on the sidelines and taken their word for it. It turns out the standards are not what these two claim they are. In their world, Unix and Apple are the standard and whatever Microsoft does is against the standard.

Whether they did that just to have a convenient punching bag or whether they really did not know what the standards said is open to debate. But it certainly tells me that there is no research like my own to uncover the real truth about anything. Now, if I had 240 hours in a day instead of 24, I will probably be able to discredit a lot more of these charlatans spouting fake "standards" and other untruths, but I don't.

For now I would have to be satisfied with the the excitement of a good debate (even though I don't consider my opponents as honorable as they could have been) as long as it lasted!

Friday, February 26, 2010

11 Tongue-in-Cheek Signs To Make You Smile!

Here are some signs that are not to be taken too literally. They are just light-hearted, whimsical expressions of the sense of humor of the person who put up the sign! Enjoy!!

The first couple are a bit long, but well worth it!

gary's weather forecasting stone
learn chinese in 5 minutes
stress reduction kit
Sensible advice from the next few signs, I feel!

This machine has no brain use your own

in case of fire . . .
push button or yell for help
I wonder if they are still taking new customers!

insured by mafia
Interesting - I didn't know I could get a refund if these turned out to be defective!

insert baby for refund
These last two are not only light-hearted and whimsical, but they are sexist too! What could be better?!!

seat for bored husbands
give it to your wife label

Thursday, February 25, 2010

Men Are From Mars, Women Are From Venus!

These are somewhat old but very funny jokes about the differences between men and women! I can't help but get a chuckle when I read these jokes. The last one says it all! Enjoy!!
-----------------------------------------------------
Here's a prime example of the differences between Men and Women offered by an English professor at Southern Methodist University: English 44A SMU, Creative Writing.

Prof. Miller's in-class assignment for Wednesday: "Today we will experiment with a new form called the tandem story. The process is simple. Each person will pair off with the person sitting to his or her immediate right. One of you will then write the first paragraph of a short story. The partner will read the first paragraph and then add another paragraph to the story. The first person will then add a third paragraph, and so on back and forth. Remember to reread what has been written each time in order keep the story coherent. The story is over when both agree a conclusion has been reached."

The following was actually turned in by two of my English students: Rebecca - last name deleted, and Gary - last name deleted."

STORY:

==========================================

At first, Laurie couldn't decide which kind of tea she wanted. The chamomile, which used to be her favorite for lazy evenings at home, now reminded her too much of Carl, who once said, in happier times, that he liked chamomile. But she felt she must now, at all costs, keep her mind off Carl. His possessiveness was suffocating, and if she thought about him too much her asthma started acting up again. So chamomile was out of the question.

=======================================
Intergalactic war
Meanwhile, Advance Sergeant Carl Harris, leader of the attack Squadron now in orbit over Skylon 4, had more important things to think about than the neuroses of an air-headed asthmatic bimbo named Laurie with whom he had spent one sweaty night over a year ago. "A.S. Harris to Geostation 17," he said into his transgalactic communicator. "Polar orbit established. No sign of resistance so far..." But before he could sign off a bluish particle beam flashed out of nowhere and blasted a hole through his ship's cargo bay. The jolt from the direct hit sent him flying out of his seat and across the cockpit.

=======================================

He bumped his head and died almost immediately, but not before he felt one last pang of regret for psychically brutalizing the one woman who had ever had feelings for him. Soon afterwards, Earth stopped its pointless hostilities towards the peaceful farmers of Skylon 4. "Congress Passes Law Permanently Abolishing War and Space Travel," Laurie read in her newspaper one morning. The news simultaneously excited her and bored her. She stared out the window, dreaming of her youth-when the days had passed unhurriedly and carefree, with no newspapers to read, no television to distract her from her sense of innocent wonder at all the beautiful things around her. "Why must one lose one's innocence to become a woman?" she pondered wistfully.

=======================================

Little did she know, but she had less than 10 seconds to live. Thousands of miles above the city, the Anu'udrian mothership launched the first of its lithium fusion missiles. The dim-witted wimpy peaceniks who pushed the Unilateral Aerospace Disarmament Treaty through Congress had left Earth a defenseless target for the hostile alien empires who were determined to destroy the human race. Within two hours after the passage of the treaty the Anu'udrian ships were on course for Earth, carrying enough firepower to pulverize the entire planet. With no one to stop them, they swiftly initiated their diabolical plan. The lithium fusion missile entered the atmosphere unimpeded. The President, in his top-secret mobile submarine headquarters on the ocean floor off the coast of Guam, felt the inconceivably massive explosion which vaporized Laurie and 85 million other Americans. The President slammed his fist on the conference table. "We can't allow this! I'm going to veto that treaty! Let's blow 'em out of the sky!"

=======================================

This is absurd. I refuse to continue this mockery of literature. My writing partner is a violent, chauvinistic, semi-literate adolescent.

===================================

Yeah? Well, you're a self-centered tedious neurotic whose attempts at writing are the literary equivalent of Valium.

====================================

Asshole.

===================================

Bitch.

=====================================

The End
-----------------------------------------------------

Let's say a guy named Roger is attracted to a woman named Elaine. He asks her out to a movie; she accepts; they have a pretty good time. A few nights later he asks her out to dinner, and again they enjoy themselves. They continue to see each other regularly, and after a while neither one of them is seeing anybody else. And then, one evening when they're driving home, a thought occurs to Elaine, and, without really thinking, she says it aloud: ''Do you realize that, as of tonight, we've been seeing each other for exactly six months?'' And then there is silence in the car. To Elaine, it seems like a very loud silence. She thinks to herself: Geez, I wonder if it bothers him that I said that. Maybe he's been feeling confined by our relationship; maybe he thinks I'm trying to push him into some kind of obligation that he doesn't want, or isn't sure of.

And Roger is thinking: Gosh. Six months.

And Elaine is thinking: But, hey, I'm not so sure I want this kind of relationship, either. Sometimes I wish I had a little more space, so I'd have time to think about whether I really want us to keep going the way we are, moving steadily toward . . . I mean, where are we going? Are we just going to keep seeing each other at this level of intimacy? Are we heading toward marriage? Toward children? Toward a lifetime together? Am I ready
for that level of commitment? Do I really even know this person?

And Roger is thinking: . . . so that means it was . . . let's see . . .February when we started going out, which was right after I had the car at the dealer's, which means . . . lemme check the odometer . . . Whoa! I am way overdue for an oil change here.

And Elaine is thinking: He's upset. I can see it on his face. Maybe I'm reading this completely wrong. Maybe he wants more from our relationship, more intimacy, more commitment; maybe he has sensed -- even before I sensed it -- that I was feeling some reservations. Yes, I bet that's it. That's why he's so reluctant to say anything about his own feelings. He's afraid of being rejected.

And Roger is thinking: And I'm gonna have them look at the transmission again. I don't care what those morons say, it's still not shifting right. And they better not try to blame it on the cold weather this time. What cold weather? It's 87 degrees out, and this thing is shifting like a goddamn garbage truck, and I paid those incompetent thieves $600.

And Elaine is thinking: He's angry. And I don't blame him. I'd be angry, too. God, I feel so guilty, putting him through this, but I can't help the way I feel. I'm just not sure.

And Roger is thinking: They'll probably say it's only a 90- day warranty. That's exactly what they're gonna say, the scumballs.
Knight on a horse
And Elaine is thinking: maybe I'm just too idealistic, waiting for a Knight to come riding up on his white horse, when I'm sitting right next to a perfectly good person, a person I enjoy being with, a person I truly do care about, a person who seems to truly care about me. A person who is in pain because of my self-centered, schoolgirl romantic fantasy.

And Roger is thinking: Warranty? They want a warranty? I'll give them a goddamn warranty. I'll take their warranty and stick it right up their......

''Roger,'' Elaine says aloud.
"What?'' says Roger, startled.
''Please don't torture yourself like this,'' she says, her eyes beginning to brim with tears. ''Maybe I should never have . . Oh God, I feel so......'' (She breaks down, sobbing.)
''What?'' says Roger.
''I'm such a fool,'' Elaine sobs. ''I mean, I know there's no knight. I really know that. It's silly. There's no knight, and there's no horse.''
''There's no horse?'' says Roger.
''You think I'm a fool, don't you?'' Elaine says.
''No!'' says Roger, glad to finally know the correct answer.
''It's just that . . . It's that I . . . I need some time,'' Elaine says.
(There is a 15-second pause while Roger, thinking as fast as he can, tries to come up with a safe response. Finally he comes up with one that he thinks might work.)
''Yes,'' he says.
(Elaine, deeply moved, touches his hand.)
''Oh, Roger, do you really feel that way?'' she says.
''What way?'' says Roger.
"That way about time,'' says Elaine.
''Oh,'' says Roger. ''Yes.''
(Elaine turns to face him and gazes deeply into his eyes, causing him to become very nervous about what she might say next, especially if it involves a horse. At last she speaks.)
''Thank you, Roger,'' she says.
''Thank you,'' says Roger.

Then he takes her home, and she lies on her bed, a conflicted, tortured soul, and weeps until dawn, whereas when Roger gets back to his place, he opens a bag of Doritos, turns on the TV, and immediately becomes deeply involved in a rerun of a tennis match between two Czechoslovakians he never heard of. A tiny voice in the far recesses of his mind tells him that something major was going on back there in the car, but he is pretty sure there is no way he would ever understand what, and so he figures it's better if he doesn't think about it. (This is also Roger's policy regarding world hunger.)

The next day Elaine will call her closest friend, or perhaps two of them, and they will talk about this situation for six straight hours. In painstaking detail, they will analyze everything she said and everything he said, going over it time and time again, exploring every word, expression, and gesture for nuances of meaning, considering every possible ramification. They will continue to discuss this subject, off and on, for weeks, maybe months, never reaching any definite conclusions, but never getting bored with it, either.

Meanwhile, Roger, while playing racquetball one day with a mutual friend of his and Elaine's, will pause just before serving, frown, and say: ''Norm, did Elaine ever own a horse?''
-----------------------------------------------------
A man was walking along the beach and found a bottle. He looked around and didn't see anyone so he opened it. A genie appeared and thanked the man letting him out. The genie said, "For your kindness I will grant you one wish, but only one."
hawaiian beach
The man thought for a minute and said, "I have always wanted to go to Hawaii but have never been able to because I'm afraid of flying and ships make me claustrophobic and ill. So, I wish for a road to be built from here to Hawaii."

The genie thought for a few minutes and said, "No, I can't do that. Just think of all the work involved with the pilings needed to hold up the highway and how deep they would have to be to reach the bottom of the ocean. Think of all the pavement that would be needed. No ... that is just too much to ask."

The man thought for a minute and then told the genie, "There is one other thing I have always wanted. I want to understand women. What makes them laugh? What make them cry? Why are they temperamental? And why are they so difficult to get along with? Basically, what makes them tick?"

The genie considered for a few minutes; then said, "So, do you want two lanes or four ?"
-----------------------------------------------------

Wednesday, February 24, 2010

Vedic Mathematics Lesson 41: Cubic Equations

A cubic equation in one variable is an equation of the sort below:

ax^3 + bx^2 + cx + d = 0

where a ≠ 0. In other words, it is a polymomial of degree 3. In general, cubic equations have 3 roots. Every cubic equation with real coefficients, a, b, c and d, has at least one real root.

You can find all my previous posts about Vedic Mathematics below:

Introduction to Vedic Mathematics
A Spectacular Illustration of Vedic Mathematics
10's Complements
Multiplication Part 1
Multiplication Part 2
Multiplication Part 3
Multiplication Part 4
Multiplication Part 5
Multiplication Special Case 1
Multiplication Special Case 2
Multiplication Special Case 3
Vertically And Crosswise I
Vertically And Crosswise II
Squaring, Cubing, Etc.
Subtraction
Division By The Nikhilam Method I
Division By The Nikhilam Method II
Division By The Nikhilam Method III
Division By The Paravartya Method
Digital Roots
Straight Division I
Straight Division II
Vinculums
Divisibility Rules
Simple Osculation
Multiplex Osculation
Solving Equations 1
Solving Equations 2
Solving Equations 3
Solving Equations 4
Mergers 1
Mergers 2
Mergers 3
Multiple Mergers
Complex Mergers
Simultaneous Equations 1
Simultaneous Equations 2
Quadratic Equations 1
Quadratic Equations 2
Quadratic Equations 3
Quadratic Equations 4

Just as in the case of quadratic equations, a cubic equation also has closed form solutions. Unfortunately, the cubic formula is quite complicated and is not taught to students in the normal course of their mathematics education. You can see why when you see the form of the cubic formula, reproduced below from Wikipedia!

cubic equation solutions

In this lesson, we will try to derive a simpler way to solve cubic equations. The method presented here is modeled after the method used to solve standard quadratic equations without using the quadratic formula. Since we did not deal with quadratic equations presented in standard form in our lessons on quadratic equations, I will start with a brief introduction to the solution of such quadratic equations without the use of the quadratic formula.

As you know, a quadratic equation in standard form can be written as ax^2 + bx + c = 0. One of the solution techniques used for the solution of such equations is to factorize it into two linear factors. Since the product of the two linear factors would equal zero, one can then individually set each of the factors to zero to get the solutions to the quadratic equation. This is a method that is commonly taught to students in school even before their introduction to the quadratic formula, so I am not going to spend too much time on this technique. This technique can, however, be illustrated using the example below:

5x^2 + 6x - 8 = 0 can be rewritten as
5x^2 + 10x - 4x - 8 = 0, which can then be rewritten as
5x(x + 2) - 4(x + 2) = 0, which gives us the factorized form of the quadratic equation as
(5x - 4)(x + 2) = 0

We can then use the factors above to get the roots of the equation as x = 4/5 and x = -2.

In general, the steps in performing the factorization are as follows:

Let the given equation by ax^2 + bx + c = 0

It is written as ax^2 + dx + ex + c = 0 with the following conditions:

d + e = b, and
a/d = e/c

These conditions enable us to rewrite the equation appropriately so that common factors emerge from the final factorization. Notice that the second condition above can be rewritten as:

ac = de

The product ac is the product of the two extreme terms of the rewritten quadratic equation, while de is the product of the middle two terms of that equation. Making them equal to each other is the principle explained in cryptic terms by the sutra "Madhyamadhyena Adhyamantyena". Literally it means "the product of the middle terms is equal to the product of the end terms". It is commonly used to solve direct ratio problems, but this is another application of this sutra.

Let us illustrate this using the following example:

Take the equation x^2 + 2x + 1 = 0. We have to split the middle term into two terms, d and e, such that two conditions have to be satisfied:

d + e = 2, and
1/d = e/1

When we know that the equation has real roots, this is usually possible to do by trial and error (note that the two conditions form a system of 2 simultaneous equations in 2 variables, but since they are not linear equations, their solution by anything other than trial and error can be complicated). We find that d = 1 and e = 1 is the solution we are looking for since 1 + 1 = 2, and also 1/1 = 1/1. Therefore, we can rewrite the given equation as below:

x^2 + x + x + 1 = 0

This can then be factorized in the two steps below:

x(x + 1) + 1(x + 1) = 0, which gives us
(x + 1)(x + 1) = 0

Thus the two solutions of the given quadratic equation are both x = -1.

This method has some limitations, chief among which is that it is difficult, if not impossible, to find irrational roots using this method. It is also mostly useless for finding non-real roots. However, if the given equation has real, rational roots, this method can usually be used to find such roots, even if it takes a bit of trial and error. More importantly, this method is extensible to equations of practically any degree. In this lesson, we will restrict ourselves us to the solution of cubic equations using this method, but there is no inherent limitation in the method that prevents it from being used to solve quartic, pentic or higher-degree equations. Given that all cubic equations have at least one real root, we know that this method can be used to get at least one of the roots (if we are willing to live with some approximations in the case of irrational roots, as we shall see).

In general, given a cubic equation of the form ax^3 + bx^2 + cx + d = 0, the first step is to rewrite it as below:

ax^3 + ex^2 + fx^2 + gx + hx + d = 0

The following conditions have to be satisfied by the new coefficients we have introducted into the equation:

a/e = f/g = h/d
e + f = b
g + h = c

Notice that, as in the case of quadratic equations, the above conditions represents a system of 4 simultaneous equations in 4 variables. The first condition provides us with 2 independent equations, and the each of the other two conditions is an independent equation, giving us a total of 4. And we have 4 unknowns, e, f, g, and h. Unfortunately, the equations are not all linear, complicating the solution of the system. In general, it is better to solve the system by trial and error.

Let us see how the trial and error method works. Consider the cubic equation x^3 + 5x^2 + 2x - 8 = 0. We see that a = 1, b = 5, c = 2 and e = -8. We now have to find e, f, g, and h such that:

e + f = 5
g + h = 2
a/e = f/g = h/-8

For the trial and error method, I find it easiest to try different values of the first ratio. This fixes the value of e. The value of f is fixed as soon as you choose a value of e because of the first sum. Because of the middle ratio, the value of g is then fixed, which then gives us a value of h from the second sum. We just have to check whether the last ratio is equal to the first two ratios. The degree of difference between the value we chose for the first ratio, and the value of the last ratio can guide us towards the right direction in most cases.

In this case, let us try a value for the first ratio of 1. This gives us:

1/1 = 4/4 ≠ -2/8

Let us therefore try a value of -1 for the first ratio. This gives us:

1/-1 = 6/-6 = 8/-8

We can then rewrite the equation as below:

x^3 - x^2 + 6x^2 - 6x + 8x - 8 = 0, which can be rewritten as
x^2(x - 1) + 6x(x - 1) + 8(x - 1) = 0, which gives the factors as below:
(x^2 + 6x + 8)(x - 1) = 0

This gives us x = 1 as one of the roots right away. We are then left with a quadratic equation. We can choose to solve this equation using the quadratic formula or by using the factorization method. Using the factorization method, we get:

x^2 + 6x + 8 can be rewritten as
x^2 + 2x + 4x + 8 = 0, which can be rewritten as
x(x + 2) + 4(x + 2) = 0, which gives us the factors:
(x + 4)(x + 2) = 0

This gives us the other two roots of the equation, x = -2, and x = -4. Thus, the three roots of the given equation are x = 1, x = -4, and x = -2.

Before we go any further, let us consider another important sutra in the context of factorization of polynomials, like we did above. We factorized the polynomial x^3 + 5x^2 + 2x - 8 to be product of the factors (x - 1), (x + 4), and (x + 2). How do we know that this factorization is correct. We can use the principle expressed succinctly by another vedic sutra that reads: "Gunakasamuccaya Samuccayagunaka". Sometimes the sutra is also written as "Gunitasamuccaya Samuccayagunita". Literally, it means "the product of the sum of the coefficients in the factors is equal to the sum of the coefficients in the product."

In this case, the factors we found are (x - 1), (x + 4) and (x + 2). The sum of the coefficients in the first factor is 1 - 1 = 0. The sum of the coefficients of the second factor is 1 + 4 = 5. The sum of the coefficients in the third factor is 1 + 2 = 3. The product of the three sums is 0 x 5 x 3 = 0 (obviously, we could have stopped right after finding the sum of coefficients of the first factor to be zero, but we found the sums from all three factors in this case for this illustration). Now, the sutra says that the sum of the coefficients in the product is the same as the product we calculated above. Indeed, we find that the sum of the coefficients in the original cubic equation is 1 + 5 + 2 - 8 = 0. Obviously, we could have interchanged the coefficients and the sutra would not have alerted us to it. But it is still a useful check when factorizing polynomials.

The same principle is used when we check multiplication results using digital roots as in this earlier lesson. We did not formally identify this sutra by name in that lesson, but the principle there was based on this sutra too!

Now, consider the equation 24x^3 + 98x^2 + 133x + 60 = 0

Let us try a ratio of 1 first. We get:

24/24 = 74/74 ≠ 59/60

A ratio of 2 gives us:

24/12 = 86/43 ≠ 90/60

A ratio of -1 gives us:

24/-24 = 126/-126 ≠ 259/60

A ratio of -2 gives us:

24/-12 = 110/-55 ≠ 188/60

Let us try a ratio of 1/2 next:

24/48 = 50/100 ≠ 33/60

Let us try a ratio of 2/3:

24/36 = 62/93 = 40/60

Thus we have found that the given equation can be rewritten as 24x^3 + 36x^2 + 62x^2 + 93x + 40x + 60 = 0 for factorization. We then get the following from that:

12x^2(2x + 3) + 31x(2x + 3) + 20(2x + 3) = 0, giving us
(12x^2 + 31x + 20)(2x + 3) = 0

This tells us that one of the roots of the equation is x = -3/2. We factorize the quadratic below to get the other two roots:

12x^2 + 31x + 20 = 0 can be rewritten as
12x^2 + 15x + 16x + 20 = 0, giving us
3x(4x + 5) + 4(4x + 5) = 0, giving us
(3x + 4)(4x + 5) = 0

This then tells us that the other too roots of the equation are x = -4/3 and x = -5/4.

Let us check our factorization by using the Gunitasamuccaya Samuccayagunita sutra once again. The three factors we found are (2x + 3), (3x + 4) and (4x + 5). The sum of the coefficients in each term are 2 + 3 = 5, 3 + 4 = 7, and 4 + 5 = 9. The product of these sums is 5 x 7 x 9 = 315. The cubic polynomial we factorized was 24x^3 + 98x^2 + 133x + 60. The sum of the coefficients in the product is 24 + 98 + 133 + 60, which is also equal to 315. Thus, we can be reasonably confident that we performed the factorization correctly!

As you can see, the process of factorizing the cubic can be quite time-consuming, requiring several trials for the right value of e, f, g, and h. Unfortunately, in most cases, it is either this or the application of the cubic formula in all its glory!

There are certain cubic equations that don't have one or more of the 4 terms a normal cubic equation has (all cubic equations have the cubic term, otherwise they are not considered cubic equations). These may be equations of the sort ax^3 + cx + d = 0, or ax^3 + bx^2 + d = 0, or ax^3 + bx^2 + cx = 0, or even ax^3 + d = 0.

The last of these is easy to solve since all we have to do in that case is find the cube root of -d/a to solve the equation. Similarly, if the constant term is missing, one of the roots is x = 0. We can then reduce the equation to a quadratic by removing the common factor from all three terms, and solve it using either the factorization method or the quadratic formula.

Equations of the first two types are called depressed cubic equations. We use the same factorization scheme as before, but because of the missing term, some simplifications can be made. Consider the equation ax^3 + bx^2 + d = 0, for instance. We can rewrite it as below to aid in factorization:

ax^3 + ex^2 + fx^2 + gx + hx + d = 0

where

a/e = f/g = h/d
e + f = b
g + h = 0

Using the last condition, we can rewrite the equation to be factorized as below:

ax^3 + ex^2 + fx^2 + gx - gx + d = 0

where

a/e = f/g = -g/d
e + f = b

Similarly, the other form of the depressed cubic equation, ax^3 + cx + d = 0, can be rewritten for factorization as below:

ax^3 + ex^2 - ex^2 + gx + hx + d = 0

where

a/e = -e/g = h/d
g + h = c

Let us now try to solve a couple of depressed cubic equations using this information. First consider the equation x^3 - 3x^2 + 4 = 0. We see that the ratios and sums are satisfied when we rewrite the equation as below:

x^3 + x^2 - 4x^2 -4x + 4x + 4 = 0

This can then be factorized as below:

x^2(x + 1) - 4x(x + 1) + 4(x + 1), which can be written as
(x^2 - 4x + 4)(x + 1) = 0

This then gives us one root as x = -1. Factorizing the quadratic gives us the other two roots as x = 2 (this is a repeated root).

Once again, the factors in this case are (x + 1), (x - 2) and (x - 2). The product of the sums of the coefficients is 2 x -1 x -1 = 2. The sum of coefficients in the product (x^3 - 3x^2 + 4), is 1 - 3 + 4 = 2, thus the factorization passes the sniff test.

Now consider the depressed cubic equation 4x^3 + 7x + 4 = 0. We see that the ratios and sums are satisfied when we rewrite the equation as below for factorization:

4x^3 + 2x^2 - 2x^2 - x + 8x + 4 = 0, which can be factorized by the two steps below:

2x^2(2x + 1) -x(2x + 1) + 4(2x + 1) = 0
(2x^2 - x + 4)(2x + 1) = 0

This then gives us x = -1/2 as one of the solutions. The other solutions have to be derived by solving the quadratic equation. We see that in this case, the quadratic equation actually does not have any real roots, so our method for factorizing quadratics will not work whatever ratio we try. The equation thus has only one real root and two complex roots (which are outside the scope of this lesson). Notice that, as we mentioned in the beginning of this lesson, this method will produce at least one solution if we are willing to spend enough time trying different ratios because cubic equations have at least one real root.

In this case, our factors were (2x^2 - x + 4), and (2x + 1). The product of sum of coefficients in these two factors is 5 x 3 = 15. The sum of the coefficients in the product (4x^3 + 7x + 4) is also 4 + 7 + 4 = 15, thus satisfying our basic sanity check.

What happens when the equation has only irrational roots? Consider the equation x^3 - 11x^2 - 22x - 3 = 0. Let us try a few ratios as below:

+1.0: 1/1 = -12/-12 ≠ -10/-3 (-3.333)
-1.0: 1/-1 = -10/10 ≠ -32/-3 (-10.667)
+0.5: 1/2 = -13/-26 ≠ 4/-3 (-1.333)
-0.5: 1/-2 = -9/18 ≠ -40/-3 (13.333)
+0.25: 1/4 = -15/-60 ≠ 38/-3 (-12.6667)
+0.75: 1/1.333 = -12.333/-16.444 ≠ -5.556/-3 (1.852)
+0.67: 1/1.5 = -12.5/-18.75 ≠ -3.25/-3 (1.0833)
+0.60: 1/1.6667 = -12.66667/-21.1111 ≠ -0.8889/-3 (0.2963)

Notice that we are getting closer and closer to satisfying the last ratio. We see that the last ratio in the last line has dipped well below the target ratio whereas it is a little higher than the target ratio in the last but one line. So, the target ratio is probably somewhere between 0.67 and 0.60. Let us therefore try 0.63.

+0.63: 1/1.5873 = -12.5873/-19.9798 ≠ -2.0202/-3 (0.6734)

The last ratio is still very slightly higher than the target ratio. So, let us try 0.625.

+0.625: 1/1.6 = -12.6/-20.16 ≠ -1.84/-3 (0.6133)

We see that the ratio has now slipped just below the target ratio. But we could consider this ratio "close enough" and decide to proceed with this (the alternative is to try and fine-tune the ratio further). If we decide to do so, we can rewrite the given equation as below:

x^3 + 1.6x^2 - 12.6x^2 - 20.16x - 1.84x - 3 = 0 which then becomes
x^2(x + 1.6) - 12.6x(x + 1.6) - 1.84(x + 1.6) = 0

Notice how we have approximated 3/1.84 as 1.6 to provide us with a common factor across all three terms. That is because we decided to use an approximate ratio without fine-tuning it further. The equation above then can be factorized as:

(x^2 - 12.6x - 1.84)(x + 1.6) = 0

This gives us the first root as x = -1.6. The other two roots have to be derived from the quadratic equation x^2 - 12.6x - 1.84 = 0. Solving this by the quadratic formula gives us the roots as -0.1444 and 12.7444. Thus, we can say that the given equation has roots of x = -1.6, x = -0.1444 and x = 12.7444. The exact roots, using the cubic formula actually turn out to be x = 12.7447, x = -0.1474 and x = -1.5973. Thus our approximation did not throw us too far off-track.

As you can see, solving equations with irrational roots is not easy. And no system of mathematics is going to make it easy to do so. However, if we are willing to live with some approximations, we may be able to get close to the exact answers by following the factorization method explained here. Use of the factorization method to solve equations requires practice. So, I hope you will take the time to work out some equations using these methods to become more proficient at it. Good luck, and happy computing!

Tuesday, February 23, 2010

12 More Weird Mice You Have Probably Never Seen!

Last week I introduced you to more than a dozen odd-looking, whimsically designed mice in this post. Here are a few more such odd-looking mice with no special functions or properties except that they catch the eye (sometimes favorably, sometimes not!).

Scream mouseYou should probably not try to scare your coworkers with the Scream mouse except on halloween!

Ghost mouseThe same goes for the ghost mouse too! Together they form the yin and yang of mice!!

minty mouseIf you are into food, this altoids mouse might appeal to you . . .

hamburger mouseOn the other hand, if you crave for something more filling, maybe the burger mouse will fit the bill better!

pig mouseYou can try your hands on a porky mouse, and see what it feels like to squish out a pig's eyes every time you need to click!

heart mouseThis would make an ideal Valentine's day gift (if you want your significant other to develop wrist problems quickly)!

grenade mouseMice modeled after common household objects. What, you don't have a grenade at home?!!

furnace mouseWell, hopefully, you at least have a furnace at home!

mus2 point and click mouseThis is the Mus2 optical mouse, shaped like a mouse cursor! Get it?

city and village mouseThis weird-looking contraption is supposed to be an ergonomic mouse. Don't ask me, I didn't design it!

stone mouseFor the nature-lovers among us, there is the stone mouse . . .

bamboo mouse. . .Or the bamboo mouse!

If you have seen other weird-looking shapes or other external features for normal mice which perform normal functions, don't hesitate to sound off by posting comments!

Monday, February 22, 2010

Microsoft Access Tips & Tricks: Crosstab Queries

Crosstab queries are used to create matrices of aggregated data out of simple row data. In some sense, you can consider crosstab queries to be very similar to pivot tables in spreadsheets. In Microsoft Access, a non-standard extension to SQL-92 in the form of the TRANSFORM keyword is used to create crosstab queries.

If you are interested, you can find my earlier posts on finding the median, the mode, the geometric and harmonic means, ranking every row in a query, selecting random rows out of a table, calculating running sums and averages, calculating running differences, creating histograms, calculating probability masses out of given data, calculating cumulative distributions out of given data, finding percentile scores, percentile values, calculating distinct counts, full outer joins and parameter queries.

In general, you are probably already familiar with the use of GROUP BY to create aggregations of data in Access. Let us suppose, for instance, that we have a table, Orders, with the following fields: OrderDate, EmployeeID, and OrderAmount. It is easy to write a query as below to get a total of orders by year:

select year(OrderDate), sum(OrderAmount) from Orders group by year(OrderDate)

Similarly, we can get the total of orders by employee ID:

select EmployeeID(OrderDate), sum(OrderAmount) from Orders group by year(OrderDate)

How do you obtain the order totals by year as well as Employee ID? You could use both employee ID and the year of the order in the group by clause as below, but the resulting results are quite hard to read.

select EmployeeID, year(OrderDate), sum(OrderAmount) from Orders
group by EmployeeID, year(OrderDate)

The above query lists each employee-year combination in a separate row and lists an order total for that combination. It becomes very difficult to compare yearly totals for the same year across employees. By the same token, comparing yearly totals across years for the same employee is difficult too.

Ideally, what we want is a matrix that has employee ID's along the left hand side, years across the top, and the totals of orders corresponding to each employee for each year as the appropriate matrix element. This would make it extremely easy to compare yearly totals across years for the same employee (just scan each row), or compare yearly totals across employees for the same year (just scan each column). This can be hacked together if we know in advance what years we need the matrix to contain. For instance, if we want order totals only for 2008, 2009 and 2010, we can write SQL as below to accomplish this:

select EmployeeID,
(select sum(OrderAmount) from Orders where year(OrderDate) = 2008) as 2008,
(select sum(OrderAmount) from Orders where year(OrderDate) = 2009) as 2009,
(select sum(OrderAmount) from Orders where year(OrderDate) = 2010) as 2010,
from Orders
group by EmployeeID

But what happens if we don't know in advance what years we want the results for? Also, what happens when a new year rolls into the table? We will have to go in and modify the query to include the query (otherwise, that year's results will never be part of the query results). What we want is a dynamic query that does not require us to specify the years for which we need results. That is where a crosstab query comes in handy. However, the syntax of a crosstab query can be quite confusing and intimidating. In this post, we will try to disentangle the syntax so that we can work with it more comfortably.

Creating a crosstab query using the graphical query designer in Access is not very difficult. Access provides you with a crosstab query wizard that can walk you through the steps in creating a crosstab query with the appropriate row headings, column headings and the aggregate value you want to see as elements of the matrix. However, the crosstab query wizard, like all other wizards and graphical design elements of Access, has severe limitations that can only be overcome by working in the SQL view of the query. That is why it is important to understand the syntax of a crosstab query so that we can create one without relying on the wizard to do it for us!

Some of the limitations of the crosstab query wizard, that we can overcome by working in native SQL are as below:

  • The crosstab query wizard can only work with one table or query at a time. If you want data from multiple tables or queries, you first have to create an intermediate query (or table) with all the fields you need before you can use the crosstab query wizard on that intermediate query (or table)
  • Column headings and order can not be specified in the wizard. Only in native SQL can you specify the columns to be included in the result and their order

The basic syntax of a crosstab query in Microsoft Access SQL is as below:

TRANSFORM AggregateFunction(matrixElement)
select rowheadings from table group by rowheadings
pivot columnheadings

Thus, in the example we have been working on a crosstab query like the one below would produce the matrix we are looking for:

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot year(OrderDate)

The select statement in the above SQL statement generates the row headings. You can have multiple row headings in a crosstab query simply by adding them to the select statement of the crosstab query. For instance, suppose you want to see employee names in addition to the ID's. If the employee names are in the Order table, you can modify the query as below to get employee names also in the row headings:

TRANSFORM sum(OrderAmount)
select EmployeeID, EmployeeName from Orders group by EmployeeID, EmployeeName
pivot year(OrderDate)

If the employee names are in a separate table that is linked to the Orders table by employee ID's you can use a join in the select statement to get the employee names as below:

TRANSFORM sum(OrderAmount)
select EmployeeID, EmployeeName from Orders inner join EmployeeDetails
on Orders.EmployeeID = EmployeeDetails.EmployeeID
group by EmployeeID, EmployeeName
pivot year(OrderDate)

The above crosstab query is one which you can not create using the crosstab query wizard directly. You would have to create an intermediate query which performs the join and creates a single result set that contains both employee ID's and employee names. You would then have to use this intermediate query as the recordsource for the crosstab query wizard.

You can also use this feature of crosstab queries to add row totals to the query result. The query below shows how:

TRANSFORM sum(OrderAmount)
select EmployeeID, sum(OrderAmount) as EmployeeTotal from Orders
group by EmployeeID
pivot year(OrderDate)

The sum of all orders of each employee ID (across all years) is now part of the select query. This adds a column titled "EmployeeTotal" in the crosstab query results.

The select query that is part of the crosstab query can also contain WHERE clauses and HAVING clauses. It is just a regular aggregate query as far as Access is concerned. It can also have an ORDER BY clause, giving you control over the order in which rows are presented in the crosstab query results. The query below illustrates this:

TRANSFORM sum(OrderAmount)
select EmployeeID, sum(OrderAmount) as EmployeeTotal from Orders
where EmployeeID < 1000
group by EmployeeID
having sum(OrderAmount) > 1000
pivot year(OrderDate)

Now, what happens if you want both the count of the number of orders as well as the sum of the order amounts as part of a single crosstab query? If you try to write a crosstab query as below, you will get a syntax error:

TRANSFORM sum(OrderAmount), count(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot year(OrderDate)

That is because the TRANSFORM clause can only contain one aggregate. This makes sense since each matrix row and column has space for only one value. That one value is supplied by the one aggregate in the TRANSFORM clause. The only way to get two aggregates is by expanding the matrix to twice its size. You can not do this directly using a single crosstab query. However, let us assume that you have the following two crosstab queries already in your database:

Query for order totals (let us say this is named QryXtabOrderTotals):

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot year(OrderDate)

And query for order counts (let us say this is named QryXtabOrderCounts):

TRANSFORM count(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot year(OrderDate)

You can then join these two queries on the common field of EmployeeID to create a new query which will expand the crosstab to twice the width and include both counts and totals. The syntax of such a query would be identical to a regular join between any two queries. All this query would do is pick up each row of the first crosstab query, join it with the other crosstab query, resulting in the addition of extra columns and produce a new set of results. There is actually no crosstabulation going on in this third query:

select * from QryXtabOrderTotals inner join QryXtabOrderCounts
on QryXtabOrderTotals.EmployeeID = QryXtabOrderCounts.EmployeeID

Sometimes, you may want the crosstab query to have the same number of columns whenever you run it. For instance, if you create a crosstab query that tabulates order amounts by month, you may want to make sure that the query always returns columns for all 12 months of the year.

Unfortunately, by default, if a column contains no data in a crosstab query, Access automatically gets rid of that column in the results rather than displaying an empty column. Thus, if you had no orders in June for whatever reason, your results would contain only 11 columns with the column for June missing entirely. This can not only be confusing and misleading, it may also cause problems if you base a report on the crosstab query and the report expects a fixed number of columns in the results of the query.

You can easily fix this problem by specifying the columns to include in the query in the PIVOT clause using the keyword IN. Take a look at the query below for an example:

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot month(OrderDate) in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

With the query above, even if there were no orders in the month of June, the column 6 (with no order totals in it) would still exist in the results of the query. If you actually want to see zeroes instead of blanks in the matrix elements that contain no data, use the NZ() function as below:

TRANSFORM nz(sum(OrderAmount),0)
select EmployeeID from Orders group by EmployeeID
pivot month(OrderDate) in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

The IN keyword also provides another important functionality to crosstab queries. Suppose you want to crosstabulate order totals by employeeID's and month names (Jan, Feb, etc.). You might think that you could accomplish this by writing the query as below:

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot format(month(OrderDate), "mmm")

The problem, as you will see immediately, is that the ordering of the columns in a crosstab query is in numerical order or alphabetic order, by default. Thus, you will have the columns in the results of the above query ordered with "Apr" first, followed by "Aug", "Dec", "Feb", and so on. This is obviously not going to serve well for any kind of trend analysis! What you want is to specify the order in which the months are to be presented.

The IN keyword comes in handy for that purpose also. When you specify a list of columns to include in the crosstab results, the order of the columns is also the same as how it is specified in the IN clause. Therefore, if you want your monthly totals presented in order from January through December, you would modify the query above as below:

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot format(month(OrderDate), "mmm")
in ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

In the query above, you will see that not only does the crosstab query always present its results in 12 columns (1 for each month) even if some months have no data, but the order in which the months are presented is always as specified in the IN clause of the query.

Crosstab queries can also take parameters, just like other types of queries. But, the parameters always have to be declared explicitly as illustrated in the post on parameter queries. Thus, the following query will generate a syntax error:

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders
where EmployeeID < [Enter Maximum Employee ID:]
group by EmployeeID
pivot format(month(OrderDate), "mmm")
in ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

But the query below will work fine because we declare the parameter explicitly:

Parameters [Enter Maximum Employee ID:] short;
TRANSFORM sum(OrderAmount)
select EmployeeID from Orders
where EmployeeID < [Enter Maximum Employee ID:]
group by EmployeeID
pivot format(month(OrderDate), "mmm")
in ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

Parameters can be used anywhere in the query except inside the IN clause of the query.

I will end this post with one last tip: We already saw how row-totals are easy to include in a crosstab query simply by adding the total to the select query inside the crosstab query. How do you include column totals though? It turns out there is no easy way to do this directly using a single query. The simplest solution is to create a query that generates a single row of totals and then UNION it with the crosstab query to provide the column totals. This is illustrated in the query example below:

TRANSFORM sum(OrderAmount)
select EmployeeID from Orders group by EmployeeID
pivot month(OrderDate) in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
UNION
select "TOTAL",
(select sum(OrderAmount) from Orders where month(OrderDate) = 1 group by month(OrderDate)),
(select sum(OrderAmount) from Orders where month(OrderDate = 2 group by month(OrderDate)),
...
from Orders

Obviously, not the most elegant thing in the world, but hopefully, functional. In Access 2007, Microsoft has created a facility to create column totals directly when looking at the results from a crosstab query, so this approach may not be necessary anymore. But the column totals are not an integral part of the query results, so if you are using the query results directly for further processing, and you need column totals, you might have to write up a UNION query as above to get them.

Hope this post has been helpful in solving any problems you might have had with crosstab queries in Access. If you have any problems or concerns with the queries in this post, please feel free to let me know by posting a comment. If you have other questions on Access that you would like me to address in future posts, please feel free to let me know through your comments too. Good luck!

Visitors Country Map

Free counters!

Content From TheFreeDictionary.com

In the News

Article of the Day

This Day in History

Today's Birthday

Quote of the Day

Word of the Day

Match Up
Match each word in the left column with its synonym on the right. When finished, click Answer to see the results. Good luck!

 

Hangman

Spelling Bee
difficulty level:
score: -
please wait...
 
spell the word:

Search The Web