It turns out this problem involves using the a ratio distribution. I felt that Wikipedia’s page on this subject was very poor, at the very least certainly unintuitive, so I hoped to come up with a more intuitive explanation.

(Note: This post does assume familiarity with probability distributions, using them to get cumulative distributions, averages, etc.)

It occurred to me that problems like this can be shown graphically. Because X and Y are between 0 and 1, you can plot (X,Y) in a unit square. Because they are uniformly distributed there, and the area of the square is exactly equal to one, the probability of getting any collection of points is exactly equal to the area of that collection.

Example, suppose you want to find the probability that x is between 0.6 and 0.7 (and you don’t care what y is). The region described by that is a rectangle with area of 0.1. Therefore, the probability of that result is 0.1.

If you want x to be between 0.6 and 0.7 and also want y to be between 0.1 and 0.3, the area of that region is 0.02, so that is the probability of that result.

However, this general idea can find the probability for more complicated relations between X and Y.

Say we want to know how to describe X+Y — what the probability of getting some S = X + Y is.

If X + Y = S, then Y = S – X. This is the equation for a straight line. Furthermore, If X + Y <= S, then Y <= S – X. The probability of getting some value for X + Y that is less than X will be the area under the line Y = S – X. The below figure shows what this area would look like if S = 1/2.

The region is a triangle whose base and width are both S. Therefore, the cumulative probability that X + Y is less than S is

However, this is only true if S < 1. If 1 < S <2, the area is the whole unit square with a triangle taken out of it. The below figure shows the case for S = 1.5.

In this case, the base and heigh of the triangular notch we are subtracting is (2-S). This means the cumulative probability that X + Y is less than S is

We can find the probability distribution by differentiating the cumulative probability by S.

This probability distribution is graphed below.

What about the product S = X * Y? Consider the case X * Y < 1/2, graphed below.

In general, the region will be a rectangle with base S and height 1, plus the area under the curve Y = S/X, from X = S to X = 1. This means the cumulative probability is

Note that while log(0) is negative infinity, the limit of S log(S), as S tends to zero, is zero; so the cumulative probability that X*Y is less than zero is of course zero.

This means that the probability distribution is

Unlike the previous probability distribution, which had mean, median, and mode all equal to 1, this one is not symmetric. In this case, the mode is zero, the median is the S that solves

or

and the mean is

Now let’s consider the example that kicked off this post. What about Y/X < S? In that case, Y = SX is again a line. The below figure shows the case that Y/X < 1/3

In general, if S <1, the area will be a triangle with base 1 and height S, so the area is

If S>1, things change. The below graph shows the case for S = 3.

Now we need to subtract the area of the white triangle from 1. This white triangle will have height 1 and base 1/S, so the area (of the shaded region) will be

By differentiating the cumulative probabilities, we get the probability density:

Going back to my criticism that Wikipedia’s article explains this poorly, they have this result, but they certainly do not give a simple, intuitive reason why the functional form of the probability density changes when S passes 1. In this derivation, the explanation is very simple: The line Y=SX passes the corner at (1,1) when S passes 1.

Now we are able to answer the question that kicked off this thread: If you take Y/X and round to the nearest integer, what is the probability that that integer will be even?

Even if we didn’t know the form of the probability density, the answer would be

This is because, if the result is between 0 and 1/2, we round it to zero (even); if the result is between one and one half and two and one half, we round it to two (even); and so on. So, we need to find the sum of all such probabilities.

Since we DO know the form of the probability density, we can substitute in

This evaluates to

Or

Everything after that first 1/4 looks very similar to the Leibniz sum for pi. Therefore, we can solve for that sum and rewrite the previous equation as

Finally, it is

Not only is the probability of getting an even number not equal to 50% (though 46.46% is sort of close), it surprisingly even involves the irrational number pi, which is especially surprising since people tend to think of pi as relating to circles. There is well known problem, Buffon’s needle problem, which includes a factor of pi in a probability, but in my opinion that is much less surprising, since Buffon’s needle problem is obviously geometrical.

Next time, we’ll use similar graphical methods to solve a more complicated, and maybe more interesting, probability problem.

]]>

Little did I know that only a few days later, at the end of the very same month, I would find another stray in our apartment parking lot. It was already dark when I came home from work. After I parked my car, a cat came out from under another car, meowing. In the darkness, I thought I saw a collar. I figured since we had good luck with our first cat, we could try to do a favor for this one. I told FO about her. FO went out to look at her.

FO told me that, first of all, I was mistaken. She did not have a collar at all. I had mistaken her tabby stripes for one. Also, she was injured. She had a gash on her back and was bleeding. She was also starving and crying for food. We later learned that she had been declawed on all four paws, so if she had been abandoned, she would not have been able to hunt for her own food. The gash was a burn from trying to warm herself under cars.

We had no idea what to do with a stray in this condition. We enticed her into a cat carrier with a bowl of cat food, and took her to a shelter that my brother had volunteered at a few years before. They agreed to take her in and take care of her.

FO could not get her out of her mind, and visited her in the shelter. The shelter had named her Christabel, but FO was already thinking of her as “Pepper”, due to her coat, which looked like it had sprinkles of salt, black pepper, and cayenne pepper. She was a “red patch tabby”, a tabby with stripes but also flecks of red.

Even at the shelter, she was lovable. I would pet her and she could not get enough. She would turn her head so each spot could get more pets.

Another one of her personality traits was immediately evident. We were in the playroom in the shelter to visit her, but she wanted to explore.

FO didn’t want to lose the chance to have Pepper, so she pre-adopted her. We picked her up the day before Christmas Eve.

Our plan was to keep her in a room by herself for a bit, until Caramel had gotten used to her. Pepper had other plans. She cried until she was allowed out to explore.

She explored around the house until she found a cat castle. She got on it, and her face registered surprise: “I like this!” She settled down and slept there for several hours.

When we had moved into our apartment, the lease had no mention of pets whatsoever. The following spring, however, the apartment sent out notices that pets were not to be allowed. We quickly found a house we could move into for our cats to have a safe home.

Pepper’s favorite hobbies:

- Exploring and finding new places to sleep

Of course, Pepper’s first favorite place to sleep with us was the cat castle. We think she generally liked hard surfaces with a little bit of soft texture, and she also liked putting her recovering back against the parapet.

Then Pepper started sleeping on an office chair, which Caramel had already learned the joys of.

If Pepper could, she also liked to combine sleeping with getting what we called a “hookah high”: lying motionless while having a catnip toy in front of her nose. (As opposed to sniffing cat nip and then playing energetically, which is what other cats seem to do)

We first noticed her having a hookah high upstairs, where she also liked to look out the window at rabbits.

FO had ordered a large cat tower, but when we got the notice that pets were not allowed at the apartment, we didn’t open the box. Pepper found a use for it anyway.

She loved that box. When it was time to eat, she would get off the box to eat, then run back and get on it again as fast as her little legs would carry her.

There were times she also used our other big tower.

When we finally opened the box and assembled the new tower, she got use out of that, too.

What we didn’t know for some time was that Pepper was older than we had thought. We first thought she was a kitten because she was so small. The shelter later estimated her at 5 years old in 2008, when the vet examined her teeth. However, we now think she was at least 8 years old then (making her at least as old as Lady), based on her developing iris atrophy a few years later. This meant that eventually she had a harder time jumping into towers to sleep, but she continued to explore to find new sleeping locations.

Because Pepper looked like a teddy bear…

…we started nicknaming her “Bear”, and we called the places she found to sleep in “Bear Caves”. One of her cutest Bear Cave discoveries was when she started sleeping in the upstairs closet after FO organized it.

But over the years Pepper managed to find lots of places she could transform into something special just by sitting on it.

- Cuddling

When Pepper first entered our lives, she didn’t seem to know what to make of us. We would pick her up, and she would deliberately turn her head away, as though she didn’t want to look us in the eyes.

FO had a plan. When FO was on the bed, she would tempt Pepper by calling to her, “Little Pot! Little Pot!” (which was her nickname for her at the time, from Pepper Pot Pie) This enticed Pepper onto the bed. Because Pepper was not very athletic, she could not jump directly to the bed. We had a “staircase” made of totes to help her up.

After Pepper learned to get on the bed, she learned how much she loved cuddling. At first, she would wait for an “invitation” (us tapping the bed).

But she always had permission, and then would get on us at any time.

When we bought a new digital camera and came home, I sat down, started filming a video, and *the very first thing* Pepper did was walk over to me for a cuddle:

She would climb on FO’s chest, grab on tight with her paws, and then nuzzle.

She loved being on us and being combed.

There was a period of time when Pepper would get on my lap every single night.

I had thought of Pepper as a “person cat”, but when I reviewed our pictures of her, I was surprised to see how often she was with another cat. I don’t always know who initiated their cuddles, though.

- Eating

Maybe it goes without saying that a cat would enjoy eating. Pepper had a special zest for it, though. She especially loved wet food.

Once, at the old townhouse apartment, I was eating a cinnamon roll on the bed. Pepper twitched her little nose, came up to my plate, and snatched a bit off, like it was hers and she needed no other reason.

There was a time when FO would share some of her dinner with Pepper.

Of course, many people consider it a bad idea to feed cats people food, and after an upset tummy caused by eating spicy crock pot turkey, we greatly reduced the food we would share with Pepper.

- Looking and going outside

Many of our cats enjoy looking out the window. Pepper was unusual in not being particularly interested in birds. Caramel, Trinket, Tabby Saddle, and Missy are all huntresses. Pepper seemed to enjoy just looking (though, as mentioned, she did seem fascinated by rabbits). She also liked to wait for us, when we had left, in the window.

I see in that picture that Pepper is looking down even as she looks out the window. It seemed to take her some time living with us before she would regularly look up with confidence.

Our neighbor had two small dogs (about the size of Pepper!). Once, when Pepper was looking out back, she saw the dogs and heard them bark, and she ran off. But she quickly regained her courage and went back, looking at them with fascination.

Because Pepper was our best-behaved cat, we gave her the privilege of going out on the porch. Even with her, I was afraid she might run off, so I first used a cat harness and leash, before deciding it was unnecessary.

Pepper also liked to explore the yard. She found a wild catnip plant growing there and ate it.

In July of 2013, after we had some work done on the house, the back door blew open in the night. I only noticed this when I woke up to use the bathroom, and I had no idea how long it had been opened. We found Lady outside, frightened, by the back door. Cheddar was there, too, but ran off from me when I came out. But when I followed him around the house, who should I see but Pepper on the front porch, sitting by the front steps, looking so calm that you’d never know how worried I had been about her. I can barely imagine that little girl walking around outside, but I’d like to think that our early time spent on the porch taught her that was a safe space to be, and that she went there must have been a sign that she liked going out.

Because Pepper was an elderly cat, she had health problems. Her first chronic problem was over-active thyroid. We treated this with methimazole, first trying liquids and topical creams, both of which she was allergic to, before settling on pills, exactly like what a human would take and even from a human pharmacy, which finally controlled her T4 levels. But then she developed heart problems, and needed baby aspirin to prevent embolisms, and kidney problems, which required a special diet. An x-ray found a calcification in her leg, the embolism weakened her back legs, and she seemed to have arthritis. On top of all this, her having been declawed did not help.

We had a set of pet steps she could use to climb on the sofa when a stack of totes was too much for her. But one day, she spontaneously tumbled off the bed. We decided it wasn’t safe for her on the bed anymore, and took the steps away. We set up areas on the floor for her to sleep. I slept next to her, and sometimes she would cuddle in to me.

She was starting to develop pneumonia at the beginning of this year. She was amazingly tough and pulled through.

Because Pepper could no longer get into the windows on her own, we had to take her on the porch for her to enjoy the outside.

Pepper had some eccentricities, and one she developed was her habit of using a water dish as a pillow.

I got a kickaroo for her this past weekend to use as a pillow instead.

One treatment we were using for Pepper’s kidney issues was subcutaneous fluids. We took her 2-3 times a week (2 due to holidays such as the 4th of July closing the office).

On Tuesday, July 28, I woke up, and again Pepper had inched her way next to me. I did not photograph this; I just cuddled with her. Later that evening, I took her to her fluid treatment. She died on the drive back home.

When Lady died, FO had seen her rainbow bridge in the morning while driving west. FO told me that she wanted to see Pepper’s rainbow bridge.

The day after Pepper died, it was hot and sunny. But around the time I would have gotten back from the vet and wanted to sit on the porch with her, I could hear the rain come down, and see that the sun came out from behind the clouds. I went out onto the porch, and Pepper’s rainbow bridge appeared.

]]>

I’ll start with my favorite song from R-Type II (the underwater theme from stage 2), and the essentially complete Bionic Commando Elite Forces. Yes, a game I reviewed in a former life. By “essentially complete”, I mean I believe I neglected only two tracks on the GBS, and both were more like sound effects than songs. As is, there are already a couple of remaining songs on the soundtrack that are quite short (such as the music for some boss fights, or overhead zones).

I’ve read that Miyamoto often doesn’t like putting some finishing touches on games: Things like a nice title or menu screen. He prefers working on the actual game. Likewise, my interest started flagging after I got these songs ripped and uploaded, so some perks (custom tags or descriptions) are missing.

]]>Track 1

Track 2

Track 3

Track 4

Track 5

Track 6

Track 7

Track 8

Track 9

Track 10

Track 12

Track 14

Track 15

Track 16

Track 17

Track 18

Track 19

I have a simple anti-spam system in place, which asks commentators to fill in a simple arithmetic problem. This probably does cut down on some automated spam, but imperfectly. Finding a better wordpress anti-spam system seems to be difficult and time consuming. Consequently, for now, all comments need to be manually approved by me before they will post.

]]>

We don’t know where Lady originally came from. The story was that she was adopted as a kitten by an elderly woman. When that women died, Lady went to another elderly woman, who also did not have long to live.

When we first met Lady at the shelter, she was nine years old and seemed depressed and disillusioned with abandonment. She spent most of her time motionless, far in the back of her cage, facing away from the entrance. Few people adopt older cats, and the employees may have felt that Lady might never leave the shelter again.

When my partner, FO, visited the shelter around that time, she tried cheering Lady up with catnip. The effect was profound! Lady would leave her cage and bat at the catnip toy, wiggling after it!

When we moved from our rented townhouse to our own home that year, FO adopted Lady. Lady moved in before we did, and had the house to herself for a while.

Once, after we moved our sleeping bags there, we couldn’t find Lady anywhere. Then I noticed a sleeping bag had started to twitch. She was hiding under it.

Once we were storing our socks on some shelves in the basement. A great Lady moment was when she climbed on the pile and used it as a bed.

Lady continued her habit, from the catnip at the shelter, of getting high on things. One of the most distinctly Lady things she did was get high from the smell of new screwdrivers.

Unfortunately, we had several cats even before we adopted Lady, and a few more from the neighborhood moved in. Different cats seem to have different degrees of identifying as a cat or a person. One of our cats, Miss Tabby Saddle, was a stray for over a year, and in that time gave birth to her own kittens. We only took her in after she broke her arm, to save her life. She still seems to identify purely as a cat, and wants to make friends with other cats, but is scared of FO and me. Lady, on the other hand, who had lived with other people for most of her life, seemed to identify more with us, and was not fond of the other cats. There were times when her depression returned, which may have been due to having to share the house with other cats, or may have been due to health issues we were not yet aware of.

I eventually decided I would have to take steps to help with her depression, and break through her shell. She had been living alone in a bedroom upstairs. I did not think that was good for her, so one night I grabbed her. She screamed and protested. I carried her into the master bedroom, sat down, set her down by me, and did some reading with her nearby. She, with a genius level of empathy, with no words exchanged, immediately knew what I was doing: That I brought her with me because I loved her and wanted to be with her.

After that one night, Lady knew that I loved her, and on her own would seek me out. I could be sitting anywhere in the house — it no longer needed to be upstairs — and she would jump up on my lap and cuddle with me. When I went to sleep, she would cuddle into my chest. This went on for months. These were some of our happiest moments together. Although Lady had a grumpy side, it only seemed to make her sweeter when she was loving. I know I have some rough edges myself, and this commonality between us only strengthened our bond.

One night, I noticed that Lady had a line of blood horizontally across one of her major fangs. It seemed to be an emergency, so we took her to a 24-hour veterinarian. They said that several of her teeth would need to be pulled. Around this time, her hair was becoming dense with hard mats and hair knots. We asked if she could be shaved while she was under. We had not realized until then, because she was a long hair and that had disguised it, that she had lost a frightening amount of weight.

We had another older cat, Pepper, who was losing weight. A veterinarian discovered that she had a hyperactive thyroid. She had other issues as well, such as Inflammatory Bowel Disease (IBD), a harsher version of the more common Irritable Bowel Syndrome (IBS). This meant that she harshly rejected the liquid Methimazole treatment intended to control her T4 levels. We switched to an ear paste, which she also harshly rejected; she lost hair on her ears and her face swelled. Moreover, it was doubtful she was even absorbing the methimazole. However, when we switched to simple pills (as in the same methimazole pills a human would take), she began to recover. She also had some subcutaneous B12 injections. On this treatment, she recovered from her low weight of less than 5.5 pounds to above 7 pounds (which is the proper weight for her frame).

We tried having Lady tested for these same issues, in the hope that a similar recovery was possible. There was, however, no indication that her thyroid was overactive. Instead, there were signs that her kidneys were failing. We switched her to renal diet food, but unfortunately she was not fond of the flavor, and would poach Pepper’s leftover wetfood whenever possible.

Once, after this, when we had some work done on the house, the contractors must have left the back door unlocked, and it blew open during a storm with high winds. Of our cats, Cheddar, Pepper, and Lady had gone out the door and outside. I only noticed this when I woke up at 5 am to use the bathroom. Fortunately, we were able to recover all of them. Lady and Cheddar were in the backyard, near the door. In the past, whenever Lady had gone outside, she had gotten overwhelmed and froze up, and this helped us that night, as she had no urge to run. She was frightened, though, and had a fit when FO picked her up and carried her back in the house.

She survived for over a year after her initial kidney diagnosis, but then her issues became chronic and her weight loss continued. I pleaded with the vets for some course of action, and when they assured me that they were doing everything, medically, that they could (recently, after such pleading, we starting giving her subcutaneous fluids), I began to think about what could be done to make her final moments as happy as possible. FO and I at least had to consider euthanasia, but we decided that if she was not in bad pain, and if it was at all possible for her to die in her sleep in her home, rather than at the vet, which she doesn’t like, we should give her that option. The vet told us that the typical discomfort associated with kidney disease is not pain, per se, but we did get some pain killers.

Some nights the previous week I had slept with her, and she cuddled into me as she had been for the past several years.

She began to lose control of her bladder, as well as her coordination. To make things as easy for her as I could, I put a litter box, water and food, and her own cat bed on the bed. The downside was, with this much stuff on the bed, I found it difficult to sleep with her as much.

Sunday morning, I woke up early, before FO, and managed to fit myself onto the bed with Lady, and cuddled with her more. Later that night, I began to wonder if it would be better for Lady to be on her own, or with the family. At the time, she was in her final sunny spot. I let her stay there.

After the sun set, I decided to take her downstairs to be with the family. We had a pen set up for her. Since one of her favorite things was catnip, we bought a brand new cosmic catnip banana and put it with her. And so I could be as close to her as possible, I slept on the floor next to her in a sleeping bag.

When we woke in the morning, she had passed on. My hope is that, by adopting her from the shelter, we were able to give her more freedom and more of a family than she would have otherwise had. My other hope is that at the end she knew she was with people who loved her. In her time with us, she had given me affection and unconditional love, and was a source of endless joy.

(FO became interesting in adopting Lady in this original thread.

This was the post in which FO discovered Lady’s love for catnip.

]]>

However, a basketball player that would do that would be hoping to GAIN something from the experience. In that case, obviously, to improve his free throw.

I think that’s the real distinction between something that is superficially repetitive, and something that is tedious. An experience is tedious if it has no challenge and nothing to teach, yet it drags on repetitiously.

So, once again, the standard of CHALLENGE is the important one. Whether or not something is tedious has little to do with whether you do one thing in a game, or two, or many. (Some misguided individuals may claim, for example, that Super Mario Bros. is repetitive, because “all you do is run and jump”)

When you play Punch-Out, while you have only a few moves to use, you are challenged to use those moves in different combinations, with different timings, with better reflexes, with different strategies. It is not tedious.

I have heard some people complain about R-Type, due to its checkpoint system, because having to replay part of the same level is “repetitive”. But the reason the game makes you do this is because it is trying to get you to learn the level. It is entirely analogous to practicing at any skill (like free throws) to improve. Once you have the skills needed to beat the level, you can beat it, and quickly, too. It is not tedious.

On the other hand, what is Wind Waker trying to teach by having you sail for minutes at a time, while nothing else happens? It is not a challenge. It isn’t anything. After you’ve done it a few times and have gotten whatever point there was to get from the experience, you have to do it again and again. It always takes too long. It is tedious.

You can do other things in Wind Waker, from sorting the mail, to fighting enemies, to carrying around pigs. But whenever you are sailing, sailing will be tedious.

In Final Fight 2, you can beat any enemy, or even any group of enemies, by jumping kicking back and forth. After you know this, there is no challenge in having to execute this simple strategy over and over. You do not need to use any variations in executing this strategy. You theoretically could use other moves, such as punches or throws, but no challenges are based around this. And even after you have the ability to beat the game, the game still takes forever. It is tedious.

]]>

Perhaps in a video game my desire is to progress forward through a linear sequence of challenges. In the 80’s,

I might have died at the end of a level containing multiple challenges, requiring me to return to the beginning of the level and repeat all of the challenges up to the one on which I died. This is frustrating and monotonous. If I die enough times, I lose all my lives and must start the entire game over. This will drive away most users.In the 90’s, I might have died at the end of the level, returning me to a mid-level checkpoint, requiring me to retry only the last couple of challenges in the sequence. I can die as many times as I want and simply return to the checkpoint in time. However, if I have to repeat this enough times,

I still get frustrated with having to redo challenges I’ve proven I can pass, and many users will still be driven away.In the 00’s, I might have died at the end of a level and been returned in space, not time, to a respawn point, allowing me to keep all of my progress and collected items and requiring me to retry only the challenge that killed me. Many fewer users will now be driven away. If the challenge itself is too difficult, users unable to surmount it will check out, but this is due to the difficulty of the challenge itself, not to the difficulty of retrying the challenge, as in prior revisions.

What is the point of making players play through a sequence of challenges? And have you proven that you can pass certain challenges?

Goldeneye is an excellent example. Think of how many challenges you have to pass to beat Aztec. The opening, when enemies have you outnumbered and you barely have cover, and they attack with grenades. The long distance sniping. Jaws. The race against time at the end as unlimited enemies pour into the base.

And when you think of that stage, you realize his comment that “after you pass something, you’ve proven you can pass it” is wrong. The point isn’t to just be able to barely squeak past that opening, quick save. Just barely squeak past the sniping, quick save. Just barely squeak past Jaws, quick save.

The point is to be able to be SO GOOD and SO CONSISTENT at those challenges that you can pass them, and still be able to handle more. And once you are consistently good at those parts, it is less frustrating to have to do them again — because now you’re good at them! Even in a long, multi-challenge stage, you will get through the challenges you are good at quickly, and only get caught on the challenges you still have trouble with.

Otherwise, if you’re still having trouble there, then you have NOT proven you can really get past those parts.

This is really the only way to train players to be that good at challenges.

Vagrant Story is also a great example for a game that does not pull punches in challenging sequences. And in an RPG — a genre some people still claim cannot have challenging games!

Like the Snowfly Forest, where, maybe after wandering around in circles, lost for an hour, you might finally stumble upon the Dragon boss — only for him to hit you with his breath attack and kill you instantly (the wussy way to have done this would have to have the maze and the boss be two separate challenges, with a save point between them).

I had been recently replaying the game when I was reminded of a similar point. You have to get through a maze in a limited amount of time — and near the end you discover it’s not just a maze. You also have to beat a boss in the time limit! And you succeed, you beat it, you’re happy — but the timer’s still counting down! You still have farther to go! And even after you’re out of the maze, you’re not home free. You can’t save yet. If you die, you’ll still have to redo the maze, and the boss. But the save point is not a gimmie. There are flying enemies before the save, in a room with a sheer cliff face, so they might be able to take potshots at you while you have trouble retaliating.

But what people like that author miss is, that those challenges are difficult or stressful to get through is what makes them rewarding once you get through them. Take away the challenge, take away the satisfaction.

Why do they miss that? Maybe these people never beat games that were very good, so they don’t know what they’re missing.

]]>

I have a fondness for calculators, and particularly for the TI89 (/ Titanium) and HP50g (/ HP49g, HP49g+), which are capable of doing symbolic math such as algebra and even calculus.

After I got them, I tried putting them through their paces and seeing what they were and were not capable of. Many people who take high school algebra learn to solve second-degree equations (the quadratic), and it turns out these calculators have the solution to these equations built-in. It is also possible to solve third-degree (cubic) and fourth-degree (quartic) equations symbolically; the solutions to these equations have been known for hundreds of years. (It has been proven that fifth-degree (quintic) equations do not have a general symbolic algebraic solution.) Many people don’t learn them, however, because the final solutions are complicated, tedious to derive or write down, and difficult to remember. A computer algebra system will not complain about that, but solutions to those equations are not built in to those calculators.

In my opinion, the TI89 is not as well suited to dealing with those solutions, due to its tendency to try to simplify every expression. This creates problems when the expression is as complicated as the solution to the quartic. The HP50g is more passive, and (usually) only simplifies expressions when explicitly told to.

There were a few challenges. One is that the HP50g *does* evaluate squareroots. For example, if have

on the stack and press the squareroot key, you will not simply get the squareroot of that, but rather the calculator will re-arraign the terms.

A solution to this problem is that the calculator does not evaluate squareroots after a substitution.

The other trick was to use stack commands (eg., DUP, ROT) to prevent the calculator from evaluating pending expressions. This may cause the programs to be unreadable, but I consider that a necessary sacrifice. RPL is not good for commenting code, anyway, and you shouldn’t really need to read the code; it can be downloaded from this page and then directly uploaded into a calculator.

Here are the raw (HP format) programs you will need. They should all be given the same name they have here (minus the .hp extensions) (because the cubic program calls the quadratic, and the quartic calls the cubic), and uploaded to the same directory.

In all cases, they assume the coefficient of the highest x power is entered first on the stack, and so on until the constant term is in level 1 of the stack.

These are the same programs in text format, so the source code is readable. Some emulators require files to be in .hp format to be loaded, but the actual calculator should be able to load them in either format.

QUADR.txt

CUBIC.txt

QUARTIC.txt

The following files are intended to hint at the solution methods for the cubic and quartic. They may be cryptic (and only understandable if you’ve seen the solutions before) but were the best concise solution I could come up with for this calculator.

Briefly, for the cubic, the substitution Y = X – B/(3A) is made to eliminate the second-order term. Then the substitution Y = Z – M/Z is made. M is solved to make the resulting equation a quadratic equation in Z^3. (It turns out it is possible to eliminate both the Z^4 and Z^2 terms with the same value for M) This is solved using the normal quadratic equation solution.

For the quartic, similarly, Y = X – B/(4A) eliminates the third-order term. The next goal is to factor the resulting quartic into the product of two quadratics. That the quartic has no Y^3 term puts a simple condition on J and M. Now here’s a particularly clever, tricky step. The resulting expressions for P and Q involve K-N and K+N. They are squared, then combined to eliminate the K^2 and N^2 terms, leaving only the KN term. But KN relates to R. This eliminates all the terms except M, which now appears in a cubic equation (in M^2). This is solved using the previous cubic solution. Then N is found with back substitution, giving one of the quadratics. This is solved using the normal quadratic method.

What happens if you actually try to solve the general quartic on a physical HP50g? In about 3 minutes, you get this:

%%HP: T(3)A(D)F(.);

‘(-\v/(XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2)-(3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3/(3*XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2))-2*((8*A*C-3*B^2)/(8*A^2))/3)-\v/(\v/(XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2)-(3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3/(3*XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2))-2*((8*A*C-3*B^2)/(8*A^2))/3)^2-4*(((8*A*C-3*B^2)/(8*A^2)+(XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2)-(3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3/(3*XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2))-2*((8*A*C-3*B^2)/(8*A^2))/3)-(8*A^2*D-4*A*B*C+B^3)/(8*A^3)/\v/(XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2)-(3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3/(3*XROOT(3,(-((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)-\v/(((-(27*((8*A^2*D-4*A*B*C+B^3)/(8*A^3))^2)-9*(2*((8*A*C-3*B^2)/(8*A^2)))*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))+2*(2*((8*A*C-3*B^2)/(8*A^2)))^3)/27)^2+4*(((3*(((8*A*C-3*B^2)/(8*A^2))^2-4*((256*A^3*E-64*A^2*B*D+16*A*B^2*C-3*B^4)/(256*A^4)))-(2*((8*A*C-3*B^2)/(8*A^2)))^2)/3)^3/27)))/2))-2*((8*A*C-3*B^2)/(8*A^2))/3))/2)))/2-B/(4*A)’

I eventually decided I wanted a better solution.

This solution is basically just plugging into an already simplified solution. It “solves” the general case in about 10 seconds, and the result can be displayed in pretty print.

%%HP: T(3)A(R)F(.); \<< 0 0 0 0 \-> A B C D E ALPHA BETA GAMM DELTA \<< C 2 ^ 3 B D * * – 12 A E * * + ‘ALPHA’ STO 2 C 3 ^ * 9 B C D * * * – 27 A D 2 ^ * * + 27 B 2 ^ E * * + 72 A C E * * * – ‘BETA’ STO BETA ‘SQUAREROOT’ \v/ ‘SQUAREROOT’ -4 ALPHA 3 ^ * BETA 2 ^ + = SUBST + ‘GAMM’ STO ‘SQUAREROOT’ \v/ ‘SQUAREROOT’ B 2 ^ 4 A 2 ^ * / 2 C * 3 A * / – ALPHA 3 A GAMM 2 / 3 INV ^ * * / 1 3 A * / GAMM 2 / 3 INV ^ * + + = SUBST ‘DELTA’ STO B NEG 4 A * / 2 INV DELTA * – 2 INV NEG ‘SQUAREROOT’ \v/ ‘SQUAREROOT’ B 2 ^ 2 A 2 ^ * / 4 C * 3 A * / – ALPHA 3 A * GAMM 2 / 3 INV ^ * / – 3 A * INV GAMM 2 / 3 INV ^ * – B 3 ^ A 3 ^ / 4 B C * * A 2 ^ / – 8 D * A / + 4 DELTA * / + = SUBST * + \>> \>>

This is the file for downloading:

The solution is:

%%HP: T(3)A(R)F(.); ‘((-(B/(4*A)))-((1/2)*(\v/((((B^2)/(4*(A^2)))-((2*C)/(3*A)))+(((((C^2)-(3*(B*D)))+(12*(A*E)))/(3*(A*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))+((1/(3*A))*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2)))))))-((1/2)*(\v/((((((B^2)/(2*(A^2)))-((4*C)/(3*A)))-((((C^2)-(3*(B*D)))+(12*(A*E)))/((3*A)*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))-((1/(3*A))*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2)))+(((((B^3)/(A^3))-((4*(B*C))/(A^2)))+((8*D)/A))/(4*(\v/((((B^2)/(4*(A^2)))-((2*C)/(3*A)))+(((((C^2)-(3*(B*D)))+(12*(A*E)))/(3*(A*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))+((1/(3*A))*XROOT(3,((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))+(\v/(((-4)*((((C^2)-(3*(B*D)))+(12*(A*E)))^3))+((((((2*(C^3))-(9*(B*(C*D))))+(27*(A*(D^2))))+(27*((B^2)*E)))-(72*(A*(C*E))))^2))))/2))))))))))’

]]>