Swap the numbers

Hi,
I am reading a book from Matt Parker now. It is called “Things to make and do in the fourth dimension” and the ~200 pages that I read are quiet amazing. The author is also YouTuber and it seems that he mostly does “Standupmaths” which is cool channel. I got inspired a bit and created this game that I started to call “Swap the numbers”.


I was thinking about battery on my phone and how it is going down and that it would be interesting, if the first and second number swapped with the first after subtraction of 1,2 or 3 or more percent at a time. I wrote down bunch sequences, beginning with 100 and going down by one digit numbers.

It is not finished since I want to find a way to predict how these sequences form and I have not figured it out yet. I will give an example and then show why this game is so peculiar.

Let’s say that we subtract the number four, that is the one that I started with:

100 (subtract four) 96 (swap both digits) 69 (subtract four) 65 (and so on…) 56 52 25 21 12 8 80 76 67 63 36 32 23 19 91 87 78 74 47 43 34 30 3 -1 10 6 60 56 65 61 16 12 21 17 71 67 76 72 27 23 32 28 82 78 87 83 38 34 43 39 93 89 98 94 49 45 54 50 5 1 10 6 60 56

If you quickly go through these numbers you will find out that they repeat. When the “10” appears for the second time it starts to repeat. (I also forgot to say that if there is negative number it will act as positive on the “swap” step.) For some reason, many of these “constants” that I start with, end in lapses of “tens” meaning that after “-1” there is “10” and then that is the cycle until new “10” appears. First few numbers have the length of the cycle or lapse “36” or “12” and so far, there seems to be only “1 and 10” as constants that will pull it down to zero. (Also 100 but that is trivial and I have not checked some that could be obvious.)

I have made a program in Delphi 7 to write for me all the numbers for any given constant, that is useful but I will still have to consider the mechanism itself to start to understand it.

Dragallur

Advertisements

Numeral systems

Hi,
today I will write a post about numeral systems and how they generally work. I already wrote about binary and decimal system, but in the last week I did some research on generally numeral systems.


So, just to recap. We normally use decimal system, this means that we use ten symbols to represent numbers, from 0 to 9. First place of number is the number itself, second position represents the number times 10 because we are in decimal system and 3rd represents number times 100 and so on. The general formula to transfer numbers to decimal system goes like this:

anbn + an − 1bn − 1 + an − 2bn − 2 + … + a0b0

a stands for the number that we see written, b stands for the system it is written in, n is the digit where a is –> 0 is the first place.

For example 1334 in the numeral system “7” would be:

4*1+3*7+3*49+1*343=515 in decimal system.

Note how you can represent easily any number in any system because of how the exponents rise in every single digit by one. If the numbers before the next digit are all full, like x9999 in decimal system or x4444 in base 5 system you always need to add only one to reach the next digit, this way there are no numbers left out.


What I really like is that if you had a machine that could change from any numeral system to other you could multiply numbers extremely easily. In decimal system if you multiply by 10 it is very easy because you just add one zero, why? Because all the numbers are “multiplied” by 10 with some exponent already and you just add one which moves all of the numbers to left. In binary system if you multiply by two you just move all the numbers by one digit:

101010111*10=1010101110      (10 is 2 in decimal) Or in 6 base system:
420351234*10=4203512340   (10 is 6 in decimal)

You are basically multiplying by “10” though you need to remember that the number is still in that system.


What about rational numbers? The stuff behind point?

I was really wondering about this and Wikipedia helped out! The exponents are simply negative as in the example below (binary number 10.11 to decimal system):

1×21 + 0×20 + 1×2−1 + 1×2−2 = 2.75

First place –> exponent 0
Second place –> exponent 1
First place behind point –> exponent -1Second place behind point –> exponent -2

Thats it for today.

Dragallur

Derivatives made easy 3a) Maximum and minimum explained

Hi,
in school we learn how to derive right now. The teacher does not do very good job. The class does not know about limits and they only learned power rule and no other rule for derivation though at the same time they learn about maxima and minima.[0]


When you derive function you can find lot of useful informations about it. Today I will talk about minima and maxima. Those are points where the function turns around creates “hill” or “valley” – maxima or minima.

https://www.mathsisfun.com/calculus/images/function-min-max.gif

Some fictional function.

In the function above (f-blue line) you can see couple of points marked. Two orange points are maxima, blue is minima and green is special to which I will get in another post.

 

As I have already said quite few times, when you derive function you will find out what is the slope (how much up or down) at one point[3]. If it does not go up or down it is zero, those are the maxima and minima you are looking for. Right before maximum you have positive slope, the function goes up towards maximum. Right after maximum you have negative slope. What is between if the function is smooth? Zero. When we derive function, lets say function like this:

f(x)=2x²    We get (according to power rule, if you do not know it ignore it right now):

f'(x)=4x    The apostrophe means that it has been derived.

Now when does this derivation equals zero? In other words? When is the slope zero?

Only when x=0 because f'(0)=4*0 = 0 [2]

The original function has minimum or maximum on the point when x=0 [1]. Tricky is that you do not know if it is minimum or maximum which needs some more work and I will get to it in another post.

Dragallur

[0]I will also talk about power rule, multiplication rule and so on in the future.

[1]To get the coordinates of the maximum or minimum you just plug the solution of the derivative to original function and you will get the y coordinate.

[2]If you work with higher order polynomials like x³ you might easily get more solutions which means more minimas and maximas.

[3]If you plot the derivation you will get the slope anywhere.

PS: sometimes I see minima or minimum and maxima or maximum so I use both as I want.

Binary system explained (part 2)

Hi,
in the last post I wrote about converting from binary to decimal number. Today I will continue, if you want to read the basics about binary just check out the post. This is also linked to my post about counting to 1,023 on your fingers.


So lets say that we have number 137 and we want to convert it into binary.

You have seen in the previous post that there is some highest digit that has the value of 1 instead of 0 which means that it stores the information[1]. We need to find out this value.

Its easy, its the highest 2ª number smaller or equal to our original value (137).

Such a number is 128 which is 2^7 so it is going to be the 8th number since we use 2º too (and 2º is on the 1st place).
Now we subtract it having 137-128=9 (1xxxxxxx)

Now we repeat with 9. The number that is smaller or equal is 2³=8
9-8=1 and the next 1 that stores information is on the fourth position. (10001xxx)

1 is easy because 2º also equals to 1 and it is on the first place. So 137 looks like this in binary: 10001001.

Lets try 759:

759-512=247 (10th number is the first 1) =1xxxxxxxxx
247-128=119 (8th number is 1, stores the information) =101xxxxxxx119-64=55 (7th number is 1) =1011xxxxxx
55-32=23 (6th number is 1) =10111xxxxx
23-16=7 (5th number is 1) =101111xxxx
7-4=3 (3rd number is 1) =10111101xx
3-2 … 1-1 === 1011110111 (quite lucky with so many ones ;))

Hope this all makes sense, if it does not just write in the comments below.


Btw. thought you have infinitely many systems that you can use, binary is the simplest of them all. You can not store information in less symbols because with one symbol you would not be able to distinquish where one information ends and another begins. You need to use “space” or some number or something.

Dragallur

Binary system explained (part 1)

Hi,
in the last post I showed cool trick, how to use your fingers to calculate to 1,023. It was based on binary system but I did not explain it much there. Here I will go through the conversion from binary to decimal system, that we normally use, and back.


So all of these digits systems work with some number of symbols, 10 in decimal system for example. These digits means some number and when you run out of them you will just add another digit, for decimal system you have of course 0,1,2,3,4,5,6,7,8,9 and after 9 you have to start repeating previous symbols. Now if you think about it you could actually use this various ways, for example we write 10 but it could also be 00.

Binary system has 2 symbols only. 0 and 1. This means that you will have to use much more digits if you want to symbolise big number. Basically if you add one to number you display one higher symbol and you never skip any of them so there is given amount of numbers you can store in x number of digits. Because there are 10 symbols in decimal system you can display 100 different numbers (different combinations of these symbols) in two digits. From 0,1,2,3… to 97,98,99. This is 10² where the exponent is number of digits you have. For binary system the base will be two because you can store only two symbols in one digit. In two digits you can store 2² numbers.

This is good to know if we want to transfer from one system to the other, lets say that we have number in binary:

10011010

We want to change this number into decimal so that we understand it.
Every digit here stands for one of those exponents first digit (from the right) stands for 2º which is one and it either stores the number one or it does not. Since it is 0 and 0 is usually reffered to as empty, the first digit, again from the right, does not store any information[1].

2nd is for 2¹ and there is 1 which means that the information is there and we know that our final number (n) equals to the rest of the numbers plus 2.

We continue and there is no number on the next place but on the 3rd 2³ we have one which means that we remember this which equals 8. The next is 16 and the last one is even higher: 128. We now add all of them together to get 154 if I count right.

It is good to notice that with this system you can create any number you like because always this applies:

2ª=2^(a-1)+2^(a-2)+2^(a-3)..2^(1)+2^(0)+1

So
8=4+2+1+1

Because the post is quite long right now I will continue in the next post. I do not know when this will be because I am going on a trip this weekend and some days after but after I return there will definitely be new stuff 😉

Dragallur

[1]Same as zero in our system! If you have number: 00456 its just 456 of course that it is something different than 45600 where it moves the place where the numbers are but still it does not count to the final number!

How to! 7) Count to 1,023 on your fingers

Hi,
as promised, weekend post is here! Ok, so I learned this cool thing when I was on seminar in Hamburg. First I thought that someone is pointing middle finger at me for fun (you will see the reason soon) but it was actually counting method. Though you have only 10 fingers you can use them to produce all numbers from zero to 1,023 which is cool.


If you pay close attention and you know something about computers you know that the number 1,023 is very special. It is 1,024 but one smaller (1,024 is actually the special number).

The thing is that 2^10 is 1,024. And in computers you work in binary system with only 0 or 1  ….    on or off and you get the number of combinations that you can arrange binary system if you put 2 to the power of digits you have. On fingers you can not arrange 1,024, you will see why[1]:

Method

Turn you palms towards you. Since in Europe we write from left we will start with left thumb (palms still towards you). Now make fists.. that is number 0

Rise your thumb, that is 1. (1000000000)
Put only your index finger up, that is 2. (010000000)Put your thumb and index finger up, that is 3. (1100000000)  –> the number of digits shows the number of fingers you have.

So basically if you have number lets say 17. You want to transef it into binary. You will do this by subtracting the highest 2^x power which is equal or less to the number itself.

The 2^x numbers go like this: 1,2,4,8,16,32,64,128,256,512,1024…

In the case of 17 you will subtract 16 which is 5th number in the row. 5th finger on your palm is your left pinkie so you will put it up. Then you are left with 1 which you again subtract by the highest 2^x number which is equal or less and this time it is 1. 1 is first number and left thumb on your hands.

If you want 349 you have to subtract 256 (9th number – right index finger)
You are left with 93-64 (7th number – right ring finger)27-16 (5th number – left pinkie)
9-8 (4th number – left ring finger)
1-1 (1st number – left thumb)

Now train a little bit and impress your friends 😉 The key is to remember the first nine numbers and at what positions they are. Also you can show others just counting one by one. Just do not turn your hands towards them, numbers 4,5,128,640 and other could be dangerous 😀

Dragallur

[1]The reason why you can not count to 1,024 is of course that you are starting with 0 not 1 so your right thumb stands for 2^9 and not 2^10. You can produce another binary digit with your tongue 😉

Quick point about equations and graphs

Hi,
mliae asked me to make some simpler post so she understands this post. So here it comes, she said that it was long since she used equations:


Well equation is something like this:

x=1

That is quite clear. Of course you can have very complicated equation with many “unknowns” which are usually noted as letters, x for example. All thats easy and it says that something (x) is equal to one, it has the value of 1.

We can manipulate these equations if we abide one rule: both sides (from left and right of equal sign) have to be manipulated. If we add one we have to do it on both sides:

x+1=1+1     —>    x+1=2

Easy. We can substitute in equations if we work with more:

a=b+42
2a+3=x

2(b+42)+3=x    (“a” was substitued by b+42 because that is what it equals to.)


Now in the post that is our concern we used this equation:

To get here we have to use graph but I did not stop on that very much so I will go through it again.

Points on graph have two coordinates. This is because graph has 2 dimensions. These coordinates are usually called x and y and they are noted like this:

(x;y)

x says how much the point is to the left or right and y says how up or down (or closer/ further)

We had two points there on the graph:

Now we will take the blue point as stacionary of course but since we are working in general and not with specific numbers, it should not matter.

So black point has coordinates x and y (x;y)

Since we want it to be general we will left it like this except the y. This is because we are going to derive functions and in those y=f(x) which means that y coordinate of the point is f(x). That is the notation that is used. We are working with the function f that gave coordinate y to our black point.

black_point(x;f(x))
blue_point(x+h;f(x+h))

The h should be clear from last time. It is the distance from the black point. Then when you insert this into the “slope” equation which I talked about here, you will get what you want.

Dragallur

Feel free to ask for more clarification.

Derivatives made easy 1) Slope on curve

Hi,
today I am going to explain one fundamental equation that is used to calculate derivatives.


Derivative of a function basically says what is the rate of change or the slope of that function. You can have both rate of change of whole function which gives you another function or just at one point which equals to some number. The fundamental thing is to find the slope. Last time I explained this only for a line, not curve. On line the slope is constant but not on curve.

On the gif above you can see a function. There is a black point that is on the same place. Blue point is getting closer and closer with each step. All the time the black line creates secant line to the curve, it cuts it on two points. When it is red it is tangent line which means that it does not cuts it at all. It is the only one step in which it is just touching. To get the rate of change of curve you need to find this tangent line. Lets call the distance between the two points “h”. The tangent line will exist when h approaches zero.

THE equation. Sometimes f'(x) is written on the left.

This thing above is the equation that we will get when we take coordinates of both points.

black point(  x;f(x)   )                    [1]
blue point  (  x+h;f(x+h)  )           [1]

Just to clear things out, the first thing in the brackets is the x coordinate and the second y coordinate. As I said blue point is moved to side by the distance h and as the distance approaches 0 we are getting tangent line of curve. In the last post I showed that you need to only divide the difference of y coordinates by difference of x coordinates. Check it out if you do not know what I mean.

We will do exactly it to get right part of the equation above without the limit. Only h will be left in the denominator because there is the difference in x coordinates which means:

x+h-x=h

Now to get the tangent line we only add the limit and we have got the fundamental equation of derivates. This we can use for any curve or line that we want to derive. The left part is just a notation for derivation.

Dragallur

PS: be sure to check out this page that lets you interactively create secant and tangent lines.

[1]Just in case you do not understand why there is f(), it is basicly the same as y though we are in functions so we use this kind of notation and yes, f(x)=y. We just add h to get the y coordinate of blue point.

 

Limits made easy and slope

Hi,
today I am going to explain to you very basic concept called the slope. This is going to be important for the basic understanding of derivation.


Slope describes how much is line steep and if it is decreasing, horizontal or vertical. There is simple equation for it.

m=\frac{y_2-y_1}{x_2-x_1}.

m is the slope of a line

m = \tan (\theta)\!

This equation equals the first one because trigonometry

So to get the slope of line at given point you simply pick one point on it which has two coordinates: x1 y1. Then you pick another point to the right side and it is going to have coordinates x2 y2.

Here you can see why tan(theta) is equal to m

The subtraction creates this kind of triangle from which you can either calculate the angle or the m value which is the steepness.

Lets make an example (from wikipedia), lets say we haw line that runs through two points: A=(1,2) B=(13,8)

When we have such a information we can calculate the slope because:

x1=1
y1=2
x2=13
y2=8

All parts of equation are set:m = \frac{\Delta y}{\Delta x} = \frac{y_2 - y_1}{x_2 - x_1} = \frac{8 - 2}{13 - 1} = \frac{6}{12} = \frac{1}{2}

To show you in practice that such slope is not very big, watch the gif below.

Slope is used often in everyday life for the steepness of road. Often you will see sign as this one in mountains.

This type means that for 100 meters in horizontal direction you will go up by 10 meters.

Next time I will talk about steepness but this time not only on line where the steepness is always the same but also on curve where it changes every moment though derivatives are capable of solving such problems.

Dragallur

PS: all pictures were from wikipedia page so I will not link them one by one.

 

How to! 5) Multiply two digit numbers in your head

Hi,
today I was sitting outside, chilling out and just as that I started to multiply numbers always adding one: 1*1=1 2*2=4 3*3=9 and so on. And I wondered, how far can this go without paper or calculator?


Well I finished with 100*100 without leaving single number and after a while I started to use this kind of fast and intuitive technique which in this post will be used only to multiply two same numbers smaller than 100.

Lets say you need to multiply 47*47.   (40+7)*(40+7)

Fourty will be called “base number”. The first thing you need to do is to multiply base numbers to get your base. This is simple because 40*40 is the same as 4*4 plus two zeros which means 1600.

Base is quite easy to remember so you do not need to concentrate on that much. Now we need to combine base numbers with, lets call them “pariah numbers”.

In our case pariah number is 7. You multiply it with base number to get 40*7=280 or simply 4*7=28 (+ zero from base number). Because we have two same brackets we need to multiply this twice and add it which is the same as multiplying your result by 2.

280*2=560

Now just add this “double number” to your base which should be quite easy:

1600+560=2160

Repeat this one few times and then add the product of two pariah numbers to get the result:

2160+(7*7)=2160+49=2209


Try this few times, and if you are sure in this simple case try any two digit numbers. It is quite nice way to warm up your brain 😉

Dragallur