1% fun_arithmetic.m — Overloaded arithmetic on surfacefuns.
2%
3% Standard MATLAB arithmetic is overloaded for surfacefuns, so you can
4% combine fields with +, -, .*, abs, etc.
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);
13x = surfacefun(@(x, y, z) x, dom);
15g = abs(f + 2*x);
17figure(1);
18plot(g), colorbar
19title('g = |f + 2x|');