Question: Why does plot not recognise functions within functions?

with(plots):
with(Grid):

HeatPC := proc (f, g, n, lambda, N, T)
 local k, u, i, L,fcoef;
 fcoef := proc (y) options operator, arrow; sqrt(2)*sin(lambda*y) end proc;
 u := proc (y, t) options operator, arrow; sum((int(fcoef(x)*g, x = 0 .. 1, numeric))*exp(-k*lambda*t)+exp(-k*lambda*t)*(int(exp(k*lambda*s)*(int(f, x = 0 .. 1, numeric)), s = 0 .. t, numeric)), k = 1 .. n) end proc;
 L := [Grid[Seq](plot(u(x, (i*T-T)/N), x = 0 .. 1, color = COLOR(HUE, i/N), legend = typeset((i*T-T)/N, "s")), i = 1 .. N)]; 
return u(1, 1), display(L, legendstyle = [location = right])
 end proc;

h := piecewise(x <= 0, 0, 0 < x and x < 1, 3, x >= 1, 0)

HeatPC(1, h, 100, Pi, 10, 1.5)

I'm trying to use the above procedure to plot graphs for different inputs. To make the code easier on the eye I want to split my main function u into several smaller functions. To that end I added the function fcoef. Now when I try to run the procedure for simple input values I get the error "Warning, expecting only range variable x in expression 100.*int(fcoef(x)*piecewise(x <= 0.,0.,0. < x and x < 1.,1.,1. <= x,0.),x = 0. .. 1.) to be plotted but found name fcoef". However u still evaluates nicely at (1,1) so obviously my function fcoef is well defined. How do I go about getting plot to recognize this?

 

 

Please Wait...