[Tex/LaTex] Type multiline equation in a table in LaTeX

tables

Who knows the way to write a multiline equation in a table? I am using the code below:

\begin{table} 
\centering 
\begin{tabular}{|c| c| c|}
\hline %inserts horizontal line

&f1& f2 \\ [0.5ex] 
\hline 
a& b& c\\ \hline 
d& e & f  \hline 
\end{tabular}
\label{label 1}
\end{table}

But b and e are two or maybe three line equations. How can I write them in my table?

Best Answer

\documentclass[letterpaper]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{table} 
\centering 
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{|c| c| c|}
\hline %inserts horizontal line
&f1& f2 \\[0.5ex] 
\hline 
a& $\begin{array} {lcl} f(x) & = & (a+b)^2 \\ & = & a^2+2ab+b^2 \end{array}$ & c\\ 
\hline 
d& $\begin{array} {r@{}l@{}} f(x) & {}= (a+b)^2 \\ & {}= a^2+2ab+b^2 \end{array}$ & f\\    \hline 
g& $\begin{aligned} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \end{aligned}$ &h \\ \hline 
\end{tabular}
\label{label 1}
\end{table}
\end{document}

The above code yields:

enter image description here

I know it is not the best but I hope it answers your question. I edited the answer as per Peter Grill's suggestion. It is a better math display.