This article discusses a recently developed Mathematica tool––a collection of functions for manipulating, evaluating and factoring quaternionic polynomials. relies on the package , which is available for download at w3.math.uminho.pt/QuaternionAnalysis.

### Introduction

Some years ago, the first two authors of this article extended the standard Mathematica package implementing Hamilton’s quaternion algebra—the package —endowing it with the ability, among other things, to perform numerical and symbolic operations on quaternion-valued functions [1]. Later on, the same authors, in response to the need for including new functions providing basic mathematical tools necessary for dealing with quaternionic-valued functions, wrote a full new package, . Since 2014, the package and complete support files have been available for download at the Wolfram Library Archive (see also [2] for updated versions).

Over time, this package has become an important tool, especially in the work that has been developed by the authors in the area of quaternionic polynomials ([3–5]). While this work progressed, new Mathematica functions were written to appropriately deal with problems in the ring of quaternionic polynomials. The main purpose of the present article is to describe these Mathematica functions. There are two parts.

In this first part, we discuss the tool, containing several functions for treating the usual problems in the ring of quaternionic polynomials: evaluation, Euclidean division, greatest common divisor and so on. A first version of was already introduced in [4], having in mind the user’s point of view. Here, we take another perspective, giving some implementation details and describing some of the experiments performed.

The second part of the article (forthcoming) is entirely dedicated to root-finding methods.

### The QuaternionAnalysis Package and the Algebra of Real Quaternions

In 1843, the Irish mathematician William Rowan Hamilton introduced the quaternions, which are numbers of the form

where the imaginary units , and satisfy the multiplication rules

This noncommutative product generates the well-known algebra of real quaternions, usually denoted by .

**Definition 1**

The standard package adds rules to , , , and the fundamental . Among others, the following quaternion functions are included: , , , , , , and . In , a quaternion is an object of the form and must have real numeric valued entries; that is, applying the function to an argument gives .

The extended version allows the use of symbolic entries, assuming that all symbols represent real numbers. The package adds functionality to the following functions: , , , , , , , , , and . We briefly illustrate some of the quaternion functions needed in the sequel. In what follows, we assume that the package has been installed.

These are the imaginary units.

These are the multiplication rules.

Here are two quaternions with symbolic entries and their product.

The product is noncommutative.

Here are some basic functions.

The function , which was extended in through the use of de Moivre’s formula for quaternions, works quite well for quaternions with numeric entries.

contains a different implementation of the power function, , which we recommend whenever a quaternion has symbolic entries.

We refer the reader to the package documentation for more details on the new functions included in the package.

### Manipulating Quaternionic Polynomials

We focus now on the polynomial in one formal variable of the form

(1) |

where the coefficients are to the left of the powers. Denote by the set of polynomials of the form (1), defining addition and multiplication as in the commutative case and assuming the variable commutes with the coefficients. This is a ring, referred to as the ring of left one-sided (or unilateral) polynomials.

When working with the functions contained in , a polynomial in is an object defined through the use of the function , which returns the simplest form of , taking into account the following rules.

The function tests if an argument is a scalar in the sense that it is not a complex number, a quaternion number or a polynomial.

For polynomials in , the rules , , and have to be defined.

** **■ *Addition*

■** ***Product by a scalar*

■** ***Multiplication*

■** ***Power*

Example* *1

The polynomials and can be defined using their coefficients in in descending order.

We now define three particularly important polynomials, the first two associated with a given polynomial and the last one associated with a given quaternion .

**Definition 2**

The first two polynomials are constructed with the functions and .

The built-in function now accepts a quaternion argument.

Observe that is a polynomial with real coefficients. For simplicity, in this context and in what follows, we assume that a quaternion with vector part zero is real.

Example* *2

Consider the polynomial of Example 1 and the quaternion .

### Evaluating Quaternionic Polynomials

The evaluation map at a given quaternion , defined for the polynomial given by (1), is

(2) |

It is not an algebra homomorphism, as does not lead, in general, to , as the next theorem remarks.

As usual, we say that is a zero (or root) of if An immediate consequence of Theorem 1 is that if , then is a zero of if and only if is a zero of .

A straightforward implementation of equation (2) can be obtained through .

As in the classical (real or complex) case, the evaluation of a polynomial can also be obtained by the use of Horner’s rule [3]. The nested form of equation (2) is

and the quaternionic version of Horner’s rule can be implemented as .

Example* *3

Consider again the polynomial . The problem of evaluating at can be solved through one of the following (formally) equivalent expressions.

Example* *4

We now illustrate some of the conclusions of Theorem 1 by considering the polynomials , and and the quaternion .

### The Euclidean Algorithm

For the theoretical background of this section, we refer the reader to [6] (see also [7] where basic division algorithms in are presented). Since is a principal ideal domain, left and right division algorithms can be defined. The following theorem gives more details.

**Theorem 2—Euclidean division**

If and are polynomials in (with ), then there exist unique , , and such that

(3) |

(4) |

If in equation (3), , then is called a right divisor of , and if in equation (4), , is called a left divisor of . This article only presents right versions of the division functions; in both the left and right versions are implemented. The function performs the right division of two quaternionic polynomials, returning a list with the quotient and remainder of the division.

Example* *5

Consider the polynomials and .

Example* *5 (continued)

and .

### The Zero Structure in

Before describing the zero set of a quaternionic polynomial , we need to introduce more concepts.

**Definition 3**

This is an equivalence relation in that partitions into congruence classes. The congruence class containing a given quaternion is denoted by . It can be shown (see, e.g. [8]) that

This result gives a simple way to test if two or more quaternions are similar, implemented with the function .

For zero or equality testing, we use the test function.

It follows that if and only if . The congruence class of a nonreal quaternion can be identified with the three-dimensional sphere in the hyperplane with center and radius .

**Definition 4**

It can be proved that if is a zero that is not isolated, then all quaternions in are in fact zeros of (see Theorem 4); therefore the choice of the term spherical to designate this type of zero is natural. According to the definition, real zeros are always isolated zeros. Identifying zeros can be done, taking into account the following results.

**Theorem 4**([9], [10])

A nonreal zero is a spherical zero of if and only if any of the following equivalent conditions hold:

Example* *6

We are going to show that the polynomial

has a spherical zero: and an isolated one: .

We first observe that both and are zeros of .

Now we use Theorem 4-1 to conclude that the zero is spherical, while the zero is isolated.

We can reach the same conclusion from Theorem 4-3.

Taking all this into account, the verification of the nature of a zero can be done using the function .

Consider the same polynomial and quaternions again.

We now list other results needed in the next section.

**Theorem 5—Factor theorem**([11], [12])

Let and . Then is a zero of if and only if there exists such that .

**Theorem 6—Fundamental theorem of algebra**([13])

Any nonconstant polynomial in always has a zero in .

### Factoring

In this section, we address the problem of factoring a polynomial . We mostly follow [4]. As in the classical case, it is always possible to write a quaternionic polynomial as a product of linear factors; however the link between these factors and the corresponding zeros is not straightforward. As an immediate consequence of Theorems 5 and 6, one has the following theorem.

**Theorem 7—Factorization into linear terms**

Any monic polynomial of degree in factors into linear factors; that is, there exist such that

(5) |

**Definition 5**

If and are chains associated with the same polynomial , then we say that the chains are similar and write .

The function constructs a polynomial with a given chain, and the function checks if two given chains are similar.

The repeated use of the next result allows the constructions of similar chains, if any.

Theorem 8 can be implemented using the function .

Example* *7

This constructs chains similar to the chain .

Observe that , and are similar chains.

We emphasize that there are polynomials with just one chain. This issue is addressed in Theorem 12. For the moment, we just give an example of such a polynomial.

These computations lead us to the conclusion that the polynomial factors uniquely as .

The next fundamental results shed light on the relation between factor terms and zeros of a quaternionic polynomial.

**Theorem 9**([12–14])

Let be a chain of the polynomial . Then every zero of is similar to some factor term in the chain and conversely, every factor term is similar to some zero of .

**Theorem 10—Zeros from factors**([12])

Consider a chain of the polynomial . If the similarity classes are distinct, then has exactly zeros , which are given by:

(6) |

The function determines the zeros of a polynomial with a prescribed chain in the case where no two factors in the chain are similar quaternions, giving a warning if this condition does not hold.

Example* *8

Consider the polynomial . One of its chains is , and it follows at once that the similarity classes of the factor terms are all distinct. Therefore, we conclude from Theorem 10 that has four distinct isolated roots, which can be obtained with the following code.

On the other hand, the polynomial has as one of its chains. Since , one cannot apply Theorem 10 to find the roots of .

Observe that this does not mean that the roots of are spherical.

This issue will be resumed later in connection with the notion of the multiplicity of a zero. The following theorem indicates how, under certain conditions, one can construct a polynomial having prescribed zeros.

**Theorem 11—Factors from zeros**([9])

If are quaternions such that the similarity classes are distinct, then there is a unique polynomial of degree with zeros that can be constructed from the chain , where

The function implements the procedure described in Theorem 11.

Example* *9

Consider the problem of constructing a polynomial having the isolated roots . We first determine one chain associated with these zeros.

Now we determine the polynomial associated with this chain.

Check the solution.

**Theorem 12**([9–15])

Let be a quaternionic polynomial of degree . Then is the unique zero of if and only if admits a unique chain with the property

(7) |

We can now introduce the concept of the multiplicity of a zero and a new *kind* of zero. In this context, we have to note that several notions of multiplicity are available in the literature (see [9], [15–17]).

**Definition 6**

Example* *10

The polynomial has an isolated root with multiplicity and an isolated root with multiplicity .

The polynomial has an isolated root with multiplicity and a sphere of zeros with multiplicity .

The polynomial has a mixed root with multiplicity and .

Finally, one can construct a polynomial with assigned zeros by the repeated use of the following result.

**Theorem 13**([4])

A polynomial with and as its isolated zeros with multiplicities and , respectively, and a sphere of zeros with multiplicity can be constructed through the chain

An alternative syntax for the function addresses the problem of constructing a polynomial (in fact it constructs a chain) once one knows the nature and multiplicity of its roots.

Example* *11

We reconsider here Example 6 of [4]. An example of a polynomial that has as a zero of multiplicity three, as a zero of multiplicity two and as a sphere of zeros with multiplicity two is

Of course this solution is not unique. For example, the polynomial

We confirm this using the function with the new syntax.

Here are two spherical roots corresponding to the same sphere.

Observe that the result is, of course, the same as this one.

Recall that a real root is always an isolated root, and two roots in the same congruence class cannot be isolated.

### Conclusion

This article has discussed implementation issues related to the manipulation, evaluation and factorization of quaternionic polynomials. We recommend that interested readers download the support file to get complete access to all the implemented functions. The increasing interest in the use of quaternions in areas such as number theory, robotics, virtual reality and image processing [18] makes us believe that developing a computational tool for operating in the quaternions framework will be useful for other researchers, especially taking into account the power of Mathematica as a symbolic language.

In the ring of quaternionic polynomials, new problems arise mainly because the structure of zero sets, as we have described, is very different from the complex case. In this article, we did not discuss the problem of computing the roots or the factor terms of a polynomial; all the results we have presented assumed that either the zeros or the factor terms of a given polynomial are known. Methods for computing the roots or factor terms of a quaternionic polynomial are considered in Part II.

### Acknowledgments

Research at the Centre of Mathematics at the University of Minho was financed by Portuguese Funds through FCT – Fundação para a Ciência e a Tecnologia, within the Project UID/MAT/00013/2013. Research at the Economics Politics Research Unit was carried out within the funding with COMPETE reference number POCI-01-0145-FEDER-006683 (UID/ECO/03182/2013), with the FCT/MEC’s (Fundação para a Ciência e a Tecnologia, I.P.) financial support through national funding and by the European Regional Development Fund through the Operational Programme on “Competitiveness and Internationalization – COMPETE 2020” under the PT2020 Partnership Agreement.

### References

[1] | M. I. Falcão and F. Miranda, “Quaternions: A Mathematica Package for Quaternionic Analysis,” in Computational Science and Its Applications (ICCSA 2011), Lecture Notes in Computer Science, 6784 (B. Murgante, O. Gervasi, A. Iglesias, D. Taniar and B. O. Apduhan, eds.), Berlin, Heidelberg: Springer, 2011 pp. 200–214. doi:10.1007/978-3-642-21931-3_17. |

[2] | F. Miranda and M. I. Falcão. “QuaternionAnalysis Mathematica Package.” w3.math.uminho.pt/QuaternionAnalysis. |

[3] | M. I. Falcão, F. Miranda, R. Severino and M. J. Soares, “Evaluation Schemes in the Ring of Quaternionic Polynomials,” BIT Numerical Mathematics, 58(1), pp. 51–72. doi:10.1007/s10543-017-0667-8. |

[4] | M. I. Falcão, F. Miranda, R. Severino and M. J. Soares, “Mathematica Tools for Quaternionic Polynomials,” in Computational Science and Its Applications (ICCSA 2017), Lecture Notes in Computer Science, 10405, (O. Gervasi, B. Murgante, S. Misra, G. Borruso, C. M. Torre, A. M. A. C. Rocha, D. Taniar, B. O. Apduhan, E. Stankova and A. Cuzzocrea, eds.), Berlin, Heidelberg: Springer, 2017 pp. 394–408. doi:10.1007/978-3-319-62395-5_27. |

[5] | M. I. Falcão, F. Miranda, R. Severino and M. J. Soares, “Weierstrass Method for Quaternionic Polynomial Root-Finding,” Mathematical Methods in the Applied Sciences, 2017 pp. 1–15. doi:10.1002/mma.4623. |

[6] | N. Jacobson, The Theory of Rings (Mathematical Surveys and Monographs), New York: American Mathematical Society, 1943. |

[7] | A. Damiano, G. Gentili and D. Struppa, “Computations in the Ring of Quaternionic Polynomials,” Journal of Symbolic Computation, 45(1), 2010 pp. 38–45. doi:10.1016/j.jsc.2009.06.003. |

[8] | F. Zhang, “Quaternions and Matrices of Quaternions,” Linear Algebra and Its Applications, 251, 1997 pp. 21–57. doi:10.1016/0024-3795(95)00543-9. |

[9] | B. Beck, “Sur les équations polynomiales dans les quaternions,” L’ Enseignement Mathématique, 25, 1979 pp. 193–201. |

[10] | A. Pogorui and M. Shapiro, “On the Structure of the Set of Zeros of Quaternionic Polynomials,” Complex Variables. Theory and Application, 49(6), 2004 pp. 379–389. doi:10.1080/0278107042000220276. |

[11] | B. Gordon and T. S. Motzkin, “On the Zeros of Polynomials over Division Rings,” Transactions of the American Mathematical Society, 116, 1965 pp. 218–226.doi:10.1090/S0002-9947-1965-0195853-2. |

[12] | T.-Y. Lam, A First Course in Noncommutative Rings, New York: Springer-Verlag, 1991. |

[13] | I. Niven, “Equations in Quaternions,” The American Mathematical Monthly, 48(10), 1941pp. 654–661. www.jstor.org/stable/2303304. |

[14] | R. Serôdio and L.-S. Siu, “Zeros of Quaternion Polynomials”. Applied Mathematics Letters, 14(2), 2001 pp. 237–239. doi:10.1016/S0893-9659(00)00142-7. |

[15] | R. Pereira, Quaternionic Polynomials and Behavioral Systems, Ph.D. thesis, Departamento de Matemática, Universidade de Aveiro, Portugal, 2006. |

[16] | G. Gentili and D. C. Struppa, “On the Multiplicity of Zeroes of Polynomials with Quaternionic Coefficients,” Milan Journal of Mathematics, 76(1), 2008 pp. 15–25.doi:10.1007/s00032-008-0093-0. |

[17] | M. I. Falcão, F. Miranda, R. Severino and M. J. Soares, “Quaternionic Polynomials with Multiple Zeros: A Numerical Point of View,” in 11th International Conference on Mathematical Problems in Engineering, Aerospace and Sciences (ICNPAA 2016), La Rochelle, France, AIP Conference Proceedings, 1798(1), 2017 p. 020099. doi:10.1063/1.4972691. |

[18] | H. R. Malonek, “Quaternions in Applied Sciences. A Historical Perspective of a Mathematical Concept,” in 17th International Conference on the Applications of Computer Science and Mathematics in Architecture and Civil Engineering (IKM 2003) (K. Gürlebeck and C. Könke, eds.), Weimar, Germany, 2003. |

M. I. Falcão, F. Miranda, R. Severino and M. J. Soares, “Computational Aspects of Quaternionic Polynomials,” The Mathematica Journal, 2018. dx.doi.org/doi:10.3888/tmj.20-4. |

### Additional Material

Available at: w3.math.uminho.pt/QuaternionAnalysis

Available at: www.mathematica-journal.com/data/uploads/2018/05/QPolynomial.m

### About the Authors

M. Irene Falcão is an associate professor in the Department of Mathematics and Applications of the University of Minho. Her research interests are numerical analysis, hypercomplex analysis and scientific software.

Fernando Miranda is an assistant professor in the Department of Mathematics and Applications of the University of Minho. His research interests are differential equations, quaternions and related algebras and scientific software.

Ricardo Severino is an assistant professor in the Department of Mathematics and Applications of the University of Minho. His research interests are dynamical systems, quaternions and related algebras and scientific software.

M. Joana Soares is an associate professor in the Department of Mathematics and Applications of the University of Minho. Her research interests are numerical analysis, wavelets mainly in applications to economics, and quaternions and related algebras.

**M. Irene Falcão**

CMAT – Centre of Mathematics

DMA – Department of Mathematics and Applications

University of Minho

Campus de Gualtar, 4710-057 Braga

Portugal

*mif@math.uminho.pt*

**Fernando Miranda**

CMAT – Centre of Mathematics

DMA – Department of Mathematics and Applications

University of Minho

Campus de Gualtar, 4710-057 Braga

Portugal

*fmiranda@math.uminho.pt*

**Ricardo Severino**

DMA – Department of Mathematics and Applications

University of Minho

Campus de Gualtar, 4710-057 Braga

Portugal

*ricardo@math.uminho.pt*

**M. Joana Soares**

NIPE – Economics Politics Research Unit

DMA – Department of Mathematics and Applications

University of Minho

Campus de Gualtar, 4710-057 Braga

Portugal

*jsoares@math.uminho.pt*