Hello,
I want to plot ‘Basin of Attraction’ for a Piecewise system of the form:
Piecewise[{{2 x + 1, x <= 0}, {0.5 x + 2, x > 0}}]
For the given example the Basin of Attraction (BoA) is (-1, \[Infinity])
How can we plot this BoA? Thank You.
Hello,
I want to plot ‘Basin of Attraction’ for a Piecewise system of the form:
Piecewise[{{2 x + 1, x <= 0}, {0.5 x + 2, x > 0}}]
For the given example the Basin of Attraction (BoA) is (-1, \[Infinity])
How can we plot this BoA? Thank You.
Hello Rajanikant Metri,
I do not know how to plot something between 1 and infinity. But you can show that there are two fixpoints (where your function intersects the identiy):
func[x_] := Piecewise[{{2 x + 1, x <= 0}, {1/2 x + 2, x > 0}}];
Solve[func[x] == x, x]
(* Out: {{x\[Rule]-1},{x\[Rule]4}} *)
The one at x=-1 is repulsive, the other one at x=4 is attractive, and that can easily be demonstrated:
Manipulate[
arrows = BlockMap[Arrow[{{#[[1]], #[[1]]}, #, {#[[2]], #[[2]]}}] &, NestList[func, startx, 10], 2, 1];
Plot[{x, func[x]}, {x, -5, 10}, AspectRatio -> Automatic, Epilog -> arrows, GridLines -> {{startx}, None},
PlotStyle -> {{Dashed, Gray}, Blue}], {{startx, 1}, -2, 10}]
Does that help?
Hello Henrik Schachner,
Thank you for your response. The code you sent is for cobweb plot with slider. Yes, it is helpful for me. I obtained earlier only cobweb plot with fixed lines with fixed initial points, and without arrow in my case ;-).
In your code the initial points can be moved and checked whether it is attracting or repelling.
I will go through and try to modify to get Basins of attraction. In BoA, I need to accumulate the steady-state values of all the initial points and classify accordingly their attractions and then need to plot.
Thank you again.
OK, I see. Maybe this simple approach comes somewhat closer to your needs:
func[x_] := Piecewise[{{2 x + 1, x <= 0}, {1/2 x + 2, x > 0}}];
limit[x_] := If[Nest[func, x, 10] > 0, 1, -1];
xvals = Range[-5, 10, .1];
NumberLinePlot[Interval /@ MinMax /@ Gather[xvals, limit[#1] == limit[#2] &]]

Thank you sir, for your solution.
I will try this.