Codes for coherent state function?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Summation n=0 to10 exp-abs(alpha)^2*alpha^n/sqrtfactorial(n)
採用された回答
Walter Roberson
2023 年 1 月 13 日
syms alpha n
result = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 10)
result =

12 件のコメント
Abu Zar
2023 年 1 月 14 日
if we put alpha=0.5 the code become?
syms alpha n
result = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ),aplha,0.5, n, 0, 10)
Walter Roberson
2023 年 1 月 14 日
syms n
alpha = sym(0.5)
result = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 10)
Abu Zar
2023 年 1 月 14 日
Thank you very much
Abu Zar
2023 年 2 月 8 日
Hello sir,can i use alpha=0.5 instead of alpha=sym(0.5)?
Walter Roberson
2023 年 2 月 8 日
On the special case that alpha is a negative power of 2 (0.5, 0.25, 0.125 and so on) greater than 2^-512 you can use the exact decimal equivalent for alpha without using sym()
The same is true if alpha is an exact integer multiple of a negative power of 2 and the multiple does not exceed 2^53 and you specify alpha as a fraction, such as alpha = 83617/2^37. However the larger the denominator, the higher the risk that matlab might approximate as a different fraction.
Abu Zar
2023 年 2 月 8 日
I Just use alpha=0.05
And i want calculate different alpha using a list and “ for “ iteration to calculate the result , one by one.
help me with one example thank you very much.
format long g
syms n
alpha = sym(0.05)
alpha =
result1 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 10)
result1 =

syms n
alpha = 0.05
alpha =
0.05
result2 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 10)
result2 =

result1 - result2
ans =
0
Alpha = rand
Alpha =
0.691938609323685
alpha = sym(Alpha)
alpha =
result3 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 10)
result3 =

alpha = Alpha
alpha =
0.691938609323685
result4 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 10)
result4 =

result3 - result4
ans =

double(ans)
ans =
-9.46009976357279e-18
This shows that for some alpha values you can get away with using numeric alpha, but for other alpha values you need to use sym() to get an accurate answer.
In particular if your input alpha has more than 26 bits of precision, the automatic conversion of abs(alpha)^2 might not match abs(sym(alpha))^2
format long g
syms n
alpha = linspace(0.01, 0.99, 25);
inner = exp(-abs(sym(alpha)).^2 .* sym(alpha).^n ./ sqrt(factorial(n)) )
inner =

resultsym = sum(subs(inner, n, (0:10).'),1).';
result = double(resultsym)
result = 25×1
10.9998989978882
10.9972830981744
10.9908097750576
10.980037695147
10.9645002860003
10.9437012720096
10.9171106809702
10.8841614122063
10.8442464792823
10.7967170574898
plot(alpha, result)

Abu Zar
2023 年 2 月 9 日
Hi , i see you create "25 X 1'',how we can create "25 X 25".
Zar
2023 年 2 月 9 日
v.nice
Walter Roberson
2023 年 2 月 9 日
remove the sum() from resultsym to get length(alpha) by length(0:11), which would be removing the summation from the formula
Abu Zar
2023 年 2 月 11 日
Hello sir,
I created this m.file to draw plot alpha vs Vnorm , but the vector is not the same length,I requetd you to look this file for my help to draw th plot.
Thank you
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Quantum Mechanics についてさらに検索
参考
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)
