From 7a01b2f895cca6398088b5ec490c896dee03d2fd Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 20 Jul 2006 18:47:23 +0000 Subject: probsoln update (3mar06) git-svn-id: svn://tug.org/texlive/trunk@1885 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/probsoln/1stprncp.tex | 91 ++ Master/texmf-dist/doc/latex/probsoln/CHANGES | 10 + Master/texmf-dist/doc/latex/probsoln/README | 47 +- Master/texmf-dist/doc/latex/probsoln/args.tex | 72 ++ Master/texmf-dist/doc/latex/probsoln/easy.tex | 115 ++ Master/texmf-dist/doc/latex/probsoln/implicit.tex | 71 ++ Master/texmf-dist/doc/latex/probsoln/manual.html | 742 ++++++++++++ Master/texmf-dist/doc/latex/probsoln/mchoice.tex | 65 + Master/texmf-dist/doc/latex/probsoln/probsoln.html | 293 ----- Master/texmf-dist/doc/latex/probsoln/probsoln.pdf | Bin 124325 -> 152103 bytes Master/texmf-dist/doc/latex/probsoln/sample.tex | 66 +- Master/texmf-dist/doc/latex/probsoln/sample2.tex | 68 ++ Master/texmf-dist/doc/latex/probsoln/sample3.tex | 54 + Master/texmf-dist/doc/latex/probsoln/sample4.tex | 44 + .../doc/latex/probsoln/samples/1stprncp.tex | 61 - .../texmf-dist/doc/latex/probsoln/samples/args.tex | 45 - .../texmf-dist/doc/latex/probsoln/samples/easy.tex | 84 -- .../doc/latex/probsoln/samples/implicit.tex | 41 - .../texmf-dist/doc/latex/probsoln/tabmchoice.tex | 43 + .../texmf-dist/source/latex/probsoln/probsoln.dtx | 1274 ++++++++++++++++---- .../texmf-dist/source/latex/probsoln/probsoln.ins | 42 +- Master/texmf-dist/tex/latex/probsoln/probsoln.sty | 191 +-- Master/texmf/lists/probsoln | 16 +- 23 files changed, 2659 insertions(+), 876 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/probsoln/1stprncp.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/CHANGES create mode 100644 Master/texmf-dist/doc/latex/probsoln/args.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/easy.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/implicit.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/manual.html create mode 100644 Master/texmf-dist/doc/latex/probsoln/mchoice.tex delete mode 100644 Master/texmf-dist/doc/latex/probsoln/probsoln.html create mode 100644 Master/texmf-dist/doc/latex/probsoln/sample2.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/sample3.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/sample4.tex delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/args.tex delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/easy.tex delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex create mode 100644 Master/texmf-dist/doc/latex/probsoln/tabmchoice.tex (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/probsoln/1stprncp.tex b/Master/texmf-dist/doc/latex/probsoln/1stprncp.tex new file mode 100644 index 00000000000..d7ccacdcda3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/1stprncp.tex @@ -0,0 +1,91 @@ +%% +%% This is file `1stprncp.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `1stprncp.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} + +\newproblem{dfp:xcube}{% +Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{% +\begin{eqnarray*} +\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\ + & = & 3x^2 +\end{eqnarray*}} + +\newproblem{dfp:Ioverxsq}{% +Differentiate $\displaystyle f(x) = \frac{1}{x^2}$ with respect to $x$ by first principles.}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{1}{(x+\Delta x)^2}-\frac{1}{x^2}}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{x^2-(x+\Delta x)^2}{x^2(x+\Delta x)^2}}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{x^2-(x^2+2x\Delta x+(\Delta x)^2)}{x^2\Delta x(x+\Delta x)^2}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{-2x\Delta x-(\Delta x)^2}{x^2\Delta x(x+\Delta x)^2}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{-2x-\Delta x}{x^2(x+\Delta x)^2}\\ + & = & \frac{-2x}{x^2x^2}\\ + & = & -\frac{2}{x^3} +\end{eqnarray*}} + +\newproblem{dfp:sqrtx}{% +Differentiate from first principles $f(x) = \surd x$}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\sqrt{x+\Delta x}-\surd x}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{(\sqrt{x+\Delta x}-\surd x)(\sqrt{x+\delta x}+\surd x)}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{x+\Delta x - x}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{\Delta x}{\Delta x(\sqrt{x+\Delta x}+\Delta x)}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{1}{\sqrt{x+\Delta x}+\surd x}\\ + & = & \frac{1}{2\surd x} +\end{eqnarray*}} + +\newproblem{dfp:cons}{% +Differentiate from first principles $f(x) = c$ where $c$ is a constant.}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{c-c}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}0\\ + & = & 0 +\end{eqnarray*}} + +\newproblem{dfp:cosx}{% +Given +\begin{eqnarray*} +\lim_{x \rightarrow 0} \frac{\cos x - 1}{x} & = & 0\\ +\lim_{x \rightarrow 0} \frac{\sin x}{x} & = & 1 +\end{eqnarray*} +differentiate from first principles $f(x) = \cos x$.}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) - f(x)}{\Delta x}\\ + & = & \lim_{\Delta x \rightarrow 0} \frac{\cos(x + \Delta x) - \cos(x)}{\Delta x}\\ + & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x\cos\Delta x - \sin x\sin\Delta x - \cos x}{\Delta x}\\ + & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x(\cos\Delta x - 1) - \sin x\sin\Delta x}{\Delta x}\\ + & = & \cos x\lim_{\Delta x \rightarrow 0}\frac{\cos\Delta x - 1}{\Delta x} + - \sin x\lim_{\Delta x \rightarrow 0}\frac{\sin\Delta x}{\Delta x}\\ + & = & -1 \qquad\mbox{(using given results)} +\end{eqnarray*}} +\endinput +%% +%% End of file `1stprncp.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/CHANGES b/Master/texmf-dist/doc/latex/probsoln/CHANGES new file mode 100644 index 00000000000..288adf8bb83 --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/CHANGES @@ -0,0 +1,10 @@ +probsoln package versions: + +Version 2.02: Added \selectallproblems which selects all the problems +in a given database, in the order in which they were defined. + +Version 2.01: Provided means to customise the way in which randomly +selected problems are displayed. Added \doforrandN command (like \@for +but for a random subset of the specified list.) Added \random command +which stores a random number in the given range in the specified +counter. diff --git a/Master/texmf-dist/doc/latex/probsoln/README b/Master/texmf-dist/doc/latex/probsoln/README index fccd89989bd..77653261977 100644 --- a/Master/texmf-dist/doc/latex/probsoln/README +++ b/Master/texmf-dist/doc/latex/probsoln/README @@ -1,36 +1,49 @@ -LaTeX Package : probsoln v 2.0 +LaTeX Package : probsoln v 2.02 -Last Modified : 21 Mar 2001 +Last Modified : 2 Mar 2006 -Author : N.L.C. Talbot +Author : Nicola L.C. Talbot Files : probsoln.dtx - documented source file probsoln.ins - installation script - sample.tex - example file - samples - directory containing files used in sample.tex - -The package probsoln.sty is designed for lecturers who have to generate -new problem sheets for their students on a regular basis (e.g. yearly) -by randomly selecting a specified number of problems defined in another file. -This means that you can easily generate a new problem sheet that is different -from the previous year, thus alieviating the temptation of students to seek -out the previous year's students and checking out their answers. -The solutions to the problems can be defined along with the problem, making -it easy to generate the solution sheet from the same source code. +The package probsoln.sty is designed for lecturers who have +to generate new problem sheets for their students on a +regular basis (e.g. yearly) by randomly selecting a +specified number of problems defined in another file. +This means that you can easily generate a new problem sheet +that is different from the previous year, thus alieviating +the temptation of students to seek out the previous year's +students and checking out their answers. The solutions to +the problems can be defined along with the problem, making +it easy to generate the solution sheet from the same source +code. To extract the code do: latex probsoln.ins +This will create the file probsoln.sty which should be placed +somewhere on your TeX path. It will also create several +sample documents, sample*.tex, and sample databases used +by the sample documents. If you can't bring yourself to +read the manual, please try out these sample +documents to give yourself an idea of what to do. + To extract the documentation do: latex probsoln.dtx latex probsoln.dtx -A sample file, sample.tex which loads in problems from samples/*.tex, is provided to illustrate -the use of this package. +Comment out \OnlyDescription if you want the documented code. + +If you experience difficulties, try reading the +troubleshooting section of the manual. If that doesn't +help try +http://theoval.cmp.uea.ac.uk/~nlct/latex/packages/faq/ -This material is subject to the LaTeX Project Public License. See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for +the details of that license. http://theoval.cmp.uea.ac.uk/~nlct/ diff --git a/Master/texmf-dist/doc/latex/probsoln/args.tex b/Master/texmf-dist/doc/latex/probsoln/args.tex new file mode 100644 index 00000000000..af1ee73778b --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/args.tex @@ -0,0 +1,72 @@ +%% +%% This is file `args.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `args.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} + +\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 +\ifnum#1=0 \ifnum#2=0 0 \fi\fi +\) +} + +\newproblem[1]{diff:sin}{% +\(f(x) = \sin(#1x)\) +}{% +\(f'(x) = #1\cos(#1x)\) +} + +\endinput +%% +%% End of file `args.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/easy.tex b/Master/texmf-dist/doc/latex/probsoln/easy.tex new file mode 100644 index 00000000000..dd2d1ba160b --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/easy.tex @@ -0,0 +1,115 @@ +%% +%% This is file `easy.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `easy.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} + +\newproblem{diffeasy:gpowh}{% +\(f(x) = g(x)^{h(x)}.\)}{% +\begin{eqnarray*} +f(x) & = & e^{\ln g(x)^{h(x)}}\\ + & = & e^{h(x)\ln g(x)}\\ +f'(x) & = & e^{h(x)\ln g(x)}(h'(x)\ln g(x) + h(x)\frac{g'(x)}{g(x)})\\ + & = & g(x)^{h(x)}(h'(x)\ln g(x) + \frac{h(x)g'(x)}{g(x)}) +\end{eqnarray*}} + +\newproblem{diffeasy:arcsin}{% +\(y = \arcsin(x)\)}{% +\[\sin(y) = x\] +diff. w.r.t. $x$: +\begin{eqnarray*} +\cos y \frac{dy}{dx} & = & 1\\ +\frac{dy}{dx} & = & \frac{1}{\cos y}\\ + & = & \frac{1}{\sqrt{1 - \sin^2y}}\\ + & = & \frac{1}{\sqrt{1-x^2}}. +\end{eqnarray*}} + +\newproblem{diffeasy:arccos}{% +$y = \arccos x$.}{% +\(\cos y = x\) +diff. w.r.t. $x$: +\begin{eqnarray*} +-\sin y \frac{dy}{dx} & = & 1\\ +\frac{dy}{dx} & = & \frac{-1}{\sin y}\\ + & = & \frac{-1}{\sqrt{1-\cos^2y}}\\ + & = & \frac{-1}{\sqrt{1-x^2}} +\end{eqnarray*}} + +\newproblem{diffeasy:tan}{% +\(y = \tan x\)}{% +\begin{eqnarray*} +y & = & \tan x\\ + & = & \frac{\sin x}{\cos x}\\ +\frac{dy}{dx} & = & \frac{\cos x}{\cos x} + \sin x\times\frac{-1}{\cos^2x}\times -\sin x\\ + & = & 1 + \tan^2x\\ + & = & \sec^2x. +\end{eqnarray*}} + +\newproblem{diffeasy:arctan}{% +\(y = \arctan x = \tan^{-1}x\)}{% +\[\tan y = x\] +diff w.r.t. $x$: +\begin{eqnarray*} +\sec^2y\frac{dy}{dx} & = & 1\\ +\frac{dy}{dx} & = & \frac{1}{\sec^2y}\\ + & = & \frac{1}{1+\tan^2y}\\ + & = & \frac{1}{1+x^2} +\end{eqnarray*}} + +\newproblem{diffeasy:cot}{% +\(y = (\tan x)^{-1} = \cot x\)}{% +\begin{eqnarray*} +\frac{dy}{dx} & = & -(\tan x)^{-2}\sec^2x\\ + & = & -\frac{\cos^2x}{\sin^2x}\cdot\frac{1}{\cos^2x}\\ + & = & \frac{-1}{\sin^2x}\\ + & = & -\csc^2x. +\end{eqnarray*}} + +\newproblem{diffeasy:cosxsqsinx}{% +$y = \cos(x^2)\sin x$.}{% +\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]} + +\newproblem{diffeasy:xlnx}{% +$y = (x+1)\ln(x+1)$.}{% +\begin{eqnarray*} +\frac{dy}{dx} & = & \ln(x+1) + \frac{x+1}{x+1}\\ + & = & 1 + \ln(x+1). +\end{eqnarray*}} + +\newproblem{diffeasy:glng}{% +$f(x) = g(x)\ln(g(x))$.}{% +\begin{eqnarray*} +f'(x) & = & g'(x)\ln(g(x)) + \frac{g(x)}{g(x)}g'(x)\\ + & = & g'(x)(1+\ln(g(x))). +\end{eqnarray*}} + +\newproblem{diffeasy:sinx/x}{% +$y = \frac{\sin x}{x}$.}{% +\[\frac{dy}{dx} = \frac{\cos x}{x} - \frac{\sin x}{x^2}\]} + +\endinput +%% +%% End of file `easy.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/implicit.tex b/Master/texmf-dist/doc/latex/probsoln/implicit.tex new file mode 100644 index 00000000000..f6b706871cd --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/implicit.tex @@ -0,0 +1,71 @@ +%% +%% This is file `implicit.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `implicit.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} + +\newproblem{imd:circ}{% +Find the gradient of the unit circle ($x^2 + y^2 = 1$).}{% +Differentiating with respect to $x$ gives: +\begin{eqnarray*} +2x + 2y\frac{dy}{dx} & = & 0\\ +\frac{dy}{dx} & = & \frac{-2x}{2y}\\ + & = & \frac{-x}{\sqrt{1-x^2}}. +\end{eqnarray*}} + +\newproblem{imd:ysq:xcuov2mx}{% +Find $\frac{dy}{dx}$, given +\begin{displaymath} +y^2 = \frac{x^3}{2-x} +\end{displaymath}}{% +Differentiating both sides w.r.t.\ $x$: +\begin{eqnarray*} +2y\frac{dy}{dx} & = & \frac{(2-x)3x^2 - x^3(-1)}{(2-x)^2}\\ + & = & \frac{3x^2(2-x) + x^3}{(2-x)^2}\\ + & = & \frac{6x^2 - 3x^3 + x^3}{(2-x)^2}\\ + & = & \frac{6x^2-2x^3}{(2-x)^2}\\ + & = & 2x^2\frac{3-x}{(2-x)^2} +\end{eqnarray*} +Therefore +\begin{displaymath} +y\frac{dy}{dx} = x^2\frac{3-x}{(2-x)^2} +\end{displaymath}} + +\newproblem{imd:exy:IIxay}{% +Differentiate w.r.t.\ $x$: +\begin{displaymath} +e^{xy} = 2x + y +\end{displaymath}}{% +Differentiating both sides w.r.t.\ $x$: +\begin{eqnarray*} +e^{xy}(1y + x\frac{dy}{dx}) & = & 2 + \frac{dy}{dx}\\ +xe^{xy}\frac{dy}{dx} - \frac{dy}{dx} & = & 2 - ye^{xy} \\ +\frac{dy}{dx}(xe^{xy}-1) & = & 2 - ye^{xy}\\ +\frac{dy}{dx} & = & \frac{2-ye^{xy}}{xe^{xy}-1} +\end{eqnarray*}} +\endinput +%% +%% End of file `implicit.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/manual.html b/Master/texmf-dist/doc/latex/probsoln/manual.html new file mode 100644 index 00000000000..8ba716bf93d --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/manual.html @@ -0,0 +1,742 @@ + + + + + +probsoln.sty v2.02: LATEX2e Package to help create problem sheets + + + + + + + + + + + + +Dr Nicola Talbot +| +School of Computing Sciences +| +University of East Anglia + +

+ +

probsoln.sty v2.02: LATEX2e Package to help create problem sheets

+
+ +

Nicola L.C. Talbot

+

2nd March 2006

+
+
+ +

+Contents +

+ + + + +

+ +

+Introduction +

+The probsoln package is designed for teachers or +lecturers who want to create problem sheets for their +students. This package was designed with specifically +mathematics problems in mind, but can be used for other +subjects as well. The idea is to create a file containing a +large number of problems with their solutions which can be +read in by LATEX, and then select a number of problems to +typeset. This means that once the database has been set up, +each year you can easily create a new problem sheet that is +sufficiently different from the previous year, thus +preventing the temptation of current students seeking out +the previous year's students, and checking out their +answers. There is also an option that can be passed to the +package to determine whether or not the solutions should be +printed. In this way, one file can either produce the +student's version or the teacher's version. + +

+ +

+Package Options +

+The following options may be passed to this package: +
+ + + + + + + +
answers Show the answers
noanswers Don't show the answers (default)
+
+ +

+ +

+Creating a New Problem +

+ +\newproblem[nargs]{label}{problem}{solution} +
+
+A new problem is defined using the command +\newproblem. This does not print anything, +but merely stores the problem. The argument label is +a unique string that is assigned to this problem so that it +can be used later. The argument problem is normal +LATEX code that should be used to typeset the problem. +The argument solution is normal LATEX code that +should be used to typeset the solution, if required. For +example, the following defines a problem with the label +quaddiff: +
+ \newproblem{quaddiff}{%
+ %This is the problem
+ \begin{displaymath}
+ f(x) = x^2 + 3x + 4
+ \end{displaymath}
+ }{%
+ %This is the solution
+ \begin{displaymath}
+ f'(x) = 2x + 3
+ \end{displaymath}
+ }
+
+ +

+The optional argument nargs specifies the number of +parameters this problem will take. By default this value is +0, but any value from 1 to 9 may be used. Each parameter is +referred to by #1, #2, ..., #9. +For example, the following problem, labelled sindiff, +takes one parameter: +

+\newproblem[1]{sindiff}{%
+\(f(x) = \sin(#1x)\)
+}{%
+\(f'(x) = #1\cos(#1x)\)
+}
+
+ +

+The quaddiff problem shown above can be made more +generic by using parameters: +

+\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 
+\)
+}
+
+The three parameters correspond to the coefficients. Note +that they must all be integers since TEX only performs +integer arithmetic. + +

+ +

+Creating a Database +

+ +

+To generate a database, simply create a .tex file +where all the problems are defined using \newproblem, +and either \input it at the start of your document if +you want to use specific problems, or pass it to +\selectrandomly. This package +comes with some sample databases, along with some sample documents +that use these databases. + +

+ +

+ +
+Displaying a Problem +

+ +\useproblem{label} +
+
+Once a problem has been defined using \newproblem, it +can be typeset using the command \useproblem. If the +problem was defined to take arguments, the arguments to the +problem should come after the label. In the case of the +sindiff example above, the command +\useproblem{sindiff}{2} would produce the following: +
+
f(x) = sin(2x) + +

+Solution: +

f'(x) = 2cos(2x) +
+
+whereas the command \useproblem{diff:quad}{3}{0}{-2} would produce: +
+
f(x) = 3x2 - 2 + +

+Solution: +

f'(x) = 6x +
+
+ +

+Suppose all the above problems are defined in the file +probs.tex, then the following code will create a +problem sheet with four questions in it: +

+\documentclass{article}
+
+\usepackage{probsoln}
+\input{probs}
+
+\begin{document}
+Differentiate the following functions with respect to $x$:
+\begin{enumerate}
+\item \useproblem{quaddiff}
+\item \useproblem{sindiff}{4}
+\item \useproblem{diff:quad}{2}{3}{1}
+\item \useproblem{diff:quad}{0}{1}{2}
+\end{enumerate}
+\end{document}
+
+The answer sheet can then be generated by passing the option +answers to the probsoln package. + +

+ +

+Selecting All Problems +

+ +

+To select all problems defined in a database, in the order in +which they were defined, use the command: + +\selectallproblems{filename} +For example, suppose the problems are defined in the file +easy.tex, then the following will create a problem sheet +which uses all these problems: +

+\documentclass[a4paper]{article}
+
+\usepackage{probsoln}
+
+\begin{document}
+Differentiate the following functions:
+\begin{enumerate}
+\selectallproblems{easy}
+\end{enumerate}
+\end{document}
+
+ +

+ +

+ +
+Selecting Problems at Random +

+ +\selectrandomly{filename}{n} +
+
+The command \selectrandomly will select n +problems that are defined in the file filename. Each +problem is proceeded by +\PSitem which is +defined to be \item, so the command +\selectrandomly should occur within one of the +list-like environments, such as enumerate. +For example: +
+\begin{enumerate}
+\selectrandomly{easy.tex}{4}
+\end{enumerate}
+
+will result in four numbered problems, selected at random +from the file easy.tex. (The .tex extension +may be omitted.) Each problem is followed by the command +\endPSNitem which by default does nothing. + +

+Multiple \selectrandomly commands may be used, however a +different file must be used each time. For +example: +

+\begin{enumerate}
+\item Differentiate the following functions with respect to $x$:
+
+\begin{enumerate}
+\selectrandomly{samples/easy.tex}{3}
+\selectrandomly{samples/args.tex}{1}
+\end{enumerate}
+
+\selectrandomly{samples/implicit.tex}{1}
+\selectrandomly{samples/1stprncpl.tex}{1}
+
+\end{enumerate}
+
+This will result in a total of 6 problems, numbered 1(a), +1(b), 1(c), 1(d), 2 and 3. + +

+If a randomly selected problem requires arguments, a message +similar to the following will be displayed: +

+Problem diff:quad requires 3 argument(s), please specify (e.g. {5}{3}):
+
+Enter the required arguments, where each argument is +enclosed in braces ({ }). + +

+ +

+Other Commands +

+ +The command \PSNrandseed{n} specifies +the seed for the random number generator. For example, +if you are using \selectrandomly, +\PSNrandseed{\year} will produce a different set of +problems each year, whereas \PSNrandseed{\time} +will produce a different set of problems each time you +LATEX the problem sheet (as long as you leave at least a +minute between runs.) + +

+The command \random{counter}{a}{b} +generates a random number from a to b and +stores it in the LATEX counter counter. For example, +to select 2, 3 or 4 problems from the file +implicit.tex: +

+\newcounter{numproblems}
+\begin{enumerate}
+\random{numproblems}{2}{4}
+\selectrandomly{implicit.tex}{\value{numproblems}}
+\end{enumerate}
+
+(Note the use of \value.) + +

+This command can also be used to generate random values for +problems that take arguments. Consider the problem diff:quad +defined earlier. Three counters can be defined to represent the +three coefficients: +

+\newcounter{A}
+\newcounter{B}
+\newcounter{C}
+
+Random values can now be assigned to these counters: +
+\random{A}{-5}{5}
+\random{B}{-5}{5}
+\random{C}{-5}{5}
+
+Finally, the problem can be used (note the use of \arabic): +
+\useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}}
+
+ +

+The command +\doforrandN{n}{cmd}{list}{text} will apply +text for a random selection of n items in the +comma separated list. In each iteration the list +item is denoted by cmd. For example, suppose you +have three files called file1.tex, +file2.tex and file3.tex, and you want to +select 1 problem from two of the three files, then you can +do: +

+\doforrandN{2}{\file}{file1,file2,file3}{\selectrandomly{\file}{1}}
+
+Note that it is also possible to do +
+\newcounter{numproblems}
+\random{numproblems}{1}{3}
+\selectrandomly{file\arabic{numproblems}}{1}
+\random{numproblems}{1}{3}
+\selectrandomly{file\arabic{numproblems}}{1}
+
+however there is a possibility that the same file may be +selected twice which will cause an error. + +

+The command \showanswers will show the solutions from +that point on. May be localised by placing within a group. + +

+The command \hideanswers will hide the solutions from +that point on. May be localised by placing within a group. + +

+The solution is placed inside the solutionsolution +environment. By default this environment simply does +\paragraph{\solutionname:} at the start, where +\solutionname +has the value: Solution. See the file sample3.tex, which +comes with this package, for an illustration of how to +customise the way in which the randomly selected problems are +displayed. This sample file randomly selects multiple choice +problems stored in the file tabmchoice.tex, and displays them +in a longtable environment. + +

+The boolean variable showanswers is defined to be +true if the answers are shown and false otherwise. You can +therefore do something like: +

+\ifthenelse{\boolean{showanswers}}{\textbf{Solution Sheet}}{}
+
+and Solution Sheet will be printed only if the +answers are displayed. (For more information on +\ifthenelse and \boolean see the +documentation for the ifthen package by +David Carlisle.) + +

+The showanswers switch can also be used within the definition +of a problem, if you want the question to appear differently if the +solution is displayed. For example: +

+\newproblem{mc:prod}{%
+Which of the following is the derivative of $x\sin(x)$?
+(Circle the correct answer.)
+\ifthenelse{\boolean{showanswers}}{}%
+{\begin{description}
+\item[A] $\sin(x)$
+\item[B] $x\cos(x)$
+\item[C] $\sin(x) + x\cos(x)$
+\end{description}
+}}{%
+\begin{description}
+\item[A] $\sin(x)$
+\item[B] $x\cos(x)$
+\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule).
+\end{description}
+}
+
+If the solutions are not displayed, the question will appear +as +
+
+
Which of the following is the derivative of +xsin(x)? +(Circle the correct answer.) +
+
A
+
sin(x) +
+
B
+
xcos(x) +
+
C
+
sin(x)+xcos(x) +
+
+
+
+otherwise it will appear as: +
+
+
Which of the following is the derivative of +xsin(x)? +(Circle the correct answer.) +
+
A
+
sin(x) +
+
B
+
xcos(x) +
+
©
+
sin(x) + xcos(x) (product rule) +
+
+
+
+ +

+ +

+Troubleshooting +

+ +

+Unexpected Output +

+ + + +

+ +

+Error Messages +

+ + + +

+ +

+Contact Details +

+Dr Nicola Talbot +
+School of Computing Sciences +
+University of East Anglia +
+Norwich. NR4 7TJ +
http://theoval.cmp.uea.ac.uk/~nlct/ +

+
+ +

+Index +

+
\arabic +
Other Commands +
\boolean +
Other Commands +
\doforrandN +
Other Commands +
\endPSNitem +
Selecting Problems at Random +
\hideanswers +
Other Commands +
\iffirstpass +
Error Messages +
\ifthenelse +
Other Commands +
\input +
Creating a Database + | Error Messages + | Error Messages + | Error Messages +
\item +
Selecting Problems at Random + | Error Messages + | Error Messages +
\newproblem +
Creating a New Problem + | Creating a New Problem + | Creating a Database + | Displaying a Problem + | Error Messages + | Error Messages +
\PSitem +
Selecting Problems at Random +
\PSNitem +
Error Messages + | Error Messages +
\PSNrandseed +
Other Commands +
\random +
Other Commands +
\selectallproblems +
Selecting All Problems +
\selectrandomly +
Creating a Database + | Creating a Database + | Selecting Problems at Random + | Selecting Problems at Random + | Selecting Problems at Random + | Selecting Problems at Random + | Other Commands + | Unexpected Output + | Unexpected Output + | Error Messages + | Error Messages + | Error Messages +
\showanswers +
Other Commands +
\solutionname +
Other Commands +
\useproblem +
Displaying a Problem + | Displaying a Problem +
\value +
Other Commands + +
+

+
+Nicola L. C. Talbot. School of Computing Sciences. University of East Anglia. Last Modified: 2006-03-02 +
+ + diff --git a/Master/texmf-dist/doc/latex/probsoln/mchoice.tex b/Master/texmf-dist/doc/latex/probsoln/mchoice.tex new file mode 100644 index 00000000000..5f266bb3cd3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/mchoice.tex @@ -0,0 +1,65 @@ +%% +%% This is file `mchoice.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `mchoice.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\newproblem{mc:prod}{% +Which of the following is the derivative of $x\sin(x)$? +(Circle the correct answer.) +\ifthenelse{\boolean{showanswers}}{}% +{\begin{description} +\item[A] $\sin(x)$ +\item[B] $x\cos(x)$ +\item[C] $\sin(x) + x\cos(x)$ +\end{description} +}}{% +\begin{description} +\item[A] $\sin(x)$ +\item[B] $x\cos(x)$ +\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule). +\end{description} +} + +\newproblem{mc:quot}{% +Which of the following is the derivative of $\frac{\sin(x)}{x}$? +(Circle the correct answer.) +\ifthenelse{\boolean{showanswers}}{}% +{\begin{description} +\item[A] $\sin(x)$ +\item[B] $\cos(x)$ +\item[C] $\frac{\cos(x)x-\sin(x)}{x^2}$ +\end{description} +}}{% +\begin{description} +\item[A] $\sin(x)$ +\item[B] $\cos(x)$ +\item[\textcircled{C}] $\frac{\cos(x)x-\sin(x)}{x^2}$ +(quotient rule) +\end{description} +} +\endinput +%% +%% End of file `mchoice.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/probsoln.html b/Master/texmf-dist/doc/latex/probsoln/probsoln.html deleted file mode 100644 index 81a36df337e..00000000000 --- a/Master/texmf-dist/doc/latex/probsoln/probsoln.html +++ /dev/null @@ -1,293 +0,0 @@ - - -probsoln.sty v 2.0 - - -Dr Nicola Talbot | -School of Computing Sciences | -University of East Anglia - -

probsoln.sty v 2.0 : LaTeX Package to help create problem sheets

- - -

Introduction

- - The package probsoln.sty is designed for teachers or lecturers who - want to create problem sheets for their students. This package was - designed with specifically mathematics problems in mind, but can - be used for other subjects as well. The idea is to create a file - containing a large number of problems with their solutions which - can be read in by LaTeX, and then select a number of problems to - typeset. This means that once the database has been set up, each - year you can easily create a new problem sheet that is sufficiently - different from the previous year, thus preventing the temptation - of current students seeking out the previous year's students, - and checking out their answers. There is also an option that can be - passed to the package to determine whether or not the solutions - should be printed. In this way, one file can either produce - the student's version or the teacher's version. - -

Package Options

- The following options may be passed to this package: -

- - - -
answersShow the answers
noanswersDon't show the answers (default)
- -

Commands Provided

-

Creating a New Problem

- -\newproblem[nargs]{label}{problem}{solution} -

- A new problem is defined using the command \newproblem. This does not print anything, - but merely stores the problem. The argument label is a unique string that is - assigned to this problem so that it can be used later. The argument problem - is normal LaTeX code that should be used to typeset the problem. The argument - solution is normal LaTeX code that should be used to typeset the solution, - if required. For example: - -

-\newproblem{quaddiff}{%
-% This is the problem
-\begin{displaymath}
-f(x) = x^2 + 3x + 4
-\end{displaymath}
-}{%
-% This is the solution
-\begin{displaymath}
-f'(x) = 2x + 3
-\end{displaymath}
-}
-
-

- The optional argument nargs specifies the number of parameters this - problem will take. By default this value is 0, but any value from 1 to 9 - may be used. Each parameter is refered to by #1, #2, ..., #9. - For example, the following problem takes one parameter: - -

-\newproblem[1]{sindiff}{%
-\(f(x) = \sin(#1x)\)
-}{%
-\(f'(x) = #1\cos(#1x)\)
-}
-
- - The quaddiff problem shown above can be made more generic by using parameters: -
-\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 
-\)
-}
-
- The three parameters correspond to the coefficients. Note that they - must all be integers since TeX only performs integer arithmetic. -

- To generate a database, simply create a .tex file where all the problems - are defined using \newproblem, and either \input it at the - start of your document if you want to use specific problems, or - pass it to \selectrandomly. - -

Displaying a Problem

- -\useproblem{label} -

- Once a problem has be defined using \newproblem, it can be typeset - using the command \useproblem. If the problem was defined to take - arguments, the arguments to the problem should come after the - label. In the case of the sindiff example above, the command - \useproblem{sindiff}{2} would produce the following: -

- f(x) = sin(2x)
- Solution: f'(x) = 2cos(2x)
-

- whereas the command \useproblem{diff:quad}{3}{0}{-2} would produce:
- f(x) = 3x2 - 2
- Solution: f'(x) = 6x -

- Suppose all the above problems are defined in the - file probs.tex, then the following code will create a problem sheet - with four questions in it: -

-\documentclass{article}
-
-\usepackage{probsoln}
-\input{probs}
-
-\begin{document}
-Differentiate the following functions with respect to $x$:
-\begin{enumerate}
-\item \useproblem{quaddiff}
-\item \useproblem{sindiff}{4}
-\item \useproblem{diff:quad}{2}{3}{1}
-\item \useproblem{diff:quad}{0}{1}{2}
-\end{enumerate}
-\end{document}
-
-The answer sheet can then be generated by passing the option answers -to the probsoln package. - -

Selecting Problems at Random

-\selectrandomly{filename}{n} -

- The command \selectrandomly will select n problems that are defined - in the file filename. Each problem is preceeded by a \item, so the - command \selectrandomly should occur within one of the list-like environments, - such as enumerate. For example: -

-\begin{enumerate}
-\selectrandomly{easy.tex}{4}
-\end{enumerate}
-
- will result in four numbered problems, selected at random from the - file easy.tex. (The .tex extension may be omitted.) -

- - Multiple \selectrandomly commands (with different filenames) may be used. For example: -

-\begin{enumerate}
-\item Differentiate the following functions with respect to $x$:
-
-\begin{enumerate}
-\selectrandomly{samples/easy.tex}{3}
-\selectrandomly{samples/args.tex}{1}
-\end{enumerate}
-
-\selectrandomly{samples/implicit.tex}{1}
-\selectrandomly{samples/1stprncpl.tex}{1}
-
-\end{enumerate}
-
- This will result in a total of 6 problems, numbered 1(a), 1(b), 1(c), 1(d), 2 and 3. -

- - If a randomly selected problem requires arguments, a message similar to the following - will be displayed: -

-Problem diff:quad requires 3 argument(s), please specify (e.g. {5}{3}):
-
- Enter the required arguments, where each argument is enclosed in braces ({ }). - -

Other Commands

-
-
\PSNrandseed
-
The command \PSNrandseed{n} specifies the seed for the random - number generator. For example, \PSNrandseed{\year} will produce a - different set of random problems each year, whereas \PSNrandseed{\time} - will produce a different set of problems each time you LaTeX the - problem (as long as you leave at least a minute between runs.) -

- -

\showanswers
-
The command \showanswers will show the solutions from that point - on. May be localised by placing within a group. -

- -

\hideanswers
-
The command \hideanswers will hide the solutions from that point - on. May be localised by placing within a group. -

- -

\solutionname
-
By default, the solution is preceeded by the text: Solution:. This can - be changed by redefining the macro \solutionname. -

- -

showanswers
-
The boolean variable showanswers is defined to be true if the answers - are shown and false otherwise. You can therefore do something like: -
-\ifthenelse{\boolean{showanswers}}{\textbf{Solution Sheet}}{}
-
-and Solution Sheet will be printed only if the answers are displayed. -(For more information on \ifthenelse and \boolean see the -documentation for the ifthen package by David Carlisle.) -
- -

Error Messages

-
-! Package probsoln Error: Label ... already used.
-
- Each label identifier used in \newproblem must be unique. - Check to make sure you haven't used the same label more than once. - Also check to make sure you haven't \inputed or randomly selected - from the same file more than once. (Or \inputed and randomly - selected from the same file.) - -
-! Package probsoln Error: Label ... undefined.
-
- You need to define a problem before you can use it. Check to - make sure you haven't mis-spelt it. - -
-! Package probsoln Error: Requested number too large.
-
- You have asked for more problems than are defined within - the specified file. All problems in that file will be selected. - - - - -Dr Nicola Talbot | -School of Computing Sciences | -University of East Anglia - -
-
N.L.C. Talbot. School of Computing Sciences. University of East Anglia. -Last Modified: 21 Mar 2004.
- - diff --git a/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf b/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf index 08ef5ff3728..cab2b84791a 100644 Binary files a/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf and b/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf differ diff --git a/Master/texmf-dist/doc/latex/probsoln/sample.tex b/Master/texmf-dist/doc/latex/probsoln/sample.tex index d797127c944..a21dd8e7042 100644 --- a/Master/texmf-dist/doc/latex/probsoln/sample.tex +++ b/Master/texmf-dist/doc/latex/probsoln/sample.tex @@ -1,40 +1,56 @@ +%% +%% This is file `sample.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `sample.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} \documentclass[a4paper]{article} \usepackage{probsoln} -% use the current year as a random seed so that -% it produces a different set of problems each -% year. -%\PSNrandseed{\year} -% or specify a fixed random seed. -\PSNrandseed{2004} - -% Uncomment the following line to generate solution sheet. \showanswers +\PSNrandseed{\year} + \begin{document} -\ifthenelse{\boolean{showanswers}}{\textbf{Solution Sheet}}{} +\title{Sample Problem Sheet} +\author{Nicola Talbot} +\maketitle \begin{enumerate} -\item Differentiate the following functions with respect to $x$: +\selectrandomly{1stprncp}{1} +\item Differentiate the following functions: \begin{enumerate} -\selectrandomly{samples/easy.tex}{6} +\selectrandomly{easy}{5} \end{enumerate} -\selectrandomly{samples/implicit.tex}{1} -\selectrandomly{samples/1stprncp.tex}{1} +\selectrandomly{implicit}{2} -% The problems defined in samples/arg.tex all take -% arguments. -\input{samples/args.tex} - -\item Differentiate the following polynomials -\begin{enumerate} -\item \useproblem{diff:quad}{3}{0}{-2} -\item \useproblem{diff:quad}{1}{2}{3} -\item \useproblem{diff:quad}{5}{3}{0} +\selectrandomly{mchoice}{1} \end{enumerate} - -\end{enumerate} - \end{document} +\endinput +%% +%% End of file `sample.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/sample2.tex b/Master/texmf-dist/doc/latex/probsoln/sample2.tex new file mode 100644 index 00000000000..2e1ea5b467a --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/sample2.tex @@ -0,0 +1,68 @@ +%% +%% This is file `sample2.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `sample2.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\documentclass[a4paper]{article} + +\usepackage{probsoln} +\showanswers + + +\PSNrandseed{\time} + +\begin{document} +\title{Sample Problem Sheet} +\author{Nicola Talbot} +\maketitle + +\begin{enumerate} + +\newcounter{numproblems} +\random{numproblems}{1}{3} + +\doforrandN{1}{\file}{1stprncp,implicit}{\selectrandomly{\file}{\value{numproblems}}} + +\item Differentiate the following functions: +\input{args}% load database +\begin{enumerate} +\newcounter{A} +\newcounter{B} +\newcounter{C} +\random{A}{-4}{5} +\random{B}{-3}{3} +\random{C}{-1}{10} +\item \useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}} + +\random{A}{-5}{5} +\whiledo{\value{A}=0}{\random{A}{-5}{5}} +\item \useproblem{diff:sin}{\arabic{A}} +\end{enumerate} +\end{enumerate} +\end{document} +\endinput +%% +%% End of file `sample2.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/sample3.tex b/Master/texmf-dist/doc/latex/probsoln/sample3.tex new file mode 100644 index 00000000000..ced57a52c51 --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/sample3.tex @@ -0,0 +1,54 @@ +%% +%% This is file `sample3.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `sample3.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\documentclass[a4paper]{article} + +\usepackage{longtable} +\usepackage{probsoln} + + +\newcounter{problem} +\renewcommand{\PSNitem}{\refstepcounter{problem}% +\theproblem. } +\renewcommand{\endPSNitem}{\\} + +\renewenvironment{solution}{}{} + +\newcommand{\selected}{\fbox{$\times$}} +\newcommand{\notselected}{\fbox{\phantom{$\times$}}} + +\begin{document} +\begin{longtable}{lrrrl} +\bfseries Question & \bfseries A & \bfseries B & +\bfseries C & \ifshowanswers \bfseries Reason\fi\\ +\selectrandomly{tabmchoice}{2} +\end{longtable} +\end{document} +\endinput +%% +%% End of file `sample3.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/sample4.tex b/Master/texmf-dist/doc/latex/probsoln/sample4.tex new file mode 100644 index 00000000000..27019aa0a09 --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/sample4.tex @@ -0,0 +1,44 @@ +%% +%% This is file `sample4.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `sample4.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\documentclass[a4paper]{article} + +\usepackage{probsoln} + + +\showanswers + +\begin{document} +Differentiate the following functions: +\begin{enumerate} +\selectallproblems{easy} +\end{enumerate} +\end{document} +\endinput +%% +%% End of file `sample4.tex'. diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex b/Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex deleted file mode 100644 index f857392a6ef..00000000000 --- a/Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex +++ /dev/null @@ -1,61 +0,0 @@ -% These all involve differentiating from 1st principles - -\newproblem{dfp:xcube}{% -Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{% -\begin{eqnarray*} -\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\ - & = & 3x^2 -\end{eqnarray*}} - -\newproblem{dfp:Ioverxsq}{% -Differentiate $\displaystyle f(x) = \frac{1}{x^2}$ with respect to $x$ by first principles.}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{1}{(x+\Delta x)^2}-\frac{1}{x^2}}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{x^2-(x+\Delta x)^2}{x^2(x+\Delta x)^2}}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{x^2-(x^2+2x\Delta x+(\Delta x)^2)}{x^2\Delta x(x+\Delta x)^2}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{-2x\Delta x-(\Delta x)^2}{x^2\Delta x(x+\Delta x)^2}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{-2x-\Delta x}{x^2(x+\Delta x)^2}\\ - & = & \frac{-2x}{x^2x^2}\\ - & = & -\frac{2}{x^3} -\end{eqnarray*}} - -\newproblem{dfp:sqrtx}{% -Differentiate from first principles $f(x) = \surd x$}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\sqrt{x+\Delta x}-\surd x}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{(\sqrt{x+\Delta x}-\surd x)(\sqrt{x+\delta x}+\surd x)}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{x+\Delta x - x}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{\Delta x}{\Delta x(\sqrt{x+\Delta x}+\Delta x)}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{1}{\sqrt{x+\Delta x}+\surd x}\\ - & = & \frac{1}{2\surd x} -\end{eqnarray*}} - -\newproblem{dfp:cons}{% -Differentiate from first principles $f(x) = c$ where $c$ is a constant.}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{c-c}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}0\\ - & = & 0 -\end{eqnarray*}} - -\newproblem{dfp:cosx}{% -Given -\begin{eqnarray*} -\lim_{x \rightarrow 0} \frac{\cos x - 1}{x} & = & 0\\ -\lim_{x \rightarrow 0} \frac{\sin x}{x} & = & 1 -\end{eqnarray*} -differentiate from first principles $f(x) = \cos x$.}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) - f(x)}{\Delta x}\\ - & = & \lim_{\Delta x \rightarrow 0} \frac{\cos(x + \Delta x) - \cos(x)}{\Delta x}\\ - & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x\cos\Delta x - \sin x\sin\Delta x - \cos x}{\Delta x}\\ - & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x(\cos\Delta x - 1) - \sin x\sin\Delta x}{\Delta x}\\ - & = & \cos x\lim_{\Delta x \rightarrow 0}\frac{\cos\Delta x - 1}{\Delta x} - - \sin x\lim_{\Delta x \rightarrow 0}\frac{\sin\Delta x}{\Delta x}\\ - & = & -1 \qquad\mbox{(using given results)} -\end{eqnarray*}} diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/args.tex b/Master/texmf-dist/doc/latex/probsoln/samples/args.tex deleted file mode 100644 index e3bd7de75ec..00000000000 --- a/Master/texmf-dist/doc/latex/probsoln/samples/args.tex +++ /dev/null @@ -1,45 +0,0 @@ -% 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)\) -} - diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/easy.tex b/Master/texmf-dist/doc/latex/probsoln/samples/easy.tex deleted file mode 100644 index 5aa99ed04ca..00000000000 --- a/Master/texmf-dist/doc/latex/probsoln/samples/easy.tex +++ /dev/null @@ -1,84 +0,0 @@ -% These are all easy differentiation problems - -\newproblem{diffeasy:gpowh}{% -\(f(x) = g(x)^{h(x)}.\)}{% -\begin{eqnarray*} -f(x) & = & e^{\ln g(x)^{h(x)}}\\ - & = & e^{h(x)\ln g(x)}\\ -f'(x) & = & e^{h(x)\ln g(x)}(h'(x)\ln g(x) + h(x)\frac{g'(x)}{g(x)})\\ - & = & g(x)^{h(x)}(h'(x)\ln g(x) + \frac{h(x)g'(x)}{g(x)}) -\end{eqnarray*}} - -\newproblem{diffeasy:arcsin}{% -\(y = \arcsin(x)\)}{% -\[\sin(y) = x\] -diff. w.r.t. $x$: -\begin{eqnarray*} -\cos y \frac{dy}{dx} & = & 1\\ -\frac{dy}{dx} & = & \frac{1}{\cos y}\\ - & = & \frac{1}{\sqrt{1 - \sin^2y}}\\ - & = & \frac{1}{\sqrt{1-x^2}}. -\end{eqnarray*}} - -\newproblem{diffeasy:arccos}{% -$y = \arccos x$.}{% -\(\cos y = x\) -diff. w.r.t. $x$: -\begin{eqnarray*} --\sin y \frac{dy}{dx} & = & 1\\ -\frac{dy}{dx} & = & \frac{-1}{\sin y}\\ - & = & \frac{-1}{\sqrt{1-\cos^2y}}\\ - & = & \frac{-1}{\sqrt{1-x^2}} -\end{eqnarray*}} - -\newproblem{diffeasy:tan}{% -\(y = \tan x\)}{% -\begin{eqnarray*} -y & = & \tan x\\ - & = & \frac{\sin x}{\cos x}\\ -\frac{dy}{dx} & = & \frac{\cos x}{\cos x} + \sin x\times\frac{-1}{\cos^2x}\times -\sin x\\ - & = & 1 + \tan^2x\\ - & = & \sec^2x. -\end{eqnarray*}} - -\newproblem{diffeasy:arctan}{% -\(y = \arctan x = \tan^{-1}x\)}{% -\[\tan y = x\] -diff w.r.t. $x$: -\begin{eqnarray*} -\sec^2y\frac{dy}{dx} & = & 1\\ -\frac{dy}{dx} & = & \frac{1}{\sec^2y}\\ - & = & \frac{1}{1+\tan^2y}\\ - & = & \frac{1}{1+x^2} -\end{eqnarray*}} - -\newproblem{diffeasy:cot}{% -\(y = (\tan x)^{-1} = \cot x\)}{% -\begin{eqnarray*} -\frac{dy}{dx} & = & -(\tan x)^{-2}\sec^2x\\ - & = & -\frac{\cos^2x}{\sin^2x}\cdot\frac{1}{\cos^2x}\\ - & = & \frac{-1}{\sin^2x}\\ - & = & -\csc^2x. -\end{eqnarray*}} - -\newproblem{diffeasy:cosxsqsinx}{% -$y = \cos(x^2)\sin x$.}{% -\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]} - -\newproblem{diffeasy:xlnx}{% -$y = (x+1)\ln(x+1)$.}{% -\begin{eqnarray*} -\frac{dy}{dx} & = & \ln(x+1) + \frac{x+1}{x+1}\\ - & = & 1 + \ln(x+1). -\end{eqnarray*}} - -\newproblem{diffeasy:glng}{% -$f(x) = g(x)\ln(g(x))$.}{% -\begin{eqnarray*} -f'(x) & = & g'(x)\ln(g(x)) + \frac{g(x)}{g(x)}g'(x)\\ - & = & g'(x)(1+\ln(g(x))). -\end{eqnarray*}} - -\newproblem{diffeasy:sinx/x}{% -$y = \frac{\sin x}{x}$.}{% -\[\frac{dy}{dx} = \frac{\cos x}{x} - \frac{\sin x}{x^2}\]} diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex b/Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex deleted file mode 100644 index 00453df3045..00000000000 --- a/Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex +++ /dev/null @@ -1,41 +0,0 @@ -% These are all implicit differentiation problems - -\newproblem{imd:circ}{% -Find the gradient of the unit circle ($x^2 + y^2 = 1$).}{% -Differentiating with respect to $x$ gives: -\begin{eqnarray*} -2x + 2y\frac{dy}{dx} & = & 0\\ -\frac{dy}{dx} & = & \frac{-2x}{2y}\\ - & = & \frac{-x}{\sqrt{1-x^2}}. -\end{eqnarray*}} - -\newproblem{imd:ysq:xcuov2mx}{% -Find $\frac{dy}{dx}$, given -\begin{displaymath} -y^2 = \frac{x^3}{2-x} -\end{displaymath}}{% -Differentiating both sides w.r.t.\ $x$: -\begin{eqnarray*} -2y\frac{dy}{dx} & = & \frac{(2-x)3x^2 - x^3(-1)}{(2-x)^2}\\ - & = & \frac{3x^2(2-x) + x^3}{(2-x)^2}\\ - & = & \frac{6x^2 - 3x^3 + x^3}{(2-x)^2}\\ - & = & \frac{6x^2-2x^3}{(2-x)^2}\\ - & = & 2x^2\frac{3-x}{(2-x)^2} -\end{eqnarray*} -Therefore -\begin{displaymath} -y\frac{dy}{dx} = x^2\frac{3-x}{(2-x)^2} -\end{displaymath}} - -\newproblem{imd:exy:IIxay}{% -Differentiate w.r.t.\ $x$: -\begin{displaymath} -e^{xy} = 2x + y -\end{displaymath}}{% -Differentiating both sides w.r.t.\ $x$: -\begin{eqnarray*} -e^{xy}(1y + x\frac{dy}{dx}) & = & 2 + \frac{dy}{dx}\\ -xe^{xy}\frac{dy}{dx} - \frac{dy}{dx} & = & 2 - ye^{xy} \\ -\frac{dy}{dx}(xe^{xy}-1) & = & 2 - ye^{xy}\\ -\frac{dy}{dx} & = & \frac{2-ye^{xy}}{xe^{xy}-1} -\end{eqnarray*}} diff --git a/Master/texmf-dist/doc/latex/probsoln/tabmchoice.tex b/Master/texmf-dist/doc/latex/probsoln/tabmchoice.tex new file mode 100644 index 00000000000..80600c17632 --- /dev/null +++ b/Master/texmf-dist/doc/latex/probsoln/tabmchoice.tex @@ -0,0 +1,43 @@ +%% +%% This is file `tabmchoice.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% probsoln.dtx (with options: `tabmchoice.tex,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\newproblem{tab:1}{% +What is $(3+2)\times5$? & +25 \ifshowanswers\selected\else\notselected\fi & +13 \notselected & +10 \notselected & +}{Brackets come first}% +\newproblem{tab:2}{% +What is $-1+2\times3$? & +3 \notselected & +-7 \notselected & +5 \ifshowanswers\selected\else\notselected\fi & +}{Multiplication comes first}% +\endinput +%% +%% End of file `tabmchoice.tex'. diff --git a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx index 07ecd28ba6b..0912f634e65 100644 --- a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx +++ b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx @@ -1,75 +1,140 @@ -%\def\filedate{21 Mar 2004} -%\def\fileversion{2.0} -%\def\filename{probsoln.dtx} -%\def\docdate{19th Dec 2000} %\iffalse +% probsoln.dtx generated using makedtx version 0.9b (c) Nicola Talbot +% Command line args: +% -src "(.+)\.(sty)=>\1.\2" +% -src "(.*\.tex)\Z=>\1" +% -doc "manual.tex" +% -author "Nicola Talbot" +% -dir "source" +% probsoln +% Created on 2006/3/2 11:26 +%\fi +%\iffalse +%<*package> +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +% +%\fi +% \iffalse % Doc-Source file to use with LaTeX2e -% Copyright (C) 2000 Nicola Talbot, all rights reserved. +% Copyright (C) 2006 Nicola Talbot, all rights reserved. +% \fi +% \iffalse +%<*driver> +\documentclass{ltxdoc} +\usepackage[colorlinks, + bookmarks, + hyperindex=false, + pdfauthor=Nicola Talbot, + pdftitle={probsoln.sty : a LaTeX2e package to help create problem sheets}]{hyperref} + + + +\newcommand{\sty}[1]{\textsf{#1}}\newcommand{\env}[1]{\textsf{#1}} +\newcommand{\cmddef}[1]{\hypertarget{#1}{\cmdname{#1}}} +\newcommand{\cmdlink}[1]{\hyperlink{#1}{\cmdname{#1}}} +\newcommand{\problabel}[2]{\hypertarget{#1}{\texttt{#2}}} +\newcommand{\probref}[1]{\hyperlink{#1}{\texttt{#1}}} +\newcommand{\cmdname}[1]{\texttt{\symbol{92}#1}} + %hyperindex conflicts with doc + %(end up with |usage|hyperpage in indexentry) +\renewcommand{\usage}[1]{\textit{\hyperpage{#1}}} +\renewcommand{\main}[1]{\hyperpage{#1}} +\newcommand{\see}[2]{\emph{see} #1} +\makeatletter +\def\index@prologue{\section*{Index}} +\makeatother + + +\OnlyDescription +\PageIndex + +\begin{document} +\DocInput{probsoln.dtx} +\end{document} +% %\fi % -% \newsavebox{\syntaxbox} -% \newenvironment{syntax}{\begin{lrbox}{\syntaxbox}\ttfamily}% -%{\end{lrbox}\par\noindent\fbox{\usebox{\syntaxbox}}\\} -% \title{probsoln.sty v\fileversion: \LaTeX\ Package to help create problem sheets} -% \author{N.L.C. Talbot} -% \date{\docdate} +% +% \title{probsoln.sty v2.02: \LaTeXe\ Package to help create problem sheets} +% \author{Nicola L.C. Talbot} +% \date{2nd March 2006} % \maketitle % \tableofcontents % % \section{Introduction} -% The package |probsoln.sty| is designed for teachers or lecturers who -% want to create problem sheets for their students. This package was -% designed with specifically mathematics problems in mind, but can -% be used for other subjects as well. The idea is to create a file -% containing a large number of problems with their solutions which -% can be read in by \LaTeX, and then select a number of problems to -% typeset. This means that once the database has been set up, each -% year you can easily create a new problem sheet that is sufficiently -% different from the previous year, thus preventing the temptation -% of current students seeking out the previous year's students, -% and checking out their answers. There is also an option that can be -% passed to the package to determine whether or not the solutions -% should be printed. In this way, one file can either produce -% the student's version or the teacher's version. -% -% \section{Package Options} -% The following options may be passed to this package: -% -% \centerline{% -% \begin{tabular}{@{\ttfamily}ll} -% answers & Show the answers\\ -% noanswers & Don't show the answers (default) -% \end{tabular} -% } +%The \sty{probsoln} package is designed for teachers or +%lecturers who want to create problem sheets for their +%students. This package was designed with specifically +%mathematics problems in mind, but can be used for other +%subjects as well. The idea is to create a file containing a +%large number of problems with their solutions which can be +%read in by \LaTeX, and then select a number of problems to +%typeset. This means that once the database has been set up, +%each year you can easily create a new problem sheet that is +%sufficiently different from the previous year, thus +%preventing the temptation of current students seeking out +%the previous year's students, and checking out their +%answers. There is also an option that can be passed to the +%package to determine whether or not the solutions should be +%printed. In this way, one file can either produce the +%student's version or the teacher's version. +% +%\section{Package Options} +%The following options may be passed to this package: +%\begin{center} +%\begin{tabular}{@{\ttfamily}ll} +%answers & Show the answers\\ +%noanswers & Don't show the answers (default) +%\end{tabular} +%\end{center} % -% \section{Commands Provided} -% \subsection{Creating a New Problem} -% \begin{syntax}|\newproblem[|\meta{nargs}|]{|\meta{label}|}{|\meta{problem}|}{|\meta{solution}|}|\end{syntax} -% \DescribeMacro{\newproblem} -% A new problem is defined using the command |\newproblem|. This does not print anything, -% but merely stores the problem. The argument \meta{label} is a unique string that is -% assigned to this problem so that it can be used later. The argument \meta{problem} -% is normal \LaTeX\ code that should be used to typeset the problem. The argument -% \meta{solution} is normal \LaTeX\ code that should be used to typeset the solution, -% if required. For example: +%\section{Creating a New Problem} +%\DescribeMacro{\newproblem} +%\cmddef{newproblem}\verb|[|\meta{nargs}\verb/]{/\meta{label}\verb!}{!\meta{problem}\verb+}{+\meta{solution}\verb=}=\\[10pt] +%A new problem is defined using the command +%\cmdname{newproblem}. This does not print anything, +%but merely stores the problem. The argument \meta{label} is +%a unique string that is assigned to this problem so that it +%can be used later. The argument \meta{problem} is normal +%\LaTeX\ code that should be used to typeset the problem. +%The argument \meta{solution} is normal \LaTeX\ code that +%should be used to typeset the solution, if required. For +%example, the following defines a problem with the label +%\problabel{quaddiff}{quaddiff}: %\begin{verbatim} -%\newproblem{quaddiff}{% -%%This is the problem -%\begin{displaymath} -%f(x) = x^2 + 3x + 4 -%\end{displaymath} -%}{% -%%This is the solution -%\begin{displaymath} -%f'(x) = 2x + 3 -%\end{displaymath} -%} +% \newproblem{quaddiff}{% +% %This is the problem +% \begin{displaymath} +% f(x) = x^2 + 3x + 4 +% \end{displaymath} +% }{% +% %This is the solution +% \begin{displaymath} +% f'(x) = 2x + 3 +% \end{displaymath} +% } %\end{verbatim} % -% The optional argument \meta{nargs} specifies the number of parameters this -% problem will take. By default this value is 0, but any value from 1 to 9 -% may be used. Each parameter is refered to by |#1|, |#2|, \ldots, |#9|. -% For example, the following problem takes one parameter: +%The optional argument \meta{nargs} specifies the number of +%parameters this problem will take. By default this value is +%0, but any value from 1 to 9 may be used. Each parameter is +%referred to by \verb|#1|, \verb/#2/, \ldots, \verb!#9!. +%For example, the following problem, labelled \problabel{sindiff}{sindiff}, +%takes one parameter: %\begin{verbatim} %\newproblem[1]{sindiff}{% %\(f(x) = \sin(#1x)\) @@ -78,7 +143,8 @@ %} %\end{verbatim} % -% The |quaddiff| problem shown above can be made more generic by using parameters: +%The \probref{quaddiff} problem shown above can be made more +%generic by using parameters\problabel{diff:quad}{}: %\begin{verbatim} %\newcount\ctr %\newproblem[3]{diff:quad}{% @@ -115,34 +181,36 @@ %\) %} %\end{verbatim} -% The three parameters correspond to the coefficients. Note that they -% must all be integers since \TeX\ only performs integer arithmetic. -% -% To generate a database, simply create a |.tex| file where all the problems -% are defined using |\newproblem|, and either |\input| it at the -% start of your document if you want to use specific problems -% (see Section~\ref{sec:useprob}), or -% pass it to |\selectrandomly| (see Section~\ref{sec:selran}). -% -% \subsection{Displaying a Problem} -% \label{sec:useprob} -% \begin{syntax}|\useproblem{|\meta{label}|}|\end{syntax} +%The three parameters correspond to the coefficients. Note +%that they must all be integers since \TeX\ only performs +%integer arithmetic. +% +%\section{Creating a Database} +% +%To generate a database, simply create a \texttt{.tex} file +%where all the problems are defined using \cmdlink{newproblem}, +%and either \cmdname{input} it at the start of your document if +%you want to use specific problems (see Section~\ref{sec:useprob}), or pass it to +%\cmdname{selectrandomly} (see Section~\ref{sec:selran}). This package +%comes with some sample databases, along with some sample documents +%that use these databases. +% +%\section{Displaying a Problem} +%\label{sec:useprob} % \DescribeMacro{\useproblem} -% Once a problem has be defined using |\newproblem|, it can be typeset -% using the command |\useproblem|. If the problem was defined to take -% arguments, the arguments to the problem should come after the -% label. In the case of the |sindiff| example above, the command -% |\useproblem{sindiff}{2}| would produce the following:\\[10pt] -% \(f(x) = \sin(2x)\) -% \paragraph{Solution:} \(f'(x) = 2\cos(2x)\)\\[10pt] -% whereas the command |\useproblem{diff:quad}{3}{0}{-2}| would produce:\\[10pt] -% \(f(x) = 3x^2 - 2\) -% \paragraph{Solution:} \(f'(x) = 6x\) -% -% \vspace{10pt} -% Suppose all the above problems are defined in the -% file |probs.tex|, then the following code will create a problem sheet -% with four questions in it: +%\cmddef{useproblem}\verb|{|\meta{label}\verb/}/\\[10pt] +%Once a problem has been defined using \cmdlink{newproblem}, it +%can be typeset using the command \cmdname{useproblem}. If the +%problem was defined to take arguments, the arguments to the +%problem should come after the label. In the case of the +%\probref{sindiff} example above, the command +%\verb|\useproblem{sindiff}{2}| would produce the following:\\[10pt] +% $f(x) = \sin(2x)$ \paragraph{Solution:} $f'(x) = 2\cos(2x)$\\[10pt]whereas the command \verb|\useproblem{diff:quad}{3}{0}{-2}| would produce:\\[10pt] +% $f(x) = 3x^2 - 2$ \paragraph{Solution:} $f'(x) = 6x$\vspace{10pt} +% +%Suppose all the above problems are defined in the file +%\texttt{probs.tex}, then the following code will create a +%problem sheet with four questions in it: %\begin{verbatim} %\documentclass{article} % @@ -159,26 +227,56 @@ %\end{enumerate} %\end{document} %\end{verbatim} -%The answer sheet can then be generated by passing the option |answers| -%to the |probsoln| package. +%The answer sheet can then be generated by passing the option +%\texttt{answers} to the \texttt{probsoln} package. +% +%\section{Selecting All Problems} +% +%To select all problems defined in a database, in the order in +%which they were defined, use the command: +%\DescribeMacro{\selectallproblems} +%\cmddef{selectallproblems}\verb|{|\meta{filename}\verb/}/ +%For example, suppose the problems are defined in the file +%\texttt{easy.tex}, then the following will create a problem sheet +%which uses all these problems: +%\begin{verbatim} +%\documentclass[a4paper]{article} +% +%\usepackage{probsoln} +% +%\begin{document} +%Differentiate the following functions: +%\begin{enumerate} +%\selectallproblems{easy} +%\end{enumerate} +%\end{document} +%\end{verbatim} % -% \subsection{Selecting Problems at Random} -% \label{sec:selran} -% \begin{syntax}|\selectrandomly{|\meta{filename}|}{|\meta{n}|}|\end{syntax} +%\section{Selecting Problems at Random} +%\label{sec:selran} % \DescribeMacro{\selectrandomly} -% The command |\selectrandomly| will select \meta{n} problems that are defined -% in the file \meta{filename}. Each problem is preceeded by a |\item|, so the -% command |\selectrandomly| should occur within one of the list-like environments, -% such as |enumerate|. For example: +%\cmddef{selectrandomly}\verb|{|\meta{filename}\verb/}{/\meta{n}\verb!}!\\[10pt] +%The command \cmdname{selectrandomly} will select \meta{n} +%problems that are defined in the file \meta{filename}. Each +%problem is proceeded by +%\DescribeMacro{\PSNitem}\cmddef{PSitem} which is +%defined to be \cmdname{item}, so the command +%\cmdname{selectrandomly} should occur within one of the +%list-like environments, such as \texttt{enumerate}. +%For example: %\begin{verbatim} %\begin{enumerate} %\selectrandomly{easy.tex}{4} %\end{enumerate} %\end{verbatim} -% will result in four numbered problems, selected at random from the -% file |easy.tex|. (The \texttt{.tex} extension may be omitted.) +%will result in four numbered problems, selected at random +%from the file \texttt{easy.tex}. (The \texttt{.tex} extension +%may be omitted.) Each problem is followed by the command +%\cmddef{endPSNitem} which by default does nothing. % -% Multiple |\selectrandomly| commands may be used. For example: +%Multiple \cmdname{selectrandomly} commands may be used, however a +%different file must be used each time. For +%example: %\begin{verbatim} %\begin{enumerate} %\item Differentiate the following functions with respect to $x$: @@ -193,67 +291,246 @@ % %\end{enumerate} %\end{verbatim} -% This will result in a total of 6 problems, numbered 1(a), 1(b), 1(c), 1(d), 2 and 3. +%This will result in a total of 6 problems, numbered 1(a), +%1(b), 1(c), 1(d), 2 and 3. % -% If a randomly selected problem requires arguments, a message similar to the following -% will be displayed: +%If a randomly selected problem requires arguments, a message +%similar to the following will be displayed: %\begin{verbatim} %Problem diff:quad requires 3 argument(s), please specify (e.g. {5}{3}): %\end{verbatim} -% Enter the required arguments, where each argument is enclosed in braces (\{ \}). -% -% \subsection{Other Commands} -% \DescribeMacro{\PSNrandseed} -% The command |\PSNrandseed{|\meta{n}|}| specifies the seed for the random -% number generator. For example, |\PSNrandseed{\year}| will produce a -% different set of random problems each year, whereas |\PSNrandseed{\time}| -% will produce a different set of problems each time you \LaTeX\ the -% problem (as long as you leave at least a minute between runs.) -% -% \DescribeMacro{\showanswers} -% The command |\showanswers| will show the solutions from that point -% on. May be localised by placing within a group. -% -% \DescribeMacro{\hideanswers} -% The command |\hideanswers| will hide the solutions from that point -% on. May be localised by placing within a group. -% -% \DescribeMacro{\solutionname} -% By default, the solution is preceeded by the text: \textbf{Solution:}. This can -% be changed by redefining the macro |\solutionname|. -% -% \DescribeMacro{showanswers} -% The boolean variable |showanswers| is defined to be true if the answers -% are shown and false otherwise. You can therefore do something like: +%Enter the required arguments, where each argument is +%enclosed in braces (\{ \}). +% +%\section{Other Commands} +%\DescribeMacro{\PSNrandseed} +%The command \cmddef{PSNrandseed}\verb|{|\meta{n}\verb/}/ specifies +%the seed for the random number generator. For example, +%if you are using \cmdlink{selectrandomly}, +%\verb|\PSNrandseed{\year}| will produce a different set of +%problems each year, whereas \verb|\PSNrandseed{\time}| +%will produce a different set of problems each time you +%\LaTeX\ the problem sheet (as long as you leave at least a +%minute between runs.) +% +%\DescribeMacro{\random} +%The command \cmddef{random}\verb|{|\meta{counter}\verb/}{/\meta{a}\verb!}{!\meta{b}\verb-}- +%generates a random number from \meta{a} to \meta{b} and +%stores it in the \LaTeX\ counter \meta{counter}. For example, +%to select 2, 3 or 4 problems from the file +%\texttt{implicit.tex}: +%\begin{verbatim} +%\newcounter{numproblems} +%\begin{enumerate} +%\random{numproblems}{2}{4} +%\selectrandomly{implicit.tex}{\value{numproblems}} +%\end{enumerate} +%\end{verbatim} +%(Note the use of \cmdname{value}.) +% +%This command can also be used to generate random values for +%problems that take arguments. Consider the problem \probref{diff:quad} +%defined earlier. Three counters can be defined to represent the +%three coefficients: +%\begin{verbatim} +%\newcounter{A} +%\newcounter{B} +%\newcounter{C} +%\end{verbatim} +%Random values can now be assigned to these counters: +%\begin{verbatim} +%\random{A}{-5}{5} +%\random{B}{-5}{5} +%\random{C}{-5}{5} +%\end{verbatim} +%Finally, the problem can be used (note the use of \cmdname{arabic}): +%\begin{verbatim} +%\useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}} +%\end{verbatim} +% +%\DescribeMacro{\doforrandN}% +%The command +%\cmddef{doforrandN}\verb|{|\meta{n}\verb/}{/\meta{cmd}\verb!}{!\meta{list}\verb+}{+\meta{text}\verb-}- will apply +%\meta{text} for a random selection of \meta{n} items in the +%comma separated \meta{list}. In each iteration the list +%item is denoted by \meta{cmd}. For example, suppose you +%have three files called \texttt{file1.tex}, +%\texttt{file2.tex} and \texttt{file3.tex}, and you want to +%select 1 problem from two of the three files, then you can +%do: +%\begin{verbatim} +%\doforrandN{2}{\file}{file1,file2,file3}{\selectrandomly{\file}{1}} +%\end{verbatim} +%Note that it is also possible to do +%\begin{verbatim} +%\newcounter{numproblems} +%\random{numproblems}{1}{3} +%\selectrandomly{file\arabic{numproblems}}{1} +%\random{numproblems}{1}{3} +%\selectrandomly{file\arabic{numproblems}}{1} +%\end{verbatim} +%however there is a possibility that the same file may be +%selected twice which will cause an error. +% +%\DescribeMacro{\showanswers} +%The command \cmddef{showanswers} will show the solutions from +%that point on. May be localised by placing within a group. +% +%\DescribeMacro{\hideanswers} +%The command \cmddef{hideanswers} will hide the solutions from +%that point on. May be localised by placing within a group. +% +%The solution is placed inside the \DescribeEnv{solution}\env{solution} +%environment. By default this environment simply does +%\verb|\paragraph{\solutionname:}| at the start, where +%\DescribeMacro{\solutionname}\cmddef{solutionname} +%has the value: Solution. See the file \texttt{sample3.tex}, which +%comes with this package, for an illustration of how to +%customise the way in which the randomly selected problems are +%displayed. This sample file randomly selects multiple choice +%problems stored in the file \texttt{tabmchoice.tex}, and displays them +%in a longtable \env{environment}. +% +%\DescribeMacro{showanswers} +%The boolean variable \texttt{showanswers} is defined to be +%true if the answers are shown and false otherwise. You can +%therefore do something like: %\begin{verbatim} %\ifthenelse{\boolean{showanswers}}{\textbf{Solution Sheet}}{} %\end{verbatim} -% and \textbf{Solution Sheet} will be printed only if the answers are displayed. -%(For more information on |\ifthenelse| and |\boolean| see the -%documentation for the |ifthen| package by David Carlisle.) +%and \textbf{Solution Sheet} will be printed only if the +%answers are displayed. (For more information on +%\cmdname{ifthenelse} and \cmdname{boolean} see the +%documentation for the \texttt{ifthen} package by +%David Carlisle.) +% +%The \texttt{showanswers} switch can also be used within the definition +%of a problem, if you want the question to appear differently if the +%solution is displayed. For example: +%\begin{verbatim} +%\newproblem{mc:prod}{% +%Which of the following is the derivative of $x\sin(x)$? +%(Circle the correct answer.) +%\ifthenelse{\boolean{showanswers}}{}% +%{\begin{description} +%\item[A] $\sin(x)$ +%\item[B] $x\cos(x)$ +%\item[C] $\sin(x) + x\cos(x)$ +%\end{description} +%}}{% +%\begin{description} +%\item[A] $\sin(x)$ +%\item[B] $x\cos(x)$ +%\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule). +%\end{description} +%} +%\end{verbatim} +%If the solutions are not displayed, the question will appear +%as +%\begin{description} +%\item Which of the following is the derivative of +%$x\sin(x)$? (Circle the correct answer.) +%\begin{description} +%\item[A] $\sin(x)$\item[B] $x\cos(x)$\item[C] $\sin(x) + x\cos(x)$\end{description} +%\end{description} +%otherwise it will appear as: +%\begin{description} +%\item Which of the following is the derivative of +%$x\sin(x)$?(Circle the correct answer.) +%\begin{description} +%\item[A] $\sin(x)$\item[B] $x\cos(x)$\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule)\end{description} +%\end{description} +% +%\section{Troubleshooting} +%\subsection{Unexpected Output} +%\begin{itemize} +%\item I have lots of blank space before the first problem when +%using \cmdlink{selectrandomly}. +% +%This is probably because you have lots of extraneous white space +%in your database. \cmdlink{selectrandomly} will input the entire +%file, so any extra space will be included. Try commenting out the +%extra space using \%. +%\end{itemize} % -% \section{Error Messages} +%\subsection{Error Messages} +%\begin{itemize} +%\item %\begin{ttfamily} %! Package probsoln Error: Label \ldots\ already used. -%\end{ttfamily}\\[10pt] -% Each label identifier used in |\newproblem| must be unique. -% Check to make sure you haven't used the same label more than once. -% Also check to make sure you haven't |\input|ed or randomly selected -% from the same file more than once. (Or |\input|ed and randomly -% selected from the same file.) -%\\[10pt] +%\end{ttfamily} +% +%Each label identifier used in \cmdlink{newproblem} must be +%unique. Check to make sure you haven't used the same label +%more than once. Also check to make sure you haven't +%\cmdname{input}ed or randomly selected from the same file more +%than once. (Or \cmdname{input}ed and randomly selected from +%the same file.) +% +%\item %\begin{ttfamily} %! Package probsoln Error: Label \ldots\ undefined. -%\end{ttfamily}\\[10pt] -% You need to define a problem before you can use it. Check to -% make sure you haven't mis-spelt it. -%\\[10pt] +%\end{ttfamily} +% +%You need to define a problem before you can use it. Check to +%make sure you haven't mis-spelt it, and check to make sure you +%have \cmdname{input}ed the file in which it is defined. +% +%\item %\begin{ttfamily} %! Package probsoln Error: Requested number too large. %\end{ttfamily} -%\\[10pt] -% You have asked for more problems than are defined within -% the specified file. All problems in that file will be selected. +% +%You have asked for more problems than are defined within the +%specified file. All problems in that file will be selected. +% +%\item +%\begin{ttfamily} +%! Package probsoln Error: Can't randomly select \meta{n} +%item(s) +%\end{ttfamily} +% +%You have asked to randomly select \meta{n} items from a list +%that has less than \meta{n} elements. For example, the +%following will generate this error: +%\begin{verbatim} +%\doforrandN{10}{\file}{file1,file2,file3}{% +%\selectrandomly{\file}{1}} +%\end{verbatim} +%In this case the list, \texttt{file1,file2,file3} has only 3 +%elements, but the user has asked for 10 elements. If you type +%`h' at the \LaTeX\ prompt it will tell you how many items it thinks +%there are in the list. Remember that each item must be separated by a +%comma. +% +%\item +%\begin{ttfamily} +%! LaTeX Error: Lonely \cmdname{item}--perhaps missing list +%environment. +%\end{ttfamily} +% +%Each problem selected using \cmdlink{selectrandomly} is +%proceeded by \cmdlink{PSNitem} which by default is defined +%as \cmdname{item}, and should therefore be +%placed in one of the list environments, such as +%\texttt{enumerate}. Alternatively, redefine \cmdlink{PSNitem}. +% +%\item I get an error when I put a command definition in my database +%when using \cmdname{selectrandomly}. +% +%\cmdlink{selectrandomly} inputs the database twice, so any +%command definition will be read twice, causing an error. You +%can use the switch \cmdname{iffirstpass} to prevent the error. For +%example: +%\begin{verbatim} +%\iffirstpass +%\newcommand{\mycmd}{} +%\fi +%\end{verbatim} +%It is generally not a good idea to put anything other than +%\cmdlink{newproblem} commands within the database. +% +%\end{itemize} % %\section{Contact Details} %Dr Nicola Talbot\\ @@ -262,26 +539,17 @@ %Norwich. NR4 7TJ\\ %\url{http://theoval.cmp.uea.ac.uk/~nlct/} % -% \StopEventually{} -% \section{The Code} -% \iffalse -% First we have the driver to get the documentation +%\StopEventually{\PrintIndex} +% +%\section{The Code} % \begin{macrocode} -%<*driver> -\documentclass{ltxdoc} -\usepackage[colorlinks,bookmarks]{hyperref} -\begin{document} -\OnlyDescription -\DocInput{probsoln.dtx} -\end{document} -% +%<*probsoln.sty> % \end{macrocode} -% \fi -% At the start of the package, specify that the \LaTeX2e format is +% At the start of the package, specify that the \LaTeXe\ format is % required. And specify the package provided. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{probsoln}[2004/03/21 Problems and their Solutions Package] +\ProvidesPackage{probsoln}[2006/03/02 v2.02 Problems and their Solutions Package (NLCT)] \RequirePackage{ifthen} % \end{macrocode} % Define newif to determine whether or not to show the answers. @@ -298,11 +566,6 @@ \ExecuteOptions{noanswers} \ProcessOptions % \end{macrocode} -% Create a newif to determine whether a command has already been defined -% \begin{macrocode} -\newif\ifdefined -\def\checkdefined#1{\ifx#1\relax \definedfalse \else \definedtrue \fi} -% \end{macrocode} % Create newifs for selecting randomly and parsing through file % \begin{macrocode} \newif\ifselectrandom \selectrandomfalse @@ -311,93 +574,93 @@ % \end{macrocode} % Define the command that creates a new problem % \begin{macrocode} -\newcommand{\solutionname}{Solution:} +\newcommand{\solutionname}{Solution} \newcommand{\newproblem}[4][0]{% \ifselectrandom \iffirstpass % on the first pass, just store the label, and increment \@probN \global\advance\@probN by 1 -\expandafter\gdef\csname @problabel\romannumeral\@probN\endcsname{#2} +\expandafter\gdef\csname @problabel\romannumeral\@probN\endcsname{#2}% \else % check to see if this problem has been selected -\checkselected{#2} +\checkselected{#2}% \ifselected -\expandafter\checkdefined\csname @prob@#2\endcsname -\ifdefined -\PackageError{probsoln}{Label #2 already used}% -{Each problem must have a unique label identifier} -\else +\@ifundefined{@prob@#2}{% \ifnum#1=0 % this problem has no arguments -\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\paragraph{\solutionname} #4\fi} +\expandafter\gdef\csname @prob@#2\endcsname{% +#3 \ifshowanswers\begin{solution}#4\end{solution}\fi}% +\expandafter\gdef\csname @prob@#2@arg\endcsname{\relax}% \else -\message{Problem #2 requires #1 argument(s), please specify (e.g. {5}{3}):} +\message{Problem #2 requires #1 argument(s), please specify (e.g. {5}{3}):}% \read-1to\@tmp -\expandafter\let\csname @prob@#2@arg\endcsname=\@tmp -\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\paragraph{\solutionname} #4\fi} -\fi +\expandafter\xdef\csname @prob@#2@arg\endcsname{\@tmp}% +\expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% +#3 \ifshowanswers\solution #4\fi}% \fi +}{% +\PackageError{probsoln}{Label #2 already used}% +{Each problem must have a unique label identifier}% +}% \fi \fi \else -\expandafter\checkdefined\csname @prob@#2\endcsname -\ifdefined +\@ifundefined{@prob@#2}{% +\expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% +#3 \ifshowanswers\begin{solution}#4\end{solution}\fi}% +}{% \PackageError{probsoln}{Label #2 already used}% -{Each problem must have a unique label identifier} -\else -\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\paragraph{\solutionname} #4\fi} -\fi +{Each problem must have a unique label identifier}% +} \fi } % \end{macrocode} % Define the command that uses a problem % \begin{macrocode} \newcommand{\useproblem}[1]{% -\expandafter\checkdefined\csname @prob@#1\endcsname -\ifdefined -\def\doprob{\csname @prob@#1\endcsname} -\else +\@ifundefined{@prob@#1}{% \PackageError{probsoln}{Label #1 undefined}% -{Can't find problem defined with label identifier '#1'} -\def\doprob{\relax} -\fi -\doprob +{Can't find problem defined with label identifier '#1'}% +}{\csname @prob@#1\endcsname}% } % \end{macrocode} % Now deal with the stuff for random selection. -% Syntax: |\selectrandomly{|\meta{filename}|}{|\meta{n}|}|. +% First define some registers for later use. % \begin{macrocode} \newcount\@probN \newcount\@probselN \newcount\@rndselctr - -% \PSNrandom{}{} stores a random number from 1 to -% in the TeX count register \newcount\r@ndcur +\newcount\@ps@randtmp \r@ndcur=1\relax +% \end{macrocode} +% Set the random generator seed +% \begin{macrocode} \newcommand{\PSNrandseed}[1]{% -\ifnum#1=0 -\typeout{Can't have 0 as random seed, changing to 1} +\ifnum#1=0\relax +\PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}% \r@ndcur=1\relax \else \r@ndcur=#1\relax \fi -\typeout{Random Seed = \the\r@ndcur} +\PackageInfo{probsoln}{Random Seed = \the\r@ndcur}% } - -\newcount\@ps@randtmp -\newcommand{\PSNrand}{ +% \end{macrocode} +% Generate a random integer. +% \begin{macrocode} +\newcommand{\PSNrand}{% \@ps@randtmp=\r@ndcur \multiply\@ps@randtmp by 16807\relax \r@ndcur=\@ps@randtmp -\divide\r@ndcur by 120001 -\multiply\r@ndcur by 120001 +\divide\r@ndcur by 120001\relax +\multiply\r@ndcur by 120001\relax \advance\@ps@randtmp by -\r@ndcur \r@ndcur = \@ps@randtmp \ifnum\r@ndcur=0\relax\r@ndcur=1\fi } - +% \end{macrocode} +% |\PSNrandom{|\meta{count}|}{|\meta{n}|}| stores a random number +% from 1 to \meta{n} +% in the TeX count register \meta{count} +% \begin{macrocode} \newcommand{\PSNrandom}[2]{% % generate new random number. \PSNrand @@ -409,33 +672,83 @@ \advance#1 by -\@ps@randtmp \advance#1 by 1\relax } - +% \end{macrocode} +% |\random{|\meta{counter}|}{|\meta{a}|}{|\meta{b}|}|: +% Generate a random number in the range $[a,b]$, and store this +% number in the \LaTeX\ counter \meta{counter}. +% \begin{macrocode} +\newcommand{\random}[3]{% +\ifnum#2=1\relax +\PSNrandom{\value{#1}}{#3}% +\else +\@rndselctr=#3% +\advance\@rndselctr by -#2\relax +\advance\@rndselctr by 1\relax +\PSNrandom{\value{#1}}{\@rndselctr}% +\addtocounter{#1}{#2}% +\addtocounter{#1}{-1}% +\fi +} +% \end{macrocode} +% Define command to use all problems from a given file. +% Syntax: |\selectallproblems{|\meta{filename}|}|. +% \begin{macrocode} +\newcommand*{\selectallproblems}[1]{% +\global\@probN=0\relax +\selectrandomtrue +\firstpasstrue +\input{#1}% +\firstpassfalse +\selectrandomfalse +\input{#1}% +\global\@rndselctr=1\relax +\whiledo{\@rndselctr < \@probN \TE@or \@rndselctr = \@probN}{% +\edef\@tmp{\csname @problabel\romannumeral\@rndselctr\endcsname}% +\edef\@probargs{{\@tmp}\csname @prob@\@tmp @arg\endcsname}% +\PSNitem \expandafter\useproblem\@probargs \endPSNitem +\global\advance\@rndselctr by 1\relax +}} +% \end{macrocode} +% Now define command to randomly select \meta{n} problems from +% a given file. +% Syntax: |\selectrandomly{|\meta{filename}|}{|\meta{n}|}|. +% \begin{macrocode} \newcommand{\selectrandomly}[2]{% -\global\@probselN=#2 -\global\@probN=0 +\global\@probselN=#2\relax +\global\@probN=0\relax \selectrandomtrue \firstpasstrue -\input{#1} +\input{#1}% \ifnum\@probselN>\@probN \PackageError{probsoln}{Requested number too large}% {You have asked for \the\@probselN \space problems, but there are only \the\@probN \space problems defined in the file #1. I will only select \the\@probN \space -problems.} +problems.}% \global\@probselN=\@probN \fi -\shuffle{@problabel}{\@probN} +\shuffle{@problabel}{\@probN}% \firstpassfalse -\input{#1} +\input{#1}% \selectrandomfalse -\@rndselctr=1\relax +\global\@rndselctr=1\relax \whiledo{\@rndselctr < \@probselN \TE@or \@rndselctr = \@probselN}{% -\edef\@tmp{\csname @problabel\romannumeral\@rndselctr\endcsname} -\edef\@probargs{{\@tmp}\csname @prob@\@tmp @arg\endcsname} -\item \expandafter\useproblem\@probargs -\advance\@rndselctr by 1\relax -} +\edef\@tmp{\csname @problabel\romannumeral\@rndselctr\endcsname}% +\edef\@probargs{{\@tmp}\csname @prob@\@tmp @arg\endcsname}% +\PSNitem \expandafter\useproblem\@probargs \endPSNitem +\global\advance\@rndselctr by 1\relax +}% } % \end{macrocode} +% What to do at start and end of each randomly selected item: +% \begin{macrocode} +\newcommand{\PSNitem}{\item} +\@ifundefined{endPSNitem}{\def\endPSNitem{}}{% +\PackageError{probsoln}{\string\endPSitem\ already defined}{}} +% \end{macrocode} +% How to display each solution +% \begin{macrocode} +\newenvironment{solution}{\paragraph{\solutionname:}}{} +% \end{macrocode} % Check to see if label has been selected % \begin{macrocode} \newcount\@ckselctr @@ -444,30 +757,531 @@ problems.} \@ckselctr=1\relax \whiledo{\@ckselctr < \@probselN \TE@or \@ckselctr = \@probselN}{% \ifthenelse{\equal{#1}{\csname @problabel\romannumeral\@ckselctr\endcsname}}% -{\global\selectedtrue \global\@ckselctr=\@probselN}{} +{\global\selectedtrue \global\@ckselctr=\@probselN}{}% \advance\@ckselctr by 1\relax -} +}% } % \end{macrocode} -% Shuffle contents of pseudo-array +% Shuffle contents of pseudo-array. For example, suppose you have +% the following definitions: |\def\fooi{A}|, |\def\fooii{B}| and +% |\def\fooiii{C}|, then |\shuffle{foo}{3}| will shuffle the +% definitions, so you may end up with, e.g.\ |\def\fooi{C}|, +% |\def\fooii{A}|, |\def\fooiii{B}|, or some other variation. % \begin{macrocode} \newcount\@shfctr \newcount\@shfA \newcount\@shfB \newcommand{\shuffle}[2]{% \@shfctr=1\relax \whiledo{\@shfctr < 101}{% -\PSNrandom{\@shfA}{#2}\PSNrandom{\@shfB}{#2} +\PSNrandom{\@shfA}{#2}\PSNrandom{\@shfB}{#2}% \ifnum\@shfA=\@shfB \else -\edef\@@tmpA{\csname#1\romannumeral\@shfA\endcsname} +\edef\@@tmpA{\csname#1\romannumeral\@shfA\endcsname}% \let\@tmpA=\@@tmpA -\edef\@@tmpB{\csname#1\romannumeral\@shfB\endcsname} +\edef\@@tmpB{\csname#1\romannumeral\@shfB\endcsname}% \let\@tmpB=\@@tmpB -\expandafter\xdef\csname#1\romannumeral\@shfA\endcsname{\@tmpB} -\expandafter\xdef\csname#1\romannumeral\@shfB\endcsname{\@tmpA} +\expandafter\xdef\csname#1\romannumeral\@shfA\endcsname{\@tmpB}% +\expandafter\xdef\csname#1\romannumeral\@shfB\endcsname{\@tmpA}% \fi \advance\@shfctr by 1\relax +}% +} +% \end{macrocode} +% Syntax: |\doforrandN{|\meta{n}|}{|\meta{cmd}|}{|\meta{list}|}{|\meta{text}|}|. +% A bit like |\@for| but only for a random subset of the given list. +% For example, +%\begin{verbatim} +%\doforrandN{2}{\tmp}{file1,file2,file3}{% +%\selectrandomly{\tmp}{1}} +%\end{verbatim} +%This will select one problem each from two out of the three listed +%files. +% \begin{macrocode} +\newcount\@ps@forrand +\newcommand{\doforrandN}[4]{% +{\@ps@forrand=0\relax +\@for#2:=#3\do{% +\advance\@ps@forrand by 1\relax +\expandafter\edef\csname @doforrandN@\romannumeral\@ps@forrand\endcsname{#2}}% +\ifnum\@ps@forrand<#1\relax +\PackageError{probsoln}{Can't randomly select \number#1 item(s)}{You +have requested \number#1 item(s), but there +are only \number\@ps@forrand item(s) in the list}% +\else +\shuffle{@doforrandN@}{\@ps@forrand}% +\ifnum#1>0\relax +\@ps@forrand=0\relax +\loop +\advance\@ps@forrand by 1\relax +\edef#2{\csname @doforrandN@\romannumeral\@ps@forrand\endcsname}% +#4% +\ifnum\@ps@forrand<#1\relax +\repeat +\fi +\fi +}} +% \end{macrocode} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*1stprncp.tex> +% \end{macrocode} +% These all involve differentiating from 1st principles + +\newproblem{dfp:xcube}{% +Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{% +\begin{eqnarray*} +\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\ + & = & 3x^2 +\end{eqnarray*}} + +\newproblem{dfp:Ioverxsq}{% +Differentiate $\displaystyle f(x) = \frac{1}{x^2}$ with respect to $x$ by first principles.}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{1}{(x+\Delta x)^2}-\frac{1}{x^2}}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{x^2-(x+\Delta x)^2}{x^2(x+\Delta x)^2}}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{x^2-(x^2+2x\Delta x+(\Delta x)^2)}{x^2\Delta x(x+\Delta x)^2}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{-2x\Delta x-(\Delta x)^2}{x^2\Delta x(x+\Delta x)^2}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{-2x-\Delta x}{x^2(x+\Delta x)^2}\\ + & = & \frac{-2x}{x^2x^2}\\ + & = & -\frac{2}{x^3} +\end{eqnarray*}} + +\newproblem{dfp:sqrtx}{% +Differentiate from first principles $f(x) = \surd x$}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\sqrt{x+\Delta x}-\surd x}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{(\sqrt{x+\Delta x}-\surd x)(\sqrt{x+\delta x}+\surd x)}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{x+\Delta x - x}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{\Delta x}{\Delta x(\sqrt{x+\Delta x}+\Delta x)}\\ + & = & \lim_{\Delta x\rightarrow 0}\frac{1}{\sqrt{x+\Delta x}+\surd x}\\ + & = & \frac{1}{2\surd x} +\end{eqnarray*}} + +\newproblem{dfp:cons}{% +Differentiate from first principles $f(x) = c$ where $c$ is a constant.}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{c-c}{\Delta x}\\ + & = & \lim_{\Delta x\rightarrow 0}0\\ + & = & 0 +\end{eqnarray*}} + +\newproblem{dfp:cosx}{% +Given +\begin{eqnarray*} +\lim_{x \rightarrow 0} \frac{\cos x - 1}{x} & = & 0\\ +\lim_{x \rightarrow 0} \frac{\sin x}{x} & = & 1 +\end{eqnarray*} +differentiate from first principles $f(x) = \cos x$.}{% +\begin{eqnarray*} +\frac{df}{dx} & = & \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) - f(x)}{\Delta x}\\ + & = & \lim_{\Delta x \rightarrow 0} \frac{\cos(x + \Delta x) - \cos(x)}{\Delta x}\\ + & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x\cos\Delta x - \sin x\sin\Delta x - \cos x}{\Delta x}\\ + & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x(\cos\Delta x - 1) - \sin x\sin\Delta x}{\Delta x}\\ + & = & \cos x\lim_{\Delta x \rightarrow 0}\frac{\cos\Delta x - 1}{\Delta x} + - \sin x\lim_{\Delta x \rightarrow 0}\frac{\sin\Delta x}{\Delta x}\\ + & = & -1 \qquad\mbox{(using given results)} +\end{eqnarray*}} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*args.tex> +% \end{macrocode} +% 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)\) } + +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*easy.tex> +% \end{macrocode} +% These are all easy differentiation problems + +\newproblem{diffeasy:gpowh}{% +\(f(x) = g(x)^{h(x)}.\)}{% +\begin{eqnarray*} +f(x) & = & e^{\ln g(x)^{h(x)}}\\ + & = & e^{h(x)\ln g(x)}\\ +f'(x) & = & e^{h(x)\ln g(x)}(h'(x)\ln g(x) + h(x)\frac{g'(x)}{g(x)})\\ + & = & g(x)^{h(x)}(h'(x)\ln g(x) + \frac{h(x)g'(x)}{g(x)}) +\end{eqnarray*}} + +\newproblem{diffeasy:arcsin}{% +\(y = \arcsin(x)\)}{% +\[\sin(y) = x\] +diff. w.r.t. $x$: +\begin{eqnarray*} +\cos y \frac{dy}{dx} & = & 1\\ +\frac{dy}{dx} & = & \frac{1}{\cos y}\\ + & = & \frac{1}{\sqrt{1 - \sin^2y}}\\ + & = & \frac{1}{\sqrt{1-x^2}}. +\end{eqnarray*}} + +\newproblem{diffeasy:arccos}{% +$y = \arccos x$.}{% +\(\cos y = x\) +diff. w.r.t. $x$: +\begin{eqnarray*} +-\sin y \frac{dy}{dx} & = & 1\\ +\frac{dy}{dx} & = & \frac{-1}{\sin y}\\ + & = & \frac{-1}{\sqrt{1-\cos^2y}}\\ + & = & \frac{-1}{\sqrt{1-x^2}} +\end{eqnarray*}} + +\newproblem{diffeasy:tan}{% +\(y = \tan x\)}{% +\begin{eqnarray*} +y & = & \tan x\\ + & = & \frac{\sin x}{\cos x}\\ +\frac{dy}{dx} & = & \frac{\cos x}{\cos x} + \sin x\times\frac{-1}{\cos^2x}\times -\sin x\\ + & = & 1 + \tan^2x\\ + & = & \sec^2x. +\end{eqnarray*}} + +\newproblem{diffeasy:arctan}{% +\(y = \arctan x = \tan^{-1}x\)}{% +\[\tan y = x\] +diff w.r.t. $x$: +\begin{eqnarray*} +\sec^2y\frac{dy}{dx} & = & 1\\ +\frac{dy}{dx} & = & \frac{1}{\sec^2y}\\ + & = & \frac{1}{1+\tan^2y}\\ + & = & \frac{1}{1+x^2} +\end{eqnarray*}} + +\newproblem{diffeasy:cot}{% +\(y = (\tan x)^{-1} = \cot x\)}{% +\begin{eqnarray*} +\frac{dy}{dx} & = & -(\tan x)^{-2}\sec^2x\\ + & = & -\frac{\cos^2x}{\sin^2x}\cdot\frac{1}{\cos^2x}\\ + & = & \frac{-1}{\sin^2x}\\ + & = & -\csc^2x. +\end{eqnarray*}} + +\newproblem{diffeasy:cosxsqsinx}{% +$y = \cos(x^2)\sin x$.}{% +\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]} + +\newproblem{diffeasy:xlnx}{% +$y = (x+1)\ln(x+1)$.}{% +\begin{eqnarray*} +\frac{dy}{dx} & = & \ln(x+1) + \frac{x+1}{x+1}\\ + & = & 1 + \ln(x+1). +\end{eqnarray*}} + +\newproblem{diffeasy:glng}{% +$f(x) = g(x)\ln(g(x))$.}{% +\begin{eqnarray*} +f'(x) & = & g'(x)\ln(g(x)) + \frac{g(x)}{g(x)}g'(x)\\ + & = & g'(x)(1+\ln(g(x))). +\end{eqnarray*}} + +\newproblem{diffeasy:sinx/x}{% +$y = \frac{\sin x}{x}$.}{% +\[\frac{dy}{dx} = \frac{\cos x}{x} - \frac{\sin x}{x^2}\]} + +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*implicit.tex> +% \end{macrocode} +% These are all implicit differentiation problems + +\newproblem{imd:circ}{% +Find the gradient of the unit circle ($x^2 + y^2 = 1$).}{% +Differentiating with respect to $x$ gives: +\begin{eqnarray*} +2x + 2y\frac{dy}{dx} & = & 0\\ +\frac{dy}{dx} & = & \frac{-2x}{2y}\\ + & = & \frac{-x}{\sqrt{1-x^2}}. +\end{eqnarray*}} + +\newproblem{imd:ysq:xcuov2mx}{% +Find $\frac{dy}{dx}$, given +\begin{displaymath} +y^2 = \frac{x^3}{2-x} +\end{displaymath}}{% +Differentiating both sides w.r.t.\ $x$: +\begin{eqnarray*} +2y\frac{dy}{dx} & = & \frac{(2-x)3x^2 - x^3(-1)}{(2-x)^2}\\ + & = & \frac{3x^2(2-x) + x^3}{(2-x)^2}\\ + & = & \frac{6x^2 - 3x^3 + x^3}{(2-x)^2}\\ + & = & \frac{6x^2-2x^3}{(2-x)^2}\\ + & = & 2x^2\frac{3-x}{(2-x)^2} +\end{eqnarray*} +Therefore +\begin{displaymath} +y\frac{dy}{dx} = x^2\frac{3-x}{(2-x)^2} +\end{displaymath}} + +\newproblem{imd:exy:IIxay}{% +Differentiate w.r.t.\ $x$: +\begin{displaymath} +e^{xy} = 2x + y +\end{displaymath}}{% +Differentiating both sides w.r.t.\ $x$: +\begin{eqnarray*} +e^{xy}(1y + x\frac{dy}{dx}) & = & 2 + \frac{dy}{dx}\\ +xe^{xy}\frac{dy}{dx} - \frac{dy}{dx} & = & 2 - ye^{xy} \\ +\frac{dy}{dx}(xe^{xy}-1) & = & 2 - ye^{xy}\\ +\frac{dy}{dx} & = & \frac{2-ye^{xy}}{xe^{xy}-1} +\end{eqnarray*}} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*mchoice.tex> +% \end{macrocode} +\newproblem{mc:prod}{% +Which of the following is the derivative of $x\sin(x)$? +(Circle the correct answer.) +\ifthenelse{\boolean{showanswers}}{}% +{\begin{description} +\item[A] $\sin(x)$ +\item[B] $x\cos(x)$ +\item[C] $\sin(x) + x\cos(x)$ +\end{description} +}}{% +\begin{description} +\item[A] $\sin(x)$ +\item[B] $x\cos(x)$ +\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule). +\end{description} +} + +\newproblem{mc:quot}{% +Which of the following is the derivative of $\frac{\sin(x)}{x}$? +(Circle the correct answer.) +\ifthenelse{\boolean{showanswers}}{}% +{\begin{description} +\item[A] $\sin(x)$ +\item[B] $\cos(x)$ +\item[C] $\frac{\cos(x)x-\sin(x)}{x^2}$ +\end{description} +}}{% +\begin{description} +\item[A] $\sin(x)$ +\item[B] $\cos(x)$ +\item[\textcircled{C}] $\frac{\cos(x)x-\sin(x)}{x^2}$ +(quotient rule) +\end{description} +} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*sample.tex> +% \end{macrocode} +\documentclass[a4paper]{article} + +\usepackage{probsoln} +%uncomment the following line to display the answers +\showanswers + +% The following will generate a different set of +% problems in subsequent years +\PSNrandseed{\year} + +\begin{document} +\title{Sample Problem Sheet} +\author{Nicola Talbot} +\maketitle + +\begin{enumerate} +% Differentiation from first principles +\selectrandomly{1stprncp}{1} + +\item Differentiate the following functions: +\begin{enumerate} +\selectrandomly{easy}{5} +\end{enumerate} + +% Implicit differentiation +\selectrandomly{implicit}{2} + +% Multiple choice question +\selectrandomly{mchoice}{1} +\end{enumerate} +\end{document} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*sample2.tex> +% \end{macrocode} +\documentclass[a4paper]{article} + +\usepackage{probsoln} +%uncomment the following line to display the answers +\showanswers + +% The following will generate a different set of +% problems in subsequent years +%\PSNrandseed{\year} + +% The following will generate a different set of +% problems on every run (where each run is at +% least a minute apart from the previous one) +\PSNrandseed{\time} + +\begin{document} +\title{Sample Problem Sheet} +\author{Nicola Talbot} +\maketitle + +\begin{enumerate} + +\newcounter{numproblems} +% store a random number from 1 to 3 in the counter numproblems +\random{numproblems}{1}{3} + +% selects 1,2 or 3 problems from 1 of the given files: +\doforrandN{1}{\file}{1stprncp,implicit}{\selectrandomly{\file}{\value{numproblems}}} + +\item Differentiate the following functions: +\input{args}% load database +\begin{enumerate} +\newcounter{A} +\newcounter{B} +\newcounter{C} +\random{A}{-4}{5} +\random{B}{-3}{3} +\random{C}{-1}{10} +\item \useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}} + +\random{A}{-5}{5} +% make sure its not 0 +\whiledo{\value{A}=0}{\random{A}{-5}{5}} +\item \useproblem{diff:sin}{\arabic{A}} +\end{enumerate} +\end{enumerate} +\end{document} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*sample3.tex> +% \end{macrocode} +\documentclass[a4paper]{article} + +\usepackage{longtable} +\usepackage{probsoln} + +%\showanswers + +\newcounter{problem} +\renewcommand{\PSNitem}{\refstepcounter{problem}% +\theproblem. } +\renewcommand{\endPSNitem}{\\} + +\renewenvironment{solution}{}{} + +\newcommand{\selected}{\fbox{$\times$}} +\newcommand{\notselected}{\fbox{\phantom{$\times$}}} + +\begin{document} +\begin{longtable}{lrrrl} +\bfseries Question & \bfseries A & \bfseries B & +\bfseries C & \ifshowanswers \bfseries Reason\fi\\ +\selectrandomly{tabmchoice}{2} +\end{longtable} +\end{document} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*sample4.tex> +% \end{macrocode} +\documentclass[a4paper]{article} + +\usepackage{probsoln} + +% Sample file illustrating use of \selectallproblems +% All problems defined in specified file will be used +% in order of definition + +\showanswers + +\begin{document} +Differentiate the following functions: +\begin{enumerate} +\selectallproblems{easy} +\end{enumerate} +\end{document} +% \begin{macrocode} +% +% \end{macrocode} +% \begin{macrocode} +%<*tabmchoice.tex> +% \end{macrocode} +% These problems are designed to be placed in a +% tabular environment +% +\newproblem{tab:1}{% +What is $(3+2)\times5$? & +25 \ifshowanswers\selected\else\notselected\fi & +13 \notselected & +10 \notselected & +}{Brackets come first}% +% +\newproblem{tab:2}{% +What is $-1+2\times3$? & +3 \notselected & +-7 \notselected & +5 \ifshowanswers\selected\else\notselected\fi & +}{Multiplication comes first}% +% \begin{macrocode} +% % \end{macrocode} %\Finale \endinput diff --git a/Master/texmf-dist/source/latex/probsoln/probsoln.ins b/Master/texmf-dist/source/latex/probsoln/probsoln.ins index 49947b3dc75..cc868fab642 100644 --- a/Master/texmf-dist/source/latex/probsoln/probsoln.ins +++ b/Master/texmf-dist/source/latex/probsoln/probsoln.ins @@ -1,11 +1,39 @@ -\def\batchfile{probsoln.ins} -\input docstrip.tex +% probsoln.ins generated using /nlctltpc/home/nlct/bin/makedtx version 0.9b 2006/3/2 11:26 +\input docstrip + \preamble -Copyright (C) 2000 Nicola Talbot, all rights reserved. +Copyright (C) 2006 Nicola Talbot, all rights reserved. If you modify this file, you must change its name first. -You are NOT ALLOWED to distribute this file alone. You are NOT -ALLOWED to take money for the distribution or use of either this -file or a changed version, except for a nominal charge for copying +You are NOT ALLOWED to distribute this file alone. You are NOT +ALLOWED to take money for the distribution or use of either this +file or a changed version, except for a nominal charge for copying etc. \endpreamble -\generateFile{probsoln.sty}{f}{\from{probsoln.dtx}{}} + +\askforoverwritefalse + +\generate{\file{sample2.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{sample2.tex,package}} +\file{1stprncp.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{1stprncp.tex,package}} +\file{probsoln.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{probsoln.sty,package}} +\file{mchoice.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{mchoice.tex,package}} +\file{tabmchoice.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{tabmchoice.tex,package}} +\file{easy.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{easy.tex,package}} +\file{args.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{args.tex,package}} +\file{sample4.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{sample4.tex,package}} +\file{sample.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{sample.tex,package}} +\file{sample3.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{sample3.tex,package}} +\file{implicit.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{probsoln.dtx}{implicit.tex,package}} +} + +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/probsoln/probsoln.sty b/Master/texmf-dist/tex/latex/probsoln/probsoln.sty index 5b5aa7d27a3..6666c3a9398 100644 --- a/Master/texmf-dist/tex/latex/probsoln/probsoln.sty +++ b/Master/texmf-dist/tex/latex/probsoln/probsoln.sty @@ -4,17 +4,30 @@ %% %% The original source files were: %% -%% probsoln.dtx -%% Copyright (C) 2000 Nicola Talbot, all rights reserved. +%% probsoln.dtx (with options: `probsoln.sty,package') +%% Copyright (C) 2006 Nicola Talbot, all rights reserved. %% If you modify this file, you must change its name first. %% You are NOT ALLOWED to distribute this file alone. You are NOT %% ALLOWED to take money for the distribution or use of either this %% file or a changed version, except for a nominal charge for copying %% etc. -%%This is the problem -%%This is the solution +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{probsoln}[2004/03/21 Problems and their Solutions Package] +\ProvidesPackage{probsoln}[2006/03/02 v2.02 Problems and their Solutions Package (NLCT)] \RequirePackage{ifthen} \provideboolean{showanswers} \newcommand{\showanswers}{\showanswerstrue} @@ -23,86 +36,75 @@ \DeclareOption{noanswers}{\showanswersfalse} \ExecuteOptions{noanswers} \ProcessOptions -\newif\ifdefined -\def\checkdefined#1{\ifx#1\relax \definedfalse \else \definedtrue \fi} \newif\ifselectrandom \selectrandomfalse \newif\iffirstpass \newif\ifselected -\newcommand{\solutionname}{Solution:} +\newcommand{\solutionname}{Solution} \newcommand{\newproblem}[4][0]{% \ifselectrandom \iffirstpass \global\advance\@probN by 1 -\expandafter\gdef\csname @problabel\romannumeral\@probN\endcsname{#2} +\expandafter\gdef\csname @problabel\romannumeral\@probN\endcsname{#2}% \else -\checkselected{#2} +\checkselected{#2}% \ifselected -\expandafter\checkdefined\csname @prob@#2\endcsname -\ifdefined -\PackageError{probsoln}{Label #2 already used}% -{Each problem must have a unique label identifier} -\else +\@ifundefined{@prob@#2}{% \ifnum#1=0 -\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\paragraph{\solutionname} #4\fi} +\expandafter\gdef\csname @prob@#2\endcsname{% +#3 \ifshowanswers\begin{solution}#4\end{solution}\fi}% +\expandafter\gdef\csname @prob@#2@arg\endcsname{\relax}% \else -\message{Problem #2 requires #1 argument(s), please specify (e.g. {5}{3}):} +\message{Problem #2 requires #1 argument(s), please specify (e.g. {5}{3}):}% \read-1to\@tmp -\expandafter\let\csname @prob@#2@arg\endcsname=\@tmp -\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\paragraph{\solutionname} #4\fi} -\fi +\expandafter\xdef\csname @prob@#2@arg\endcsname{\@tmp}% +\expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% +#3 \ifshowanswers\solution #4\fi}% \fi +}{% +\PackageError{probsoln}{Label #2 already used}% +{Each problem must have a unique label identifier}% +}% \fi \fi \else -\expandafter\checkdefined\csname @prob@#2\endcsname -\ifdefined +\@ifundefined{@prob@#2}{% +\expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% +#3 \ifshowanswers\begin{solution}#4\end{solution}\fi}% +}{% \PackageError{probsoln}{Label #2 already used}% -{Each problem must have a unique label identifier} -\else -\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\paragraph{\solutionname} #4\fi} -\fi +{Each problem must have a unique label identifier}% +} \fi } \newcommand{\useproblem}[1]{% -\expandafter\checkdefined\csname @prob@#1\endcsname -\ifdefined -\def\doprob{\csname @prob@#1\endcsname} -\else +\@ifundefined{@prob@#1}{% \PackageError{probsoln}{Label #1 undefined}% -{Can't find problem defined with label identifier '#1'} -\def\doprob{\relax} -\fi -\doprob +{Can't find problem defined with label identifier '#1'}% +}{\csname @prob@#1\endcsname}% } \newcount\@probN \newcount\@probselN \newcount\@rndselctr - \newcount\r@ndcur +\newcount\@ps@randtmp \r@ndcur=1\relax \newcommand{\PSNrandseed}[1]{% -\ifnum#1=0 -\typeout{Can't have 0 as random seed, changing to 1} +\ifnum#1=0\relax +\PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}% \r@ndcur=1\relax \else \r@ndcur=#1\relax \fi -\typeout{Random Seed = \the\r@ndcur} +\PackageInfo{probsoln}{Random Seed = \the\r@ndcur}% } - -\newcount\@ps@randtmp -\newcommand{\PSNrand}{ +\newcommand{\PSNrand}{% \@ps@randtmp=\r@ndcur \multiply\@ps@randtmp by 16807\relax \r@ndcur=\@ps@randtmp -\divide\r@ndcur by 120001 -\multiply\r@ndcur by 120001 +\divide\r@ndcur by 120001\relax +\multiply\r@ndcur by 120001\relax \advance\@ps@randtmp by -\r@ndcur \r@ndcur = \@ps@randtmp \ifnum\r@ndcur=0\relax\r@ndcur=1\fi } - \newcommand{\PSNrandom}[2]{% \PSNrand #1=\r@ndcur @@ -112,59 +114,112 @@ \advance#1 by -\@ps@randtmp \advance#1 by 1\relax } - +\newcommand{\random}[3]{% +\ifnum#2=1\relax +\PSNrandom{\value{#1}}{#3}% +\else +\@rndselctr=#3% +\advance\@rndselctr by -#2\relax +\advance\@rndselctr by 1\relax +\PSNrandom{\value{#1}}{\@rndselctr}% +\addtocounter{#1}{#2}% +\addtocounter{#1}{-1}% +\fi +} +\newcommand*{\selectallproblems}[1]{% +\global\@probN=0\relax +\selectrandomtrue +\firstpasstrue +\input{#1}% +\firstpassfalse +\selectrandomfalse +\input{#1}% +\global\@rndselctr=1\relax +\whiledo{\@rndselctr < \@probN \TE@or \@rndselctr = \@probN}{% +\edef\@tmp{\csname @problabel\romannumeral\@rndselctr\endcsname}% +\edef\@probargs{{\@tmp}\csname @prob@\@tmp @arg\endcsname}% +\PSNitem \expandafter\useproblem\@probargs \endPSNitem +\global\advance\@rndselctr by 1\relax +}} \newcommand{\selectrandomly}[2]{% -\global\@probselN=#2 -\global\@probN=0 +\global\@probselN=#2\relax +\global\@probN=0\relax \selectrandomtrue \firstpasstrue -\input{#1} +\input{#1}% \ifnum\@probselN>\@probN \PackageError{probsoln}{Requested number too large}% {You have asked for \the\@probselN \space problems, but there are only \the\@probN \space problems defined in the file #1. I will only select \the\@probN \space -problems.} +problems.}% \global\@probselN=\@probN \fi -\shuffle{@problabel}{\@probN} +\shuffle{@problabel}{\@probN}% \firstpassfalse -\input{#1} +\input{#1}% \selectrandomfalse -\@rndselctr=1\relax +\global\@rndselctr=1\relax \whiledo{\@rndselctr < \@probselN \TE@or \@rndselctr = \@probselN}{% -\edef\@tmp{\csname @problabel\romannumeral\@rndselctr\endcsname} -\edef\@probargs{{\@tmp}\csname @prob@\@tmp @arg\endcsname} -\item \expandafter\useproblem\@probargs -\advance\@rndselctr by 1\relax -} +\edef\@tmp{\csname @problabel\romannumeral\@rndselctr\endcsname}% +\edef\@probargs{{\@tmp}\csname @prob@\@tmp @arg\endcsname}% +\PSNitem \expandafter\useproblem\@probargs \endPSNitem +\global\advance\@rndselctr by 1\relax +}% } +\newcommand{\PSNitem}{\item} +\@ifundefined{endPSNitem}{\def\endPSNitem{}}{% +\PackageError{probsoln}{\string\endPSitem\ already defined}{}} +\newenvironment{solution}{\paragraph{\solutionname:}}{} \newcount\@ckselctr \newcommand{\checkselected}[1]{% \selectedfalse \@ckselctr=1\relax \whiledo{\@ckselctr < \@probselN \TE@or \@ckselctr = \@probselN}{% \ifthenelse{\equal{#1}{\csname @problabel\romannumeral\@ckselctr\endcsname}}% -{\global\selectedtrue \global\@ckselctr=\@probselN}{} +{\global\selectedtrue \global\@ckselctr=\@probselN}{}% \advance\@ckselctr by 1\relax -} +}% } \newcount\@shfctr \newcount\@shfA \newcount\@shfB \newcommand{\shuffle}[2]{% \@shfctr=1\relax \whiledo{\@shfctr < 101}{% -\PSNrandom{\@shfA}{#2}\PSNrandom{\@shfB}{#2} +\PSNrandom{\@shfA}{#2}\PSNrandom{\@shfB}{#2}% \ifnum\@shfA=\@shfB \else -\edef\@@tmpA{\csname#1\romannumeral\@shfA\endcsname} +\edef\@@tmpA{\csname#1\romannumeral\@shfA\endcsname}% \let\@tmpA=\@@tmpA -\edef\@@tmpB{\csname#1\romannumeral\@shfB\endcsname} +\edef\@@tmpB{\csname#1\romannumeral\@shfB\endcsname}% \let\@tmpB=\@@tmpB -\expandafter\xdef\csname#1\romannumeral\@shfA\endcsname{\@tmpB} -\expandafter\xdef\csname#1\romannumeral\@shfB\endcsname{\@tmpA} +\expandafter\xdef\csname#1\romannumeral\@shfA\endcsname{\@tmpB}% +\expandafter\xdef\csname#1\romannumeral\@shfB\endcsname{\@tmpA}% \fi \advance\@shfctr by 1\relax +}% } -} +\newcount\@ps@forrand +\newcommand{\doforrandN}[4]{% +{\@ps@forrand=0\relax +\@for#2:=#3\do{% +\advance\@ps@forrand by 1\relax +\expandafter\edef\csname @doforrandN@\romannumeral\@ps@forrand\endcsname{#2}}% +\ifnum\@ps@forrand<#1\relax +\PackageError{probsoln}{Can't randomly select \number#1 item(s)}{You +have requested \number#1 item(s), but there +are only \number\@ps@forrand item(s) in the list}% +\else +\shuffle{@doforrandN@}{\@ps@forrand}% +\ifnum#1>0\relax +\@ps@forrand=0\relax +\loop +\advance\@ps@forrand by 1\relax +\edef#2{\csname @doforrandN@\romannumeral\@ps@forrand\endcsname}% +#4% +\ifnum\@ps@forrand<#1\relax +\repeat +\fi +\fi +}} \endinput %% %% End of file `probsoln.sty'. diff --git a/Master/texmf/lists/probsoln b/Master/texmf/lists/probsoln index 36671448b8a..9b0d18bd028 100644 --- a/Master/texmf/lists/probsoln +++ b/Master/texmf/lists/probsoln @@ -1,11 +1,17 @@ +texmf-dist/doc/latex/probsoln/1stprncp.tex +texmf-dist/doc/latex/probsoln/CHANGES texmf-dist/doc/latex/probsoln/README -texmf-dist/doc/latex/probsoln/probsoln.html +texmf-dist/doc/latex/probsoln/args.tex +texmf-dist/doc/latex/probsoln/easy.tex +texmf-dist/doc/latex/probsoln/implicit.tex +texmf-dist/doc/latex/probsoln/manual.html +texmf-dist/doc/latex/probsoln/mchoice.tex texmf-dist/doc/latex/probsoln/probsoln.pdf texmf-dist/doc/latex/probsoln/sample.tex -texmf-dist/doc/latex/probsoln/samples/1stprncp.tex -texmf-dist/doc/latex/probsoln/samples/args.tex -texmf-dist/doc/latex/probsoln/samples/easy.tex -texmf-dist/doc/latex/probsoln/samples/implicit.tex +texmf-dist/doc/latex/probsoln/sample2.tex +texmf-dist/doc/latex/probsoln/sample3.tex +texmf-dist/doc/latex/probsoln/sample4.tex +texmf-dist/doc/latex/probsoln/tabmchoice.tex texmf-dist/source/latex/probsoln/probsoln.dtx texmf-dist/source/latex/probsoln/probsoln.ins texmf-dist/tex/latex/probsoln/probsoln.sty -- cgit v1.2.3