4:37 PM

Origin of Logs

Posted by pradeep T

Links
http://logbase2.blogspot.com/2007/12/log-base-2.html


History of Logarithms
Logarithms were invented independently by John Napier, a Scotsman, and by Joost Burgi, a Swiss. Napier's logarithms were published in 1614; Burgi's logarithms were published in 1620. The objective of both men was to simplify mathematical calculations. This approach originally arose out of a desire to simplify multiplication and division to the level of addition and subtraction. Of course, in this era of the cheap hand calculator, this is not necessary anymore but it still serves as a useful way to introduce logarithms. Napier's approach was algebraic and Burgi's approach was geometric. The invention of the common system of logarithms is due to the combined effort of Napier and Henry Biggs in 1624. Natural logarithms first arose as more or less accidental variations of Napier's original logarithms. Their real significance was not recognized until later. The earliest natural logarithms occur in 1618.
It can’t be said too often: a logarithm is nothing more than an exponent. The basic concept of logarithms can be expressed as a shortcut........ Multiplication is a shortcut for Addition: 3 x 5 means 5 + 5 + 5
Exponents are a shortcut for Multiplication: 4^3 means 4 x 4 x 4
Logarithms are a shortcut for Exponents: 10^2 = 100.
The present definition of the logarithm is the exponent or power to which a stated
number, called the base, is raised to yield a specific number.
The logarithm of 100 to the base 10 is 2. This is written: log10 (100) = 2.
Before pocket calculators — only three decades ago, but in “student years” that’s the age of dinosaurs — the answer was simple. You needed logs to compute most powers and roots with fair accuracy; even multiplying and dividing most numbers were easier with logs. Every decent algebra books had pages and pages of log tables at the back.
The invention of logs in the early 1600s fueled the scientific revolution. Back then scientists, astronomers especially, used to spend huge amounts of time crunching numbers on paper. By cutting the time they spent doing arithmetic, logarithms effectively gave them a longer productive life. The slide rule, once almost a cartoon trademark of a scientist, was nothing more than a device built for doing various computations quickly, using logarithms. See Eli Maor’s e: The Story of a Number for more on this.
Today, logs are no longer used in routine number crunching. But there are still good reasons for studying them. Why do we use logarithms, anyway?
• To find the number of payments on a loan or the time to reach an investment goal
• To model many natural processes, particularly in living systems. We perceive loudness
of sound as the logarithm of the actual sound intensity, and dB (decibels) are a logarithmic scale. We also perceive brightness of light as the logarithm of the actual light energy, and star magnitudes are measured on a logarithmic scale.
• To measure the pH or acidity of a chemical solution. The pH is the negative logarithm of the concentration of free hydrogen ions.
• To measure earthquake intensity on the Richter scale.
• To analyze exponential processes. Because the log function is the inverse of the
exponential function, we often analyze an exponential curve by means of logarithms. Plotting a set of measured points on “log-log” or “semi-log” paper can reveal such relationships easily. Applications include cooling of a dead body, growth of bacteria, and decay of a radioactive isotopes. The spread of an epidemic in a population often follows a modified logarithmic curve called a “logistic”.
• To solve some forms of area problems in calculus.
(The area under the curve 1/x, between x=1 and x=A, equals ln A.)

1:54 PM

Algos Problems

Posted by pradeep T

Prime number computation
topological sorting - library of machine parts- each part should be placed in the order of useage
dynamic programming - DNA Matching - (A,B,C,D,F) .. (B,C,D) close match
convex hull or convex envelope
discrete Fourier transforms

1:16 PM

Links for DS

Posted by pradeep T

http://cgm.cs.mcgill.ca/~godfried/teaching/algorithms-web.html
http://sbge.tripod.com/DSIndex.html
http://www.cs.berkeley.edu/~jrs/61b/lec/07
http://www.cs.auckland.ac.nz/~jmor159/PLDS210/ds_ToC.html

Finite automata
Computation Theory
Complexity Theory

1:12 PM

Smart pointers

Posted by pradeep T

To be smarter than regular pointers, smart pointers need to do things that regular pointers don't. What could these things be? Probably the most common bugs in C++ (and C) are related to pointers and memory management: dangling pointers, memory leaks, allocation failures and other joys. Having a smart pointer take care of these things can save a lot of aspirin...

The simplest example of a smart pointer is auto_ptr, which is included in the standard C++ library. You can find it in the header , or take a look at Scott Meyers' auto_ptr implementation. Here is part of auto_ptr's implementation, to illustrate what it does:

template class auto_ptr
{
T* ptr;
public:
explicit auto_ptr(T* p = 0) : ptr(p) {}
~auto_ptr() {delete ptr;}
T& operator*() {return *ptr;}
T* operator->() {return ptr;}
// ...
};
As you can see, auto_ptr is a simple wrapper around a regular pointer. It forwards all meaningful operations to this pointer (dereferencing and indirection). Its smartness in the destructor: the destructor takes care of deleting the pointer.