1
$\begingroup$

I want to generate a list of simple trigonometric questions in TeXForm, for example, as follows.

Evaluate the following expressions.
\begin{enumerate}
\item $\sin 30^\circ$
\item $\sec 90^\circ$
% ... others go here ...
\item $\csc 315^\circ$
\end{enumerate}

So I can just copy and paste it to my LaTeX input file to create a problem sheet.

I have a list of arguments args and a list of functions funcs as follows.

args = Array[15 # &, 24, 0];
funcs = {Sin, Cos, Tan, Csc, Sec, Cot};

How to define a function GenerateProblem[n_] where n represents the number of problems to generate in TeXForm?

$\endgroup$
3
$\begingroup$

Roughly

args=Array[15 #&,24,0];
funcs={Sin,Cos,Tan,Csc,Sec,Cot};

generateProblem=Column[StringRiffle/@RandomSample[Tuples@{funcs,args},#]]&

TeXForm@generateProblem@4

\begin{array}{l} \text{Tan 180} \\ \text{Sin 210} \\ \text{Sec 210} \\ \text{Tan 300} \\ \end{array}

Edit 1. This produces TeX math expressions like \sin , \sec etc

generateProblem = Column[#1@#2 & @@@ RandomSample[Tuples@{funcs, args}, #]] &

TeXForm@generateProblem@4

\begin{array}{l} \sec (60) \\ \sec (255) \\ \csc (195) \\ \sin (30) \\ \end{array}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.