I have an expression with subscripted variables. I would like to replace all those terms with other symbols. For example,
$P_1 + P_2^3 \rightarrow P1 + P2^3$
I used the following code but it doesn't work
X = Subscript[P, 1] + Subscript[P, 3]^2 - I*Subscript[P, 5]
X /. {Subscript[P, n_] -> Pn}
If I replace Subscript[P, n_]
with P[n]
then it works (e.g. $P_1$ will be replaced with P[1]
) but I don't want the bracket. I want P1
instead. Is there any way to solve this?