tag:blogger.com,1999:blog-9955940935215053212017-03-04T13:12:34.582-08:00Cobweb StorageWhen my head is full of cobwebs, I put some here to make room for more...Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-995594093521505321.post-81112284430983308482011-12-21T16:27:00.000-08:002011-12-22T16:39:39.233-08:00Why 1 ≠ 2 (and how divide by zero can work)So, the argument is posed that:<br /><br />0 * 1 = 0<br />0 * 2 = 0<u><br /></u><br /><br />Therefore:<br /><br />0 * 1 = 0 * 2<br /><br />So far so good, but according to the rules of algebra, you can add any operation to 1 side as long as you do it to the other side so let's add a division by 0:<br /><br />(0 * 1)/0 = (0 * 2)/0<br /><br />or<br /><br />0 * (1/0) = 0 * (2/0)<br /><br />or<br /><br />(0/0) * 1 = (0/0) * 2<br /><br />and through simplification of x/x = 1:<br />(1) * 1 = (1) * 2<br /><br />Obviously this is not correct...<br /><br />As I talked about in my last blog entry, x/0 = {}, the answer to a division by zero is actually a set. Now the question is, what is returned in the set? Is it always -inf to inf? Or is there a relevance factor that has to be taken into account that returns a subset?<br /><br />Let's say for a moment that 0/0 = {-inf, inf}.<br /><br />the the above proof actually translates to:<br /><br />{-inf, inf} * 1 = {-inf, inf} * 2<br /><br />which is true. All numbers multiplied by 2 results in the same numbers as all numbers multiplied by 1.<br /><br />But let's try breaking it by dividing both sides by {-inf, inf}:<br /><br />({-inf, inf}/{-inf, inf}) * 1 = ({-inf, inf}/{-inf, inf}) * 2<br /><br />Well, now we're back in trouble.<br /><br />Or are we? If we treat these sets as matrices with an infinite number of values ranging from -inf to inf then we can almost do this! The only problem we face is that the matrices are all in the same dimension. What if we made a rule that said if the matrices are in the same dimension, that one (perhaps the bottom one) should always be transposed? From there we simply invert and multiply.<br /><br />The result would simply become:<br />inf * 1 = inf * 2<br /><br />Which is again true since infinity is as big as you can get. OK, it is said that some infinities are bigger than others, but really? Infinity literally means "boundless" or "without limit". You can get an equation that solves to 2*inf, but like any x*0=0, any x*inf really is just inf.<br /><br /><br /><br /><br />Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0tag:blogger.com,1999:blog-995594093521505321.post-8847012585266737892011-12-21T08:03:00.000-08:002011-12-21T08:03:02.679-08:00x / 0 = {}It has been a very long time since I posted here, but I have just had a Eureka! moment.<div><br /></div><div>Since I have started this blog, I have contemplated what 0^0 means, and what x/0 means, and I have been stumped by the lack of a truly real world example that has a neat mathematical equation to go with it. Sure pies are nice, but they leave room for debate.</div><div><br /></div><div>Lately, I have been working with geometry for 3D image rendering, and I cam across an interesting problem: How do I get the Z coordinate of a point in a triangle when given the X and Y coordinates?</div><div><br /></div><div>That's easy enough; Use the 3 vertices of the triangle to determine the plane the triangle sets on, and then solve the plane equation:</div><div><br /></div><div>Ax + By + Cz + D = 0</div><div><br /></div><div>for the Z coordinate:</div><div><br /></div><div>z = (-Ax-By-D) / C = x(-A/C) + y(-B/C) + (-D/C)</div><div><br /></div><div>So here is an obvious situation of x/0, and when you are programming, you need to define the answer so your program doesn't crash.</div><div><br /></div><div>What does x/0 mean here?</div><div>It means you are looking at a plane parallel to the Z axis is what it means. And this is a very real world situation that has a very clear mathematical expression.</div><div><br /></div><div>A real world example would be, say you are standing on a street corner and you point at the side of a building. Your finger (or what ever pointing apparatus you might be using) points at a single spot on the wall. You can clearly establish one answer. You are pointing at a spot that is 5feet above the side walk and 20feet from the front of the building and that spot is 150feet away from you. Your example may differ, but this illustrates the point.</div><div><br /></div><div>Now, say you moved yourself so you were in perfect alignment with the wall (so you are on the same plane as it is) and you point at that same spot on the wall. What you will likely think is that you are now actually pointing at the front corner of the building, and you would be right. But imagine the line your finger (or pointing apparatus) makes. It goes through that front corner and extends all the way along the wall. By pointing at the wall, you are actually pointing at many points on that wall at the same time!</div><div><br /></div><div>You are pointing at that spot on the wall, so that spot is real, and is a valid answer to the question "What are you pointing at?" But you should also realize that you are pointing at every spot on the line that is formed by you pointing at that one spot. This means that there is actually a whole set of correct answers. Remember how you were thinking you were pointing at the front corner of the building? That was ALSO a valid answer!</div><div><br /></div><div>This proves that what divide by zero represents is multiple answers at once! It's not necessarily infinity, and it's not necessarily 0 or 1 or anything.</div><div><br /></div><div>In the pure plane equation, for any given X and Y pair that looks down a plain parallel to the Z axis, all the answers from -infinity to +infinity are valid answers.</div><div><br /></div><div>C = 0 therefore z = (-Ax-By-D) / C = {-inf, inf}</div><div><br /></div><div>Now, my notation may not be perfect but I wasn't a math major, but this is clear enough to state the point.</div><div><br /></div><div>In the case of our wall, only a subset of those answers are correct. We have stated that we are pointing at a point ON the wall. The wall does not extend for forever, so the answers are only valid from one side of the wall to the other.</div><div><br /></div><div>Say you are the reference point so our wall starts 5 feet away and ends 100 feet away. We can say that the range of valid answers are between 5 and 100 feet.</div><div>C = 0 therefore z = (-Ax-By-D) / C = {5, 100} </div><div><br /></div><div>You could even reduce the set to exactly one answer if you defined the parameters well enough. For instance you could just say you are pointing at the front corner of the building. Then our answer is simply:</div><div>C = 0 therefore z = (-Ax-By-D) / C = {5}</div><div><br class="Apple-interchange-newline" /></div><div>The whole set of the possible answers is made up of only 1 answer.</div><div><br /></div><div>And thus x/0 IS defined as a set.</div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div>Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0tag:blogger.com,1999:blog-995594093521505321.post-89011773646760352232009-08-20T11:46:00.000-07:002009-08-20T12:43:03.771-07:00Proofs of of div-by-zero and 0^0Ok. I'm refreshed and I've had a few new thoughts on how to pursue this topic. I have been noticing that people seem to use patterns as proof that 2^0 = 1. Defining exponents as repetitive multiplication, and multiplication as repetitive addition, it would seem that 2^0 is undefined:<br /><br />2^3 = 2 * 2 * 2 = (2+2)+(2+2) = 8<br />2^2 = 2 * 2 = (2+2) = 4<br />2^1 = 2 = 2 = 2<br />2^0 = = = ???<br />2^-1= 1/2 = 1/2 = 1/2<br /><br />Although the empty product would explain it as:<br /><br />2^3 = 1 * 2 * 2 * 2 = 1*((2+2)+(2+2)) = 8<br />2^2 = 1 * 2 * 2 = 1* (2+2) = 4<br />2^1 = 1 * 2 = 1* (2) = 2<br />2^0 = 1 = 1 = 1<br />2^-1= 1 * 1/2 = 1* (1/2) = 1/2<br /><br />But when considering 0^0, the empty product would say:<br />0^3 = 1 * 0 * 0 * 0 = 1*0 = 0<br />0^2 = 1 * 0 * 0 = 1*0 = 0<br />0^1 = 1 * 0 = 1*0 = 0<br />0^0 = 1 = 1 = 1<br />0^-1= 1 * 1/0 = 1*0 = 0 <-- ?<br /><br />Also defining 0^0 as equal to 1.<br /><br />Now, the 0^-1 leads to the div-by-0 question, especially 0/0?<br />Using the pattern, x/x = 1 for all x, why wouldn't 0/0 be 1? x/x, for every number, even those infinitely close to 0 (Lim x->0), yields 1, yet not 0, which leaves an undefined point on the graph.<br /><br />The same argument is used for z^0 = 1(where z not equal 0). I use z here since I'm talking about a graph and want the exponent to be the x axis for clarification. The graph of z^x looks like it would go right through 1 (except for z=0) there for it must go through 1, right? Well, we know that, just because something seems like it should be, doesn't make it so, but let's go with it for the time being.<br /><br />If that is the case, then let's consider all z for z^x from inf as it approaches 0. When z = inf, z^x = inf for all positive x and infinitely close to 0 for all negative x. Does it equal 1 when x = 0?<br /><br />As z falls from inf and approaches 1, the exponential curve broadens until, at z=1, it becomes a perfectly horizontal line at y=1. As z continues down from 1 towards 0, the curve changes so that the negative exponents increase towards infinity, and the positives fall towards 0. When we are infinitely close to z=0, we have the mirror of z=inf, so what about when z = 0?<br /><br />0^x represents the true impulse function. It is 0 for all x's except x=0 where it equals 1.<br /><br />0^0 is 1, unless all other x^0 are also considered undefined. We have a choice to either use the empty product or not.<br /><br />Now, going back to div-by-zero; 0 can divide 0 into 0 parts evenly. My friend Mal made the next logical leap: 0 can not divide 1 evenly into 0 parts, there for the answer is 0 remainder 1. Here's a few examples:<br /><br />3/0 = 0 reaminder 3<br />2/0 = 0 reaminder 2<br />1/0 = 0 reaminder 1<br />0/0 = 0 reaminder 0 or 1 remainder 0<br />-1/0 = 0 reaminder -1<br /><br />This is supported by the long division process:<br /> _00_<br />0 ) 10<br /> 0<br /> ----<br /> 10<br /> 0<br /> ----<br /> 10<br /><br />Let's follow the procedure in words:<br />The first question can be phrased a couple of ways: "How many times can 0 go into 1?", but also "How many parts can 0 divide 1 into evenly?"<br />One might think the answer is infinity, or 0, but 0 is the only correct answer, and here's why. Zero represents nothing. Even if you chopped 1 into an infinite number of pieces, there would still be pieces, not nothing, so the answer is simply, you can not divide 1 into 0 parts which means that the answer to put above the 1, is 0.<br />Doing the remainder for the first part, we subtract off 0*0, which leaves 1. Bring down the next most significant digit, the 0, and now we have to divide 10, in its entirety, by zero. Well, the same logic applies as before. 10 can not be divided by 0, so a 0 goes above the 0 also. That completes the quotient part of the process, and now we have to determine how we want to handle the remainder. The remainder is 10, so we can either put that into fraction form (10/0) or we can continue the division process into the decimal places, which would yield infinite 0's.<br /><br />Let's look at it a different way. <a href="http://malsmath.blogspot.com/2009/04/division-by-zero.html">Mal described div-by-zero as removing pennies from a pile on a table.</a> I would like to use the examples of pies. When you serve pie, you divide it up and put it onto plates to be served. If you have one pie, and 3 people want it, each plate will get 1/3 of the pie put on their plate. If two people wanted the pie divided between them, then 1/2 the pie would be removed from the pie pan and placed on 1 plate and the other 1/2 would be put on a second plate.<br /><br />Now here is were an interesting concept get's introduced, the remainder. If only 1 person wanted 1/2 the pie, then 1/2 the pie would be taken out of the pie pan and placed on the plate, leaving 1/2 remaining in the pan. What ever is left in the pan after the pie is divided represents the remainder.<br /><br />So next comes the idea that no one wants any pie. No pie will be removed from the pie pan and put onto 0 plates. The answer to 1 pie divided for zero servings is 0 servings with 1 whole pie remaining, thus 1/0 = 0 remainder 1. This applies to 2 pies, three pie and even x number of pies divided into 0 servings.<br /><br />The debatable point to this pattern of x/0 = 0 remainder x, is that of the infamous 0/0. 0*0 = 0 therefore 0/0 = 0, but x/x = 1 therefore 0/0=1. Is one right, is neither right, or are both right? The rules of math must evenly apply to all aspects of math, ultimately, without exception. This then says that the rules of multiplication and division must be followed, and the statement x/x = 1 is a pattern, not a rule. This ultimately tells us that 0/0 = 0 remainder 0, and that x/x is an inverse impulse function. It is 1, everywhere except x=0.<br /><br />But what does that remainder do for math? Well, let's look at another principle of math:<br /><br />2/4 = 1/(4/2)<br /><br />This is provable. I'm using easily divisible numbers so the proof to follow doesn't get huge:<br />2/4 = 1/4 = 0.5<br /><br />and:<br />1/(4/2) = 1/(2/1) = 1/2 = 0.5<br /><br />so what about 0/1?<br />0/1 = 1/(1/0) = 1/(0 remainder 1) = 0<br /><br />This tells us that the remainder is meaningless. Perhaps this falls into the realm of imaginary numbers, or something very much like it.<br /><br />So, if x/0 is now defined, then 0^x is defined for all x's, even negatives:<br />0^1 = 1 * 0 = 1*0 = 0<br />0^0 = 1 = 1 = 1<br />0^-1= 1 * 1/0 = 1*(0+1/0) = 0<br />0^-2= 1 * 1/(0*0) = 1*(0+1/0) = 0<br /> 0^-3= 1 * 1/(0*0*0) = 1*(0+1/0) = 0Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com3tag:blogger.com,1999:blog-995594093521505321.post-15965757124744605532009-08-17T21:14:00.000-07:002009-08-17T23:59:20.264-07:00The foundations of math or "Bunches of something different than nothing"I'm taking a quick detour to explore the foundations of math. It seems that there is something that isn't settling right, and I have to make sure I understand it before I go on.<br /><br />I'll just tell you this came from 0^0 debate. Is it 0, 1, undefined, indefinite, or what?<br /><br />So I started to work through what exponents are. Seems easy enough; exponentiation is the multiplication of multiplication. So:<br /><br />2^3 = 2 * 2 * 2 = (2 * 2) * 2 = 8<br /><br />To sum it up better, x^y says multiply x against itself y times. Like in the example, you multiplied two against two and then again against two.<br /><br /><span class="blsp-spelling-corrected" id="SPELLING_ERROR_0">OK</span>, but then what does multiplication mean? Well, multiplication is short hand notation for adding a number to itself so many times, right?<br /><br />2 * 3 = 2 + 2 + 2 = 6<br /><br />so we can expand our exponent example (above) to be:<br /><br />2^3 = 2 * 2 * 2 = (2 * 2) * 2 = (2 + 2) + (2 + 2) = 8<br /><br />Wow, That's so neat. But what is addition?<br /><br />...<br /><br />Um, <span class="blsp-spelling-corrected" id="SPELLING_ERROR_1">OK</span>, that's a little harder to explain. It's like making something more than it was, right?<br /><br />2 + 2 = 4<br /><br />So 4 is 2 more that 2. But 2 is pretty abstract. What is 2? Well, 2 is 2. This is why they teach kindergartners about apples. :(<br /><br />But using apples, we can say that 2 apples is 2 more than no apples. That would insinuate that 1 apple is 1 more than no apples and no apples is just no apples. So, numbers, such as 2, are the change from nothing. (i.e. there was nothing and now there is 2 is more than nothing)<br /><br />Now, what about -1 apples? Well, then that would mean you have less than nothing or a hole has formed in the universe and made a <span class="blsp-spelling-corrected" id="SPELLING_ERROR_2">trans dimensional</span>/temporal crack and the whole thing is going to collapse in on itself!<br /><br />...<br /><br />Or, it means that 0 isn't always really nothing. Maybe 0 can just be the status <span class="blsp-spelling-error" id="SPELLING_ERROR_3">quo</span>, and when there isn't anything to relate the status <span class="blsp-spelling-error" id="SPELLING_ERROR_4">quo</span> to, them 0 is actually nothing. So I guess that would mean that numbers are a change from 0, which is a change from the status <span class="blsp-spelling-error" id="SPELLING_ERROR_5">quo</span>, which may be nothing.<br /><br />That would define numbers to have the following format:<br /><br />0+2<br /><br />That says 2 more than nothing and:<br /><br />0+2 -1 = 0+1<br /><br />says 2 more than nothing is the status <span class="blsp-spelling-error" id="SPELLING_ERROR_6">quo</span>, and there is 1 less than that.<br /><br />Seems like boring stuff, but really, this is going some place. There is a raging debate about what 0^0 means, and if I want to know what the answer is, we have to understand the very fundamentals of math.<br /><br />So now we have a good understanding of numbers, and numbers them selves are addition, as we saw in the last example. Next on the list is to understand multiplication:<br /><br />2*2 = (0+2) * 2 = (0+2) + (0+2) = 4<br /><br />What does that mean? The parenthesis makes them look like groups, kinda like what we learned in kindergarten. 2 apples and 2 more apples is a total of 4 apples. So that's saying 1 group of 2 apples was combined with another group of 2 apples to make 4 apples. so the multiplier is really just saying how many groups of the same size/content we have. Like this:<br /><br />2*2 + 3*2 = (0+2) * 2 + (0+3) * 2 = (0+2) + (0+2) + (0+3) + (0+3) = 10<br /><br />Imagine if that were 2 groups of 2 apples and 2 groups of 3 sticks. Well, you would have 10 things, but you would still have 4 apples and 6 sticks, so we have to group things that are the same, and bunched the same way. This leads to a new form for numbers:<br /><br />1*(0+2)<br /><br /><span class="blsp-spelling-corrected" id="SPELLING_ERROR_7">which</span> says "There is 1 group of 2 things". Addition works on changing the contents of a group, and multiplication works on grouping groups.<br /><br />So let's look at the special cases:<br /><br />1*(0+0) = 1 bunch of nothing:<br />How can you have a bunch of nothing? Let's do an experiment. Actually go and get me 1 bunch of apples that have no apples more than nothing in them. You can't, but conceptually, you brain is capable of conjuring into <span class="blsp-spelling-corrected" id="SPELLING_ERROR_8">existence</span> a bunch of something that has nothing in it. Your brain is <span class="blsp-spelling-corrected" id="SPELLING_ERROR_9">capable</span> of storing part of a fact and waiting for the rest to be filled in, and this skill has granted us the ability to abstract nothing into something.<br /><br />Example: If I tell you you have a bunch of apples, you brain might draw up the mental image of a wicker basket full of apples. Now, when I tell you your bunch of apples has no apples in it, your brain suddenly empties the basket and you can see to the bottom of the basket. Your brain still holds onto the basket as the symbol for the bunch of apples that doesn't exist.<br /><br />1*(0+1) = 1 bunches of 1 more than nothing:<br />One bunch of a thing is easy to physically manifest. You have 1 bunches of 1 more than 0 keyboards connected to your computer. That makes sense; you have 1 thing that actually exists as a single group.<br /><br />0*(0+0) = 0 bunches of nothing:<br />This is also pretty easy; You have no groups of nothing. It simply doesn't exist in any fashion.<br /><br />0*(0+1) = 0 bunches of 1 more than nothing:<br />This a bit odder again. Let's play that little mental game like we did before. So, I tell you to group the apples into groups of 1 (set them by themselves), but then I tell you there are zero groups. Well, how can you group nothing together? It's like the first special case. Your brain can abstract the idea, but it would be an impossible task to actually do.<br /><br />So what do we do from here? Do we let our brains play these games, or do we stick to what we can physically accomplish? We could call these odd ball cases undefined, but the math community has decided to accept them as equal to nothing, making the answer to 3 out of the 4 cases 0. But that's <span class="blsp-spelling-corrected" id="SPELLING_ERROR_10">OK</span>, because it seems reasonable. 0 groups of any size still means the group never existed, <span class="blsp-spelling-corrected" id="SPELLING_ERROR_11">which</span> means there is nothing.<br /><br />Additionally, multiple groups of nothing makes some sense. If I have nothing and you have nothing, then there are 2 nothings, right? That would make 2 bunches of nothing, and nothing is nothing more than nothing.<br /><br />So what about exponential and 0^0?<br /><br />2^3 = 2*(2*(0+2)) = 1*(1*(0+2) + 1*(0+2)) + 1*(1*(0+2) + 1*(0+2)) = 1*(1*(0+2) + 1*(0+2) + 1*(0+2) + 1*(0+2)) = 8<br /><br />(I have to admit. I'm getting tired, so the <span class="blsp-spelling-corrected" id="SPELLING_ERROR_12">writing</span> may not be as good).<br /><br />This is saying to do a lot of adding. Take a bunch of 2 more than nothing and double it, and then double it again. As the equation was expanded, parenthesis were added to show grouping.<br /><br />Now imagine 1^3, That says you have 1 group of 1 bunch of 1 more than 0. How about 0^3? That says you have 0 groups of 0 groups of nothing more than nothing.<br /><br />So here comes the million dollar question: What about 0^0? That would say, following the convention that multiplication is compounded addition and exponents are compounded multiplications, I don't know what to say here.<br /><br />As far as this would suggest, 0^0 is simply 0, but we will keep exploring...Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0tag:blogger.com,1999:blog-995594093521505321.post-41016213566221859972009-08-14T11:52:00.000-07:002009-08-14T13:37:01.483-07:00CEIL(x)As promised, I have returned to reveal the mystical secrets of the math universe. Yes, step right up, step right up!<br /><br />So, now that we have the FLOOR(x) function, now we are going to build on that to create the CEIL(x) function.<br /><br />Refresher:<br />FLOOR(x) = x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_POS))<br /><br />IS_POS was our switch function that equaled 1 when sin(x*2pi) was positive or 0. Using the fact that 0^0 = 1 and 0^(any other positive number) = 0, it went like this:<br />IS_POS = 0^abs(sin(x*2pi)-abs(sin(x*2pi)))<br /><br />And the NOT(x) function there could be implemented a few ways. In the floor function post, I again used the properies of 0 raised to flip the IS_POS switch like this:<br /><br />IS_POS = 1<br />0^abs(IS_POS) = 0^1 = 0<br /><br />IS_POS = 0<br />0^abs(IS_POS) = 0^0 = 1<br /><br />Perdy neat!<br /><br />But this time, and for no real particular reason except to be explorative, we'll redefine the NOT(x) function.<br /><br />Using the constraint of IS_POS (it can only be 0 or 1), we can make the function:<br /><br />IS_POS = 1<br />NOT(IS_POS) = 1 - IS_POS1 = 1-1 = 0<br /><br />IS_POS = 0<br /> NOT(IS_POS) = 1 - IS_POS1 = 1-0 = 1<br /><br />This is an old computer programming trick.<br /><br />Anyway, back from the tangent to the task at hand; Developing a working CEIL(x) function! I just wanted to get everybody back on the same page.<br /><br />So looking at FLOOR(x) again:<br />FLOOR(x) = x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_POS))<br /><br />we have these switches on two very similar looking chunks of the equations-<br />First:<br />arccos(cos(x*2pi))/2pi<br /><br />Second:<br />1-arccos(cos(x*2pi))/2pi<br /><br />Well, the first is "active" (multiplied by 1) when the IS_POS function is true and "deactivated" (multiplied by 0) when the IS_POS function is returning 0. Conversely the second is activated and deactivated oppositely, thanks to the NOT(x) function.<br /><br />The reason for this is (explained by the following exaples of flooring 3.r were r is the decimal or fractional part of the number):<br />arccos(cos(3.00*2pi))/2pi = 0.00<br />arccos(cos(3.25*2pi))/2pi = 0.25<br />arccos(cos(3.50*2pi))/2pi = 0.50<br /><br />so our neat little equation there returns just the fractional part of the number for us but, because the cos function is cyclical, after 3.5 up to 4.0, the result reverses:<br />arccos(cos(3.60*2pi))/2pi = 0.40, but +1-0.40 = 0.60<br /> arccos(cos(3.75*2pi))/2pi = 0.25, but +1-0.25 = 0.75<br />arccos(cos(3.90*2pi))/2p) = 0.10, but +1-0.10 = 0.90<br /><br />So, you see, for 3.0 to 3.5, we want to just straight subtract off the result, but once we are past 3.5 but less than 4 (when the IS_POS is false), we need to subtract off the difference between 1 to make the floor function work.<br /><br />Ok, so we are all caught up on how it works, so let's use these blocks to make the CEIL function!<br /><br />CEIL(x) = x+what?<br /><br />Well, let's see what CEIL(x) should return (using 3.r again):<br />CEIL(3.00) = 3.00<br />CEIL(3.25) = 4.00<br />CEIL(3.50) = 4.00<br />CEIL(3.75) = 4.00<br />CEIL(4.00) = 4.00<br /><br />So now, we need to add, but let's lookj at what we need to add:<br />CEIL(3.00) = 3.00, add 0.00<br /> CEIL(3.25) = 4.00, add 0.75<br /> CEIL(3.50) = 4.00, add 0.50<br /> CEIL(3.75) = 4.00, add 0.25<br /> CEIL(4.00) = 4.00, add 0.00<br /><br />Well, it looks like we are adding 1-r (remember that r was the fractional part) so:<br />CEIL(x) = x+(1-(arccos(cos(x*2pi))/2pi))<br /><br />Let's test it and make sure:<br />CEIL(3.25) = 3.25+(1-(arccos(cos(3.25*2pi))/2pi)) = 3.25+0.75 = 4.0, Good<br />CEIL(3.50) = 3.50+(1-(arccos(cos(3.50*2pi))/2pi)) = 3.50+0.50 = 4.0, Good<br /> CEIL(3.75) = 3.75+(1-(arccos(cos(3.75*2pi))/2pi)) = 3.75+0.75 = 4.5, oops!<br /> CEIL(4.00) = 4.00+(1-(arccos(cos(5.00*2pi))/2pi)) = 4.00+1.00 = 5.0, oops!<br /> <br />So what went wrong? Well, 2 things:<br />1) Integers (like 3.0 and 4.0) should stay as they are, not have 1 added to them<br />2) In the CEIL(3.75) example, the old cos function being cyclical thing got us again.<br /><br />so, for 3.5 to 4.0 and on the integers(3.00 and 4.00 for example) we want to add just the fractional part, not the 1-fractional. This is very much the opposite of what we were seing before. Ofcourse that makes sence in that the FLOOR(x) and the CEIL(x) are opposites.<br />So let's go crazy and create an IS_NEG function that is equal to 1 when sin(x*2pi) is negative or 0!<br /><br />IS_NEG = 0^abs(-sin(x*2pi)-abs(sin(x*2pi)))<br /><br />What's the difference from IS_POS? I multiplied the first sin * -1. Now, if sin(x*2pi) is positive, then it becomes a negative and then subtracting off the abs value will not be 0, and because 0 raised to anything but 0 equals 0, IS_NEG will be False ( or 0).<br /><br />This means that IS_NEG will equal 1 when sin(x*2pi) equals 0 or is negative. Perfect.<br /><br />So let's work the rest of the peices out:<br /><br />CEIL(x) = x+ (arccos(cos(x*2pi))/2pi)*IS_NEG + (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_NEG))<br /><br /><br />And there we go. A working CEIL(x) function.Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0tag:blogger.com,1999:blog-995594093521505321.post-68064108316671313812009-08-12T23:18:00.000-07:002009-08-20T15:02:36.289-07:00FLOOR(X) - And so the saga continues...So, the ultimate answer to the ultimate question of life, the universe and everything is...<br /><br />Oops, wrong story.<br /><br />But in the last episode, I was looking for a signal that would tell me if I was greater that half way around the circle, so I could signal the arccos function to keep increasing, and that answer is sin.<br /><br />Sin, being the y axis vector, is positive while traversing the circle's circumference counterclockwise for half the journey, and then becomes negative. That is exactly the indicator I need, but how can i make it work for me?<br /><br />Well, there is an odd, and little known, fact about exponents, that goes something like this:<br /><br />x^0=1 (any number raised to the 0th power is 1)<br />0^x = 0 (0 raised to any power is zero)<br /><br />putting these two equations at conflict. To solve this, it was determined that exponents actually take the form:<img src="file:///C:/Documents%20and%20Settings/rholmes/Desktop/Exponent_equation_simple.png" alt="" /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_uO8Fej0PqYA/So3G9CBDW8I/AAAAAAAAAA0/p8mQs7uCSxM/s1600-h/Exponent_equation_simple.png"><img style="cursor: pointer; width: 104px; height: 51px;" src="http://3.bp.blogspot.com/_uO8Fej0PqYA/So3G9CBDW8I/AAAAAAAAAA0/p8mQs7uCSxM/s200/Exponent_equation_simple.png" alt="" id="BLOGGER_PHOTO_ID_5372168682338474946" border="0" /></a><br /><br />that says, recursively, start with 1, and then multiply x to it, y times. Here's an example:<br /><br />5^3 = 1 * 5 *5 * 5 = 125<br />5^2 = 1 * 5 * 5 = 25<br />5^1 = 1 * 5 = 5<br />5^0 = 1<br /><br />or for 0:<br /><br />0^3 = 1 * 0 * 0 * 0 = 0<br />0^2 = 1 * 0 * 0 = 0<br />0^1 = 1 * 0 = 0<br />0^0 = 1<br /><br />Very interesting, but more importantly, this acts like a built in mathematical switch! In order to use this switch, we write an equation for the power applied to 0, and we know that the total result will be 0, until the equation is equal to 0, thus making 0^0 = 1.<br /><br />Let me use an example to clarify:<br /><br />Say I revisited my original goal to find an equation that would indicate if a number is an integer or not:<br /><br />Well, thinking about the trig functions and the unit circle,<br /><br />sin(n*pi) = 0<br /><br />n representing only integers. Non integers will return a number other than 0. Again, an example to clarify:<br /><br />sin( 0.0 * pi) = 0<br />sin( 0.5 * pi) = 1<br />sin( 1.0 * pi) = 0<br />sin( 1.5 * pi) = -1<br />sin( 2.0 * pi) = 0<br /><br />this seems to meet our conditions for this switch. We wanted 0^0 only when there is an integer, so a true integer detection equation would be:<br /><br />0^sin(x*pi)<br /><br />well, almost. You can't have a negative power (remember, roots are fractional powers, not negative) with 0^x or you would get div-by-zero, so an easy solution to this is the absolute value function, which basically removes the negative sign from all negative numbers. So, we really need:<br /><br />0^abs(sin(x*pi))<br /><br />Viola!<br /><br />So you get the jist of how this switch thingy-ma-bobber works, right? So back to the FLOOR(X) function. I currently have:<br /><br />FLOOR(x) = x - (arccos(cos(2pi*x))/(2pi))<br /><br />which works as long as the fractional part of x is 1/2 or less. So, using my switch and knowing the sin funxtion becomes negative when the fractional part of x is greater that 1/2, i can use a switch like:<br /><br />0^abs(sin(x*2pi)-abs(sin(x*2pi)))<br /><br />to tell me if sin(x*2pi) >= 0.<br /><br />This works because:<br /><br />arccos(cos(3.2*2pi))/2pi = 0.2 which requires us to subtract this result from the 3.2 to floor it.<br />arccos(cos(3.5*2pi))/2pi = 0.5 which requires us to subtract this result from the 3.5 to floor it.<br /><br />but:<br /><br />arccos(cos(3.6*2pi))/2pi = 0.4<br />arccos(cos(3.7*2pi))/2pi = 0.3<br />arccos(cos(3.8*2pi))/2pi = 0.2<br />arccos(cos(3.9*2pi))/2pi = 0.1<br /><br />we now have to subtract 1-this result from the number we entered to floor it:<br /><br />1-arccos(cos(3.6*2pi))/2pi = 0.6 and 3.6 - 0.6 = 3<br />1-arccos(cos(3.7*2pi))/2pi = 0.7 and 3.7 - 0.7 = 3<br />1-arccos(cos(3.8*2pi))/2pi = 0.8 and 3.8 - 0.8 = 3<br />1-arccos(cos(3.9*2pi))/2pi = 0.9 and 3.9 - 0.9 = 3<br /><br />This new development is why we need the mathematical switch; without it, we have a piecewise function that isn't subject to all of the normal algebreaic motions. We can't reduce in a more complex equation, or apply commutative properties, etc. With the switch in place, however, it's game on.<br /><br />So now we need the switch implimented:<br /><br />x-arccos(cos(x*2pi))/2pi or x+1-arccos(cos(x*2pi))/2pi<br /><br />to make it readable, I'm going to substitute the label IS_POS for the switch:<br /><br />IS_POS = 0^abs(sin(x*2pi)-abs(sin(x*2pi)))<br /><br />so we getsomething roughly like:<br /><br />x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_POS))<br /><br />Ok, ok. I slipped one in there on ya. The not function basically says if IS_POS is 0, make it a 1, otherwise, make it a 0. Hmm, kinda like a switch...<br /><br />NOT(a) = 0^abs(a)<br /><br />so you see, the equation can be written:<br /><br />x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*0^abs(IS_POS)<br /><br />but NOT is more human readable.<br /><br />Enough for now, in the next post, I will make the CEIL(x) function work from these same blocks and then later I will write up the various MOD(x,y) functions.Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0tag:blogger.com,1999:blog-995594093521505321.post-39971893688599996552009-08-12T21:34:00.000-07:002009-08-12T23:00:14.487-07:00FLOOR(x)Monday, just before I left work, an old problem that had been swirling around in my head decided to surface. Mal and i worked on the RSA challenges (trying to factor really large numbers that are the product of two primes).<br /><br />So, we found tons of solutions that would get us the answers quickly if we could put our equations into a non-recursive form. Unfortunately, they all used modulo or floor functions, which are conceptual, piecewise functions.<br /><br />So, back to Monday; As I was packing up to go home, the thought that had occurred to me several times came to the front of my brain again, Integers are periodic. Numbers can be represented in many ways, but fractions make this Integers very clear.<br /><br />Here is an example:<br />1.333333333333333(...) is a hard number to write. It could literally take for ever to write it out completely without using fractions. As a fraction though:<br /><br />1+1/3 is all you need.<br /><br />so I can talk about parts of it, I will use the following generic format for fractions:<br /><br />q+(n/d)<br /><br />where:<br />q is the "whole" number or the biggest possible number than n/d will allow<br />n is the numerator and has only the left overs (or remainder)<br />d is the denominator<br /><br />What I mean by all of that is, say you had:<br /><br />0+11/3<br /><br />Then you are not really in the right form. You would want to simplify the (n/d) or fractional part as much as possible:<br /><br />3+(2/3)<br /><br />Is the best answer. But I do digress to my real point, that integers are periodic, or, as the thought actually came to me, cyclical. Integers are special numbers whose fractional part (n/d) is equal to 0.<br /><br />If integers are cyclical, and the only mathematically cyclical thing I know of is trig functions (specifically sin and cos functions), then maybe I can use them.<br /><br />I thought, I need to write an equation that is true only when I have hit some point on the unit circle, as i traverse the circumference. So I started looking at the circle and noticed the same thing probably a billion other people have, cos starts at 1 and goes to -1. There had to be something there, so i dropped my victim number into the cos function (with 2pi) and that didn't help me to much.<br /><br />What did help me was remembering that the cos function always returned a number 1 to -1, no matter how many times you went around the circle. It, in effect, chopped of the whole number (the "q" in my form above) and left a wierd number, that was consistent base on my fractional part, but didn't directly match or seem to directly correlate.<br /><br />Well, duh! cos is the x axis vector for where you are on the circumference of the unit circle. drop that result back into arccos and it should return how far around the circle my fractional part has taken me.<br /><br />For instance:<br /><br />cos(2pi*3.25) = 0<br />arccos(0) = pi/2<br /><br />Well, that's not exactly returning just the fractional part of 3.25 (3+1/4) or the 0.25 (0+1.4), but that's because it's scaled by 2pi!<br /><br />(pi/2)/(2pi) = 0.25<br /><br />So, now, what if I take my 3.25 - (arccos(cos(2pi*3.25))/(2pi))?<br /><br />3.25 - (arccos(cos(2pi*3.25))/(2pi)) = 3<br /><br />Good stuff. I'm well on my way to being able for the equation to tell me if it is an integer or... Wait a second. Didn't that just separate the fractional part from the whole part? Did I just FLOOR that with a real equation? Friggin' wholly grails!<br /><br />Upon testing there turns out to be a problem though. It works, returning q from q+(0/2) to q+(1/2), but then it sudenly breaks and ramps with a slope of 2 from ther on up to q+(2/2) (or q+1).<br /><br />Now the problem with this solution emerges. cos is cyclical and get's to -1 half way around the circle, but then starts increasing back towards 1 there after. The arccos function can't tell the difference between the the -0.9 just before we get half way around the circle or just after. The slope of 2 is due to the fact that the rate in change in the number we are testing (3.4, 3.5, 3.6, 3.7, etc) is the same rate of change that is coming out of the arccos function, thusly doubling.<br /><br />I'm sure I'm rambling and not making a ton of sense, but the important thing that occured to me was that, if I had some sort of indicator that I could use to tell the arccos function to just keep going up, it would work.<br /><br />Now a few hours after I should have left work, I had developed some imperfect solutions, but the answer was in my grasp.<br /><br />And with that I leave you with the thrilling cliffhanger of how I developed working equations of the FLOOR(x), CEIL(x), MOD(x,n) functions and much, much more! Untill next time, be sure to drink your Ovaltine!Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0tag:blogger.com,1999:blog-995594093521505321.post-29387391949622031272009-08-12T21:25:00.000-07:002009-08-12T21:33:50.069-07:00Christening my mental mini-storageWell, I recently came up with some interesting equations for implementing modulo, floor, ceil, rounding, etc. Well, as boring as all of that sounds, my friend, Mal, urged me to start a blog to record my notes and progress as I continue to develop them.<br /><br />So, alas, here I am, christening this blog, which I will use as mini-storage, so I can make room for more cobwebs in the space between my ears.Reginald Holmeshttps://plus.google.com/107198781311211156361noreply@blogger.com0