I have tried x /. x->a using the Simplify with assumption x==a, using the ComplexityFunction in the Doc., but my code does not show the expected output. Which part of my code should be corrected? (Although x==a did not work, but interestingly x==1 did work)
Simplify[expr,ComplexityFunction->f] applies f to each intermediate expression generated by Simplify, treating the one which yields the smallest numerical value as simplest.
f[e_] := Module[{c},c=100Count[e,x,{0, Infinity}];Print[{ e,LeafCount[e],c}]]
Simplify[x,x==a,ComplexityFunction->f] (* not a ? *)
※Although x==a did not work, but interestingly x==1 did work
f[e_] := Module[{c},c=100Count[e,x,{0, Infinity}];Print[{ e,LeafCount[e],c}]]
Simplify[x,x==1,ComplexityFunction->f](* 1 *)
Simplify[x, x == y]andSimplify[x, x == a]. $\endgroup$FullForm[f[x]]. (FullForm[]shows exactly what the return value is. It's not typeset all pretty and can be long; but it's not as confusing as the default output style.) $\endgroup$