Message Boards Message Boards

0
|
302 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

How can i correct this NIntegrate code?

Posted 1 month ago

please help me to correct my code

Attachments:
POSTED BY: Minaa Askari

There are several problems. The package NumericalCalculus is not required. The D0 is the symbol of a musical note. In your definitions like Subscript[\[Rho], 11][v]= you forget the underscore after v, and you cannot use immediate = because NIntegrate does not work with functions with parameters; you should use delayed :=. You call NIntegrate on a very large interval, with a function that is almost zero everywhere except in a very small subinterval, so that the subinterval is not detected by the algorithm; I advice to integrate up to Infinity, which will trigger an algorithm that will discover the subinterval.

Here is a reworking that gives results, hopefully I didn't introduce mistakes:

\[CapitalDelta] = 1;
Subscript[x, 0] = -100000;
Subscript[b, 0] = (2/\[Pi])^(1/4) Sqrt[\[CapitalDelta]];
\[Alpha][k_, v_] = -((I v)/(4 k));
Subscript[R, 11][k_, v_] = -(\[Alpha][k, v]/(2 + \[Alpha][k, v]));
Subscript[R, 22][k_, v_] = \[Alpha][k, v]/(2 - \[Alpha][k, v]);
\[EmptySet][k_] = (2/\[Pi])^(1/4) Sqrt[\[CapitalDelta]]
    Exp[-\[CapitalDelta]^2 (k - Subscript[b, 0])^2 - 
     I (k - Subscript[b, 0]) Subscript[x, 0]];
M[v_] := 
  1/2 NIntegrate[
    Abs[\[EmptySet][k]]^2 (Abs[Subscript[R, 11][k, v]]^2 + 
       Abs[Subscript[R, 22][k, v]]^2), {k, 0, Infinity}];
Subscript[\[Rho], 11][v_] := 
  M[v] NIntegrate[
    Abs[Subscript[R, 11][k, v]]^2 Abs[\[EmptySet][k]]^2, {k, 0, 
     Infinity}];
Subscript[\[Rho], 14][v_] := Subscript[\[Rho], 11][v];
Subscript[\[Rho], 41][v_] := Subscript[\[Rho], 11][v];
Subscript[\[Rho], 44][v_] := Subscript[\[Rho], 11][v];
Subscript[\[Rho], 12][v_] := 
  M[v] NIntegrate[
    Subscript[R, 11][k, v] Conjugate[Subscript[R, 22][k, v]]
      Abs[\[EmptySet][k]]^2, {k, 0, Infinity}];
Subscript[\[Rho], 13][v_] := Subscript[\[Rho], 12][v];
Subscript[\[Rho], 42][v_] := Subscript[\[Rho], 12][v];
Subscript[\[Rho], 43][v_] := Subscript[\[Rho], 12][v];
Subscript[\[Rho], 21][v_] := 
  M[v] NIntegrate[
    Conjugate[Subscript[R, 11][k, v]]
      Subscript[R, 22][k, v] Abs[\[EmptySet][k]]^2, {k, 0, 
     Infinity}];
Subscript[\[Rho], 31][v_] := Subscript[\[Rho], 21][v];
Subscript[\[Rho], 24][v_] := Subscript[\[Rho], 21][v];
Subscript[\[Rho], 34][v_] := Subscript[\[Rho], 21][v];
Subscript[\[Rho], 22][v_] := 
  M[v] NIntegrate[
    Abs[Subscript[R, 22][k, v]]^2 Abs[\[EmptySet][k]]^2, {k, 0, 
     Infinity}];
Subscript[\[Rho], 23][v_] := Subscript[\[Rho], 22][v];
Subscript[\[Rho], 32][v_] := Subscript[\[Rho], 22][v];
Subscript[\[Rho], 33][v_] := Subscript[\[Rho], 22][v];
\[Rho][v_] := ( {
    {Subscript[\[Rho], 11][v], Subscript[\[Rho], 12][v], 
     Subscript[\[Rho], 13][v], Subscript[\[Rho], 14][v]},
    {Subscript[\[Rho], 21][v], Subscript[\[Rho], 22][v], 
     Subscript[\[Rho], 23][v], Subscript[\[Rho], 24][v]},
    {Subscript[\[Rho], 31][v], Subscript[\[Rho], 32][v], 
     Subscript[\[Rho], 33][v], Subscript[\[Rho], 34][v]},
    {Subscript[\[Rho], 41][v], Subscript[\[Rho], 42][v], 
     Subscript[\[Rho], 43][v], Subscript[\[Rho], 44][v]}
   } );
A[v_] := Eigenvalues[\[Rho][v]];
list = Range[0, 14];
n = list*Subscript[b, 0] // N;
Do[Print[{A[v], v}], {v, n}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract