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

I am wondering how I can combine terms with derivatives, for example

{a,b,c}::Indices(full);
\partial{#}::PartialDerivative;

ex := \partial_{a}{F} + \partial_{a}{G}

I want a function foo such that the output of foo(ex); is \partial_{a}{F + G}. How could I achieve this?

Thanks very much.

in General questions by (240 points)

1 Answer

+2 votes
 
Best answer

There's nothing built-in, but some variation of

substitute(ex, $\partial_{a}{A??} + \partial_{a}{B??} -> \partial_{a}{A??+B??}$);

will probably do the trick.

by (82.6k points)
selected by

Thanks very much Kasper, this solves my problem nicely!

...