# How to replace==in the equation with ->?

It is required to replace the ==

in equation

2b==E ^ x0- x0

with ->,

becoming:

 2b ->E ^ x0- x0

My personal attempt was like this, but it didn't achieve the goal

eq1 = E^x0 - x0 - 2 b == 0
eq2 = eq1 /. k_ + m_ - 2 b == 0 :> 2 b == k + m
eq3 = eq2 /. Thread["==" -> "->"]

• Solve[E^x0 - x0 - 2 b == 0 /. b -> b/2, b] /. b -> 2*b // Flatten // First
– I.M.
Commented Sep 25, 2023 at 3:03
• 2 b == E^x0 - x0 /. Equal -> Rule
– Syed
Commented Sep 25, 2023 at 3:07
• Why is ToRules not an option? Commented Sep 25, 2023 at 3:08
• MMA 13.3 ToRules works. Commented Sep 25, 2023 at 6:50
• Does this answer your question? What is an easy way to transform an equality into a replacement rule? Commented Oct 7, 2023 at 5:50

A few observations

eq = 2 b == E^x0 - x0;


The Head of eq is Equal

Head @ eq


Equal

The Head is always at position 0

ps = Position[Equal] @ eq


{{0}}

Therefore we must ReplaceAt position 0

ReplaceAt[eq, _ :> Rule, ps]


2*b -> E^x0 - x0

or use ReplaceAll like Syed suggested in his commentary.

We can also use ToRules:

First @ ToRules @ eq


2*b -> E^x0 - x0

or Apply with its third argument:

Apply[Rule, eq, {0}]


2*b -> E^x0 - x0

Like lericr mentioned in his comment, Apply doesn't need the third argument in this case and can also be written as:

Apply[Rule, eq];


or

Apply[Rule] @ eq


or

Rule @@ eq

• The default levelspec is sufficient: Apply[Rule, eq]. Special form: Rule @@ eq. Commented Sep 25, 2023 at 10:27
• Thank you, I added your comment to the answer
– eldo
Commented Sep 25, 2023 at 10:40