Archive

Archive for the ‘Mathematics’ Category

Using non-standard bases

January 4th, 2010 1 comment

There are a number of different bases, or radices. Most of us use the decimal positional numeral system, i.e. base 10 for our everyday jobs. When it comes to computers most people use the binary, the hexadecimal or even the octal numeral system. However, there are a number of different “unusual” bases.

For example, there are negative bases. An example is the negadecimal positional numeral system, that is using the base -10. Converting a number from base -10 to base 10 is as simple as:

d_1d_2d_3d_4\ _{(-10)} = d_1(-10)^3 + d_2(-10)^2 +d_3(-10)^1 + d_4(-10)^0

But why use such a base? It’s very simple, you can represent any number you want, positive or negative, without using a sign. For example:

-1_{(10)} = 1(-10)^1 + 9(-10)^0 = 19_{(-10)}

The conversion from decimal to negadecimal is pretty simple. You continuously divide by -10 and keep the remainder as you would do with any other positional numeral system. For example:

-256 = 26 * (-10) + 4

26 = -2 * (-10) + 6

-2 = 1 * (-10) + 8

1 = 0 * (-10) + 1

So -256_{10} = 1864_{-10} . Converting a positive number is done the same way too.

256 = -25 * (-10) + 6

-25 = 3 * (-10) + 5

3 = 0 * (-10) + 3

So 256_{(10)} = 356_{(-10)} . As you can see, there is no need for a sign symbol. And when using the negabinary numeral system there is no problem with signed and unsigned integers since there is no need for a sign bit!

But a negative base isn’t the only non-standard base. You can use complex numbers as bases too. This way there is no need to use a real and an imaginary part to represent a complex number. An example of such a base is -1 + i where of course i^2 = -1 . A number can then have the form

d_1d_2d_3d_4 = d_1(-1 + i)^3 + d_2(-1 + i)^2 + d_3(-1 + i)^1 + d_4(-1 + i)^0, d_i \in {0,1}

Using this base you can represent any complex you want without using the i symbol.

Converting from this base to decimal is pretty simple, however the reverse is a little bit difficult. What you do for the convertion is divide continuously with -1 + i as usual. The remainder will always be 0 or 1 . So, if the quotient is q = q_1 + q_2i then:

a + bi = (q_1 + q_2i)(-1 + i) + r

a + bi = -q_1 + q_1i - q_2i - q_2 + r

a + bi = (-q_1 - q_2 + r) + (q_1 - q_2)i

-q_1 - q_2 + r = a

q_1 - q_2 = b

q_1 = \frac{b - a + r}{2}

q_2 = \frac{-b - a + r}{2}

That means that if a and b are both odd or even, then r = 0 , otherwise r = 1 . Then we continue the division of the quotient as usual.

Now let’s calculate the value of 2.

2 has both the real and imaginary part even, so r = 0 .

\frac{2}{-1 + i} = \frac{2(-1 - i)}{(-1 + i)(-1 - i)} = -1 - i

The real and imaginary part are both odd, so r = 0 again.

\frac{-1 - i}{-1 + i} = \frac{(-1 - i)(-1 - i)}{(-1 + i)(-1 - i)} = i

Since the real part is even and the imaginary is odd, r = 1 . So, we can divide by the number minus 1 and the remainder will be 0.

\frac{i - 1}{-1 + i} = 1

Now, the real part is odd and the imaginary is even. So again r = 1 . We divide by 1 - 1 so,

\frac{1 - 1}{-1 + i} = 0

We now stop since q = 0 . So we have 2_{(10)} = 1100_{(-1 + i)} . Pretty cool!

Categories: Mathematics Tags:

Zero to the zero power at google, wolfram alpha and others

August 23rd, 2009 1 comment

Yesterday I was trying some features of the google search engine such as the built-in calculator. After trying some simple functions that it supports, I wanted to see its limitations.

First, I tried searching for 1 / 0 or ln(0) in order to see if it has support for infinity. The calculator didn’t even show up to return results, even if searches with a similar format that don’t return infinity such as 4 / 2 and ln(e) returned the correct result. So, google calculator supports infinity but doesn’t inform you about it when it is the result of a calculation.

Then I tried searching for something that is an indeterminate form, such as 0^0 . And the result given by google when searching for 0 ^ 0 was 1! I then tried the same query at Wolfram Alpha which uses the mathematica engine and I got the correct result, indeterminate. EDIT: I made a HUGE error trying to fool the mathematica engine and I fooled myself!!! Thanks to my readers I had the chance to fix it! Still, I wasn’t satisfied and I wanted to see if I could fool it. First I had to find something that is equal to 0 but doesn’t look like this. I decided to use e^{-\frac{1}{x}} which is equal to 0 when x equals 0. Then I tried to evaluate (e^{-\frac{1}{x}})^x , i.e. 0^0 for x = 0. The query I used was (e^(-1/x))^x which returned a lot of information for this function. One thing that I noticed is that it stated «Alternate form assuming all variables are real: \frac{1}{e} ». Since 0 is real, by substituting in the function we get 0^0 = \frac{1}{e} ! To be honest I didn’t believe that the mathematica engine would fail here and it would be difficult to fool it but it seems I was wrong!

After all these I made some tests to see what real calculator programs return when computing 0^0 . Some results are given below:

  • Libc 2.9
    pow, powf, powl return 1
    Since this returns 1 many of the following will return 1 too
  • Perl 5.10.0
    0**0 returns 1
  • Python 2.5.4
    0**0 returns 1
  • Bash 3.2.48
    $((0**0)) returns 1
  • XCalc from X.Org 7.4
    0 x^y 0 returns 1
  • Kcalc 2.5 using kde 4.3.0
    0 x^y 0 returns nan! Well done!
  • Windows calculator 5.1 from windows xp with sp3
    0 x^y 0 returns 1
  • Mac OS X calculator version 4.0
    0 y^x 0 returns 1
Categories: Google, Mathematics, Wolfram Alpha Tags:
SEO Powered by Platinum SEO from Techblissonline

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close