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

For example,

u::Coordinate.
f::Depends(u).
\partial{#}::PartialDerivative.
ex:=\partial_u{u f};
product_rule(_);
unwrap(_);

where $\partial_u(u)=0$, there seems to be a bug here.

in Bug reports by (2.1k points)

1 Answer

0 votes

Hi Eureka.

I don't thing it is a bug, just a misunderstanding of the philosophy of cadabra.

According to the unwrap documentation:

Derivatives will be set to zero if an object inside does not depend on it.

Hence, the command is not a computational aid... I mean, stricktly speaking you have not declare any dependence for u! So the algorithm set its derivative to zero.

My advice would be to use first a substitution rule, e.g.

rl := \partial_{u}{u} -> 1;
ex:=\partial_u{u f};
product_rule(_)
substitute(ex, rl)
unwrap(ex);

or if your calculation is "simple", call the sympy module:

from cdb.sympy.calculus import *

ex := u f;
d_ex = diff(ex);

NOTE the absence of the colon in the last assignation (it is a python assignation not a cadabra one).

Hope this would be useful!

Cheers, Dox.

by (14.3k points)

Thanks, Dox. I have just used map_sympy(_,"simplify") to implement it. Sometimes, simplify(_) also works, but I don't know where it will go to failure, so most of the time, I just use map_sympy(_,"simplify").

...