| 1 |
% This file is public domain |
| 2 |
% |
| 3 |
% These problems require arguments |
| 4 |
% |
| 5 |
% Arguments: #1->a_2, #2->a_1 and #3->a_0 |
| 6 |
% (Arguments must be integers) |
| 7 |
\newcount\ctr |
| 8 |
\newproblem[3][{1}{2}{3}]{diff:quad}{% |
| 9 |
\(f(x) = |
| 10 |
\ifnum#1=0 |
| 11 |
\else |
| 12 |
\ifnum#1=1\else#1\fi x^2 |
| 13 |
\fi |
| 14 |
\ifnum#2=0 |
| 15 |
\else |
| 16 |
\ifnum#2>0 \ifnum#1=0 \else + \fi \fi |
| 17 |
\ifnum#2=1\else#2\fi x |
| 18 |
\fi |
| 19 |
\ifnum#3=0 |
| 20 |
\else |
| 21 |
\ifnum#3>0 \ifnum#2=0 \ifnum#1=0 \else + \fi \else + \fi\fi |
| 22 |
#3 |
| 23 |
\fi\) |
| 24 |
}{% |
| 25 |
\(f'(x) = |
| 26 |
\ifnum#1=0 |
| 27 |
\else |
| 28 |
\ctr=2 |
| 29 |
\multiply\ctr by #1 |
| 30 |
\the\ctr x |
| 31 |
\fi |
| 32 |
\ifnum#2=0 |
| 33 |
\else |
| 34 |
\ifnum#2>0 \ifnum#1=0 \else + \fi \fi |
| 35 |
#2 |
| 36 |
\fi |
| 37 |
% print 0 if both #1 and #2 are 0 |
| 38 |
\ifnum#1=0 \ifnum#2=0 0 \fi\fi |
| 39 |
\) |
| 40 |
} |
| 41 |
|
| 42 |
\begin{defproblem}[1][{6}]{diff:sin} |
| 43 |
\begin{onlyproblem} |
| 44 |
\(f(x) = \sin(#1x)\) |
| 45 |
\end{onlyproblem} |
| 46 |
\begin{onlysolution} |
| 47 |
\(f'(x) = #1\cos(#1x)\) |
| 48 |
\end{onlysolution} |
| 49 |
\end{defproblem} |