For a given expression, such as:
exp=p[x]+p'[x]+p''[x]...Derivative[n][p][x]
I want to replace all the derivatives of p[x] to a constant 1. But the following rule:
rule=Derivative[_][p][x]:>1
works for the derivatives when n>=1, except `p[x]. That is:
p'[x]/.rule
(* output: 1 *)
p''[x]/.rule
(* output: 1 *)
p[x]/.rule
(* output: p[x] *)
I wonder what is the correct rule to replace all the Derivative[n][p][x] to 1, including p[x].
Thank you.
rule={Derivative[_][p][x] :> 1, p[x] :> 1}– Oscillon Apr 26 '19 at 15:56rule = p[x] | Derivative[_][p][x] :> 1. – Somos Apr 26 '19 at 16:55rule = _[x] | Derivative[_][_][x] :> 1or something there-abouts. – march Apr 26 '19 at 17:01