Multifocal microscopes (MFMs) are becoming increasingly popular in fluorescence microscopy due to their high speed three-dimensional (3D) imaging capabilities. Conventional MFMs use a fixed fabricated grating as the multifocal grating but these are limited to a restricted wavelength range and a fixed object-plane separation. Spatial light modulators (SLMs) represent an alternative to fabricated gratings due to their real-time programmability, providing complete control over emission wavelength range and object plane separations. However, algorithms commonly used to obtain multifocal grating patterns which provide uniform intensity across the subimages are not directly applicable to SLM-based MFMs due to inherent pixel-to-pixel crosstalk effects present in the SLM chip. We recently developed an in-situ iterative algorithm which generates grating patterns that provide near-uniform illumination of the subimages in SLM-based MFMs. This algorithm is universal across wavelengths, object-plane separations, and SLM manufacturers. As part of our efforts to develop an SLM-based MFM that can respond rapidly to changing experimental parameters, we implement a gradient descent-based optimization method. We evaluate its performance in comparison with a grid search based routine. Experimental results obtained on a custom-made SLM-based MFM indicate that the grid-search optimized grating patterns provide superior subimage intensity uniformity versus the gradient-descent method. These experiments also provide an insight into the energy landscape involved in these optimizations. This study increases the utility of SLM-based MFMs in high-speed imaging.