A quick question on handling expressions. Suppose I have an expression like:

z1 == y[-1] + 1/2 y[0] + 2 y''[0] + 3 w'''[-2]

How can I transform it so that the zeroth derivatives are left unevaluated and I get the following expressions :

z1 == Hold[y(0)[-1]] + 1/2 Hold[y(0)[0]] + 2 y''[0] + 3 w'''[-2]

The closest I could get to a solution was using the function:

Replace[#, y_[x_] -> Hold[Derivative[0][y][x]], \[Infinity]]&

But this rather yields

z1 == Hold[y(0)[-1]] + 1/2 Hold[y(0)[0]] + 2 Hold[(y'')(0)[0]] + 3 Hold[(w(3))(0)[-2]]

So the replacement is applied to more than I want it to be.


1 Answer 1


Almost, try y[x_] :> instead of y_[x_]-> because you need y, not whatever head which pattern you called y.

:> will scope x in case when x has a value. p.s. you may be interested in HoldForm which renders nicely (it is still there though!)

z1 == y[-1] + 1/2 y[0] + 2 y''[0] + 3 w'''[-2] /. 
 y[x_] :> HoldForm[Derivative[0][f][x]]

enter image description here


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.