summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/probsoln/samples/prob-args.tex
blob: 8276790feb6c52b0d05ae0a4d4bbf24e6875e59d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 % 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}