I'm trying to make a randomly generated, say, square equations with integer coeffs. Like this 3x^2 - 6x + 8 = 0
But i want them to have integer roots too, so it would be way smarter to generate roots instead, and then produce coeffs. I came up with this
\pgfmathsetmacro{\x}{random(1,9)*((random(0,1)==0)?-1:1)}
\pgfmathsetmacro{\y}{random(1,8)*((random(0,1)==0)?-1:1)}
\pgfmathsetmacro{\a}{random(1,9)*((random(0,1)==0)?-1:1)}
\pgfmathsetmacro{\b}{-\a*(\x+\y)}
\pgfmathsetmacro{\c}{\a*\x*\y}
$$\a x^2 + \b x + \c = 0$$
Couple of problems here:
It looks like 8.0 instead of 8.
When it makes negative numbers, i get smth like
+ -9.0xinstead of-9x. Can i generate random signs too? I tried it, but with no success.- Obviously it would be better to have x instead of 1x. Is there a way to remove 1 if it gives me 1?
- Well, the major idea was, of course, to generate linear and quadratic equations and inequalities (with parametres, for ex.
$4ax^2 -5x + 6a = 0 $. Since i don't quite understand this code Random quadratic equation can someone explain it or at least show how to remake it?
The ability to generate coefficients is important, since you can do all the things after that. Make stuff like $3sin(x)^2 - 5sinx + 8 = 0$

6in\pgfmathrandominteger{\a}{\ifnum#1>1 1\else0\fi}{6}by something larger. However, I'd have to play with it in order to understand better what it does. – Jan 14 '18 at 20:27