Question: how do I get sums produced by "add" to immediately evaluate?

In Maple 15.01, the commands

   f := x -> sin(2 x)
   h := n -> (1/Pi) int(f(x) sin(n x), x = -Pi .. Pi)
   g := x -> add(h(n) sin(n x), n = 1 .. 4)
   g(x)

result in

   sin(2 x)

which is what I expect.  However, the command

   evalhf(g(2))

results in the error message
   "Error, unable to evaluate function `int` in evalhf"
so evalhf is not being passed sin(4) as I want.

How can I force the addition to be evaluated so that g(x)
actually is sin(2 x), which evalhf can then deal with?

(Note that this *could* be done by running the command

add(h(n) sin(n x), n = 1 .. 4)

and then copy-and-pasting the output into the definition of g, but I'm looking for a less ugly solution.)



Please Wait...