How can I use FindRoot with 2 variables function? Is there a different way to do that? For example

f[x_,y_]=Sin[x + y^2];
FindRoot[f[x,y], {x, -1}, {y, -3}]
  • $\begingroup$ FindRoot[{Cos[x + y], Sin[x y]}, {x, 2}, {y, 3}]? $\endgroup$ – AccidentalFourierTransform Jun 23 '19 at 1:35
  • 1
    $\begingroup$ @AccidentalFourierTransform I think HD2006 means functions that take 2 arguments f[x_, y_]. $\endgroup$ – Rohit Namjoshi Jun 23 '19 at 2:01
  • $\begingroup$ If you have 2 unknowns, you need 2 equations, as in @AccidentialFourierTransform's comment. $\endgroup$ – Carl Woll Jun 23 '19 at 3:07

You cannot use FindRoot to find a root of

f[x_, y_] := Sin[x + y^2]

because a function of two variables like f doesn't have roots in the sense that a function of one variable has. When a function of two variables intersects the xy-plane, it normally produces contour lines not individual points. You can examine such contours with ContourPlot. Your function f, because of the oscillatory nature of Sin has several contours at f[x, y] == 0 in the vicinity of $(-1,\,-3)$ as can be seen from the following plot.

ContourPlot[f[x, y] == 0, {x, -2, 0}, {y, -4, -2},
  Epilog -> {Red, AbsolutePointSize[5], Point[{-1, -3}]}]


  • $\begingroup$ Assume that these Contours have a minima/maxima at specific points, is it possible to find them? For example, the ContourPlot of Sin[x^3 + y] - 2 Cos[x y] has a maximum around (-1.8,2.6) $\endgroup$ – HD2006 Jun 23 '19 at 3:58
  • 1
    $\begingroup$ @HD2006. That seems to be an entirely different question concerning the finding critical points of a function of two variables. You might look at FindMaximum. If that doesn't work for you, I suggest posting a new question. $\endgroup$ – m_goldberg Jun 23 '19 at 4:17

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