Skip to main content

Posts

Showing posts with the label COMPUTERS

ENCRYPTING AND DECRYPTING

    We are going to see one of the earliest method used in cryptography to send secret messages.  It was used by Julies Caesar and hence named Caesar cipher.        Here, each letter of the message is shifted forward by 3 places in the alphabet .  That is, A will become D, B will become E and so on. For quick reference;  Plain text:    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Cipher text: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C  So the message 'Welcome to my blog' encrypted as  'ZHOFRPH WR PB EORJ'   This is technically called mono alphabetic substitution cipher.  Here a shift of +3 is used.  But we could use a shift of +1 to +25.  A person who knows the algorithm (method) can only decipher the code and retrieve the message.  Suppose someone wants to break the code and get the message,  Is there a way? Yes, there is.       ...

DIGITAL LOGIC

  We know, if the switches A and B are closed in the above circuit, the bulb will light up.Even if one is open, the bulb is off.  Logically we can say,  if A and B are true, the output is true else the output is false.  In digital logic it can be written, "if A AND B are 1 the output is 1 else the output is 0".      The AND logic can be wired electronically.  Instead of switches we will be using automatic switches like diode and transistor.       Then we have OR  logic.  That is written as; "if either A OR B is 1 then output is 1" . ( If both are 0 then output is 0).    Next NOT  logic; here the input is reversed and given as output(0 to 1: 1 to 0 ).     NOT  and  AND  can be combined and it is called NAND logic.  NOT + OR  is called NOR  logic.      All this logic statements can be hard wired using electronic components and they are us...

ART OF PROGRAMMING

    Let us consider a simple BASIC program which checks marks of each student and count the number of students passed.  Using this program, we will try to learn the nuance of this art .      A program is made of three fundamental components namely 1. sequential flow 2. conditional flow, 3. repetitive flow. 1. Statements from line 10 to 40 are just flowing sequentially .  Line 10 is just a title.  Rem means remark. 20 initiates a counter.  Pass marks is fixed in 30.  In line 40, N stores number of students.  These statements are  executed one by one. 2. Line no. 50 to 80 is executed repeatedly .  That is, the statements 60 and 70 is executed 10 times since N =10.  Each time the control comes to line 60, it READs a value from DATA statement (line 90) and store it in "MARK". 3.  When the control comes to line 70,  it makes a decision .  If the mark is equal to or greater than pas...

"BITS" OF INFORMATION

  If a dog bites man, it is not a news.  If a man bites dog, it is a news.  Anything surprise is the news and an information.  If an event certainly is not going to occur then its probability of happening is 0 and it is not an information.  If an event is certainly going to happen then its probability is 1 and it is also not an information.      An event which is having probability between 0 and 1 carries some information.  For example:  In tossing of a coin getting a head or tail is having a 50% chance or 0.5 probability.  Out come of the toss is an information.  In the case of rolling of dice, each outcome has 1/6 chance or 0.167 probability.  Certainly the outcome of a  dice is  the surprise and an information.      Shannon gave a formula to calculate information content in an event based on probability.      I want to calculate the information content of coin ...

ROTATE AN IMAGE WITH A MATHS OPERATOR

   In Cartesian coordinates, we marked two points P and P1.  The coordinates of P is x, y and that of P1 is x1, y1.  Both are connected to the origin by straight lines.  They make angles A and B with the x-axis respectively.  The length of the lines connecting both the points to the origin is equal and it is   ' r'.  That means, P1 is rotation of the point P by an angle B .   From the figure we can write x = r*cosA y = r*sinA similarly, x1 = r*cos (A+B) y1 = r*sin (A+B) using trigonometry formula, we can expand the equations. x1 = r*(cosAcosB - sinAsinB) y1 = r*(sinAcosB+cosAsinB) If we substitute x=r*cosA and y= r*sinA in the above equations we get,  x1 = xcosB -ysinB y1 = xsinB+ycosB writing in matrix form,   So R(B) is a matrix rotation operator .  If we multiply coordinates of any point by the matrix operator R(B), the point will be rotated by an angle B and we will get the new coordinates ...

MONTE CARLO TECHNIQUE

  Imagine a square of unit side. Inscribe a quarter circle within the square.  The area of the square is  1 unit. The area of the quarter circle is pi/4 unit.      Let us randomly select N points within the square.  Out of N points, let C points fall within the circle.  Logically, the area of the square is proportional to N points and the area of the circle is proportional to C points .                                                   Circle:  pi/4  proportional  C                                                   Square: 1 proportional  N.                                    ...

INFORMATION STORAGE THROUGH TIME

   To our knowledge, first scripts were sculpted in stone slabs and walls.  Then letters were engraved in leafs, leathers, and metal sheets using nails and knives.  Next paper, ink, quills came.  Followed by nib, fountain pen, etc,.The major step is printing technology.  It revolutionized the news and information industry.           With the development of science,  storage was also developed. After the invention of cine films, pages were photographed and stored as microfilms.  Audio and video information were stored in plastic tapes using magnetization.  Even today, ATM cards, hard disc uses magnetization.      Next came the big digital revolution .  Here all the info. is represented in binary form.  The 0 and 1 is called binary digit or a bit .  8 bits or 16 bits make one byte .  Today we talk about info in terms of mega bytes and giga bytes.  Digital info has one m...

SIMULATION

    In a bank,  a customer may enter randomly.  He has to join a queue.  He has to wait for sometime before his turn comes.  Each customer may require 5 minutes of service.      The manager of the bank wants to know,  how to reduce the waiting time?  How many windows should be kept open?  What is the average waiting time for a customer? etc,.       One may write a computer program to simulate the queue situation in the bank and get answers.           We have to simulate the situation minute by minute.                                                   ROUGH ALGORITHM A minute begins: A customer may arrive(based on a random number) If the customer arrives, we have to increase the length of the queue by 1 . A customer is being served (duration of 5 mi...

CELLULAR AUTOMATA

    Let us make a row of 5 cells and fill it with binary numbers as in figure 1. Only the center cell contains " 1 " and all other cells have " 0 s".   Now let us frame one rule and start a game.  Rule:  " If either one of a cell's  neighbors are 1, but not both, then the corresponding cell the next row will get 1 otherwise it will have 0 ".  .    Refer figure 2.  First cell do not have neighbors of 1, so first cell in the second row get 0.  Second cell's right neighbour is 1.  Hence the corresponding cell in the second row gets 1.  Proceeding with the rule, we can fill up the second row.   Apply the rule and create up to 4 rows. Blacken the cells having 1 and leave the cells with 0s blank. So a pattern is starting to emerge.(figure 3&4)      If we add more rows and more cells( a computer program is suitable), the pattern as given in the figure 5 appears.  Oh, it is sierpinski tri...

THE ANCIENT ALGORITHM

   I have two numbers and I want to find the greatest common divisor (GCD) for them.  Then, I have to find all the factors of two numbers and select "the common big one" from both the set of factors.  It will be a tedious task for very big numbers.        There is a sleek procedure(algorithm) to do this .  This algorithm is devised by euclid in 300 B.C.   Let us find out GCD for 30 and 18 in euclid's way .        Divide the big integer by the small integer and get the remainder.         30 MOD 18 = 12 .    Now divide the divisor 18 by the remainder 12 and get the new remainder.         18 MOD 12 = 6 .    Next again, divide the divisor 12 by the remainder 6 and get the fresh remainder.         12 MOD 6 = 0      6 must be the GCD of 30 and 18  because it is derived from both the integers by repeated divisi...

WHY SHOULD LIGHT BEND?

     put a spoon in a glass which is half filled with water.  The spoon looks bent, because light traveling from air to water is bent(refracted).  why should light refract?      When light waves travel in a denser medium like water and glass, its slows down.  like we slow down, when we move into a knee deep water.       If all the light waves travels straight(perpendicular to the line of separation of two media) and enter the denser medium, the wave speed will decrease, but they will go undeviated.      But if the waves enter the line of separation at an angle (obliquely), part of the first wave front will enter the denser medium and" that part " will be slowed down; remaining part will move with original speed in the first medium.  This process causes the wavefront to bend.  similarly all the waves that follow will bend (when they enter) and follow a different path in the denser medium. ...

COMPUTER KNOWS ADDITION ONLY!

      We know there are four fundamental operations namely addition, subtraction, multiplication, and division.  Multiplication is the repeated addition and division is the repeated subtraction.  So we are left with only two fundamental operations addition and subtraction.  But subtraction can be done in terms of addition as follows.  To subtract 6 from 9 . get the 10's compliment of 6, which is 10-6 = 4 . add the 9 and the compliment     9+4 = 13 . then drop the carry 1 3 = 3 which is the answer.     So we require only addition .       In computers, all numbers are represented in binary. That is, in 0's and  1's .  So 1's compliment is 0 and 0's compliment is 1.  Hence computer does the subtraction in terms of addition easily.        Computer does all the mathematical operations using addition only.  It is easy for computers not for humans.