# How to get a solution set of a nonlinear system of equations?

I'm trying to find the solution set of {x, y} variables for the following system of equations:

Solve[{0 == -1/2*Tan[Pi*x/2] + y, 0 == -1/2*Tan[Pi*y/2] + x}, {x, y}]


But when I try this, I can't get a result. Is there another function I should use? I can get the "basic" solutions by hand noting that if $x = 0$, then $y = 2n$ where $n$ is an integer (and vice-versa for when $y = 0$). But I think there are other solutions...

Any help would be appreciated, thanks!

I'm using Mathematica 8, BTW.

• What you have there is a system of transcendental equations that are difficult to solve in general. If you don't mind approximate solutions, you can use FindRoot[] or FindAllCrossings2D[]. – J. M. is away May 18 '13 at 16:54
• Or plot the two functions and see where they cross... that will tell you if you should expect to find answers. – bill s May 18 '13 at 16:58
• i dont know exactly but, the command Reduce may run. – MATIRMAK May 18 '13 at 16:59
• Can get a result if you restrict the space, e.g. try Solve[{0 == y - 1/2 Tan[(\[Pi] x)/2], 0 == x - 1/2 Tan[(\[Pi] y)/2], -10 <= x <= 10, -10 <= y <= 10}, {x, y}] – Daniel Lichtblau May 18 '13 at 20:48

## 1 Answer

There are other solutions, this is correct. ContourPlot gives an idea:

ContourPlot[{
-.5 Tan[.5 Pi x] + y == 0,
-.5 Tan[.5 Pi y] + x == 0}, {x, -5.5, 5.5}, {y, -5.5, 5.5},
PlotPoints -> 20,
Frame -> False, Axes -> True,
Exclusions -> Join[
Table[{x == i}, {i, -5, 5, 2}],
Table[{y == i}, {i, -5, 5, 2}]]] Exclusions prevents drawing of asymptotes and poles. This plot can tell you where to search for roots. (Note also that you don't have to type * for multiplication, pressing space instead achieves the same effect.) Now use FindRoot for example with starting values you read off the plot (select plot > right click > Get Coordinates). Click some points close to intersections and Ctrl + C copy them. Let's say these thriteen pasted and assigned to start:

start = {{-1.279, 1.279}, {0.9913, 2.543}, {3.002, 2.773}, {2.6,
0.9913}, {1.336, -1.307}, {-0.4166, -0.589}, {-0.1006,
0.1006}, {0.5603,
0.5603}, {-2.543, -1.02}, {-0.9913, -2.83}, {-3.031, -2.686}, \
{1.164, -3.405}, {3.175, -1.192}};
Length@start
(* 13 *)


I visualize solution points with the same ContourPlot command to which I added Epilog overdraw specification (black points). You can see that not every starting point (gray) converged to a desired destination. Perhaps I should've start-clicked more carefully, or one could tell FindRoot to search differently, you'd have to consult help on that.

sol = Map[Function[ini,
With[{x0 = First@ini, y0 = Last@ini},
{x, y} /. FindRoot[{
-.5 Tan[.5 Pi x] + y == 0,
-.5 Tan[.5 Pi y] + x == 0}, {{x, x0}, {y, y0}}]]], start]; • ...and FindAllCrossings2D[] is effectively a mechanical implementation of your approach. – J. M. is away May 18 '13 at 18:11
• @J.M. Yes, that's a truly great post and discussion. Should a beginner be pointed to a post like that however, it could scare him s******* easily, no? – BoLe May 18 '13 at 18:18
• Well, he can just copy the code and turn it loose on his equations... ;) – J. M. is away May 18 '13 at 18:20
• Amazing... thank you! – jon May 18 '13 at 19:58