This paper proposes an efficient actual inverse kinematics method to compensate the geometric errors of five-axis machine tools. The analytical expressions of corrected numerical control (NC) code are derived according to the invertibility, associative law of multiplication, and block calculation of homogenous transformation matrix (HTM). No additional analysis and models are needed for the compensated expressions, appropriate conversion with the geometric error model based on HTM is sufficient. It is simple, convenient and universal for geometric error compensation. The corrected NC code can be obtained through algebraic operation, without time-consuming iteration, differential, or pseudo-inverse algorithm. Then compensation accuracy and efficiency of the method are simulated. And the results indicate higher efficiency compared to existing method. At last, the method is verified by cutting experiment on a five-axis machine tool. Both simulation and experiment results can validate the feasibility of the method. The proposed method significantly improves the computation efficiency and is considered more suitable for real-time compensation.