Codes for coherent state function?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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)
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)?
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
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
