[GiNaC-list] Question regarding symbolic differentiation
jens.vollinga at googlemail.com
Sun Jul 22 19:43:15 CEST 2012
On 22.07.2012 19:29, Martin Ettl wrote:
> I have to variables a(t) and b(t), both are dependent from time (t).
> Suppose, this two variables are multiplied liked this:
> a(t) * b(t)
> Is it possible to derive this expression (a(t)*b(t)) according time with
yes, and like your notation already suggests, you need to define a and b
as functions of t.
A simple code example would be:
using namespace GiNaC;
using namespace std;
ex expr = a(t) * b(t);
cout << expr << endl;
cout << expr.diff(t,1) << endl;
But you will get fderivative objects in the result (printed as something
like D, because with dummy() in the function definition macro you
have not told GiNaC what the partial derivative of a or b with respect
to t is supposed to be. You can look in the tutorial in section 6.2.2
for a more elaborate example.
More information about the GiNaC-list