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

  • $\begingroup$ Without more context, there is an infinity of different solution pairs $(x,y)$. You cannot solve this (without further context) not because maths has failed, but because the question does not really make sense. $z=ax+by$ sketches a line; which point on the line is the right solution? This also has nothing to do with functional analysis or O.D.Es... please use tags judiciously! $\endgroup$
    – FShrike
    Dec 21, 2021 at 19:14
  • $\begingroup$ Are you looking for solutions in the real numbers, or some other ring? $\endgroup$
    – healynr
    Dec 21, 2021 at 19:22
  • $\begingroup$ I got a and b, I need x and y (but I guess I could reverse the names and be in the same situation as given by @Boateng). The variables are positive integers, z should be a single number (which suggests a kind of min|max for this function). For the rest, there is not much more contextualization. The authors only give the formula like it was a simple f(x). $\endgroup$
    – Gigiux
    Dec 21, 2021 at 20:55
  • 1
    $\begingroup$ If you know $a$, $b$, and $c$, then $ax+by=c$ is the equation of a line. Every point on the line has a different pair of coordinates $(x,y)$ that satisfies the equation. You can pick any value you want for one of $x,y$ and solve the equation to get the value of the other one. (This assumes $a$ and $b$ are both nonzero. If one of them is $0$ then the equation effectively has only one variable.) $\endgroup$
    – Karl
    Dec 21, 2021 at 21:49
  • $\begingroup$ but I don't know c either... $\endgroup$
    – Gigiux
    Dec 22, 2021 at 16:16

1 Answer 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.


Not the answer you're looking for? Browse other questions tagged or ask your own question.