First of all it is a good programming style is to use functions with their explicit (independent) variables, i.e. if one has to solve an equation with respect to a parameter, it should be treated as an explicit argument. Thus we define the functions this way :
f[x_, a_] := a/x^2 - 3 x + 2
g[x_, a_] := a Sin[2 x]
The question doesn't imply that the solution must be necessarily real. In fact, there is only one real solution, you can find it this way :
Solve[ f[ f[-1, a], a] == Sqrt[2] + g[ f[ 2, a], a], a, Reals]
but since there are (most likely infinitely) many complex solutions and since Mathematica
is to find them all, we should tell the system to restrict somehow the search for solutions to a region where it may have only finite numbers of solutions. In order to provide a completion to algorithms behind equation-solving functionality we need to restrict the search for roots to a finite complex range (e.g. square - like ). For the sake of brevity we define a new function :
funcfg[a_] := f[ f[ -1, a], a] - Sqrt[2] - g[ f[ 2, a], a]
Let's find all roots of funcfg
e.g. in a circle of radius 51
with the center in 0
, i.e. where complex numbers satisfy Abs[a] < 51
:
sol = Solve[ funcfg[a] == 0 && Abs[a] < 51, a];
There are
Length @ sol
21
solutions, so write here only 3
of them, e.g. (from 8
-th to 10
-th) :
sol[[8 ;; 10, 1, 2]]
{Root[{325 + 25 Sqrt[2] + 204 #1 + 10 Sqrt[2] #1 + 25 Sin[2 (-4 + #1/4)] #1 + 43 #1^2
+ Sqrt[2] #1^2 + 10 Sin[2 (-4 + #1/4)] #1^2 + 3 #1^3 + Sin[2 (-4 + #1/4)] #1^3 &,
-11.953414742816708318902832339138612161461271256190 +
2.454413085381160585476672761493761068260205214286 I}],
Root[{325 + 25 Sqrt[2] + 204 #1 + 10 Sqrt[2] #1 + 25 Sin[2 (-4 + #1/4)] #1 + 43 #1^2
+ Sqrt[2] #1^2 + 10 Sin[2 (-4 + #1/4)] #1^2 + 3 #1^3 + Sin[2 (-4 + #1/4)] #1^3 &,
-5.81217740175980465827061286458}],
Root[{325 + 25 Sqrt[2] + 204 #1 + 10 Sqrt[2] #1 + 25 Sin[2 (-4 + #1/4)] #1 + 43 #1^2
+ Sqrt[2] #1^2 + 10 Sin[2 (-4 + #1/4)] #1^2 + 3 #1^3 + Sin[2 (-4 + #1/4)] #1^3 &,
- 4.131337899047017233724977013012392200221448674862
- 0.658093853165542882211799231745725310996904431942 I}]}
You can see there is that only one real near -5.8121
.
roots = {Re @ #, Im @ #}& /@ sol[[All, 1, 2, 1, 2]];
Now we'd like to plot only 3 roots of the function in an especially more restricted region to to discover its trefoil-quatrefoil like structure :
GraphicsRow[
Table[ Show[
ContourPlot @@@ {
{ h[ funcfg[x + I y]], ##, Contours -> 11, ColorFunction -> "DeepSeaColors",
Epilog -> {PointSize[0.025], Red, Point[roots]}},
{ Re[ funcfg[x + I y]] == 0, ##, ContourStyle -> {Darker @ Green, Thick}},
{ Im[ funcfg[x + I y]] == 0, ##, ContourStyle -> {Cyan, Thick}}},
AspectRatio -> Automatic], {h, {Re, Im}}]& @ Sequence[{x, -6, -3.8}, {y, -1.1, 1.1}]]
