How to solve equations with two unknown computationally? [closed]

I have an equation in the form: z= ax+by. Is it possible to solve z using some computational trick? Like using many combinations of x and y? What would be the approach for this kind of problem? Thank you


Solution 1:

If you wish to determine the coefficients a and b, you would at least need two linear independent set of equations. Say \begin{array}{{rC}l} ax_1 & +by_1= & z_1 \\ ax_2 & + by_2 = & z_2 \\ \end{array}

which is equivalent to solving the following linear system $$\begin{pmatrix} x_1 & y_1 \\ x_2 & y_2 \\ \end{pmatrix} \begin{pmatrix} a\\ b \end{pmatrix} = \begin{pmatrix} z_1 \\ z_2 \end{pmatrix}$$

You can use python to solve this( numpy,scipy..) or you can also make use of online solvers like wolfram alpha, symbolab etc. If you are trying to fit some data(in case the number of equations exceed 2), you might consider the linear least square method.