I have an expression, not necessarily a polynomial, and want to take all the coefficients on whatever terms there are and replace them with the RootApproximant
versions of them. For example,
a = 0.111803 z + 0.298142396
I would like the result of my replacement to look like
a = 1/(4 Sqrt[5]) z + 2/(3 Sqrt[5])
.
I have tried to use some conditional replacement rules, but I cannot figure out how to take the coefficient and use it in a function, then put it back in front of the symbolic part. I have tried this
a /. t_ /; NumberQ[t] -> RootApproximant[t]
But this doesn't understand what the final t
in the RootApproximant
is.
a /. r_Real :> RootApproximant[r]
$\endgroup$