 % This file is public domain
 %
 % These problems require arguments
%
 % Arguments: #1->a_2, #2->a_1 and #3->a_0
 % (Arguments must be integers)
\newcount\ctr
\newproblem[3][{1}{2}{3}]{diff:quad}{%
\(f(x) = 
\ifnum#1=0
\else
\ifnum#1=1\else#1\fi x^2 
\fi
\ifnum#2=0
\else
\ifnum#2>0 \ifnum#1=0 \else + \fi \fi
\ifnum#2=1\else#2\fi x 
\fi
\ifnum#3=0
\else
\ifnum#3>0 \ifnum#2=0 \ifnum#1=0 \else + \fi \else + \fi\fi
#3
\fi\)
}{%
\(f'(x) = 
\ifnum#1=0
\else
\ctr=2
\multiply\ctr by #1
\the\ctr x 
\fi
\ifnum#2=0
\else
\ifnum#2>0 \ifnum#1=0 \else + \fi \fi
#2
\fi
 % print 0 if both #1 and #2 are 0
\ifnum#1=0 \ifnum#2=0 0 \fi\fi 
\)
}

\begin{defproblem}[1][{6}]{diff:sin}
\begin{onlyproblem}
  \(f(x) = \sin(#1x)\)
\end{onlyproblem}
\begin{onlysolution}
  \(f'(x) = #1\cos(#1x)\)
\end{onlysolution}
\end{defproblem}
