Improving Matrix Exponential for Generative AI Flows: A Taylor-Based Approach Beyond Paterson-Stockmeyer

Authors: J. Sastre, D. Faronbi, J.M. Alonso, P. Traver, J. Ibáñez, N. Lloret

Summary

The paper proposes an improved algorithm for computing the matrix exponential, a key operation in scientific computing and system simulation (control theory, quantum mechanics and, more recently, generative machine learning models).

Background

The traditional standard has been to combine Padé approximants with the scaling and squaring technique. However, Taylor-based methods, which use polynomial evaluation schemes more efficient than the classical Paterson-Stockmeyer approach, offer higher accuracy and lower computational cost.

Contributions

  • An optimized Taylor-based algorithm designed for the high-throughput requirements of generative AI flows.
  • A rigorous error analysis.
  • A dynamic strategy for selecting the Taylor order and scaling factor, minimizing computational effort within a given error tolerance.

Results

Numerical experiments show significant acceleration and good numerical stability compared to current state-of-the-art implementations, making the method an efficient tool for large-scale generative modeling.

Link

https://www.themoonlight.io/en/review/improving-matrix-exponential-for-generative-ai-flows-a-taylor-based-approach-beyond-paterson-stockmeyer

Keywords

Matrix exponential, scaling and squaring, Taylor approximation, Padé approximant, efficient matrix polynomial evaluation,
Algorithmic Efficiency, Generative AI flows.

New Taylor method for the matrix sign function

Emilio Defez, José Miguel Alonso, Javier Ibáñez and Jorge Sastre present a new Taylor-based method for computing the matrix sign function at MME&HB 2026.

The matrix sign function is an important tool in numerical linear algebra, with applications to the solution of matrix equations and matrix decomposition problems. Its efficient computation remains an interesting challenge, particularly when accuracy and computational cost must be considered together.

Building on the research group’s experience in polynomial approximation and efficient matrix polynomial evaluation, the authors introduce a new approach within the family of Taylor methods for this function. The contribution extends their ongoing work on polynomial-based algorithms for matrix functions, exploring how Taylor approximations can provide an alternative framework for their numerical computation.

The proposed method adds to the group’s research into efficient algorithms for matrix functions, with a particular focus on developing numerical techniques that combine mathematical accuracy with practical computational efficiency.


Publication Details

  • Title: A new Taylor method for the matrix sign function
  • Authors: Emilio Defez, José Miguel Alonso, Javier Ibáñez, Jorge Sastre
  • Conference: Mathematical Modelling in Engineering & Human Behaviour 2026 (MME&HB 2026), Valencia, July 12–15 of 2026
  • Proceedings: Mathematical Modelling Conference Series at the Institute for Multidisciplinary Mathematics, Universitat Politècnica de València, pp. 356–363
  • ISBN: 978-84-09-89823-7
  • Enlace: https://imm.webs.upv.es/jornadas/2026/2026_Proceedings_MME_HB.pdf

Main Contributions

  • A new method based on Taylor series for the matrix sign function.
  • An alternative within the set of polynomial techniques for this function.
  • A connection with the group’s research on efficient matrix polynomial evaluation.

Why This Matters

The matrix sign function arises in control problems, the solution of Riccati equations, and the computation of other matrix functions. An additional Taylor method broadens the range of available algorithmic approaches.

An Optimized Taylor Algorithm for the Matrix Exponential in Generative AI Workflows

The matrix exponential is a key operation in scientific computing and system simulation, with applications ranging from control theory and quantum mechanics to modern generative machine learning. Although Padé approximants combined with scaling and squaring have traditionally been the standard approach, recent advances in Taylor-based methods have shown that more efficient polynomial evaluation schemes can outperform the classical Paterson–Stockmeyer algorithm, both in accuracy and computational cost.

In this work, J. Sastre, D. Faronbi, J. M. Alonso, P. Traver, J. Ibáñez, and N. Lloret introduce an optimized Taylor-based algorithm for computing the matrix exponential, specifically developed to address the computational demands of generative AI flows. The method combines advanced matrix polynomial evaluation techniques with a rigorous error analysis and an adaptive strategy for selecting the Taylor approximation order and scaling factor. This allows the algorithm to adjust its computational effort to the properties of each input matrix while meeting a prescribed accuracy tolerance.

Beyond the numerical formulation itself, the main contribution lies in translating these algorithmic improvements into measurable gains in generative model training and inference. By reducing the number of matrix multiplications required without compromising numerical accuracy, the proposed approach addresses a significant computational bottleneck in flow-based architectures. Experiments on standard image datasets report training speedups ranging from 3.91× to 9.74× compared with the original implementation, while inference on batches of 128 samples is approximately 1.95× faster. These results illustrate how improvements in numerical algorithms can directly contribute to the efficiency and scalability of modern generative models.


Publication Details


Main Countributions

  • Optimized Taylor algorithm for the matrix exponential, designed for generative AI flows.
  • Error analysis and an adaptive strategy for selecting the Taylor approximation order and scaling factor.
  • Significant speedups while maintaining high numerical stability compared with reference implementations.

Why This Matters

Generative AI flows rely on computationally intensive matrix operations. A faster and more stable method for computing the matrix exponential can reduce the computational cost of these models without compromising accuracy.

Beyond Paterson–Stockmeyer: Advancing Matrix Polynomial Computation

For over fifty years, the Paterson–Stockmeyer method has been considered the benchmark for efficient matrix polynomial evaluation. In our recent open access article, we provide a summary of recent advances in this area and present a constructive scheme that evaluates a degree‑20 matrix polynomial using only 5 matrix multiplications—two fewer than Paterson–Stockmeyer.

We also show how the coefficients of this scheme can be derived from the solutions of a single equation involving one coefficient, and we include the full process in our supplementary materials.


Publication Details

  • Title: Beyond Paterson–Stockmeyer: Advancing Matrix Polynomial Computation
  • Authors: J. Sastre, J. Ibáñez, J. M. Alonso, E. Defez
  • Journal: WSEAS Transactions on Mathematics, Vol. 24, pp. 684–693, 2025
  • Conference: 5th Int. Conf. on Applied Mathematics, Computational Science and Systems Engineering (AMCSE), Paris, France, April 14–16, 2025
  • Open Access: https://doi.org/10.37394/23206.2025.24.68
  • Supplementary Material:

Main Contributions

  • Survey of recent advances in matrix polynomial evaluation.
  • Constructive result: A method to compute a degree‑20 matrix polynomial with just 5 matrix multiplications, improving efficiency over Paterson–Stockmeyer (needing 7 matrix products).
  • Coefficient derivation: All coefficients can be obtained by solving an equation in one unknown, documented step by step in the .txt file.
  • Generalization: We propose a framework for evaluation formulas of the type yk2(A)y_{k2}(A), see with Ck2C_k^2​ available variables, and set two conjectures for future research.

Why This Matters

Reducing matrix multiplications significantly lowers computational cost, which is crucial for:

  • Large-scale scientific computing
  • Numerical linear algebra
  • AI and machine learning models involving matrix functions

Access and Resources


Next Steps

If you work with matrix functions or large-scale computations:

  • Try the 5-multiplication scheme for degree‑20 polynomials.
  • Benchmark against Paterson–Stockmeyer.
  • Explore adapting the rational-coefficient approach to other degrees.

We welcome collaboration on proving the conjectures and extending these ideas to broader polynomial families.

Polynomial approximations for the matrix logarithm with computation graphs

Polynomial approximations for the matrix logarithm with computation graphs, E. Jarlebring, J. Sastre, J. Ibáñez, Linear Algebra Applications, in Press (open access), 2024. https://doi.org/10.1016/j.laa.2024.10.024, https://arxiv.org/abs/2401.10089, code.

In this article the matrix logarithm is computed by using matrix polynomial approximations evaluated by using matrix polynomial multiplications and additions. The most popular method for computing the matrix logarithm is a combination of the inverse scaling and squaring method in conjunction with a Padé approximation, sometimes accompanied by the Schur decomposition. The main computational effort lies in matrix-matrix multiplications and left matrix division. In this work we illustrate that the number of such operations can be substantially reduced, by using a graph based representation of an efficient polynomial evaluation scheme. A technique to analyze the rounding error is proposed, and backward error analysis is adapted. We provide substantial simulations illustrating competitiveness both in terms of computation time and rounding errors.

On the backward and forward error of approximations of analytic functions and applications to the computation of matrix functions

Jorge Sastre, Javier Ibáñez, Journal of Computational and Applied Mathematics, Volume 419, 2003, 114706, https://doi.org/10.1016/j.cam.2022.114706

A new formula to write the forward error of Taylor approximations of analytical functions in terms of the backward error of those approximations is given, overcoming problems of the backward error analysis that use inverse functions. Examples for the backward error analysis of functions such as the matrix cosine cos(A) or cos(sqrt(A)) are given.

An Improved Taylor Algorithm for Computing the Matrix Logarithm

An Improved Taylor Algorithm for Computing the Matrix Logarithm, J. Ibáñez, J. Sastre, P. Ruiz, J.M. Alonso, E. Defez ), Mathematics. Vol. 9 (17), 2021, pp. 2018.

The matrix logarithm is the used in many applications of science and engineering [2], such as machine learning [7,8,9,10], computer-aided design (CAD) [19], computer graphics [17], the analysis of the topological distances between networks [23], graph theory [11,12], quantum chemistry and mechanics [3,4], buckling simulation [5], biomolecular dynamics [6], the study of Markov chains [13], sociology [14], optics [15], mechanics [16], control theory [18], optimization [20], the study of viscoelastic fluids [21,22], the study of brain–machine interfaces [24], and also in statistics and data analysis [25], among other areas.

The most popular method for computing the matrix logarithm is a combination of the inverse scaling and squaring method in conjunction with a Padé approximation, sometimes accompanied by the Schur decomposition. In this work, we present a Taylor series algorithm, based on the free-transformation approach of the inverse scaling and squaring technique, that uses recent matrix polynomial formulas for evaluating the Taylor approximation of the matrix logarithm more efficiently than the Paterson–Stockmeyer method. Two MATLAB implementations of this algorithm, related to relative forward or backward error analysis, were developed and compared with different state-of-the art MATLAB functions. Numerical tests showed that the new implementations are generally more accurate than the previously available codes, with an intermediate execution time among all the codes in comparison.

Efficient Evaluation of Matrix Polynomials beyond the Paterson–Stockmeyer Method

Efficient Evaluation of Matrix Polynomials beyond the Paterson–Stockmeyer Method (License CC BY 4.0), J. Sastre, J. Ibáñez, Mathematics 2021, 9(14), 1600; https://doi.org/10.3390/math9141600, Researchgate link

Two general methods for evaluating matrix polynomials requiring one matrix product less than the Paterson–Stockmeyer method were proposed in J. Sastre, Efficient evaluation of Matrix Polynomials, Linear Algebra Applications, where the cost of evaluating a matrix polynomial is given asymptotically by the total number of matrix product evaluations.

An analysis of the stability of those methods was given and the methods have been applied to Taylor-based implementations for computing the exponential, the cosine and the hyperbolic tangent matrix functions. Moreover, a particular example for the evaluation of the matrix exponential Taylor approximation of degree 15 requiring four matrix products was given, whereas the maximum polynomial degree available using Paterson–Stockmeyer method with four matrix products is 9.

Based on this example, a new family of methods for evaluating matrix polynomials more efficiently than the Paterson–Stockmeyer method was proposed, having the potential to achieve a much higher efficiency, i.e., requiring less matrix products for evaluating a matrix polynomial of certain degree, or increasing the available degree for the same cost. However, the difficulty of these family of methods lies in the calculation of the coefficients involved for the evaluation of general matrix polynomials and approximations.

In this paper, we provide a general matrix polynomial evaluation method for evaluating matrix polynomials requiring two matrix products less than the Paterson-Stockmeyer method for degrees higher than 30. Moreover, we provide general methods for evaluating matrix polynomial approximations of degrees 15 and 21 with four and five matrix product evaluations, respectively, whereas the maximum available degrees for the same cost with the Paterson–Stockmeyer method are 9 and 12, respectively. Finally, practical examples for evaluating Taylor approximations of the matrix cosine and the matrix logarithm accurately and efficiently with these new methods are given.

Advances in the Approximation of the Matrix Hyperbolic Tangent

Advances in the Approximation of the Matrix Hyperbolic Tangent (License CC BY 4.0), J. Ibáñez, J.M. Alonso, J. Sastre, E. Defez, P.A. Alonso, Mathematics 2021, 9(11), 1219; https://doi.org/10.3390/math9111219, Researchgate Link.

In this paper, we introduce two approaches to compute the matrix hyperbolic tangent. While one of them is based on its own definition and uses the matrix exponential, the other one is focused on the expansion of its Taylor series. For this second approximation, we analyse two different alternatives to evaluate the corresponding matrix polynomials. This resulted in three stable and accurate codes, which we implemented in MATLAB and numerically and computationally compared by means of a battery of tests composed of distinct state-of-the-art matrices.

Our results show that the Taylor series-based methods were more accurate, although somewhat more computationally expensive, compared with the approach based on the exponential matrix. To avoid this drawback, we propose the use of a set of formulas that allows us to evaluate polynomials in a more efficient way compared with that of the traditional Paterson–Stockmeyer method, thus, substantially reducing the number of matrix products (practically equal in number to the approach based on the matrix exponential), without penalising the accuracy of the result.

Simulation of harmonic oscillators on the lattice

Simulation of harmonic oscillators on the lattice, M.Tung, J. Ibáñez, E. Defez, J. Sastre, Mathematical Methods in the Applied Sciences 43(14), May 2020. Researchgate Link

This work deals with the simulation of a two‐dimensional ideal lattice having simple tetragonal geometry. The harmonic character of the oscillators give rise to a system of second‐order linear differential equations, which can be recast into matrix form. The explicit solutions which govern the dynamics of this system can be expressed in terms of matrix trigonometric functions.

For the derivation we employ the Lagrangian formalism to determine the correct solutions, which extremize the underlying action of the system. In the numerical evaluation we develop diverse state‐of‐the‐art algorithms which efficiently tackle equations with matrix sine and cosine functions. For this purpose, we introduce two special series related to trigonometric functions. They provide approximate solutions of the system through a suitable combination.

For the final computation an algorithm based on Taylor expansion with forward and backward error analysis for computing those series had to be devised. We also implement several MATLAB programs which simulate and visualize the two‐dimensional lattice and check its energy conservation.