Half the run time of my code right now is evaluating a big function over many, many points, it takes maybe about 20 seconds per evaluation
The function consists of a bunch of simple operations that look like
Ux = ((1./72).*(x.^2+y.^2+z.^2).^(-5./2).*((-5).*x.*(4.*x.^4+3.*y.^2.*( ... y.^2+z.^2)+x.^2.*(7.*y.^2+z.^2)).*gx^2+(-10).*y.*(3.*x.^4+5.* ... x.^2.*y.^2+2.*y.^2.*(y.^2+z.^2)).*gx.*gy+5.*x.*(x.^4+3.*y.^2.* ... z.^2+x.^2.*(y.^2+z.^2)).*gy^2));
is there any way to speed this up? Additionally it spends like 10% of this function evaluation concatenating these large matrices as
Are there any tricks to speeding up these sorts of evaluations?