5.120 How to use RootOf to solve an equation?

If we have equation \(x=f(t)\) and want to solve for \(t\) as function of \(x\) and we do not want to use Maple’s solve, one option it to explicitly do it use RootOf as follows

restart; 
eq:= x=f(t); 
sol:= t=RootOf(  subs(t=_Z,rhs(eq))-x , _Z);
 

Which gives

sol := t = RootOf(f(_Z) - x)
 

The same can be obtained using solve command, but there can be cases where solve fails to do this, so this is an option to use to do it explicitly like this. Just remember to use  _Z variable.