Exercises

1a. Make side-by-side surface and contour plots of f(x,y)=2y+exy,[0,2]×[1,1]

f = (x,y) -> 2*y + exp(x-y);
plotlyjs();  # use better 3D renderer
m = 60;   x = range(0,2,length=m+1);
n = 50;   y = range(-1,1,length=n+1);
F = [ f(x,y) for x in x, y in y ];

plot(x,y,F', layout=(1,2), levels=10,fill=true,aspect_ratio=1,
    color=:redsblues,
    xlabel="x",ylabel="y");
surface!(x,y,F', l=0,leg=:none,
    subplot=2, color=:redsblues,
    xlabel="x",ylabel="y",zlabel="f(x,y)")

2a. make side-by-side surface plots of fx and fy using Chebyshev spectral differentiation matrix

_,Dx = FNC.diffcheb(m,[0,2]);
_,Dy = FNC.diffcheb(n,[-1,1]);

surface(x,y,(Dx*F)',layout=(1,2), l=0,leg=:none,
    color=:redsblues,
    xlabel="x",ylabel="y",zlabel="df(x,y)/dx");
surface!(x,y,(F*Dy')', l=0,leg=:none,
    subplot=2, color=:redsblues,
    xlabel="x",ylabel="y",zlabel="df(x,y)/dy")

3a. Make a contour plot of the mixed derivative fxy

plot(x,y,(Dx*F*Dy')', levels=10,fill=true,aspect_ratio=1,
    color=:redsblues, clims = (-10, 0),
    xlabel="x",ylabel="y")