# Simplify function with a derivative

This may be a very simple question: how can I substitute out a term involving a derivative in Mathematica?

I have the following derivative:

D[Wf, X] /. {z -> zbar, B[h] -> Bbar, x -> xbar, y -> ybar, X -> xbar,Y -> ybar}


...and it's solution in Mathematica: Now whenever the following term appears anywhere in my Mathematica code, I would like to substitute in the variable 'bf': i.e.:

bf = ef*(Derivative[B][ef xbar (1 - zbar) + em ybar zbar])/Bbar


In other words, the result of my derivative should be:

(1-zbar)bf


The 'Simplify' function should do this, I think, but the following doesn't seem to work: Is this a simple mistake in syntax for 'Simplify'? Or perhaps I have misunderstood the scope of 'Simplify'?

• What does Wf look like? A lot of times it is simpler to give Derivative a downvalue that does your replacement instead of trying to undo things after the fact. – Carl Woll Oct 4 '19 at 18:45

mySubstitution = ef*(Derivative[B][ef xbar (1 - zbar) + em ybarzbar])/Bbar -> Bf

D[Wf, X] /. {z -> zbar, B[h] -> Bbar, x -> xbar, y -> ybar, X -> xbar,Y -> ybar}

% /. MySubstitution