Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi!

Thanks for Cadabra! I just started playing around. I'm using the Fedora 40 package of Version 2.5.10 (build private dated 2024-12-24).

I'm trying the following:

\partial{#}::PartialDerivative;
t::Coordinate;
O::Depends(t);
{H,O_0}::NonCommuting;

ex := O = \exp(i*H*t) O_0 \exp(-i*H*t);
ex2 := \partial_t{O};

substitute(ex2, ex);

So far so good. However

evaluate(_);

yiels 0 which should not be because H and O_0 are not commuting.

I've read that simplify should not be used (https://cadabra.science/qa/798/simple-commutator-in-quantum-mechanics?show=798#q798) but is this true for evaluate as well?

Thanks in advance,

Sebastian

in General questions by (130 points)

1 Answer

+1 vote

Evaluate calls simplify under the hood. You can turn this off by using

evaluate(_, simplify=False);

However, I think you probably want

product_rule(_);

instead (evaluate is for evaluating components of a tensor expression, but yours is a scalar, so it is already 'evaluated' for that purpose; see the docs for more detail and ask again if it's not clear).

by (84.8k points)

Thanks a lot! If you like, I can work out your version into a tutorial or example. What do you say?

sbstnschmtt: Would you say that I should always evaluate derivatives by explicit substitution?

Would you be so kind to comment on this?

Best,

Sebastian

You don't have much choice at the moment: except for product_rule and distribute, there is no functionality to 'work out' derivatives. Until this is implemented you would need the route through sympy, which is fine for expressions with commuting symbols only.

Examples/tutorials are always welcome, so yes please!

The development branch now has some safeguards which will throw an exception if you attempt to use the sympy bridge with an expression containing non-commuting or anti-commuting objects. This will go into 2.5.12.

Great! Thanks a lot!

...