Conputation with symbolic elements
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I'm trying to make symbolic computation with matlab. My problem is that, since the moment there is symbol in the expression, it doesn't want to compute the rest.
To be explicit I have this kind of probleme: let suppose 'eps' symbolic variable: my output are kind of: 213263172/3216586391302232716*eps while I would like it compute 213263172/3216586391302232716 and then multiply by 'eps'.
I heard it is because he take each element as string now and not as number... ??
Thank you for any help,
Here is the code:
expup=[0 1 0 0 0; 0 0 1 0 0; 0 0 0 1 0; 0 0 0 0 1; 1 0 0 0 0];
expdown=transpose(expup);
ket0=[1 0];
ket1=[0 1];
qx=[0 0 1 0 0];
qy=[0 0 1 0 0];
qz=[0 0 1 0 0];
point=kron(qx,qz);
syms alpha beta eps phi;
alpha=1/sqrt(2);
beta=1/sqrt(2);
phi=pi/4;
m=alpha*ket0+beta*ket1;
vec=kron(m,point).';
sigma_x=[0 1; 1 0];
sigma_y=[0 -i; i 0];
sigma_z=[1 0; 0 -1];
up_p=-i*eps*logm(expup)
down_p=i*eps*logm(expdown)
droite=expm(i*(kron(kron(sigma_x,up_p),eye(5))+kron(kron(sigma_z,eye(5)),up_p)));
gauche=expm(-i*(kron(kron(sigma_x,up_p),eye(5))+kron(kron(sigma_z,eye(5)),up_p)));
the result of up_p is:
up_p =
[ (eps*7998807863191437i)/10141204801825835211973625643008, -(eps*4814164849790005i)/4503599627370496, (eps*5950635009230501i)/9007199254740992, -(eps*5950635009230503i)/9007199254740992, (eps*4814164849790003i)/4503599627370496]
[ (eps*2407082424895001i)/2251799813685248, (eps*1663548296596613i)/5070602400912917605986812821504, -(eps*4814164849790009i)/4503599627370496, (eps*743829376153813i)/1125899906842624, -(eps*5950635009230501i)/9007199254740992]
[ -(eps*5950635009230499i)/9007199254740992, (eps*601770606223751i)/562949953421312, -(eps*6027246515204799i)/20282409603651670423947251286016, -(eps*4814164849790009i)/4503599627370496, (eps*1487658752307625i)/2251799813685248]
[ (eps*2975317504615257i)/4503599627370496, -(eps*5950635009230511i)/9007199254740992, (eps*4814164849790011i)/4503599627370496, -(eps*6827359916614769i)/40564819207303340847894502572032, -(eps*4814164849790005i)/4503599627370496]
[ -(eps*2407082424895003i)/2251799813685248, (eps*5950635009230509i)/9007199254740992, -(eps*5950635009230503i)/9007199254740992, (eps*2407082424895001i)/2251799813685248, (eps*215792426952591i)/316912650057057350374175801344]
I would like he compute number and then times epsilon.
The next step is to get 'droite' (which is 50x50 matrix) in function of 'eps'
0 件のコメント
採用された回答
Steven Lord
2021 年 5 月 17 日
Call double (if the result doesn't contain any symbolic variables) or vpa (if it does) on the result.
two = sym(2);
y = (sqrt(two)+1)^100
double(y)
vpa(y)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!