Showing posts with label NOT(x). Show all posts
Showing posts with label NOT(x). Show all posts

Thursday, August 20, 2009

Proofs of of div-by-zero and 0^0

Ok. 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:

2^3 = 2 * 2 * 2 = (2+2)+(2+2) = 8
2^2 = 2 * 2 = (2+2) = 4
2^1 = 2 = 2 = 2
2^0 = = = ???
2^-1= 1/2 = 1/2 = 1/2

Although the empty product would explain it as:

2^3 = 1 * 2 * 2 * 2 = 1*((2+2)+(2+2)) = 8
2^2 = 1 * 2 * 2 = 1* (2+2) = 4
2^1 = 1 * 2 = 1* (2) = 2
2^0 = 1 = 1 = 1
2^-1= 1 * 1/2 = 1* (1/2) = 1/2

But when considering 0^0, the empty product would say:
0^3 = 1 * 0 * 0 * 0 = 1*0 = 0
0^2 = 1 * 0 * 0 = 1*0 = 0
0^1 = 1 * 0 = 1*0 = 0
0^0 = 1 = 1 = 1
0^-1= 1 * 1/0 = 1*0 = 0 <-- ?

Also defining 0^0 as equal to 1.

Now, the 0^-1 leads to the div-by-0 question, especially 0/0?
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.

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.

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?

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?

0^x represents the true impulse function. It is 0 for all x's except x=0 where it equals 1.

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.

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:

3/0 = 0 reaminder 3
2/0 = 0 reaminder 2
1/0 = 0 reaminder 1
0/0 = 0 reaminder 0 or 1 remainder 0
-1/0 = 0 reaminder -1

This is supported by the long division process:
_00_
0 ) 10
0
----
10
0
----
10

Let's follow the procedure in words:
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?"
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.
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.

Let's look at it a different way. Mal described div-by-zero as removing pennies from a pile on a table. 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.

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.

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.

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.

But what does that remainder do for math? Well, let's look at another principle of math:

2/4 = 1/(4/2)

This is provable. I'm using easily divisible numbers so the proof to follow doesn't get huge:
2/4 = 1/4 = 0.5

and:
1/(4/2) = 1/(2/1) = 1/2 = 0.5

so what about 0/1?
0/1 = 1/(1/0) = 1/(0 remainder 1) = 0

This tells us that the remainder is meaningless. Perhaps this falls into the realm of imaginary numbers, or something very much like it.

So, if x/0 is now defined, then 0^x is defined for all x's, even negatives:
0^1 = 1 * 0 = 1*0 = 0
0^0 = 1 = 1 = 1
0^-1= 1 * 1/0 = 1*(0+1/0) = 0
0^-2= 1 * 1/(0*0) = 1*(0+1/0) = 0
0^-3= 1 * 1/(0*0*0) = 1*(0+1/0) = 0

Friday, August 14, 2009

CEIL(x)

As promised, I have returned to reveal the mystical secrets of the math universe. Yes, step right up, step right up!

So, now that we have the FLOOR(x) function, now we are going to build on that to create the CEIL(x) function.

Refresher:
FLOOR(x) = x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_POS))

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:
IS_POS = 0^abs(sin(x*2pi)-abs(sin(x*2pi)))

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:

IS_POS = 1
0^abs(IS_POS) = 0^1 = 0

IS_POS = 0
0^abs(IS_POS) = 0^0 = 1

Perdy neat!

But this time, and for no real particular reason except to be explorative, we'll redefine the NOT(x) function.

Using the constraint of IS_POS (it can only be 0 or 1), we can make the function:

IS_POS = 1
NOT(IS_POS) = 1 - IS_POS1 = 1-1 = 0

IS_POS = 0
NOT(IS_POS) = 1 - IS_POS1 = 1-0 = 1

This is an old computer programming trick.

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.

So looking at FLOOR(x) again:
FLOOR(x) = x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_POS))

we have these switches on two very similar looking chunks of the equations-
First:
arccos(cos(x*2pi))/2pi

Second:
1-arccos(cos(x*2pi))/2pi

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.

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):
arccos(cos(3.00*2pi))/2pi = 0.00
arccos(cos(3.25*2pi))/2pi = 0.25
arccos(cos(3.50*2pi))/2pi = 0.50

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:
arccos(cos(3.60*2pi))/2pi = 0.40, but +1-0.40 = 0.60
arccos(cos(3.75*2pi))/2pi = 0.25, but +1-0.25 = 0.75
arccos(cos(3.90*2pi))/2p) = 0.10, but +1-0.10 = 0.90

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.

Ok, so we are all caught up on how it works, so let's use these blocks to make the CEIL function!

CEIL(x) = x+what?

Well, let's see what CEIL(x) should return (using 3.r again):
CEIL(3.00) = 3.00
CEIL(3.25) = 4.00
CEIL(3.50) = 4.00
CEIL(3.75) = 4.00
CEIL(4.00) = 4.00

So now, we need to add, but let's lookj at what we need to add:
CEIL(3.00) = 3.00, add 0.00
CEIL(3.25) = 4.00, add 0.75
CEIL(3.50) = 4.00, add 0.50
CEIL(3.75) = 4.00, add 0.25
CEIL(4.00) = 4.00, add 0.00

Well, it looks like we are adding 1-r (remember that r was the fractional part) so:
CEIL(x) = x+(1-(arccos(cos(x*2pi))/2pi))

Let's test it and make sure:
CEIL(3.25) = 3.25+(1-(arccos(cos(3.25*2pi))/2pi)) = 3.25+0.75 = 4.0, Good
CEIL(3.50) = 3.50+(1-(arccos(cos(3.50*2pi))/2pi)) = 3.50+0.50 = 4.0, Good
CEIL(3.75) = 3.75+(1-(arccos(cos(3.75*2pi))/2pi)) = 3.75+0.75 = 4.5, oops!
CEIL(4.00) = 4.00+(1-(arccos(cos(5.00*2pi))/2pi)) = 4.00+1.00 = 5.0, oops!

So what went wrong? Well, 2 things:
1) Integers (like 3.0 and 4.0) should stay as they are, not have 1 added to them
2) In the CEIL(3.75) example, the old cos function being cyclical thing got us again.

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.
So let's go crazy and create an IS_NEG function that is equal to 1 when sin(x*2pi) is negative or 0!

IS_NEG = 0^abs(-sin(x*2pi)-abs(sin(x*2pi)))

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).

This means that IS_NEG will equal 1 when sin(x*2pi) equals 0 or is negative. Perfect.

So let's work the rest of the peices out:

CEIL(x) = x+ (arccos(cos(x*2pi))/2pi)*IS_NEG + (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_NEG))


And there we go. A working CEIL(x) function.

Wednesday, August 12, 2009

FLOOR(X) - And so the saga continues...

So, the ultimate answer to the ultimate question of life, the universe and everything is...

Oops, wrong story.

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.

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?

Well, there is an odd, and little known, fact about exponents, that goes something like this:

x^0=1 (any number raised to the 0th power is 1)
0^x = 0 (0 raised to any power is zero)

putting these two equations at conflict. To solve this, it was determined that exponents actually take the form:



that says, recursively, start with 1, and then multiply x to it, y times. Here's an example:

5^3 = 1 * 5 *5 * 5 = 125
5^2 = 1 * 5 * 5 = 25
5^1 = 1 * 5 = 5
5^0 = 1

or for 0:

0^3 = 1 * 0 * 0 * 0 = 0
0^2 = 1 * 0 * 0 = 0
0^1 = 1 * 0 = 0
0^0 = 1

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.

Let me use an example to clarify:

Say I revisited my original goal to find an equation that would indicate if a number is an integer or not:

Well, thinking about the trig functions and the unit circle,

sin(n*pi) = 0

n representing only integers. Non integers will return a number other than 0. Again, an example to clarify:

sin( 0.0 * pi) = 0
sin( 0.5 * pi) = 1
sin( 1.0 * pi) = 0
sin( 1.5 * pi) = -1
sin( 2.0 * pi) = 0

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:

0^sin(x*pi)

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:

0^abs(sin(x*pi))

Viola!

So you get the jist of how this switch thingy-ma-bobber works, right? So back to the FLOOR(X) function. I currently have:

FLOOR(x) = x - (arccos(cos(2pi*x))/(2pi))

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:

0^abs(sin(x*2pi)-abs(sin(x*2pi)))

to tell me if sin(x*2pi) >= 0.

This works because:

arccos(cos(3.2*2pi))/2pi = 0.2 which requires us to subtract this result from the 3.2 to floor it.
arccos(cos(3.5*2pi))/2pi = 0.5 which requires us to subtract this result from the 3.5 to floor it.

but:

arccos(cos(3.6*2pi))/2pi = 0.4
arccos(cos(3.7*2pi))/2pi = 0.3
arccos(cos(3.8*2pi))/2pi = 0.2
arccos(cos(3.9*2pi))/2pi = 0.1

we now have to subtract 1-this result from the number we entered to floor it:

1-arccos(cos(3.6*2pi))/2pi = 0.6 and 3.6 - 0.6 = 3
1-arccos(cos(3.7*2pi))/2pi = 0.7 and 3.7 - 0.7 = 3
1-arccos(cos(3.8*2pi))/2pi = 0.8 and 3.8 - 0.8 = 3
1-arccos(cos(3.9*2pi))/2pi = 0.9 and 3.9 - 0.9 = 3

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.

So now we need the switch implimented:

x-arccos(cos(x*2pi))/2pi or x+1-arccos(cos(x*2pi))/2pi

to make it readable, I'm going to substitute the label IS_POS for the switch:

IS_POS = 0^abs(sin(x*2pi)-abs(sin(x*2pi)))

so we getsomething roughly like:

x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*(NOT(IS_POS))

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...

NOT(a) = 0^abs(a)

so you see, the equation can be written:

x- (arccos(cos(x*2pi))/2pi)*IS_POS - (1-arccos(cos(x*2pi))/2pi)*0^abs(IS_POS)

but NOT is more human readable.

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.