We can try FindRoot
as follows
h=1/4;grid = Range[-20, 20, h]; s = DeleteDuplicates@ Flatten[ParallelTable[{x1, x2} /. Quiet@FindRoot [ x1 - x1*Sin[x1 + 5*x2] - x2*Cos[5 x1 - x2] == 0 && x2 - x2*Sin[5 x1 - 3 x2] + x1*Cos[3 x1 + 5 x2] == 0, {{x1, grid[[i]]}, {x2, grid[[j]]}}, WorkingPrecision -> 30], {i, Length[grid]}, {j, Length[grid]}], 1]
In this example we have
s // Dimensions Out[]= {10313, 2}
But some of the roots lie outside the region Rectangle[{-20, -20}, {20, 20}]
. Then we can decries step size from h=1/4
to h=1/8
and increase from 1/4 to 1/2 and look if there is convergence. For h=1/2
we have {3855, 2}
, and for h=1/8
we have {34175, 2}
(it takes about 12m on my Silver Pentium). As we can see there is no convergence at all. Therefore, we need some deep analytical research, since number of roots increases with h
decreases - see Figure below.
Using Select
we can take roots from Rectangle[{-20, -20}, {20, 20}]
only,
s0 = Select[s, Abs[#[[1]]] <= 20 && Abs[#[[2]]] <= 20 &]
For this number we have
s0 // Dimensions Out[]= {9085, 2}
For h=1/2,1/8
numbers are {3423, 2}
, and {30484, 2}
consequently. Roots shown below
Update 1. To find all branches and exclude some of them we use Reduce
as follows
Reduce[{x1 - x1*Sin[a] - x2*Cos[b] == 0, x2 - x2*Sin[c] + x1*Cos[d] == 0}, {x1, x2}] Out[]= (Sin[c] == 1 && x1 == 0 && x2 == 0 && Cos[b] Cos[d] != 0) || (Sin[c] == 1 && Cos[b] == 0 && x1 == 0 && Cos[d] != 0) || (Sin[c] == 1 && Cos[d] == 0 && Cos[b] != 0 && x2 == Sec[b] (x1 - x1 Sin[a])) || (Sin[c] == 1 && Sin[a] == 1 && Cos[d] == 0 && Cos[b] == 0) || (Cos[d] != 0 && Cos[b] == Sec[d] (-1 + Sin[a] + Sin[c] - Sin[a] Sin[c]) && -1 + Sin[c] != 0 && x2 == (x1 Cos[d])/(-1 + Sin[c])) || (-1 + Sin[c] != 0 && Sin[a] == 1 && Cos[d] == 0 && x2 == 0) || (1 + Cos[b] Cos[d] - Sin[a] - Sin[c] + Sin[a] Sin[c] != 0 && x1 == 0 && -1 + Sin[c] != 0 && x2 == 0) || (Sin[c] == 1 && Cos[d] == 0 && Cos[b] == 0 && -1 + Sin[a] != 0 && x1 == 0)
Where {a = x1 + 5*x2, b = 5 x1 - x2, c = 5 x1 - 3 x2, d = 3 x1 + 5 x2}
. First 4 branches describe trivial solution $x1=0, x2=0$ . We interested in nontrivial solution that described by branch 5
(Cos[d] != 0 && Cos[b] == Sec[d] (-1 + Sin[a] + Sin[c] - Sin[a] Sin[c]) && -1 + Sin[c] != 0 && x2 == (x1 Cos[d])/(-1 + Sin[c]))
As we can see it is a nontrivial solution of homogenous linear system with zero discriminant that we can represent with
{vec, mat} = CoefficientArrays[{x1 - x1*Sin[a] - x2*Cos[b] == 0, x2 - x2*Sin[c] + x1*Cos[d] == 0}, {x1, x2}]; mat // Normal (*Out[]= {{1 - Sin[a], -Cos[b]}, {Cos[d], 1 - Sin[c]}}*) With[{a = x1 + 5*x2, b = 5 x1 - x2, c = 5 x1 - 3 x2, d = 3 x1 + 5 x2}, Det[{{1 - Sin[a], -Cos[b]}, {Cos[d], 1 - Sin[c]}}]] Out[]= 1 + Cos[5 x1 - x2] Cos[3 x1 + 5 x2] - Sin[5 x1 - 3 x2] - Sin[x1 + 5 x2] + Sin[5 x1 - 3 x2] Sin[x1 + 5 x2]
Finally we can compute nontrivial roots with FindRoot
using norm of equations to select right
solutions
grid1 = Range[-20, 20, 1]; snorm1 = Flatten[ParallelTable[{x1, x2, Norm[{1 + Cos[5 x1 - x2] Cos[3 x1 + 5 x2] - Sin[5 x1 - 3 x2] - Sin[x1 + 5 x2] + Sin[5 x1 - 3 x2] Sin[x1 + 5 x2], x2 - (x1 Cos[3 x1 + 5 x2])/(-1 + Sin[5 x1 - 3 x2])}]} /. Quiet@FindRoot [{1 + Cos[5 x1 - x2] Cos[3 x1 + 5 x2] - Sin[5 x1 - 3 x2] - Sin[x1 + 5 x2] + Sin[5 x1 - 3 x2] Sin[x1 + 5 x2] == 0, x2 - (x1 Cos[3 x1 + 5 x2])/(-1 + Sin[5 x1 - 3 x2]) == 0}, {{x1, grid1[[i]]}, {x2, grid1[[j]]}}, WorkingPrecision -> 30], {i, Length[grid1]}, {j, Length[grid1]}], 1]
Selection
sol1 = DeleteDuplicates@Select [snorm1, #[[3]] < 10^-16 &]; Length[sol1] (*Out[]= 425*)
Using 4 grids with h=1,1/2,1/4,1/8
we plot results as
As we can see number of roots increasing with h decreasing even we select the reliable solutions only with norm of equations <10^-16.
Update 2 Ignoring small differences we can select roots as follows
grid = Range[-20, 20, #] & /@ {1/5, 1/10}; snorm[k_] := Flatten[ParallelTable[{x1, x2, Norm[{1 + Cos[5 x1 - x2] Cos[3 x1 + 5 x2] - Sin[5 x1 - 3 x2] - Sin[x1 + 5 x2] + Sin[5 x1 - 3 x2] Sin[x1 + 5 x2], x2 - (x1 Cos[3 x1 + 5 x2])/(-1 + Sin[5 x1 - 3 x2])}]} /. Quiet@FindRoot [{1 + Cos[5 x1 - x2] Cos[3 x1 + 5 x2] - Sin[5 x1 - 3 x2] - Sin[x1 + 5 x2] + Sin[5 x1 - 3 x2] Sin[x1 + 5 x2] == 0, x2 - (x1 Cos[3 x1 + 5 x2])/(-1 + Sin[5 x1 - 3 x2]) == 0}, {{x1, grid[[k, i]]}, {x2, grid[[k, j]]}}, WorkingPrecision -> 30], {i, Length[grid[[k]]]}, {j, Length[grid[[k]]]}], 1] sol = snorm[#] & /@ {1, 2}; // AbsoluteTiming sol1 = DeleteDuplicates@ Select[sol[[1]], #[[3]] < 10^-16 && Abs[#[[1]]] <= 20 && Abs[#[[2]]] <= 20 &]; Length[sol1] (*Out[]= 2462*) sol2 = DeleteDuplicates@ Select[sol[[2]], #[[3]] < 10^-16 && Abs[#[[1]]] <= 20 && Abs[#[[2]]] <= 20 &]; Length[sol2] (*Out[]= 5522*)
Now we apply filter to select unique roots and so ignoring multiple roots
sol11 = DeleteDuplicates[sol1, Norm[#1 - #2] < 10^-15 &] sol21 = DeleteDuplicates[sol2, Norm[#1 - #2] < 10^-15 &] Length[#] & /@ {sol11, sol21} Out[]= {1385, 1421}
These numbers look as reasonable and maybe we can reach number 1617 computed with other methods.