As science and technology advance, the need for novel optimization techniques has led to an increase. The recently proposed metaheuristic algorithm, Gradient-based optimizer (GBO), is rooted in the gradient-based Newton's method. GBO has a more concrete theoretical foundation. However, GSR and LEO operators in GBO still have some shortcomings. The insufficient updating method and the simple selection process limit the search performance of the algorithm. In this paper, an improved version is proposed to compensate for the above shortcomings, called RL-SDOGBO. First, during the GSR phase, the Spearman rank correlation coefficient is used to determine weak solutions on which to perform dynamic opposite learning. This operation assists the algorithm to escape from local optima and enhance exploration capability. Second, to optimize the exploitation capability, reinforcement learning is used to guide the selection of solution update modes in the LEO operator. RL-SDOGBO is tested on 12 classical benchmark functions and 12 CEC2022 benchmark functions with seven representative metaheuristics, respectively. The impact of the improvements, the scalability and running time of the algorithm, and the balance of exploration and exploitation are analyzed and discussed. Combining the experimental results and some statistical results, RL-SDOGBO exhibits excellent numerical optimization performance and provides high-quality solutions in most cases. In addition, RL-SDOGBO is also used to solve the anchor clustering problem for small target detection, making it a more potential and competitive option.