1
$\begingroup$

In the following code, I'm trying to substitute Sin[x] for f[x]. What's the right way to do it so that f'[x] gets replaced with Cos[x]?

e = f[x] + f'[x]
e /. f[x] -> Sin[x]
$\endgroup$
2
  • 1
    $\begingroup$ And e/. f->(# Sin[#]&) for f=x Sin[x]? $\endgroup$
    – Wynne
    Apr 5 '21 at 0:53
  • $\begingroup$ Wynne, that's right... $\endgroup$
    – kglr
    Apr 5 '21 at 0:57
2
$\begingroup$
e /. f -> Sin
Cos[x] + Sin[x]
$\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.