kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
228 stars 37 forks source link

Using two derivatives wih same object #244

Open slazav opened 2 years ago

slazav commented 2 years ago
\nabla{#}::Derivative;
{A}::Depends(\nabla{#});

ex := \nabla{A};
unwrap(_);

\partial{#}::Derivative;
{A}::Depends(\partial{#});

ex := \nabla{A};
unwrap(_);

Result is 0 for the second unwrap. It looks like after {A}::Depends(\partial{#}); the dependence on \nabla is lost.

kpeeters commented 2 years ago

Yes, that's intentional; properties overwrite previous properties of the same type. So instead do

A::Depends(\nabla{#}, \partial{#});

I'll convert this into an enhancement request ("please add functionality to amend an existing property") so we don't lose it, but it's not likely to get implemented soon

slazav commented 2 years ago

Thanks, I just did not read manual for Depends carefully, it's written there.

By the way, am I right that SortOrder property does not overwrite previous one?

{A,B,C}::SortOrder;
ex := C A B;
sort_product(_);

{B,C,A}::SortOrder;
ex := C A B;
sort_product(_);

Here I have ABC in both cases. How sorting works if I have both definitions?

Anyway, it makes sense to define all properties once in the beginning and do not change them.