2
$\begingroup$
(q''[x] - Exp[q[x]/2)] /. q[x] -> y[x] + a*t[x]

gives

-Exp^[1/2 (y[x] + a*t[x])] + q''[x]

Which is not what I want.

I would like to have

-Exp^[1/2 (y[x] + a*t[x])] + y''[x] + a*t''[x]

Is that possible?

$\endgroup$
2
  • 3
    $\begingroup$ Do this: q -> (y[#] + a*t[#]&). (Duplicate, but I don't have time to look for it.) $\endgroup$
    – march
    Commented Oct 28, 2016 at 15:32
  • $\begingroup$ Nice, the search engine didn't show me anything, but I am bad at formulating questions. $\endgroup$ Commented Oct 28, 2016 at 15:38

1 Answer 1

6
$\begingroup$

Check the FullForm of your expression. That will make it clear why it doesn't work.

The solution is to replace q and not q[x].

q''[x] - Exp[q[x]/2] /. q -> Function[x, y[x] + a*t[x]]

Recommended reading:

$\endgroup$
2
  • 1
    $\begingroup$ I checked FullForm before posting and it showed me Derivative[2][q][x], hence I assumed (without checking) that if I replace just q with a function of x I will get something like (...[x])[x] and so I didn't even try it $\endgroup$ Commented Oct 28, 2016 at 15:40
  • 1
    $\begingroup$ @user1482714 q -> f[x] of course won't work. You need q -> Function[x, f[x]]. $\endgroup$
    – Szabolcs
    Commented Oct 28, 2016 at 15:44

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.