Normalization of complex eigenvector
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
What is the best way of normalisation of a complex eigenvector of a complex hermitian matrix. Here I am doing this in the following way, but norm remaim as it is.
syms theta phi
a=[cos(theta) sin(theta)*exp(1i*phi);sin(theta)*exp(-1i*phi) cos(theta)];
[V,~]=eig(a);
V(:,1)/norm(V(:,1))
This produces the vector as
exp(phi*1i)/(exp(-2*imag(phi)) + 1)^(1/2)
1/(exp(-2*imag(phi)) + 1)^(1/2)
But Normalization factor remain in symbolic form, but it should by sqrt(2). Pl somebody help me to understand.
5 件のコメント
Walter Roberson
2020 年 2 月 1 日
Why should sqrt(2) be involved?
AVM
2020 年 2 月 1 日
@walter: Thanks for your reply. If Z is a complex number , its norm would be sqrt(z.z*). Here, z=exp(-1i*phi)+1,
Walter Roberson
2020 年 2 月 1 日
So? What does that have to do with sqrt(2)?
@walter: Is it little bit of faster if I run the Matlab code using cmd in windows compare to Matlab script? I mean without opening Matlab display?
Walter Roberson
2020 年 2 月 1 日
Possibly, but I would not expect the difference to be much.
採用された回答
Vladimir Sovkov
2020 年 2 月 1 日
You probably want
V(:,1) = V(:,1)/norm(V(:,1));
Besides, if your theta and phi are supposed to be real, the overall computation would be simpler with the assumptions
syms theta phi
assume(theta,'real');
assume(phi,'real');
18 件のコメント
@vladimir: Thanks a lot. Actually I am trying to plot using the code below, It is taking som much time more than one day, it is still busy and system getting slow down. You pl have a look and advise me what to do.
clc;clear;
syms theta phi b k1 alpha
alpha=1;
b=0.5;
sigma1=[0 1;1 0];
sigma2=[0 -1i;1i 0];
sigma3=[1 0;0 -1];
sigmap=1/2*(sigma1+1i*sigma2);
sigmam=1/2*(sigma1-1i*sigma2);
I1=eye(2);
n=[sin(theta)*cos(phi) sin(theta)*sin(phi) cos(theta)];
d1=sigma1*sin(theta)*cos(phi)+sigma2*sin(theta)*sin(phi)+sigma3*cos(theta);
d2=kron(sigmap,sigmap)+kron(sigmam,sigmam);
hami1=1/2*alpha*b*kron(d1,I1)+k1*d2;
[V,~]=eig(hami1);
u=V(:,1)/norm(V(:,1));
w=diff(u,phi);
r=dot(u,w);
r=simplify(r,'Steps',10);
f=1/pi*1i*int(r,phi,0,2*pi);
ffcn = matlabFunction(f);
theta = linspace(0.001,4, 30);
k1 = linspace(0.001,10, 30);
[Th,K] = meshgrid(theta, k1);
F=ffcn(Th,K);
figure
mesh(Th,K, F)
colormap(cool)
grid on
xlabel('\bf\theta','FontSize',14)
ylabel('\bf\alpha','FontSize',14)
zlabel('\bf\itf','FontSize',14)
I thought, using function calling of that integartion part, it may be faster. That's way I have introdued some function like that. and call that in my main programming. here, in the above , it is without calling that fucntion. Pl help me to get the fast result.
Walter Roberson
2020 年 2 月 1 日
編集済み: Walter Roberson
2020 年 2 月 1 日
To get a faster result, obtain a supercooled overclocked computer.
There is also the possibility that a completely different symbolic package such as Maxima might be faster for this work.
Vladimir Sovkov
2020 年 2 月 1 日
編集済み: Vladimir Sovkov
2020 年 2 月 1 日
The symbolic computations are always slow. If you have predefined grids of your variables, it would be faster to define them as numeric vectors from the very beginning and process them using the efficient vector and matrix (i.e., element-wise or in the sence of matrix algebra, avoiding loops) algorithms of Matlab, not using the symbolic tools at all.
AVM
2020 年 2 月 1 日
@Vladimir: Thanks for reply. But how can I do differentiation and integration without symbolic tool? Is there any way of getting that one? Pl help
Vladimir Sovkov
2020 年 2 月 1 日
In the number of ways, e.g., using the finite-difference formula and the Riemann formula (say, in the form of the Simpson's rule); the matlab functions "diff" and "integral" work with numeric arrays and functions.
Vladimir Sovkov
2020 年 2 月 1 日
編集済み: Vladimir Sovkov
2020 年 2 月 1 日
At the first glance, all your functions are rather simple compositions of sin, cos, exp. It is possible that all the derivatives and integrals can be precomputed analytically (either manually or with a separate program using symbolic computations, which must be executed only once) and provided to your program as a ready-to-use result. This would be the best decision possible.
AVM
2020 年 2 月 1 日
@Vladimir:Thanks a lot.the main problem is the eigenvector of the h is a very large expression. Even it is not displaying in the command plate entirely. Another thing, is the Runge-kutta method is helpful here for derivative part??
Vladimir Sovkov
2020 年 2 月 1 日
The Runge-Kutta method is for solving differential equations but not for computing derivatives.
AVM
2020 年 2 月 1 日
@Vladimir:Thanks..but can you tell me how I can do a derrivative under integration numerically with respect to same variable \phi? PL tell me few steps.
theta = linspace(0.001,4, 30);
Wait... is theta in degrees or in radians? 4 radians seems like an odd place to stop.
AVM
2020 年 2 月 2 日
@Walter: Thanks for your reply. Here theta is in degree. Is there any problem with this unit?
Walter Roberson
2020 年 2 月 2 日
Yes! If theta is degrees then you need sind() and cosd() instead of sin() and cos()
AVM
2020 年 2 月 2 日
@walter: Thanks for your advice. By the way, for that sin() and cos(), if I use the arguments in deg., then the execution of code will take long time? Does this worng command seriously drop the speed of the execution? PL inform me.
Walter Roberson
2020 年 2 月 2 日
Your r turns out to be the sum of four terms. I would need to further analysis, but it looks to me as if the integral of the first and fourth terms are each theoretically zero. For the values that I looked at, the second term is about 2% of the third term and all imaginary. The numeric integration of the second terms and third terms independently are each comparatively quick, but the second and third terms interact in ways that make computing the numeric integral of the two of them together rather slow as the software tries ensure that it meets tolerances.
At the moment it is looking to me as if your F will be complex valued and so not plottable using the techniques you are using.
The implication of the tests I am doing are that if you were to try to evaluate the integral numerically over an evenly spaced grid, then it would have to be very finely spaced to get an accurate integral.
However I need to go back and have another look knowing that theta is intended to be degrees: possibly it is much smoother near 0 than where I tested.
AVM
2020 年 2 月 2 日
@Walter: Many many thanks for heartedly investigation. I am really overwhelming that you are spending your valuable time regarding my problem. I am really confused what to do. PL help as far as possible to get over this painful situation.
Walter Roberson
2020 年 2 月 3 日
I mentioned earlier that r can be broken up into the sum of 4 parts, and that two of the parts integrate to 0 over 2 to 2*pi. I mentioned that the magnitude of the other two parts is generally fairly different.
With further testing, I see that the magnitude of the imaginary component of the third part is up to 10^17 times larger than the magnitude of the imaginary component of the second part, and often is more than 10^14 times larger.
I also see that the magnitude of the real component of the third part is up to 10^60 times larger than the magnitude of the real component of the second part,
But these are "up to", and there are places where the magnitudes are much closer, especially in the places where the parts approach 0. The numeric integrations end up needing to spend a lot of time to resolve the differences, because for some phi and some k1 they end up being important for the value there, even if the value there is minor compared to the value at some other point.
If accuracy within (roughly) 2% is acceptable, then I would say to extract just the third component of r, and create a matrix of theta and k1 values that you substitute into r[3], vpa() that, and then integrate over phi from 0 to 2*pi . This approach will give you some round-off errors, with some very small components not exactly vanishing when they theoretically should... but I did say accuracy only within roughly 2%.
When I taylor r[3] near k1=5, order 5, at theta=2*Pi/180 (2 degrees, right in the middle of your range) and integrate over phi=0..2*pi then the result involves values ranging between 10^16 and 10^115, and the values are all magically supposed to cancel out to give you a final result in the range 0 to 1 for the real component and 0 to 10 for the imaginary component. This is implausible numerically in binary floating point calculations: the integrals .
At theta = acos(999/100) and k1=4, the values involved are on the order of of 10^74 for real and imaginary components, and the values cancel down to the order of 10^21 and are then multiplied by 10^-21 to get the same kind of real and imaginary range mentioned above. This will never work out in binary floating point.
In binary floating point, your equations are numerically unstable and could produce answers that are pretty far off. Even symbolically with the default of 32 digits you are going to get nonsense -- you need somewhere on the order of 80 digits to get reasonable cancellation.
I would recommend giving up on this equation.
AVM
2020 年 2 月 3 日
@Walter: Thanks for your brilliant analysis and observation. I am really great ful to you for your valuable advice. So there is no hope to go further with this kind of situation at all according to your suggestion. Thanks a lot once again.
Walter Roberson
2020 年 2 月 3 日
Well, given sufficient time you can get some result, but if you want values that mean anything, you need to evaluate symbolically to 80 or so digits and set a relatively large numeric integration target.
If you are willing to give up that approximately 2% contribution term then the process would be to extract the 3rd term of r, evaluate it at a matrix of theta and k1, evalf(), and integrate the matrix over phi = 0..2*pi and the integration will not take a grindingly long time. If you keep the approximately 2% contribution term you would probably have to set a larger permitted relative error term in order to prevent the numeric integration from being very very slow.
Integrating r as a whole and then substituting k1 and theta into it is probably going to take much too long.
If you substitute in a particular theta value then the third term of r expands to a surprisingly long expression involving k1 and phi that is not profitable to do an exact integration on with respect to phi.
I don't know if an exact integral of r even exists. I had to kill the exact integration when it got up to 75 gigabytes of memory on my system.
その他の回答 (1 件)
Thanks a lot. If I just avoid that 2% contribution, then the plotting will appear shortly? I need to see the graph anyhow. I had to see the nature of graph only. I am not worried about any particular data. If that 2% contributing term takes so long time, just avoid it. I think it will not change the nature of the graph drastically. If at least that can be done, then there is a positive sign for me.
カテゴリ
ヘルプ センター および File Exchange で Code Performance についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
