kids encyclopedia robot

Lookup table facts for kids

Kids Encyclopedia Facts

A lookup table (often called a LUT) is a special kind of list or chart that computers use to find answers very quickly. Instead of doing a long calculation every time, the computer just looks up the answer in the table. This is much faster, like looking up a word in a dictionary instead of trying to guess its meaning.

Imagine you have a big math problem that takes a long time to solve. If you know you'll need the answer to that problem many times, you could solve it once and write the answer down in a table. Then, every time you need it, you just look it up! Computers do the same thing with lookup tables. They can store these tables in their memory, ready to be used. Sometimes, these tables are even built directly into the computer's hardware for super-fast access. Lookup tables are also great for checking if something is valid, like seeing if a password is on a list of allowed passwords.

How Lookup Tables Started

Abramowitz&Stegun.page97.agr
Part of a 20th-century table of common logarithms in the reference book Abramowitz and Stegun.

People used lookup tables long before computers existed. For example, ancient mathematicians in India, like Aryabhata in 499 AD, created tables to quickly find values for trigonometry, which deals with triangles and angles. In 493 AD, a person named Victorius of Aquitaine made a huge multiplication table with 98 columns!

Even today, kids learn "times tables" (like 7x8=56) by heart. This is a simple form of a lookup table. You memorize the answers so you don't have to calculate them every time.

When computers were first invented, they were much slower at reading information from storage than they were at doing calculations. So, programmers would create lookup tables to store frequently used data. This way, the computer didn't have to wait for slow storage. Even with modern, super-fast computers, lookup tables can still make programs run quicker, especially for information that doesn't change often.

Lookup tables were also one of the first features in computer programs like spreadsheets. The very first spreadsheet, VisiCalc (from 1979), had a "LOOKUP" function. Later spreadsheets, like Microsoft Excel, added even more specialized lookup functions to make it easier to find data in rows or columns.

What Lookup Tables Can't Do

While lookup tables are super fast for finding information, they have some limits.

  • Too Much Memory: If you need a table for every possible answer to a very big problem, the table might become too huge to fit in the computer's memory. Imagine trying to make a lookup table for every single number in the world! That would be impossible.
  • Unique Keys: Each item in a lookup table needs its own unique "key" or "address" to be found. You can't have two different answers stored at the same spot.

For problems where the possible "keys" are too many, or where you might have duplicate keys, other methods like hash tables are often used instead.

Examples of Lookup Tables

Simple Lookups

Sometimes, a computer can use a number directly as an address to find an answer in a lookup table. This is incredibly fast because the computer doesn't have to do any complex searching. It just goes straight to the right spot. This can even be faster than other quick search methods.

Lookup Tables in Image Processing

Red Green Blue 16 bit Look up Table Sample
Red (A), Green (B), Blue (C) 16-bit lookup table file sample. (Lines 14 to 65524 not shown)

Lookup tables are very useful in image processing, which is how computers change or improve pictures. For example, if you have a black and white picture of a planet, you can use a lookup table to add colors. This makes it easier to see different features, like the rings of Saturn.

In image processing, these tables are often called LUTs (or 3DLUTs). They help decide what color and brightness each part of an image should have. A common type of LUT is called a colormap or palette, which tells the computer exactly how to display the colors in a picture.

Calculating Sine Values

A great example of using lookup tables to speed things up is when a computer needs to find the sine of a number. Sine is a value used in trigonometry, and calculating it with a mathematical formula can take a lot of computer power and time.

Instead, a computer can pre-calculate the sine for many different numbers (like for every degree from 0 to 360). It stores all these answers in a lookup table. When the program needs the sine of a value, it just looks it up in the table. If the exact value isn't in the table, the computer can guess a very close answer by looking at the values around it. This guessing method is called linear interpolation. It's like drawing a straight line between two points in the table to find a value in between.

Interpolation example linear
Linear interpolation on a portion of the sine function

Using lookup tables for calculations like sine can make computer programs run much faster, especially in things like computer graphics where many sine values are needed every second. In fact, a famous mistake in an early Intel computer chip (the Pentium FDIV bug) was caused by an error in its lookup table for division!

Lookup tables can also be used for functions with more than one input, like calculating "x to the power of y" (xy). For these, the table would be like a grid with rows and columns.

While lookup tables are great, they aren't always the best choice. If the calculation is very simple, it might actually be faster to just do the math than to look it up in a table. Also, if a lookup table is very big, it might take up too much memory or slow down the computer's cache, which is a special fast memory.

There are two main things that limit how big a lookup table can be:

  • Available Memory: The table can't be bigger than the memory the computer has.
  • Time to Create: It takes time to calculate all the values and build the table in the first place. Even if this only happens once, it might take too long for some uses.

Other Ways Lookup Tables Are Used

Caches

Computer caches (like the super-fast memory inside your computer's processor) work a lot like lookup tables. When your computer needs some data, it first checks a small, very fast cache. This cache has a lookup table that tells the computer if the data it needs is already stored there. If it is, the computer gets the data super fast without having to go to the slower main memory.

Hardware Lookup Tables

In digital logic, which is how computer circuits work, lookup tables can be built directly into the hardware. These are like tiny, super-fast electronic charts. For example, modern field-programmable gate arrays (FPGAs), which are special computer chips that can be reprogrammed, use these hardware lookup tables to create different electronic functions. An n-bit LUT can store the "truth table" for any n-input Boolean function, which is a basic building block of computer logic.

Data Control Systems

Lookup tables are also used in systems that collect data and control machines. They can help:

  • Calibrate Data: Correct measurements from sensors to make them more accurate.
  • Convert Units: Change measurements from one unit to another (like Celsius to Fahrenheit).
  • Perform Calculations: Do other specific calculations defined by the user.

See also

  • Associative array
  • Branch table
  • Gal's accurate tables
  • Memoization
  • Memory-bound function
  • Shift register lookup table
  • Palette, a.k.a. color lookup table or CLUT – for the usage in computer graphics
  • 3D lookup table – usage in film industry
kids search engine
Lookup table Facts for Kids. Kiddle Encyclopedia.