How can write Dirac bra-ket notation in MATLAB? Example please.

Bra-ket notation is | > , <|

3 件のコメント

Jan
Jan 2022 年 12 月 22 日
Where do you want to "write" this? Inside code, in the command window, as annotation or label in a diagram, on a button of a GUI?
Image Analyst
Image Analyst 2022 年 12 月 22 日
@Idrees Muhammad You accepted the answer below so we assume you figured it out and got it working. 🙂 Thanks for accepting and awarding @Bjorn Gustavsson "reputation points".
Idrees Muhammad
Idrees Muhammad 2022 年 12 月 22 日
Sir, you also can help me.

サインインしてコメントする。

 採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2022 年 12 月 22 日

2 投票

That depends on what you want to apply the bra-ket on. If it is simple vectors you might get away with simple inner-products using dot. If you have some more advanced objects (wave-functions, and some quantum-mechanical operator) you might start with something like:
function Q = bra_ket(Psi,Phi,f_op)
Q = integral3(@(r1,r2,r3) Psi(r1,r2,r3).*f_op(Phi(r1,r2,r3)),r1min,r1max,r2min,r2max,r3min,r3max)
end
(There should surely be a conjugation in there somewhere). This might run into problems when you need to calculate gradients for the operator acting on Phi for example, the function should be in the integral3-call should be capable to handle vectorized input and that might require some ingenuity.
If you have wave-functions on some finite grid you might get something starting with trapz:
function Q = bra_ket_traps(Psi,Phi,f_op,r1,r2,r3)
opPhi = f_op(Phi,r1,r2,r3); % Here you might need additional argument
Q = trapz(r3(1,1,:),trapz(r2(1,:,1),trapz(r1(:,:,1),conj(Psi).*(opPhi)),2),3);
end
You might also have some good use of the chebfun-toolbox for more clever tools. You can find it on the file exchange.
HTH

5 件のコメント

Jan
Jan 2022 年 12 月 22 日
@Idrees Muhammad: Accepting an answer is a signal, that the problem is solved.
What have you tried so far and what is the actual problem? "Do not get" does not explain this.
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 12 月 22 日
@Idrees Muhammad, the way you ask makes me suspect that you are very new to matlab. If that's the case you might get off to a faster start by spending a couple of hours on the on-ramp course/information/material, which is designed to get people up to speed as fast as possible. You can browse through the parts that you think are most relevant for your current problem.
HTH
Idrees Muhammad
Idrees Muhammad 2022 年 12 月 22 日
Thank you very much 🌹
Idrees Muhammad
Idrees Muhammad 2023 年 2 月 9 日
Hello , whenever i run these funtion its not worked,please help me and put some values to run.i try much more but not get the idea.
function Q = bra_ket(Psi,Phi,f_op)
Q = integral3(@(r1,r2,r3) Psi(r1,r2,r3).*f_op(Phi(r1,r2,r3)),r1min,r1max,r2min,r2max,r3min,r3max)
end
function Q = bra_ket_traps(Psi,Phi,f_op,r1,r2,r3)
opPhi = f_op(Phi,r1,r2,r3); % Here you might need additional argument
Q = trapz(r3(1,1,:),trapz(r2(1,:,1),trapz(r1(:,:,1),conj(Psi).*(opPhi)),2),3);
end
Bjorn Gustavsson
Bjorn Gustavsson 2023 年 2 月 10 日
What are yout Psi, Phi? Wavefunctions defined in what way? What dimensionality are your problem? What is the operator f_op? Does f_op work on Phi and Psi in the way you intend?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeQuantum Mechanics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by