Best way to Plot it

101 views Asked by At

Im trying to Plot the DOS of a infinity linear chain. By the following:

s = 10; (*Number of decimation*) 
t = 1;
step = 0.01;
SubStar[E] = w + I*\[Eta];
\[Eta] = 0.01;
\[Epsilon] = 0;


Subscript[\[Beta], 1] = t*1/(SubStar[E] - \[Epsilon])*t;

Subscript[\[Beta], 0] = 1;



For[j = 2, j < s + 1, j++, 
 Subscript[\[Beta], j] = 
  Subscript[\[Beta], j - 1]*1/(SubStar[E] - \[Epsilon] - 2 \!\(
\*SubsuperscriptBox[\(\[Sum]\), \(i = 1\), \(j - 1\)]
\*SubscriptBox[\(\[Beta]\), \(i\)]\))*Subscript[\[Beta], j - 1]];

Subscript[G, 1, 1] = 1/(SubStar[E] - \[Epsilon] - \!\(
\*SubsuperscriptBox[\(\[Sum]\), \(j = 1\), \(s\)]
\*SubscriptBox[\(\[Beta]\), \(j\)]\));

G22 = (1/(1 - Subscript[G, 1, 1]*Subscript[G, 1, 1]))*Subscript[G, 1, 
   1];

\[Rho] = -1/\[Pi]*Im[G22];

I want to plot [Rho] as a w's function. So, if I let w undefined in the beginning (code above) and plot: ListPlot[Table[{w, \[Rho]}, {w, -2.5, 2.5, step}], Joined -> True, Frame -> True]
It works well, but its very slow, maybe because the mathematica is doing all the thing algebraically. If I make w change, like using: w=Range[-2.5,2.5,step], then I can plot something like this:

ListPlot[{\[Rho]}, Joined -> True, Frame -> True, PlotStyle -> Orange]

It works pretty faster, but the horizontal axis is not okay in comparison with the previous Plot.

Then, I was thinking in do something like, defining

 \[Rho][w]:= Module[{.....},....]

And work with this as a function and Plot at the end. Any suggestions? What should I do?

Edit1: After the suggestion:

Comparison between them

1

There are 1 answers

3
Chris Degnen On BEST ANSWER

Why not just this?

Plot[\[Rho], {w, -2.5, 2.5}, Frame -> True],

or better still

Plot[\[Rho], {w, -2.5, 2.5}, Frame -> True, PlotRange -> All]

Perhaps try this before plotting, but it looks time-consuming.

\[Rho] = Simplify[-1/\[Pi]*Im[G22]]

I tried this, which was interesting ...

For[j = 2, j < s + 1, j++, 
 Print[j];
  Subscript[\[Beta], j] = 
  Simplify[Subscript[\[Beta], 
    j - 1]*1/(SubStar[E] - \[Epsilon] - 2 \!\(
\*SubsuperscriptBox[\(\[Sum]\), \(i = 1\), \(j - 1\)]
\*SubscriptBox[\(\[Beta]\), \(i\)]\))*Subscript[\[Beta], j - 1]]]

The 10th iteration is the killer. It aborted with this message:-

enter image description here