I’ve got this simple loop that prints out the solutions to 2 simple equations for various values of parameters $a$ and $b$.
I need to add a command that would display the parameter values that lead to the solution which is closest (in absolute way) to $x = 0.21$, $y = 0.34$. In my particular case it happens when $a=3$ and $b=2$ (which leads to $x=2/9$, $y=1/3$ exactly), but how to get this {a=3,b=2}
answer? Thank you.
q := Do[sol = Solve[{a*x + y == 1, -3*x + b*y == 0}, {x, y}];
Print[{x /.sol[[1]], y /.sol[[1]]}], {a, 2, 3, 1}, {b, 2, 3, 1}]
q