This paper presents an analytical method to solve the optimal control problem for affine nonlinear systems with unknown drift dynamics. A new non‐quadratic cost function over an infinite horizon is presented that considers input constraints and includes the cost of the feed‐forward component of the control law. The mean value theorem for vector‐valued functions has been used to derive an integral form of this theorem. Based on this theorem, a rigorous proof is provided demonstrating that the cost function can be converted into another form. In the presence of input constraints, this converted form enables extracting the optimal control solution without solving the HJB equation. Additionally, unknown nonlinearity effects in drift dynamics are compensated in the control input. This is accomplished by estimating the unknown drift dynamics via an adaptive neural network (NN) approach. It is proven that the states and weights of NN are uniformly ultimately bounded based on a Lyapunov technique. The necessary and sufficient conditions are provided that ensure the optimality of the infinite horizon optimal control problem with a discount factor. As a result, it is demonstrated that the proposed approach satisfies the optimality criteria. To evaluate the effectiveness of the proposed approach, simulation examples are provided.