I have a problem, in which I have an equation $$(x-19)^2+(y-59)^2+(z-65)^2+(w-79)^2=11586$$ with the conditions $x\geq 0, y\geq 0, z\geq 0, w\geq 0$, and all the variable are integers. I know the solution is $x=2,y=5,z=6,w=9$. But how do I solve this, and is this unique. Do I solve this using Lagrange's multiplier. Or can somebody suggest some solvers using Python or Matlab
Edit: I give an elaborate description of what my problem is and how I landed to the question. I have two matrices say $$A=\begin{bmatrix} 2&6\\5&9\end{bmatrix} ~~\text{and} ~\begin{bmatrix}79 & 65\\ 59&19\end{bmatrix}$$ I needed to arrange the matrix $B$, keeping $A$ fixed, such that the $$\sum_{i,j=1}(A_{ij}-B_{ij})^2$$ remains the minimum. For this is used the Assignment problem (Hungarian problem as suggested in one of my earlier questions). I got the optimum places for my elements in $B$ and it turned out to be $$B=\begin{bmatrix}19&65\\59&79\end{bmatrix}$$, with minimum cost being $11586$. Now, need to find out the matrix $A$ given only the new $B$ and the assignment index which is the vector $[4,2,3,1]$. Now this means that means that if the matrix $A$ was originally $$A=\begin{bmatrix} x & y\\ z&w\end{bmatrix}$$, the cost matrix that was formed was $$\begin{bmatrix} (x-79)^2 & (x-59)^2 & (x-65)^2 & (x-19)^2\\ (y-79)^2 & (y-59)^2 & (y-65)^2 & (y-19)^2\\ (z-79)^2 & (z-59)^2 & (z-65)^2 & (z-19)^2\\ (w-79)^2 & (w-59)^2 & (w-65)^2 & (w-19)^2\\ \end{bmatrix}$$, thus we know that the minimum cost is corresponding to the vector $[4,2,3,1]$, thus we solve $$(x-19)^2+(y-59)^2+(z-65)^2+(w-79)^2=11586$$ Now my questions on this problem is
- If I modify this problem from quadratic to just the absolute function $\sum_{i,j=1}|(A_{ij}-B_{ij})|$, can this problem be a bit easy to solve?
- Is my approach even worth trying to find the solution for, or is just too infeasable?
- Can this problem be solved by some other approach?
Well, I just coded something in Mathematica:
And it gave me a lot of solutions (the solutions I show downhere they are not all the solutions, if you want all the solutions that Mathematica found, you can contact me):