For inexact coefficients MonomialList seems to apply N.
How to avoid this?
expr = 1.0c[1] x ;
MonomialList[expr, {x}]
(* {1. x c[1.]} *)
It is possible to:
SetAttributes[c, NHoldAll] ;
expr =1.0c[1] x ;
MonomialList[expr, {x}]
(* {1. x c[1]} *)
But this fails in the following case:
SetAttributes[c, NHoldAll] ;
expr =1.0c[1] [1]x ;
MonomialList[expr, {x}]
{1. x c[1][1.]}
It is possible to use ReplaceAll and Rationalizeto post-process the result, but this is some extra work I want to avoid.
MonomialList[]aside, note that attributes do not apply to sub-value expressions. SoNHoldHallprotects the argument1ofcin the expressionN[c[1]]but not the argument2ofc[1]inN[c[1][2]]. (2) As forMonomialList[], it explicitly sets the precision of the result to the precision of the input. So it seems intentional, but I don't know the reason why. $\endgroup$1.0 c[1, 1] xinstead of1.0 c[1][1] x. $\endgroup$