이산 동적 시스템의 이미지 플로팅

Jan 02 2021

나는 형태의 이산 동적 시스템을 플롯하려고합니다. $$\vec{x}_{k+1} = A \vec{x}_k$$ 어디 $A$ 이다 $2\times 2$ 형태의 행렬 $$\begin{pmatrix}a&b\\c&d\end{pmatrix}$$ 어디 $a$, $b$$c$실수입니다. 형식의 초기 값이 있습니다.$$\begin{pmatrix}e \\f\end{pmatrix}$$

나는에서 유사한 플롯 만들고 싶습니다 : 이산 동적 시스템의 이미지를 만들기 그러나 함수가 나는 모두 시도로 꾸몄다 얻을 수있는 딱하다 VectorPlotListPlot작은 성공. 모든 조언을 주시면 감사하겠습니다 :-)

내가 작업하고있는 정확한 문제는 다음과 같습니다. $$\begin{align*} &\vec{x}_k = \begin{pmatrix}2ba-a-b&ba-a-b\\2(a+b-ab)&2(a+b)-ab\end{pmatrix}\vec{x},&\vec{x}_0 = \begin{pmatrix}2\\1/3\end{pmatrix}. \end{align*}$$ 다른 값으로 만든 플롯을보고 있습니다. $a$$b$ 같은 $1$$1/2$.

다음을 시도했습니다.

a = 1; b = 1/2;
A = {{2*b*a-a-b,b*a-a-b},{2(a+b-a*b),2(a+b)-ab}};
x0 = {1, 1/3};
pts = NestList[A.# &, x0, 15];
ListPlot[pts, Joined -> True, AspectRatio -> Automatic]

답변

10 kglr Jan 02 2021 at 07:53

슬라이더를 사용하여 매트릭스 항목을 수정합니다. 로케이터 (작은 디스크)를 클릭하고 끌어 초기 지점을 수정합니다. 로케이터를 추가 / 제거하려면 Alt + 클릭합니다.

Manipulate[ListLinePlot[Transpose @ NestList[#.{{a, b}, {c, d}} &, pt, 100],
   PlotStyle -> PointSize[Medium], PlotRange -> 5 {{-1, 1}, {-1, 1}}, 
   BaseStyle -> Arrowheads[{0., .05, 0.}], AspectRatio -> Automatic, 
   PlotLegends -> Placed[LineLegend[Defer /@ pt, LegendLabel -> "{x0,y0}", 
      LegendFunction -> Panel], Right], 
   Epilog -> {AbsolutePointSize[10], 
        {ColorData[97]@#, Point@pt[[#]]} & /@ Range[Length[pt]]}, 
   ImageSize -> 400, Frame -> True] /. Line -> Arrow,
 Spacer[10], Spacer[10], Spacer[10], 
 Grid[{{Item[Labeled[Control@{{a, .8, Style["a", 18]}, 0, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[a], 20], Top], 
     Background -> (Dynamic @ ColorData[{"Rainbow", {-1, 1}}][a])], 
    Item[Labeled[Control@{{b, .0, Style["b", 18]}, -1, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[b], 20], Top], 
     Background -> (Dynamic @ ColorData[{"Rainbow", {-1, 1}}][b])]}, 
    {Item[Labeled[Control@{{c, .0, Style["c", 18]}, -1, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[c], 20], Top], 
     Background -> (Dynamic@ColorData[{"Rainbow", {-1, 1}}][c])], 
    Item[Labeled[Control@{{d, .4, Style["d", 18]}, 0, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[d], 20], Top], 
     Background -> (Dynamic@ColorData[{"Rainbow", {-1, 1}}][d])]}}, 
  Alignment -> {Center, Center}, ItemSize -> {15, 15}, Dividers -> All],
 {{pt, 3 {{1, 1}, {-1, 1}, {1, -1}}}, Locator, 
    Appearance -> None, LocatorAutoCreate -> {1, 10}}, 
 Alignment -> Center, ControlPlacement -> Left]

다음을 사용하는 대체 구현 Graphics:

Manipulate[Legended[Graphics[{AbsolutePointSize[10], ColorData[97]@#, 
    Arrowheads[.03], Point @ pt[[#]], 
    Arrow[Partition[NestList[{{a, b}, {c, d}}.# &, pt[[#]], t - 1], 2, 1]]} & /@ 
     Range[Length[pt]], 
   ImageSize -> 400, Frame -> True, Axes -> True, 
   PlotRange -> 5 {{-1, 1}, {-1, 1}}], 
  Placed[LineLegend[ColorData[97] /@ Range[Length @ pt], Defer /@ pt, 
    LegendLabel -> "{x0,y0}", LegendFunction -> Panel], Right]],
 Spacer[10], Spacer[10], Spacer[10], 
 Grid[{{Item[Labeled[Control @ {{a, .8, Style["a", 18]}, 0, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[a], 20], Top], 
     Background -> (Dynamic @ ColorData[{"Rainbow", {-1, 1}}][a])], 
    Item[Labeled[Control @ {{b, .0, Style["b", 18]}, -1, 1, Slider, 
         ImageSize -> Small}, Style[Dynamic[b], 20], Top], 
       Background -> (Dynamic @ ColorData[{"Rainbow", {-1, 1}}][b])]},
    {Item[Labeled[Control @ {{c, .0, Style["c", 18]}, -1, 1, Slider, 
         ImageSize -> Small}, Style[Dynamic[c], 20], Top], 
       Background -> (Dynamic @ ColorData[{"Rainbow", {-1, 1}}][c])], 
    Item[Labeled[Control @ {{d, .4, Style["d", 18]}, 0, 1, Slider, 
         ImageSize -> Small}, Style[Dynamic[d], 20], Top], 
       Background -> (Dynamic @ ColorData[{"Rainbow", {-1, 1}}][d])]}}, 
  Alignment -> {Center, Center}, ItemSize -> {16, 16}, Dividers -> All],
  {{pt, 3 {{1, 1}, {-1, 1}, {1, -1}}}, Locator, 
     Appearance -> None, LocatorAutoCreate -> {1, 10}},
  Spacer[10],
  {{t, 1}, 1, 80, 1, Animator, AnimationRunning -> False, DisplayAllSteps -> True}, 
 Alignment -> Center, ControlPlacement -> Left]

업데이트 : OP 업데이트의 예제에 대한 두 번째 방법 수정 :

ClearAll [a, b, aA, x0] aA [a_, b_] : = {{2 ab-a-b, ab-a-b}, {2 (a + b-ab), 2 (a + b) -ab}} x0 = {1, 1/3};

Manipulate[Graphics[{AbsolutePointSize[10], ColorData[97]@1, Arrowheads[.03], 
   Point@x0, 
   Arrow[Partition[NestList[aA[a, b].# &, x0, t - 1], 2, 1]]}, 
  AspectRatio -> 1, ImageSize -> 400, Frame -> True, Axes -> True, 
  PlotRange -> All], Spacer[10], Spacer[10], Spacer[10], 
 Grid[{{Item[Labeled[Control@{{a, 1, Style["a", 18]}, -1, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[a], 20], Top], 
     Background -> (Dynamic@ColorData[{"Rainbow", {-1, 1}}][a])], 
    Item[Labeled[Control@{{b, .5, Style["b", 18]}, -1, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[b], 20], Top], 
     Background -> (Dynamic@ColorData[{"Rainbow", {-1, 1}}][b])]}}, 
  Alignment -> {Center, Center}, ItemSize -> {16, 16}, Dividers -> All], 
 Spacer[10], 
 {{t, 1}, 1, 15, 1, Animator, AnimationRunning -> False, DisplayAllSteps -> True}, 
 Alignment -> Center, ControlPlacement -> Left]

다음을 사용하여 시작점을 제어하려는 경우 Locator:

Manipulate[Labeled[Graphics[{AbsolutePointSize[10], ColorData[97]@#, 
      Arrowheads[.03], Point@pt[[#]], 
      Arrow[Partition[NestList[aA[a, b].# &, pt[[#]], t - 1], 2, 1]]} & /@ 
        Range[Length[pt]], ImageSize -> 400, Frame -> True, 
   Axes -> True, PlotRange -> All, AspectRatio -> 1], 
  Dynamic[pt[[1]]], Top], Spacer[10], Spacer[10], Spacer[10], 
 Grid[{{Item[Labeled[Control@{{a, 1, Style["a", 18]}, 0, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[a], 20], Top], 
     Background -> (Dynamic@ColorData[{"Rainbow", {-1, 1}}][a])], 
    Item[Labeled[Control@{{b, .5, Style["b", 18]}, -1, 1, Slider, 
        ImageSize -> Small}, Style[Dynamic[b], 20], Top], 
     Background -> (Dynamic@ColorData[{"Rainbow", {-1, 1}}][b])]}}, 
  Alignment -> {Center, Center}, ItemSize -> {16, 16}, Dividers -> All], 
  {{pt, {x0}}, Locator, Appearance -> None,  LocatorAutoCreate -> False}, 
 Spacer[10], 
 {{t, 1}, 1, 15, 1, Animator, AnimationRunning -> False, DisplayAllSteps -> True}, 
  Alignment -> Center, ControlPlacement -> Left]

7 cvgmt Jan 02 2021 at 06:40

편집하다

우리는 변경할 수 있습니다 x0에 의해 Locator변경 {a,b}에 의해 Slide2D.

A[{a_, b_}] := {{2*b*a - a - b, b*a - a - b}, {2 (a + b - a*b), 
    2 (a + b) - a*b}};
Manipulate[
 ListPlot[NestList[A[ab] . # &, x0, 15], Joined -> True, 
  PlotRange -> {{-10, 10}, {-10, 10}}, 
  AspectRatio -> 1], {{ab, {1, 1/2}, 
   Dynamic["{a,b}=" <> 
     ToString[ab, TraditionalForm]]}, {.8, .4}, {1.2, .6}}, 
 Dynamic["x0=" <> ToString[x0, TraditionalForm]], {{x0, {2, 1/3}}, 
  Locator}, ControlPlacement -> Right]

실물

A = {{Cos[π/3], -Sin[π/3] - .1}, {Sin[π/3], Cos[π/3]}};
x0 = {1, 1};
pts = NestList[A . # &, x0, 15];
ListPlot[pts, Joined -> True, AspectRatio -> Automatic]

또는

A = {{Cos[π/3], -Sin[π/3] - .1}, {Sin[π/3], Cos[π/3]}};
x0 = {1, 1};
pts = NestList[A . # &, x0, 15];
Graphics[Arrow[Partition[pts, 2, 1]]]