0
$\begingroup$

I am plotting the numerical solutions of the following

eq[α_, k_, x_] := Sin[k + α] + k Sin[k] == x*Cos[k]
   y = sol[x_?NumericQ, k_ /; 0 <= k <= Pi] := α /. 
   NSolve[{eq[α, k, x], 0 <= α <= Pi}, α, Reals]
Manipulate[ContourPlot[Evaluate[eq[α, k, x]], {α, 0, Pi}, {k, -Pi, Pi}], 
 {{x,1}, 0, 10, .01}]

There are regions where I have two solutions and regions where I have one e.g., sol[1, 0.1] returns two solutions, sol[2,0.1] has no solution, sol[0.1,0.1] has one solution and so on. Is it possible to exclude say two solutions regime say sol[1, 0.1] i.e., excluding x=1,k=0.1 and plotting for the rest of the parameters, and is it also implementable to exclude more than one such parameter ranges e.g., sol[1,0.1],sol[1,0.2]?

$\endgroup$
2
  • 1
    $\begingroup$ Check out plotting the followig function over x ans k: sol[x_?NumericQ, k_ /; 0 <= k <= Pi] := With[{sols = NSolve[{eq[\[Alpha], k, x], 0 <= \[Alpha] <= Pi}, \[Alpha], Reals]}, If[Length[sols] == 1, \[Alpha] /. NSolve[{eq[\[Alpha], k, x], 0 <= \[Alpha] <= Pi}, \[Alpha], Reals], {}] ] with Plot3D[sol[x, k], {k, -Pi, Pi}, {x, 0, 2}]. Is that whay you want? $\endgroup$ Aug 29 '18 at 11:34
  • $\begingroup$ @HenrikSchumacher this is perfect, Thanks. It allows to consider only specific solutions with the Length command. Do I need to also care about the parameter range with this command? like e.g., plotting for x=0 to x=2 with Length[sols] == 1 and Length[sols] == 2 will automatically pick up the relevant solutions to plot even if in some ranges there are no solutions satisfying this condition, like sol[2,0.1] has no solution so this did not return any error. $\endgroup$
    – AtoZ
    Aug 30 '18 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.