48
Incompletely completing the cube (a rough and ready method for solving cubic equations) by Dave Coulson, 2015 [email protected] 0 762 31 10 2 3 x x x ? x

Incompletely completing the cube

Embed Size (px)

Citation preview

Incompletely completing the cube (a rough and ready method for solving cubic equations)

by Dave Coulson, 2015

[email protected]

07623110 23 xxx

?x

Not long ago a student of mine asked me if there was a way to solve cubic equations that was like the method of completing the square; in other words, a method of completing the cube.

(From Wikipedia)

I told him that there was such a method and that it had been known for nearly 500 years. But nobody ever uses it because it is so dizzyingly complicated. It is hard to learn, hard to use and most damning of all, hard to remember.

If you’re an engineer in the middle of an engineering problem, keen to get the job done effortlessly rather than elegantly, it is far easier and far more intuitive to click open a spreadsheet and find the roots of a cubic equation through digital trial and error, numerically hammering the problem to death with systematic guesses. It takes maybe three minutes to solve a problem this way.

07623110 23 xxx

But my student’s question started me thinking about that 500-year-old method and wondering whether it could be simplified in some way, to the point where it was as fast as using a spreadsheet. I think I have found something.

It’s approximate (naturally) and doesn’t always work, but it’s easy to use and just as fast as using a spreadsheet. And best of all, it’s easy to remember.

Cubic equations conventionally look like this: But it doesn’t have to be this way. This is really just a tradition. Cubic equations are just as cubic if they are written like this: ...or even like this:

79231 xxx

79234 23 xxx

079234 23 xxx

x+1 cm

x cm

x+3 cm

I like seeing polynomial functions written in this last form because it is the form truest to reality. I can see the problem in my imagination when it is expressed like this. I can see it as a brick-shaped object whose volume is known but whose dimensions are not. And that helps steer me towards a method for solving it.

79231 xxx

(792 cm3)

79233.13x

92.7x

34

3

31

x

xxx

The true answer is 8.

(792 cm3)

x+1.33 cm

If I had a brick like this in front of me, a real brick, I would squash it down into a perfect cube. The height gets shorter and the sides get fatter. The resultant sidelength is more or less the average of the original three sidelengths.

Therefore it is important to find out what makes this method work. When is it reliable? How accurate does it get at the best of times, and why doesn’t it produce exact answers?

(792 cm3)

x+1.33 cm

I have experimented with this method across a range of numbers and found that it performs surprisingly well in certain circumstances but fails in others.

322323 33 kxkkx xabx xbax

3 kxbxaxx

Here’s the idea stated mathematically:

where bak 31

Both sides expand as follows:

Equating the x2 coefficients verifies my assumption that squashing the brick makes a cube with averaged sidelengths.

bask 13

3 kxbxaxx

322323 33 kxkkx xabx xbax

absk 2

23

! 03 k

bask 13

But then it all goes wrong! Equating the linear and constants terms produces completely different values for ‘k’. Where am I going wrong?

3 kxbxaxx

322323 33 kxkkx xabx xbax

What’s wrong is that I am completely forgetting what completing the cube means. COMPLETING the cube is not the same as SQUASHING the cube.

If I squash a rectangle so that its sides become equal, the new sidelength is NOT the exact average of the original sidelengths, it’s a little bit smaller (red box).

This is best explained by looking at its baby brother, completing the square (in two dimensions).

If we want to use the exact average of the two sidelengths (which we do) then we need to fill in the gap in the corner, hence COMPLETING the square. Perhaps completing the cube is like this too: we need to add something to fill in a gap.

This is what it looks like in three dimensions. If we force the sidelengths to be the exact average of the three original sidelengths, then we have to add three strips along the edges of the cube and put a cube-shaped plug out on the corner.

That means three strips that are proportional to ‘x’, and a cube-shaped plug which has sidelength determined only by the differences in sidelength.

3223 33 kxk kx xBAx bxaxx

So to complete the cube I need to add two correction terms: one which is linear in ‘x’ and one which is a constant.

Now when I open up the brackets and equate terms, I get a consistent result:

B k xAk kx xx abxbax 322323 33

kba 3

Akab 23

Bk 30

Therefore...

322

313

kxabbakxbxaxx

where bak 31

322

313

kxabbakxbxaxx

where bak 31

So the complete transform requires three terms whereas my squashed brick method only uses one of them. That explains why my answers are not perfect. I can make the answers better by adding either or both of those extra terms. The constant term can be added, that’s no problem. But the linear term is a big problem because now ‘x’ is written in two places and I can no longer simply use the cube-root key on my calculator to get the answer.

322

313

kxabbakxbxaxx

where bak 31

I’d really like that middle term to go away. So I’m going to continue to ignore it and see what happens.

So the complete transform requires three terms whereas my squashed brick method only uses one of them. That explains why my answers are not perfect. I can make the answers better by adding either or both of those extra terms. The constant term can be added, that’s no problem. But the linear term is a big problem because now ‘x’ is written in two places and I can no longer simply use the cube-root key on my calculator to get the answer.

Let me try this out with a sample problem:

1000 32 xxx 10003

353

35 - x

3

35 1004.6 x

35.8x ( 1 % error)

322

313

kxabbakxbxaxx

where bak 31

Adding the k3 term in this example had very little impact on the quality of the approximation because it is so small compared to the other numbers involved.

1000 32 xxx 10003

353

35 - x

1 32 xxx

.65 3

35 x

.10 x (should be 0.145)

13

353

35 - x

But see what happens when the volume of the brick is very small compared to the differences in sidelength. Now the plug is bigger than the brick itself.

1 32 xxx

(should be 0.145)

1 3

35 x

0.67 x

(If I did this calculation without using the constant term, the error would be very much greater, to the point of being absurd.)

If I draw a graph of the approximation curve and compare it to the function it represents, I can see what the three parts of the approximation do. The cubic term moves the approximation curve (red) leftwards so that the points of inflection of the two curves coincide.

33

22

313

3 baba xabbaxbxaxx

33

22

313

3 baba xabbaxbxaxx

The constant term at the end moves the curve downwards so that the curves coincide as they pass through the origin.

33

22

313

3 baba xabbaxbxaxx

The middle term, the one that I’ve been ignoring, twists the baseline clockwise around the origin so that the red line falls onto the blue line. This presumably is what Tartaglia’s clever transformation does, and why it is so complicated.

This is what I am trying to avoid.

Therefore this is not a universal tool. It’s like a large screwdriver meant just for large screws, or a sledgehammer meant for hitting big items. This is a tool meant for large, positive numbers.

So if I ignore that twisting step, how wrong will my answers be?

33

22

313

3 baba xabbaxbxaxx

From here it looks as though the incomplete transform works well for positive numbers but poorly for negatives.

The error created by ignoring the linear term will be the linear term itself. And if I divide this by the actual volume I will be able to express this as a relative error. Note that that’s a relative error for the volume, not for the sidelength.

33

22

313

3 baba xabbaxbxaxx

22

31

bxaxx

xabba

3

22

bxax

abba

Relative error =

13

1

2

xfx

ff

22

31

bxaxx

xabba

3

22

bxax

abba

Relative error =

This will be made a lot easier if I standardise things a little. I’d like to set the longest sidelength ‘b’ equal to 1 so that it becomes the yardstick by which everything else is calculated. ‘a’ therefore becomes a fraction somewhere between 0 and 1.

13

432

21

xfx

f

This error is at its smallest when f = ½ . This means bricks for which the middle-sized sidelength is exactly the average of the other two. I need a name for bricks of this kind so I’ll call them good bricks.

14

1

21 xx

When the bricks are good, the relative error becomes

13

432

21

xfx

fRelative error

The worst error for a good brick happens when ‘x’ is very small. It approaches 50% as ‘x’ tends towards zero, which is not a very satisfactory result. But remember that this is the percentage error in the volume, not in the sidelength which should be a third as much, i.e., 17%.

This still looks pretty awful but the error decreases rapidly as the sidelengths grow. By the time ‘x’ is as large as ‘b’, the error has dropped to about 3%. This would be a brick with sidelengths in ratio 2:3:4.

If we want the error to fall below 1%, then we need ‘x’ to be more than twice the size of ‘b’. That requires a brick with sidelengths in ratio 4:5:6, something that is already looking quite cubish.

There are two kinds of bad brick: tiles (for which f = 1) and rods (for which f = 0).

13

1

xfxWhen the bricks are bad, the relative error becomes

Bad bricks are bad because the relative error declines at a slower rate (as the sidelengths grow). This means your answers won’t be as accurate for shapes that are very eccentric.

In the case of tiles, where f = 1, this reduces finally to 13

12

x

The worst error is achieved for ‘x’ near zero, where it starts at 11%. By the time ‘x’ is as large as ‘b’, the error has fallen to 3%, equivalent to the error for good brick. This would mean a tile which is twice as long on each square side as it is thick.

To get error below 1%, you’d need ‘x’ to be somewhat more than twice the size of ‘b’, leading to a tile with sidelengths in ratio 7:10:10.

The worst error occurs in the case of rods.

This starts at infinity but drops quickly to 6% by the time ‘x’ is as large as ‘b’. This is for a rod of sidelengths in ratio 1:1:2. To get error below 1%, ‘x’ would have to be three times as big as the sidelength, which means a rod of sidelengths in ratio 3:3:4.

13

1

xxRelative error =

All this becomes relevant when faced with a cubic function for which the roots are not expressed directly.

volxsxsx 2

2

1

3 where kbas 31 abs 2

To have confidence that the error induced by ‘not completely completing the cube’ is less than 1%, we would want the volume to be very large and positive. In all the cases I outlined, this volume had to be two or three times the size of ‘b’, the biggest difference in sidelength. We can get an idea of how big ‘b’ is by noting that for the worst kind of brick (a rod),

Therefore the volume should be at least three times the size of s1.

bs 1 ( For a good brick, ) bs23

1

The volume should be at least three times the size of s1. To understand why this needs to be so, we should look again at a typical graph. The red line is the approximation for the blue line. The red line will always be horizontal at the point of inflection whereas cubic curves in general can be as humpy as they choose.

Let me call that bendy part in the middle the Nessie region. Clearly this is the place where the approximation is going to be the worst. This means the method will not be any good at finding the roots of a cubic. It shows also why we are only ever getting one solution for the cubic function: That far from the Nessie region, there IS only one solution.

To illustrate the point, here’s what happens when the volume of the brick is too small to be handled reliably by this method.

8 83.5 17.0 6 23 xxxxxx

236 k

822 33x

52.0x

(should be 1)

(a very rod-like brick)

So what should we do when the Nessie part of the curve lies on the positive side of the origin? This would happen if any of the coefficients in the formula are negative. Let me illustrate this with an example.

56 223 xxx

56 12 xxx

Because ‘x’ is no longer the shortest sidelength of the brick, the point of intersection of the two curves is poorly placed.

We can overcome this simply by a change of coordinates: Let u = x-2.

56 12 xxx

56 3 2 uuu

Now all the interior terms are positive and the point of intersection moves accordingly.

56 -3

353

35 u

26.4

26.2

x

u

(correct answer 4.378)

(relative error = 3%)

56 3 2 uuu

Is the effort worth it, given that the answer is still an approximation?

As soon as a method requires a lot of pen-pushing, you know you’re in trouble. I think by this stage I would rather use a spreadsheet. I know that six months from now, when these transforms are no longer fresh in my mind, I will instinctively go back to the familiar, which is to use a spreadsheet.

But I find it interesting that the approximation CAN be made to work in cases like this.

ix 1

ix 1

x

xxxVol 22 23

1 1 ixixx

32k

3323

32 - xVol

What about a brick whose sidelengths are complex numbers?

Some cubic functions based on complex roots have no Nessie region. That’s good because the red line will approximate the blue line reasonably well right through the entire range of the graph.

In that sense, some complex bricks are better than real ones.

But this is not always the case. Some complex bricks have a Nessie region well above or below the horizontal axis. This would be a nuisance if the humps are close to the volume you are looking for.

3343

34 xVol

ixixx

xxxVol

2 2

54 23

The approximation can be improved by shifting the horizontal axis as shown, but the improvement in accuracy is slight and doesn’t justify the amount of work required to obtain it.

2

2

ux

xu

22 23 uuuVol

3323

32 uVol

ixixx

xxxVol

2 2

54 23

So what should we make of this? It’s worth remembering where I started and what I set out to achieve, 44 pages ago. This was NOT supposed to be hard work. This was supposed to be a simple, intuitive, easily memorised procedure for estimating the solution to particular kinds of cubic equation. It doesn’t have to be a one-size-fits-all tool, it just has to work well in situations it is designed for.

So what should we make of this? It’s worth remembering where I started and what I set out to achieve, 44 pages ago. This was NOT supposed to be hard work. This was supposed to be a simple, intuitive, easily memorised procedure for estimating the solution to particular kinds of cubic equation. It doesn’t have to be a one-size-fits-all tool, it just has to work well in situations it is designed for. So I will draw back from this fascination with improving the approximation and draw your attention to the kinds of numbers for which this method is BEST suited: integers. In all the examples I have shown you across 44 pages, the approximations always produced answers that were closest to the correct integer answer. So if you know in advance that you are looking for an integer solution, this method will lead you to it very quickly and quite reliably.

Something else I like about leaving the approximation function in this form:

33 kkxbxaxx where bak

31

See how closely it resembles the approximation function for quadratics.

22kkxaxx where ak

21

The two-dimensional form is exact and the three-dimensional form is approximate, but they are structurally identical.

nn

n kkxaxaxx 1 where

n

inak

1

1

So how about the approximation functions for higher dimensions? I wonder how good these approximations are.

[END]