1
$\begingroup$

I have several variables (coordinates) $x_1, x_2, x_3, x_4, z$ and a lot (21, to be precise) functions $g_i$ which are assumed to depend on $x_1, x_2,x_3, x_4$, but not on $z$. I also have a function Differentiation which uses Dt in its definition. I would like to apply Differentiation to my functions $g_i$.

I found that this question proposed giving constants the attribute "Constant". However, I cannot apply it directly, as my functions are constants only with respect to one variable.

Is there any way to do this?

$\endgroup$
9
  • $\begingroup$ Dt[x^2 y + z, x, y, Constants -> {z}]? $\endgroup$
    – kglr
    Sep 29, 2018 at 1:40
  • $\begingroup$ or Internal`InheritedBlock[{Dt}, SetOptions[Dt, Constants -> {z}]; Differentiation[x1,x2,x3,x4,z]]? $\endgroup$
    – kglr
    Sep 29, 2018 at 1:46
  • $\begingroup$ Hello, @kglr ! I tried to implement your suggestion with a simple function diff[expr_, x_] := Dt[expr, x];. However, InternalInheritedBlock[{Dt}, SetOptions[Dt, Constants -> {z}]];diff[z r, z]` gives the same answer as diff[r z , z] - r + z Dt[r, z], when expected simply r. Did I somehow misinterpret your suggestion? $\endgroup$
    – user108687
    Sep 29, 2018 at 1:56
  • $\begingroup$ @klgr And as far as I understand, Constant attribute corresponds to setting all derivative of a variable to zero. And I want all the derivatives of other variables wrt this one to be set to zero. $\endgroup$
    – user108687
    Sep 29, 2018 at 2:04
  • $\begingroup$ @klgr I think that I've found solution: ff[expr_, x_] = Dt[expr, x]; A /: Dt[A, z] = 0; ff[A B, z] returns A Dt[B, z]. Thanks for help! $\endgroup$
    – user108687
    Sep 29, 2018 at 2:13

1 Answer 1

1
$\begingroup$

With suggestions from @kglr I arrived at the following solution for a toy problem of differentiating $AB$ with respect to $z$, assuming that $A$ doesn't depend on $z$, using A /: Dt[A, z] = 0, which sets the derivative of $A$ with respect to $z$ equal to zero:

ff[expr_, x_] = Dt[expr, x];
A /: Dt[A, z] = 0;
ff[A B, z]

returns A Dt[B, z].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.