% vec_gradient.m — The surface gradient as a vector field. % % grad(f) of a surfacefun is a surfacefunv. The gradient is tangent to % the surface, as the quiver plot shows. mip load --install flatironinstitute/flatironinstitute/surfacefun rng(0) p = 16; nref = 2; dom = surfacemesh.blob(p + 1, nref); f = surfacefun(@(x, y, z) cos(6*x) .* y + exp(z), dom); figure(1); quiver(grad(f), 0.05, 6) title('Surface gradient of f (tangent to the surface)'); % Identity: the divergence of the gradient is the Laplacian. fprintf('|| div(grad f) - lap(f) || = %.3e\n', norm(div(grad(f)) - lap(f)));