What is the simplest way to make a command that produces a quadratic expression?

\documentclass{article}
\usepackage{polynomial}

\begin{document}
$\polynomial{\frac12,0,-1,1}$

$\polynomial[reciprocal]{\frac12,0,-1,1}$
\end{document}

alt text

See manual of polynomial for more options.

http://www.ctan.org/tex-archive/help/Catalogue/entries/polynomial.html


\documentclass{article}
\usepackage{amsmath}

\def\MinusOne{-1}
\newcommand\qec[4][x]{%
  \ifx\relax#2\relax\else\def\temp{#2}
    \ifx\temp\MinusOne -\else #2\fi#1^2\fi
  \ifx\relax#3\relax\else\def\temp{#3}
    \ifx\temp\MinusOne -\else+#3\fi#1\fi
  \ifx\relax#4\relax\else+ #4\fi}
\begin{document}

\begin{align}
\qec{a}{b}{c}\\
\qec[y]{-1}{}{-c}\\
\qec[y]{-1}{}{}\\
\qec{}{1}{2}
\end{align}

\end{document}

Tags:

Macros