Question: plot3d fails with "invalid input: expects numeric"

I am implementing the Fokas (unified transform) method for the heat equation on a finite interval [0,1]. The solution is expressed as a contour integral in the complex k-plane and I evaluate it numerically in Maple.

When I call plot3d I get the following error, even though approx_u(0.5, 0.1)

Is there a way to make plot3d work? Any help appreciated.

restart; with(plots)

V := exp(-k^2*t)*((-4*k*(sin(k*x)/exp(1)+sin(k*(1-x)))*(k^2-1))*(1/((k^2+1)*(k^4+1))))/((2*Pi)*(exp(I*k)-exp(-I*k)))

-2*exp(-k^2*t)*k*(sin(k*x)/exp(1)+sin(k*(1-x)))*(k^2-1)/(Pi*(exp(I*k)-exp(-I*k))*(k^2+1)*(k^4+1))

(1)

L := 3/4; k1 := proc (r) options operator, arrow; L+(3/4)*I+r*exp(((1/6)*I)*Pi) end proc; k2 := proc (r) options operator, arrow; -L+(3/4)*I+r*exp(((5/6)*I)*Pi) end proc; k3 := proc (s) options operator, arrow; s+(3/4)*I end proc; dk1 := D(k1); dk2 := D(k2); dk3 := D(k3)

3/4

 

proc (r) options operator, arrow; L+(3/4)*I+r*exp(((1/6)*I)*Pi) end proc

 

proc (r) options operator, arrow; -L+(3/4)*I+r*exp(((5/6)*I)*Pi) end proc

 

proc (s) options operator, arrow; s+(3/4)*I end proc

 

proc (r) options operator, arrow; exp(((1/6)*I)*Pi) end proc

 

proc (r) options operator, arrow; exp(((5/6)*I)*Pi) end proc

 

1

(2)

integrand1 := Re((eval(V, k = k1(r)))*dk1(r)-(eval(V, k = k2(r)))*dk2(r)); integrand3 := Re((eval(V, k = k3(s)))*dk3(s)); integrand2 := simplify(evalc(integrand1)); integrand4 := simplify(evalc(integrand3))

approx_u := proc (x, t) local temp1, temp2; temp1 := Int(eval(integrand2, [:-x = x, :-t = t]), r = 0 .. infinity, method = _d01amc); temp2 := Int(eval(integrand4, [:-x = x, :-t = t]), s = -L .. L, method = _d01ajc); evalf(temp1+temp2) end proc

approx_u(.5, .1)

.6536368264

(3)

``

forget(`evalf/int`); forget(evalf); CodeTools:-Usage(plot3d(approx_u, 0 .. 1, 0 .. 2*Pi, grid = [10, 10], axes = boxed, labels = ["x", "t", "u(x,t)"], title = "Fokas Method of solution", shading = zhue))

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

 

memory used=14.27GiB, alloc change=-16.00MiB, cpu time=92.96s, real time=88.85s, gc time=8.99s

 

 

 

Download heat_equation_on_finte_interval.mw

Please Wait...