Jump to content

Fun with maths!


Arugela

Recommended Posts

Doing random math in a video game. Trying to figure out how to figure out a bunch of numbers added in succession with changing values. Ran into two things. Might be useful in some circumstances.

No zero value:

Odd:

1+2+3+4+5+6+7+8+9=45

This value works out to the end number times the middle number. 4 in each direction is 5. 9x5 is 45.

Even:

1+2+3+4+5+6+7+8+9+10 = 55

This also works out and even numbers are 5 and 6. So 10x5.5=55

Zero value:

Even number: (odd sequence)

0+1+2+3+4+5+6+7+8=36

In this version you take the middle value and multiply by the end number and then add it as well. 8x4=32+4=36

Odd number: (even sequence)

0+1+2+3+4+5+6+7+8+9=45!

9*4.5=40.5+4.5=45!

Not sure how to easily add in complex changes in numbers. This c0uld act as the basis for a formula to add to things besides +1.

 

Another defining feature of this is that the numbers are all additions of the same value.

0+10=10, 1+9=10, 8+2=10, 7+3=10, 6+4=10. So it's 10*5+5=55. (5/6 previous. 66.)

0+1+2+3+4+5+6+7+8+9=45 10x4+5 (9/11 previous)

0+1+2+3+4+5+6+7+8=36 10x3+5+1 (4/5 previous)

0+1+2+3+4+5+6+7=28 10x2+5+1+2 (7/9 previous)

0+1+2+3+4+5+6=21 10x1+5+1+2+3 (3/4 previous)

0+1+2+3+4+5=15 10x0+5+1+2+3+4 (4+1=4, 2+3=5) (5/7 previous)(3/2)

0+1+2+3+4=10 10x0+1+2+3+4 (2/3 previous)

0+1+2+3=6 10x0+1+2+3 (3/5 previous)

0+1+2+=3 10x0+1+2 (1/2 previous)

0+1=1 10x0+1 (1/3 previous)

0=0 (0/1, 0/-1, -0/1, -0/-1 previous?)

0-1=1 10x0-1 (-1/3 previous If mirrored downward. If coming from positive I'm not sure of the relationship.)

Some of this has to do with 10 base, but the rest is neutral. In some cases the numbers add back up to 10 like 5+2+3 with more than two numbers or 5 with 2 numbers.

 

Edited by Arugela
Link to comment
Share on other sites

5 hours ago, Arugela said:

0+10=10, 1+9=10, 8+2=10, 7+3=10, 6+4=10. So it's 10*5+5=55.

This is the one I've seen most really.

Another way is to look at the middle number but this is quite a way away. This method would work with non-consequent numbers, by picking one number as the "pivot" then look at the difference of the other numbers (say, if you have to manually add lots of whole numbers that don't wander too far off from each other for some reason). You can then simply add the differences up, then multiply the "pivot" with the number of numbers you're doing, then add / subtract the summed differences.

Link to comment
Share on other sites

I was once looking for a simple way to generate a formula for sums of natural powers. In other words, find sum 1k + 2k + 3k + ... + Nk. I failed on simple, but I got a generic algorithm that works and isn't hard to understand if you know a bit of calculus.

Start with an observation that d/dx (x0 + x1 + x2 + ... ) = 1 + 2x + 3x2 + ... Which has values we're interested in for x = 1 and power in question being 1.

This does, however, break down on second derivative, as d/dx (1 + 2x + 3x2 + ... ) = 2 + 6x + 12x2 + ...

But we can fix it by simply pre-multiplying by x. d/dx (x + 2x2 + 3x3 + ...) = 1 + 4x + 9x2 + ..., which gives us the sums we want for x = 1 and power being 2.

So lets define operator D[f(x)] = x * d/dx[f(x)]. Then D2 (x0 + x1 + x2 + ...) = 1 + 4x + 9x2 + ...,

We can also compute partial geometric sums Σ{0, N} xn = (1 - xN+1)/(1 - x) for x < 1. Derivation in spoiler.

Spoiler

Consider series S0 = 1 + x + x2 + x3 + x4 + ...

x * S0 = x + x2 + x3 + x4 + ... = S0 - 1

S0 = 1 / (1 - x)

We can also start series with a higher power: SN = xN + xN+1 + xN+2 + ... = xN * S0

The sum we're interested in: Σ{0, N} xn = 1 + x + x2 + ... + xN = 1 + x + x2 + ... (to inf) - xN+1 - xN+2 - ... (to inf) = S0 - SN+1 = 1/(1 - x) - xN+1/(1 - x) = (1 - xN+1)/(1 - x)

Putting it all together, we can express the actual sum we care about as a limit.

1k + 2k + 3k + ... + Nk = Lim{x->1-} Dk[(1 - xN+1) / (1 - x)]

And there you have it. General formula for summing up any natural power of integer sequence.

 

What do you mean that's not it? You want to actually expand it? Oh, fine. Lets just do the simple case of k = 1.

D[(1 - xN+1) / (1 - x)] = x * d/dx ( (1 - xN+1) / (1 - x) ) = x * [ (1 - xN+1) - (1 - x) * (N + 1) xN ] / (1 - x)2 = (x - (N + 1) xN+1 + N xN+2) / (1 - x)2

Using L'Hopital rule twice to find the limit.

Lim{x->1-}  ... = Lim{x->1-} ( N (N + 2) xN+1 - (N + 1)2 xN ) / (2 (x + 1)) = Lim{x->1-} ( N (N + 1) (N + 2) xN-2 - N (N + 1)2 xN-1 ) / 2 = (N (N + 1) (N + 2) - N (N + 1)2) / 2 = N (N + 1) / 2.

So 1 + 2 + 3 + 4 + ... + N = Lim{x->1-} D[(1 - xN+1) / (1 - x)] = N (N + 1) / 2   QED.

 

Using this method to derive an expression for k = 2 takes about a page. I've been able to get results for k = 3 and k = 4 in Mathematica. There is probably a systematic way to attack these that gives you some straight forward recursion relationship, but I haven't been able to see it. So for the time being, this is filed away in my brain as "curious, but not useful."

Link to comment
Share on other sites

Playing with maths is fun. I remember the thrill when I found how to add the n first positive integers through playing around. Sure, the formula is well known but back then I didn't know that. I could have picked up a book and read about it but I wouldn't have gotten that thrill. It's not always the end goal but the journey to get there.

Another fun one I found by playing around with maths was an alternative to Herons formula for an area of a triangle without knowing (or caring for) the height. The maths took me something like 2 densely packed A4 pages but the end result I just find oddly beautiful in how it really shows how all sides in a triangle are of equal importance, that no particular side is more or less important. I like the symmetry of

A = 1/4 sq.r [2(a2b2 + a2c2 + b2c2) - (a4 + b4 + c4)]

where a, b and c. are the 3 sides

It's not the tidiest of formulas but again, the symmetry is something I like. If p = a2b2 + a2c2 + b2c2 and q = a4 + b4 + c4 then

A = 1/4 sq.r(2p - q)

Edited by LN400
Link to comment
Share on other sites

2 hours ago, LN400 said:

A = 1/4 sq.r [2(a2b2 + a2c2 + b2c2) - (a4 + b4 + c4)]

Checks out. Simplest way to derive this is still by using height.

Spoiler

a2 - x2 = h2 = b2 - (c - x)2

c2 + a2 - b2 = 2cx

c2x2 = (a4 + b4 + c4 + 2a2c2 - 2a2b2 - 2b2c2) / 4

A2 = c2h2 / 4 = (c2a2 - c2x2) / 4 = (2a2b2 + 2b2c2 + 2a2c2 - a4 - b4 - c4) / 16

And it is fully equivalent to Heron's formula. You can rearrange the terms in a multitude of ways.

My favorite by far is 16A2 = (a + b + c)(a + b - c)(a + c - b)(b + c - a), which is equivalent to the above.

Link to comment
Share on other sites

I sometimes have this habit of looking at whole numbers and adding their digits together to reduce them, until they're reduced to one digit. I wonder if there's a way to turn it into an algorithm. 

 

Example of what I'm taking about; I'll type in a random number. 

 

785655

7+8+5+6+5+5 = 36

3+6 = 9.

 

Is there a name for this? 

 

Link to comment
Share on other sites

22 minutes ago, starcaptain said:

I sometimes have this habit of looking at whole numbers and adding their digits together to reduce them, until they're reduced to one digit. I wonder if there's a way to turn it into an algorithm. 

 

Example of what I'm taking about; I'll type in a random number. 

 

785655

7+8+5+6+5+5 = 36

3+6 = 9.

 

Is there a name for this? 

 

That would be a cross sum. Fun (perhaps) tidbit: To check if an integer is divisible by 3, check if the cross sum is divisible by 3. You can also check the cross sum of the cross sum etc etc if you're not sure at first.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...