randRange( 1, 10 ) randRange( 1, 10 ) randRange( 0, 3 ) randRangeWeighted( 1, 3, 1, 0.5 ) * randRangeNonZero( -1, 1 ) INDEX === 0 ? -1 * Z1 : randRangeWeighted( -4, 4, -1, 0 ) * Z1 randRange( 2, 6 ) * randRangeNonZero( -1, 1 ) randRange( 2, 6 ) * randRangeNonZero( -1, 1 ) randRange( 2, 6 ) * randRangeNonZero( -1, 1 ) randRange( 2, 6 ) * randRangeNonZero( -1, 1 )
[ Z1, Z1, Z2, Z5 ][ INDEX ] Z3 A1 * X + B1 * Y [ Z2, Z2, Z1, Z6 ][ INDEX ] Z4 A2 * X + B2 * Y [ 1, -A2 / A1, 1, A2 > 0 && A1 < 0 ? A2 : -A2 ][ INDEX ] [ 1, 1, -A1 / A2, A2 > 0 && A1 < 0 ? -A1 : A1 ][ INDEX ] B1 * Y > 0 ? "-" : "+" B2 * Y > 0 ? "-" : "+"

Solve for `x` and `y` using elimination.

`\color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}`
`\color{GREEN}{expr(["+", ["*", A2, "x"], ["*", B2, "y"]]) = C2}`

`x` = X

`y` = Y

We can eliminate `x` by adding the equations together when the `x` coefficients have opposite signs.

Multiply the bottomtop equation by `MULT2` `MULT1` and the bottom equation by `MULT2`.

`\color{BLUE}{expr(["+", ["*", A1 * MULT1, "x"], ["*", B1 * MULT1, "y"]]) = C1 * MULT1}`
`expr(["+", ["*", A2 * MULT2, "x"], ["*", B2 * MULT2, "y"]]) = C2 * MULT2`

Add the top and bottom equations together.

`expr(["*", B1 * MULT1 + B2 * MULT2, "y"]) = C1 * MULT1 + C2 * MULT2`

`\dfrac{expr(["*", B1 * MULT1 + B2 * MULT2, "y"])}{\color{BLUE}{B1 * MULT1 + B2 * MULT2}} = \dfrac{C1 * MULT1 + C2 * MULT2}{\color{BLUE}{B1 * MULT1 + B2 * MULT2}}`

`\color{ORANGE}{y = Y}`

Now that you know `\color{ORANGE}{y = Y}`, plug it back into `\thinspace \color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}\thinspace` to find `x`.

`\color{BLUE}{expr(["*", A1, "x"]) + B1-}\color{ORANGE}{(Y)}\color{BLUE}{= C1}`

`expr(["+", ["*", A1, "x"], B1 * Y]) = C1`

`expr(["+", ["*", A1, "x"], B1 * Y])\color{BLUE}{SIGN_1abs( B1 * Y )} = C1\color{BLUE}{SIGN_1abs( B1 * Y )}`

`expr(["*", A1, "x"]) = C1 - B1 * Y`

`\dfrac{expr(["*", A1, "x"])}{\color{BLUE}{A1}} = \dfrac{C1 - B1 * Y}{\color{BLUE}{A1}}`

`\color{red}{x = X}`

You can also plug `\color{ORANGE}{y = Y}` into `\thinspace \color{GREEN}{expr(["+", ["*", A2, "x"], ["*", B2, "y"]]) = C2}\thinspace` and get the same answer for `x`:

`\color{GREEN}{expr(["*", A2, "x"]) + B2-}\color{ORANGE}{(Y)}\color{GREEN}{= C2}`

`\color{red}{x = X}`

Z3 [ Z1, Z1, Z2, Z5 ][ INDEX ] A1 * X + B1 * Y Z4 [ Z2, Z2, Z1, Z6 ][ INDEX ] A2 * X + B2 * Y [ 1, -B2 / B1, 1, B2 > 0 && B1 < 0 ? B2 : -B2 ][ INDEX ] [ 1, 1, -B1 / B2, B2 > 0 && B1 < 0 ? -B1 : B1 ][ INDEX ] A1 * X > 0 ? "-" : "+" A2 * X > 0 ? "-" : "+"

Solve for `x` and `y` using elimination.

`\color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}`
`\color{GREEN}{expr(["+", ["*", A2, "x"], ["*", B2, "y"]]) = C2}`

`x` = X

`y` = Y

We can eliminate `y` by adding the equations together when the `y` coefficients have opposite signs.

Multiply the bottomtop equation by `MULT2` `MULT1` and the bottom equation by `MULT2`.

`\color{BLUE}{expr(["+", ["*", A1 * MULT1, "x"], ["*", B1 * MULT1, "y"]]) = C1 * MULT1}`
`expr(["+", ["*", A2 * MULT2, "x"], ["*", B2 * MULT2, "y"]]) = C2 * MULT2`

Add the top and bottom equations together.

`expr(["*", A1 * MULT1 + A2 * MULT2, "x"]) = C1 * MULT1 + C2 * MULT2`

`\dfrac{expr(["*", A1 * MULT1 + A2 * MULT2, "x"])}{\color{BLUE}{A1 * MULT1 + A2 * MULT2}} = \dfrac{C1 * MULT1 + C2 * MULT2}{\color{BLUE}{A1 * MULT1 + A2 * MULT2}}`

`\color{red}{x = X}`

Now that you know `\color{red}{x = X}`, plug it back into `\thinspace \color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}\thinspace` to find `y`.

`\color{BLUE}{A1-}\color{red}{(X)}\color{BLUE}{ + expr(["*", B1, "y"]) = C1}`

`expr(["+", A1 * X, ["*", B1, "y"]]) = C1`

`A1 * X\color{BLUE}{SIGN_1abs( A1 * X )} + expr(["*", B1, "y"]) = C1\color{BLUE}{SIGN_1abs( A1 * X )}`

`expr(["*", B1, "y"]) = C1 - A1 * X`

`\dfrac{expr(["*", B1, "y"])}{\color{BLUE}{B1}} = \dfrac{C1 - A1 * X}{\color{BLUE}{B1}}`

`\color{ORANGE}{y = Y}`

You can also plug `\color{red}{x = X}` into `\thinspace \color{GREEN}{expr(["+", ["*", A2, "x"], ["*", B2, "y"]]) = C2}\thinspace` and get the same answer for `y`:

`\color{GREEN}{A2-}\color{red}{(X)}\color{GREEN}{ + expr(["*", B2, "y"]) = C2}`

`\color{ORANGE}{y = Y}`