# Getting thet derivative of a user defined function in terms of an auxiliary function

I'm currently struggling with evaluation control when getting the derivative of a function (I dont know if that's the correct term here. Sorry, beginner). My function is of the form

f[vx_, vy_, omega_] :=
c1 Sin[c2] FLat[x, vy, omega] + ... + cn Sin[n] FLat[vx, vy, omega]


where

FLat[x_] := Dp*Sin[Cp*ArcTan[Bp*x - Ep*(Bp*x - ArcTan[Bp*x])]];


and

x = ArcTan[(vy + af*omega)/vx + 0.5*bf*omega] - delta1;


When I evaluate D[f, vx], I get a horrible expression in terms of ArcTan whereas I would prefer something in terms of FLat'. How can I control the evaluation of that function to obrtain a nice representation of my derivative?

• I think the easy way is to evaluate the derivative before evaluating the definition of FLat; alternatively you can use Block to temporarily change the assignment made to FLat into something that doesn't evaluate to the def of your function eg Block[{FLat=f},<your code here>]; Dec 31, 2018 at 22:54
• Your code is incorrect: (1) FLat is called with three arguments in the definition of f[] and defined with only one. (2) D[f, vx] yields 0. Just to be clear, did you mean D[f[vx, vy, omega], vx]? (3) What's x = ArcTan... got to do with it? There is no variable x used in any of the executed code, only a pattern named x (i.e. x_). Jan 1, 2019 at 5:08
• Anyway, my answer was going to be to inactivate FLat, but whether and how that would work depends on the actual code it would be applied to. Jan 1, 2019 at 5:10

I will use a simplified version of your function f in this discussion because you don't give us the full form. Hopefully, the simplified version will be adequate,

f[vx_, vy_, omega_] := c1 Sin[c2] flat[vx, v y, omega] + c3 Sin[c4] flat[vx, vy, omega]


If the derivitive is taken before flat is defined, there is no difficulty.

D[f[vx, vy, omega], vx]

c1 Sin[c2] Derivative[1, 0, 0][flat][vx, vy, omega] +
c3 Sin[c4] Derivative[1, 0, 0][flat][vx, vy, omega]


But after flat is defined by code such as

With[{x = ArcTan[(vy + af omega)/vx + 0.5 bf omega] - delta1},
flat[vx_, vy_, omega_] =
Dp Sin[Cp ArcTan[Bp x - Ep (Bp x - ArcTan[Bp x])]]];


Mathematic will use that definition and

Short[D[f[vx, vy, omega], vx], 4]


gives the complicated result

However, it is possible to generate a cell showing the same result as obtained before flat was defined in the following way:

Block[{flat, \$Post = Inactivate[#, flat] &},
Print[D[f[vx, vy, omega], vx]]]

c1 Sin[c2] Derivative[1, 0, 0][flat][vx, vy, omega] +
c3 Sin[c4] Derivative[1, 0, 0][flat][vx, vy, omega]


Try to use the FullSimplify function, and also u can storage your derivative in another function.

FlatDeriv=FullSimplify[f,vx];


Then you can use the replace comand in terms of visualization. Of course it will only work if the derivative has Flat[] on it. let me aclare it with an example.

f = Exp[2*x];

deriv = D[f, {x, 2}]

4 E^(2 x)


Then Use the replace comand to replace the fuction in terms of the original function

deriv /. Exp[2x] -> "f"


The result will be

4 f