Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

Wednesday, December 3, 2008

High-precision math

I was wondering a couple of months ago about how to achieve accuracy in floating-point computations such as say, try to multiple 4.34524362 with 2.456357642456 while we know that there is only finite precision that can be provided by programming languages. A way around this problem was to save the values as strings and multiple two strings rather than two numbers - so you won't be able to multiply two "values" a and b as a*b but you multiply them as multiply(a,b). Using operator overloading, even a*b can easily be achieved. Now, what I have done so far is +,-,*,/, factorial, combinations on integers and being too lazy, I only implemented the * functions on floating-point values. The implementation works for extremely large values (as high as the compiler would support for a string - which is pretty high :D)

The math_library.cpp (right click and choose "save target as") can be used by anyone but NOT for commercial purposes.

Sunday, October 7, 2007

G2 numbers

a couple of months ago, Faiq reminded me of a puzzle in endgame in times of india -

find a number n such that if the last digit is moved to first digit, the value is doubled.

eg if n=1234, you move 4 to the front and n becomes 4123 but 4123 is not equal to 1234*2

i had posted one solution to the paper about 5/6 years back using rudimentary approach.

but being the super-geek-nerd phd student, i derived the root family of such numbers (8 such

numbers only) along with a proof that a concatenation of any such number n (n n n.....)

is also a member of the family. so there are infinite such numbers - proof is here :)

the sad thing was, when i contacted the global math repository people, turns out somebody

already proved this 20 years back - damn you, mathematicians :'(