Ask Your Question

johanneh's profile - activity

2020-12-15 07:52:54 +0200 received badge  Popular Question (source)
2018-11-13 22:17:02 +0200 received badge  Supporter (source)
2018-11-13 22:16:59 +0200 received badge  Scholar (source)
2018-11-12 18:21:14 +0200 asked a question Express the derivative in the Hamiltonian operator in sage

I want to compute the expectation value of the energy $ \langle H \rangle $ for a quantum system with the wave function $ \psi(x) $. This is done with $$ \langle H \rangle = \int_{-\infty}^{\infty} \psi^* \hat{H} \psi d x $$ where $$ \hat{H} = - \frac{\hbar^2}{2 m} \frac{d^2}{d x^2} + V(x) $$ is the Hamiltonian operator for some potential $V(x)$. How do I express $ \frac{d}{d x} $ in sage if I don't know on which function it will be applied?

I know it is possible to use psi.diff(x), but is there a way to declare the operator so that it automatically does the derivative when it is multiplied with some function?

2018-05-13 12:53:52 +0200 received badge  Student (source)
2018-05-13 07:30:04 +0200 asked a question Define custom unit

Is it possible to declare custom units that can be converted to SI base units? For example: if I want to measure time in ticks and I know that one tick is exactly one nanosecond, can I create a unit 'tick' that can later be converted to seconds?

I know that a custom unit can be declared with

sage: sage.symbolic.units.str_to_unit('tick')
tick

I also know that predefined units can be converted, for example by

sage: units.time.minute.convert(units.time.second)
60*second

However, I want to be able to declare a unit that has both its own name and that can be converted to other units.

sage: tick = sage.symbolic.units.str_to_unit('tick')
sage: tick
tick
sage: #(define relation to SI units here)
sage: tick.convert(units.time.second)
(ValueError: Incompatible units)

Is it possible to define a unit ‘tick’ that can be converted to seconds in this manner?