1
$\begingroup$

I have the following operator $T:[0,1]\rightarrow[0,1]$ by $Tx=\frac{x}{2}$. I use the following method for two different initial point $x_{0}\in[0,1]$ as $x_{n+1}=Tx_{n}$ $n=0,1,2,3,...$ I have set the following codes in mathemtica for $x_{0}=0.1$ and $x_{0}=0.9$ as

Clear[x, T, a, b, c]
T[x_] := T[x] = (x/2)
x[0] = 0.1;
x[n_] := x[n] = T[x[n - 1]]
NumberForm[a1 = {Table[x[i], {i, 0, 6}]}, 4]

The plot code is for this I used

plot1 = ListPlot[a1, Joined -> True, PlotStyle -> Red]

Now for the secod initial Point

Clear[x, T, a, b, c]
T[x_] := T[x] = (x/2)
x[0] = 0.1;
x[n_] := x[n] = T[x[n - 1]]
NumberForm[a1 = {Table[x[i], {i, 0, 6}]}, 4]

The plot code is for this I used

Clear[x, T, a, b, c]
[x_] := T[x] = (x/2)
x[0] = 0.9;
x[n_] := x[n] = T[x[n - 1]]
NumberForm[a2 = {Table[x[i], {i, 0, 6}]}, 4]

And plotting these vales as:

plot2 = ListPlot[a2, Joined -> True, PlotStyle -> Blue]

I have combined these two plots as:

Show[plot1, plot2, PlotRange -> Automatic, Frame -> {{True, True}, {True, True}},FrameLabel -> {Style["Number of iterates", Black, Small],Style["Absolute error", Black, Small]},Epilog->Inset[LineLegend[{Red, Blue, Cyan}, {"x0=0.1", "x0=0.9"}], {5,0.4}]]

I get the following attached graph enter image description here. But I need a graph and legend Plotmarker like https://i.stack.imgur.com/KWX9u.jpg this full post is at Show[List of plot] how to color them differently?

$\endgroup$
1
  • $\begingroup$ Dear @Michael I need PlotMarkers $\endgroup$
    – Junaid
    Apr 2, 2022 at 18:53

1 Answer 1

2
$\begingroup$
Clear[x, T]
T[x_] := T[x] = (x/2)
x[0] = 0.1;
x[n_] := x[n] = T[x[n - 1]]
NumberForm[a1 = Table[x[i], {i, 0, 6}], 4]

enter image description here

Clear[x, T]
T[x_] := T[x] = (x/2)
x[0] = 0.9;
x[n_] := x[n] = T[x[n - 1]]
NumberForm[a2 = Table[x[i], {i, 0, 6}], 4]

enter image description here

ListLinePlot[{a1, a2},
 PlotStyle -> {Red, Blue},
 PlotMarkers -> {Automatic, 8},
 Frame -> True,
 FrameLabel -> {Style["Number of iterates", Black, Small], 
   Style["Absolute error", Black, Small]},
 PlotLegends -> 
  Placed[
   StringForm["`` = ``", Subscript[x, 0], #] & /@ {0.1, 0.9}, {5/7, 
    2/3}]]

enter image description here

$\endgroup$
5
  • $\begingroup$ Thanks Dear @Bob I have got what I need. Thanks Again $\endgroup$
    – Junaid
    Apr 2, 2022 at 19:39
  • $\begingroup$ @Junaid since you tested the code and said that it works, it's a simple task to upvote and/or accept the answer, and also a matter of politeness. I am just sharing a thought here, since you have not accepted any answers to any of your questions. $\endgroup$
    – bmf
    Apr 2, 2022 at 19:54
  • $\begingroup$ Dear @Bob can you provide me a code for dashing? $\endgroup$
    – Junaid
    Apr 2, 2022 at 20:50
  • $\begingroup$ Use PlotStyle -> {{Red, Dashed}, {Blue, Dotted}} Also see the documentation for Dashing, AbsoluteDashing, and DotDashed $\endgroup$
    – Bob Hanlon
    Apr 2, 2022 at 20:56
  • $\begingroup$ I got the desired aims. Thanks dear @Bob Hanlon $\endgroup$
    – Junaid
    Apr 3, 2022 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.