# System of Equations Generator

I often find myself spending too much time coming up with systems of equations for exercises for my students to practice on (that come out to nice integers). For two variables this is trivial, albeit annoying, but for three, four, five, etc variables it becomes increasingly more arduous. I was wondering if anyone knows of a program/website that will generate systems of equations with an arbitrary (up to at least four) number of variables.

Alternatively, any resource on generating systems of equations would be awesome. I have a feeling, based on google searches, that this ideal tool may not exist so I am totally willing to code it myself, but a starting point would be nice.

• Do you want systems that have unique solutions? – mweiss Dec 10 '14 at 3:19
• ideally yes also no solutions of zero – celeriko Dec 10 '14 at 3:28
• How would you like such a tool to output its systems? – NiloCK Dec 10 '14 at 11:50

This can be done very easily, with nothing more complex than a spreadsheet:

1. Start by randomly generate your solution to the system, using whatever "niceness" criteria you like. In Excel, for example, use the function RANDBETWEEN(-10,10) to generate a random integer between $-10$ and $10$. Call the four numbers so generated $x,y,z,w$.
2. Now randomly generate the coefficients of an equation, again using whatever "niceness" criteria you like. If you are using four equations with four unknowns, you need to generate 4 coefficients. Call them $a, b, c, d$.
3. Now compute $ax+by+cz+dw$, call the total $N$, and write the equation $$ax+by+cz+dw=N$$ (replacing $a,b,c,d,N$ with their randomly-generated numerical values and leaving $x,y,z,w$ as variables). You have now generated an equation. If you don't like it -- for example if $N$ is an "ugly" number -- just refresh the values of $a,b,c,d$ and get a new one.

Iterate steps 2-3 until you have four equations you like. You now have a system for which the "nice" values generated in Step 1 is a guaranteed solution.

Of course it is possible that this method will produce a degenerate system, but you can also test for that by having Excel calculate the determinant of the matrix of coefficients. As long as it isn't $0$, your solution is unique.

If you have access to software such as Maple, Mathematica, or Matlab, then you can figure out how to have it generate an nxn matrix A with integer entries and with determinant 1.

Once you have such a matrix, you are essentially done. The system of equations is AX=B where B is a column matrix that can be arbitrary integers. The fact that the det(A)=1 guarantees a solution vector X that will be integers.

I have used this approach to write MapleTA and WeBWorK questions like you are trying to come up with. You always want to check the size of the entries of the solution vector X to make sure they are not too big.

Just work backwards. For instance let's say you want x=2, y=3, z=1 as your answers. So you need to do what amounts to row operations on those equations to generate a linear system.

You can add them up into new arbitrary combinations or multiply any of your equations by a non-zero constant. For instance,

$$x+y+z = 6$$ $$x + y = 5$$ $$2x +z = 5$$

Or I can add up Eqs 1 and 2, 2 and 3, and 1 and 3 to get a new system:

$$2x+2y+z = 11$$ $$3x + y+z = 10$$ $$3x+y +2z = 11$$

Both of these system will have solutions (x,y,z) = (2,3,1).