0
$\begingroup$

Code

Does anyone know why my plot is not showing up? I get a recursion error.

ω = Range[0, 5, 1];
U = 0;
μ = 0;
Σ[ω_] := 0;
G[ω_] := 0.5*(ω + μ - Σ[ω]) + 0.5*Sqrt[(ω + μ - Σ[ω]) ^2 - 4];
G0[ω_] := ((G[ω])^(-1) + Σ[ω]);
Gnew[ω_] := 0.5*G0[ω] + 0.5*( (G0[ω])^(-1) - U)^(-1);
Σ[ω_] := (G0[ω])^(-1) - (G[ω])^(-1);

Plot[Im[G[ω]], {ω, 0, 5}]
$\endgroup$
3
  • $\begingroup$ It would be much easier to answer if you placed the code as text rather than as an image. But you might try Evaluate[Im[G[omega]] $\endgroup$
    – bill s
    Nov 11, 2019 at 2:20
  • $\begingroup$ You have G depending on \[CaptialSigma] and \[CapitalSigma] depending on G, leading to a recursion error. $\endgroup$
    – Carl Woll
    Nov 11, 2019 at 2:27
  • $\begingroup$ Thank you so much!! $\endgroup$ Nov 11, 2019 at 2:27

1 Answer 1

3
$\begingroup$

It's because of how you redefine Σ[ω]. If we take a look at the DownValues of G

S[x_] := 0
G[x_] := 0.5 (x - S[x]) + 0.5 Sqrt[(x - S[x])^2 - 4]
DownValues@G
G0[x_] := G[x]^-1 + S[x]
S[x_] := G0[x]^-1 - G[x]^-1

{HoldPattern[G[x_]] :> 0.5 (x - S[x]) + 0.5 Sqrt[(x - S[x])^2 - 4]}

we can see that the previously defined S[x] isn't explicitly replaced with 0 as you may have wanted, but rather with the unevaluated function. Since this is the case, you can redefine S later and not have to change the definition of G. Which is exactly what happened.

Since any time G is called, S is also called, and every time S is called, G is called again. So there is an infinite loop whenever you call G. That's why there is recursion error.

$\endgroup$

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.