This is something I wanted to write about because it has been on my mind and I wanted to make it real and subject to scrutiny so that I would doubt myself and see if the concepts are reasonable.
It starts with numbers in the same sense as Newtonian relativity in an odd way to establish a 'proof' sequence of concepts in a more people friendly way.
So I have two stones in front of me, one to the left and one to the right. I walk around to the other side and now the stones are right and left instead of the other way around. This is what would seem to be the additive commutative property of matter.
From this multiplication is just adding in sequence so it is the same. a+a+b+b=a+b+a+b=(a+a)+(b+b)=(a+b)+(a+b)=2a+2b=2(a+b) and so on.
The program to deal with GCF ( greatest common factor ) using this principle. I start by assuming I have solved the problem and just return the solution. This a recursive function and the most important thing is to make the escape from infinity clause first, otherwise it can crash and like any CAT and MOUSE, you only get to lose once if you are a mouse. Also it needs to take into account that there can be improper numbers input by accident (- , non integer, 0, too big).
This code is 0xBAD! because it passes by value instead of reference.
unsigned int gcf(unsigned int a, unsigned int b) { // This is just the invalid numbers escape clauses. // One must plan for somebody calling with silliness // I also want to avoid recursive calls that go too deep in the stack // No negative or zero if (a <= 0){return 0;};if (b <= 0){return 0;}; // No non integers (I think GCC disallows this anyway) if (floor(a) != a){return 0;};if (floor(b) !=b){return 0;}; // Don't recurse too much to be boring by accident if (abs(a-b) > 100000){return 0;}; //This is the real process with two cases. if (a == b){return a;} //If a=b then it is divisible // now one more case a != b if (a > b){a-=b;gcf(a,b);} //These are actually the same case //viewed from a different direction if (a < b){b-=a;gcf(a,b);} } // DONE!
It seems that this is a natural consequence of the commutative property. This is the framework so I can add the detail as I consider the flow of each part and if it really as simple as this. There are several relationships here that could be applied in other conditions and I will add the causative elements as I clarify the thinking on it. I assume this works, though I have not tested. So I will compile it and throw some Monte Carlo at it for fun, but this is a classic relationship and I just want to observe and quantify one of the steps, which is the a-b meaning in this context as a number relationship rule. I will extend this as I think about it some more. This post is a WIP.( Work In Progress )
ADDED: So this a kind of modulo or division of b by a in steps of subtraction and if it become equal then it is a factor. But, that is not all there is to it as it defines division in the same way that multiplication is defined by grouping.
ADDED (About coding in C): If you are wondering about comparing in C and why a == b is used. It is a convention that needs to be carefully observed. '=' is used as an assignment operator by definition and == is a comparison. It can be dangerous as it is easy to think contextually and anthropomorph the computer, about context. You might think that if( a = b ) is a valid way to see if something is equal and the compiler should say "Did you mean to ask if these are the same, or did you mean assign the value of b to a and then be true always?" I bet I could make a code checker that looked for single '=' signs in an if, but the problem is that it can be intended, as you can do assignment as you evaluate so it is easier to just remember == is a comparison and = is an assignment operator. I fixed the HTML for < in code and used unsigned integer as in and out which would exclude negatives and floats as possible, however it can still have 1 billion and 1 as inputs and it would recurse on the stack to about 16 gigabyte of values on the stack so that is going to be doing single subtracts for a very long time. It isn't optimized as I should do a mod operation and that is where it ends up, but I want to study the process and define division in the same way as I define multiplication.
So: when 'a' > 'b', 'a-b' can be done and results eventually in 0 or an integer. Then: a-b where a and b are a(gcf)/(gcf) and b(gcf)/(gcf). Or: a*C - b*C = (a-b)*C. Then a*C-b*C = δ(a,b)*C. That is still not clear or simple enough to be an algorithm.
RUNNING: after fixing some reversed slashes gives me this as the pairs as they transform with a starting set of 30 and 99 , and obviously it isn't right to go from 3,3 to 3,6 so something is hinked up in my reasoning on this.
30 99 ...30 69 ...30 39 ...30 9 ...21 9 ...12 9 ...3 9 ...3 6 ...3 3 ...3 6 ...3 3 ...
30 99 ...30 69 ...30 39 ...30 9 ...21 9 ...12 9 ...3 9 ...3 6 ...3 3 ... DONE
void gcf(){
printf ("%d %d ...",g[0],g[1]);
if (g[0] == g[1]){ printf(" DONE\n");return;}
if (g[0] > g[1]){g[0]-=g[1];gcf();}
if (g[0] < g[1]){g[1]-=g[0];gcf();}}
Wow! that was stupid., pass by reference and pass by value. I need to pay more attention to my variable rules.
All of the integer things are inter-related in some strange ways. Clearly primes are different than squares and products and things which move along the number line and then can be represented in n-dimensional space like 3*5*7 could describe a 3 dimensional shape. I have not gotten what I want from this yet, but I am getting there. I usually reject the significance of numbers as meta facts, however integers is a very special case and many people have realized this. It is possible to have a system that deals with dimensional relations of products and division which is coherent and solvable. It is when addition and subtraction are combined with this that it gets unusual and this does have some meaning in things that can only assume integer states.
I guess what I am trying to get at is the vector relationships of numbers in an almost infinite dimensional space that is their sets of combinations and how the interact as products and sums. It implies something about wave interaction as primes are a combination of the negative intersect of each preceding prime in a way like the Fibonacci sequence is a product of its predecessors in a less complex way.
0 comments:
Post a Comment