The call to meval is almost always a mistake. In hec3, I think you want
something like
(take '($trigsimp) x) instead of (meval `(($trigsimp) ,x))); example:
(%i3) (a : b, b : c, c : d)$
OK:
(%i4) ?hec2(a);
(%o4) b
Not OK:
(%i5) ?hec3(a);
(%o5) c
Also, consider changing funcall --> mfuncall (maybe not all of them). That
way, a user could write a cost function
in Maxima. Sorry for the three back to back postings---for now, this is all
that I can think of.
Barton