Most efficient way of calculating a multidimensional complex function many times

What I meant by redundant is that there are a ton of repeated calculations. Here is a version with most of them removed (designed to work on scalars)

function F(X, Y, T)
	sinX, cosX = sincos(X)
    sinY, cosY = sincos(Y)
    rx=(1-X)*sinX
    ry=(1-Y)*sinY
	ans = (T^2/2+1)*(
			+rX*rY*
				(exp(T)*β*(sinpi(X)*sinpi(Y))^2
				+225*((T^2/2+1)*rX*rY)^2
				-1)
			-2*γ*(rX*rY+rX*cosY+cosX*rY)
			+δ*(rY*(rx-sinX)+rX*(ry-sinY))
			) + T*im*rX*rY
	return 15*cis(T)*ans
end
8 Likes