I have to say my fav fact is the multiplication by 11.
Let b1, b2, .... , bn be the digits of a number, then
b1*11 = b_1b_1
b1b2*11=b1(b1+b2)b2
b1b2b3*11=b1(b1+b2)(b2+b3)b3
[...]
b1b2...bn*11=b1(b2+b3)....(bn-1 + bn)bn
This "fun fact" could be proved by induction.
Friday, October 27, 2006
Wednesday, October 25, 2006
Monday, October 23, 2006
Googlism
While looking for scripts colorize python code into html I stumbled to googlism! You cant find xsignal on it just yet. But give it time. I also found the script I was looking for http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298/index_txt
Vector Fun
Here is a simple program to help you find the magnitude, dot product,
cross product of 2 vectors of size 3, and the projection vectors of each.
This is nothing ground breaking, but it shows you how fast you can code
something like this up in python with out much work. Some sample output:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
--------------------------------------------
ERROR: vectors entered are not the same size
--------------------------------------------
Vectors entered:
x = < 1 , 1 , 1 , 1 >
y = < -1 , 1 , -1 >
Magnitude of x is sqrt(4)=2.0
Magnitude of y is sqrt(3)=1.73205080757
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
Vectors entered:
x = < 3 , 2 , 1 >
y = < -1 , -2 , 4 >
Magnitude of x is sqrt(14)=3.74165738677
Magnitude of y is sqrt(21)=4.58257569496
Dot product of x and y is -3
The angle between x and y (in degrees) is: 1.74666507689
The cross product of x and y:
x cross y = < 10 , -13 , -4 >
The projection of y onto x:
proj_x(y) = < -9/14 , -3/7 , -3/14 >
The projection of x onto y:
proj_y(x) = < 1/7 , 2/7 , -4/7 >
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
Vectors entered:
x = < 0 , 1 >
y = < -1 , 0 >
Magnitude of x is sqrt(1)=1.0
Magnitude of y is sqrt(1)=1.0
Dot product of x and y is 0
The angle between x and y (in degrees) is: 1.57079632679
The projection of y onto x:
proj_x(y) = < 0 , 0 >
The projection of x onto y:
proj_y(x) = < 0 , 0 >
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
--------------------------------------------
ERROR: vectors entered are not the same size
--------------------------------------------
Vectors entered:
x = < 1 , 1 , 1 >
y = < -1 , 1 >
Magnitude of x is sqrt(3)=1.73205080757
Magnitude of y is sqrt(2)=1.41421356237
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
Vectors entered:
x = < 1 , 1 , 1 , 1 , 1 >
y = < -1 , 1 , -1 , 1 , -1 >
Magnitude of x is sqrt(5)=2.2360679775
Magnitude of y is sqrt(5)=2.2360679775
Dot product of x and y is -1
The angle between x and y (in degrees) is: 1.77215424759
The projection of y onto x:
proj_x(y) = < -1/5 , -1/5 , -1/5 , -1/5 , -1/5 >
The projection of x onto y:
proj_y(x) = < 1/5 , -1/5 , 1/5 , -1/5 , 1/5 >
Enter another pair of vectors [y/n]?
You did not enter a y/n so we exit anyways.
cross product of 2 vectors of size 3, and the projection vectors of each.
This is nothing ground breaking, but it shows you how fast you can code
something like this up in python with out much work. Some sample output:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
--------------------------------------------
ERROR: vectors entered are not the same size
--------------------------------------------
Vectors entered:
x = < 1 , 1 , 1 , 1 >
y = < -1 , 1 , -1 >
Magnitude of x is sqrt(4)=2.0
Magnitude of y is sqrt(3)=1.73205080757
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
Vectors entered:
x = < 3 , 2 , 1 >
y = < -1 , -2 , 4 >
Magnitude of x is sqrt(14)=3.74165738677
Magnitude of y is sqrt(21)=4.58257569496
Dot product of x and y is -3
The angle between x and y (in degrees) is: 1.74666507689
The cross product of x and y:
x cross y = < 10 , -13 , -4 >
The projection of y onto x:
proj_x(y) = < -9/14 , -3/7 , -3/14 >
The projection of x onto y:
proj_y(x) = < 1/7 , 2/7 , -4/7 >
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
Vectors entered:
x = < 0 , 1 >
y = < -1 , 0 >
Magnitude of x is sqrt(1)=1.0
Magnitude of y is sqrt(1)=1.0
Dot product of x and y is 0
The angle between x and y (in degrees) is: 1.57079632679
The projection of y onto x:
proj_x(y) = < 0 , 0 >
The projection of x onto y:
proj_y(x) = < 0 , 0 >
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
--------------------------------------------
ERROR: vectors entered are not the same size
--------------------------------------------
Vectors entered:
x = < 1 , 1 , 1 >
y = < -1 , 1 >
Magnitude of x is sqrt(3)=1.73205080757
Magnitude of y is sqrt(2)=1.41421356237
Enter another pair of vectors [y/n]?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Enter in vector x: (separated by spaces)
Enter in vector y: (separated by spaces)
Vectors entered:
x = < 1 , 1 , 1 , 1 , 1 >
y = < -1 , 1 , -1 , 1 , -1 >
Magnitude of x is sqrt(5)=2.2360679775
Magnitude of y is sqrt(5)=2.2360679775
Dot product of x and y is -1
The angle between x and y (in degrees) is: 1.77215424759
The projection of y onto x:
proj_x(y) = < -1/5 , -1/5 , -1/5 , -1/5 , -1/5 >
The projection of x onto y:
proj_y(x) = < 1/5 , -1/5 , 1/5 , -1/5 , 1/5 >
Enter another pair of vectors [y/n]?
You did not enter a y/n so we exit anyways.
Subscribe to:
Posts (Atom)