# How to enforce a rule on terms that are a combination of the original term?

I have an equation of the type

Exp[a[r]] + Exp[a[r]/2] + Exp[-a[r]]


And I want to rule

Exp[a[r]] -> 1-2*m[r]/r


so that it fits the other terms as well. How can I do this directly?

• Thanks. I made some changes. a[r] is any function of r Feb 2, 2023 at 2:17
• You haven't resolved the issue. Exp has a predefined meaning. If it is intended to be a user-defined symbol then use some other symbol. Otherwise, you presumably mean either Exp[a[r]] or E^(a[r]) (they are equivalent). Feb 2, 2023 at 2:23
• And on the RHS of the rule, do you mean 1 - 2*m[r]/2 as shown (which is just 1 - m[r]) or did you intend (1 - 2*m[r])/2 Feb 2, 2023 at 2:36
• Sorry, I was using the python language. I made the changes you mentioned Feb 2, 2023 at 2:38

## 1 Answer

Keep the LHS of rules as simple as possible

expr = Exp[a[r]] + Exp[a[r]/2] + Exp[-a[r]];

expr /. a[r] -> Log[1 - 2*m[r]/r] // Simplify

(* 1 + r/(r - 2 m[r]) - (2 m[r])/r + Sqrt[1 - (2 m[r])/r] *)