concept-collection / numbl-surfacefun-intro
numbl-surfacefun-intro / fun_integral_norm.m
17 lines · 675 BBlameHistoryRaw
1% fun_integral_norm.m — Integrals, means and norms of a surfacefun.
2%
3% These reductions integrate over the surface using the on-surface
4% measure. No plot here — just printed quantities.
6mip load --install flatironinstitute/flatironinstitute/surfacefun
8p = 16;
9nref = 2;
10dom = surfacemesh.sphere(p + 1, nref);
12f = surfacefun(@(x, y, z) cos(6*x) .* y + exp(z), dom);
14fprintf('integral(f) = %.6f\n', integral(f)); % definite integral over the surface
15fprintf('mean(f) = %.6f\n', mean(f)); % integral / surface area
16fprintf('L2 norm = %.6f\n', norm(f)); % sqrt(integral of f^2)
17fprintf('Linf norm = %.6f\n', norm(f, inf)); % max |f|