0
$\begingroup$

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:

enter image description here

Now whenever the following term appears anywhere in my Mathematica code, I would like to substitute in the variable 'bf':

enter image description here

i.e.:

bf = ef*(Derivative[1][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:

enter image description here

Is this a simple mistake in syntax for 'Simplify'? Or perhaps I have misunderstood the scope of 'Simplify'?

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Carl Woll Oct 4 '19 at 18:45
0
$\begingroup$

I've realised how to do it:

  1. Set up a substitution rule:
mySubstitution = ef*(Derivative[1][B][ef xbar (1 - zbar) + em ybarzbar])/Bbar -> Bf
  1. Find the derivative:
D[Wf, X] /. {z -> zbar, B[h] -> Bbar, x -> xbar, y -> ybar, X -> xbar,Y -> ybar}
  1. Apply the substitution rule:
% /. MySubstitution
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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