Ask Your Question

hiro protagonist's profile - activity

2021-05-24 00:34:31 +0200 received badge  Notable Question (source)
2021-05-24 00:34:31 +0200 received badge  Popular Question (source)
2020-07-05 03:36:59 +0200 received badge  Famous Question (source)
2020-07-05 03:36:59 +0200 received badge  Notable Question (source)
2018-06-13 03:24:51 +0200 received badge  Nice Question (source)
2017-11-29 11:30:37 +0200 received badge  Popular Question (source)
2017-04-03 21:57:19 +0200 received badge  Scholar (source)
2017-04-03 21:57:16 +0200 commented answer sympy.physics.quantum Bra and Ket: orthonormal basis

that looks good! thanks for the update!

2017-03-30 19:25:03 +0200 received badge  Supporter (source)
2017-03-30 19:25:00 +0200 commented answer sympy.physics.quantum Bra and Ket: orthonormal basis

well... i would very much like to demonstrate a basis change. the new basis vectors should have the same simple form as the original ones... in any case: thanks a lot for your effort! +1 anyway. should you find some other way, i'd be really happy!

2017-03-30 14:45:54 +0200 commented answer sympy.physics.quantum Bra and Ket: orthonormal basis

thanks, i saw that. but what if i want to rotate the basis vectors and create a new set of orthonormal vectors that are not in the computational basis? (something like |+> = n(|0> +|1>) ; |-> = n(|0>-|1> ; $n=1/\sqrt(2) $; how do i tell sage now that $|+\rangle $ and $|-\rangle $ are orthonormal)?

2017-03-29 20:23:40 +0200 received badge  Good Question (source)
2017-03-29 13:02:42 +0200 received badge  Nice Question (source)
2017-03-29 08:52:02 +0200 asked a question sympy.physics.quantum Bra and Ket: orthonormal basis

i would like to be able to tell qapply from sympy.physics.quantum that i have a set (2 in my example) of orthonormal vectors:

from sympy.physics.quantum import Bra, Ket, qapply, Dagger

e0 = Ket('e0')
e1 = Ket('e1')

X = e1*Dagger(e0) + e0*Dagger(e1)
qapply(X * e1)
# ->  <e0|e1>*|e1> + <e1|e1>*|e0>

is there a way to tell sage (or sympy in that case) that $\langle e_i|e_j \rangle = \delta_{ij}$?

the best i could come up with is a substituion rule:

# e_rules = [(Dagger(e0)*e0, 1), (Dagger(e1)*e1, 1), (Dagger(e0)*e1, 0), (Dagger(e1)*e0, 0)]
e_rules = {Dagger(e0)*e0: 1, Dagger(e1)*e1: 1, Dagger(e0)*e1: 0, Dagger(e1)*e0: 0}
qapply(X * e1).subs(e_rules)
# ->  |e0>

isn't there something more elegant?

2017-03-29 08:40:27 +0200 commented answer differences between .sage and .spyx in numerical evaluation

thanks for the update. but then: how could i prevent this in .spyx mode?

2017-03-29 08:39:17 +0200 commented question differences between .sage and .spyx in numerical evaluation

@kcrisman : yes, the first time i posted the question it took hours for it to get approved (from stackoverflow i was used to higher speeds...), and i could no longer find any trace of it. so i re-posted, etc etc etc. sorry for the confusion. hope everything is correct now. and yes, after i could not find my question here i posted it over on stackoverflow...

2017-03-28 19:40:53 +0200 received badge  Student (source)
2017-03-28 19:37:56 +0200 received badge  Editor (source)
2017-03-28 16:01:46 +0200 asked a question differences between .sage and .spyx in numerical evaluation

the question seems very basic, i'm sorry but i could not find an answer in the documentation.

the content of both files test.sage and test.spyx is identical; it's just

a = 1/sqrt(2)
print a

if i run test.sage and with

$ sage test.sage

i get

1/2*sqrt(2)

but the outcome is different from if i run the file test.spyx with

$ sage test.spyx

where i get

Compiling test.spyx...
0.707106781187

how can i prevent sage from numerically evaluating $1/\sqrt(2)$ in .spyx mode?