Overview
My title is the not the best, and I will edit it if there are any better suggestions! In a nutshell, what I am trying to achieve is to randomly change numbers in a maths question and have a solution that appropriately 'solves' the that questions.
I am also considering more than just TeX in my solution - a solution using other languages such as C++ to generate the tex file to be complied by pdflatex is fine too. The end goal would be to have an autonomous system. A simpler example of what I'm thinking of (in both terms of maths and not using LaTeX) can be found here: http://www.tutorfinder.com.au/maths/multiplication.php
Finally, I already have a complete template using exam class which I am hoping to use. If your solution requires a package that is not compatible with exam class, please let me know!
My Current Thoughts
Pure LaTeX Solution
Suppose a simple question is:
Solve $\intop 6\sin(2x)\, dx$
And my solution that I wish to show (requires mathtools package) is:
\begin{align*}
\shortintertext{\text{Recall from the formula sheet that:}}
\intop\sin(nx)\, dx & =-\frac{1}{n}\cos(nx)+C\\
\shortintertext{\text{Here, \ensuremath{n=2}}}
\therefore\intop6\sin(2x)\, dx & =6\times\left(-\frac{1}{2}\right)\cos(2x)+C\\
& =-3\cos(2x)+C
\end{align*}
Is there a way to randomise the 2 in 2x such that it is between 1 and 4, and randomise the 6 in front of the sin(2x) between -2 and 10, such that it changes every time the tex file is complied?
And then , where 6\times\left(-\frac{1}{2}\right)
occurs, this will be replaced by the multiplication of the new randomised numbers? I'm thinking of defining the 2 and the 6 as variables and then using one of the calculator packages to find the product. Later though, I will need LaTeX to solve more complex equations such as trigonometry (e.g. sin(0.4)), simple definite integrals (e.g. integral from 0 to 1 of x^3), permutations (e.g. nCr, nPr, factorials) and normal distributions...
This is where my other idea comes in:
Generate TeX File Using Another Program
Because I don't know what the capabilities of LaTeX for generating random numbers and making calculations, I'm considering using another language to calculate the relevant coefficients and then print it in a tex file with relevant markup. For example:
Program:
<a> = random integer between -2 and 10 (here: 6)
<b> = random integer between 1 and 4 (here: 2)
<c> = <a> / <b> (here: 6/2 = 3)
Then, it prints:
Solve $\intop <a> \sin(<b>x)\, dx$
\begin{align*}
\shortintertext{\text{Recall from the formula sheet that:}}
\intop\sin(nx)\, dx & =-\frac{1}{n}\cos(nx)+C\\
\shortintertext{\text{Here, \ensuremath{n=2}}}
\therefore\intop<a>\sin(<b>x)\, dx & =<a>\times\left(-\frac{1}{<b>}\right)\cos(<b>x)+C\\
& =-<c>\cos(<b>x)+C
\end{align*}
The benefit is when it comes to solving integrals or probabilities, I know there will be a library/tool box/add on available that can find the answer. Also, I know if statements and such will work.
For example, with parabolas there can be zero, one or two intercepts. I could code the program to determine what the discriminant is, and then print the correct using if elseif statements depending on what the sign of the discriminant. I have no idea how I would do this in LaTeX...
Summary
I know this is a long post and I do apologise. It's because my question is rather specific and I don't want some kind hearted person to spend hours writing up a solution only to find that they'd misinterpreted what I'm trying to achieve.
I'm really looking for packages in LaTeX that can do what I'm looking for and can be implemented in my question; or suggest an efficient way to create a program that does this; or some other amazing idea that is much more efficient than my current thoughts.
Cheers, Alwin
Later though, I will need LaTeX to solve more complex equations such as trigonometry ...
it's no more clear. Please ask one clear question by (question)