% These problems require arguments % Arguments: #1->a_2, #2->a_1 and #3->a_0 % (Arguments must be integers) \newcount\ctr \newproblem[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 \) } \newproblem[1]{diff:sin}{% \(f(x) = \sin(#1x)\) }{% \(f'(x) = #1\cos(#1x)\) }