1 Introduction

In this paper, linear functional equations of the type

$$\begin{aligned} \sum _{i=0}^{n+1} f_i (p_i x + q_i y) = 0 \quad (x,y \in X) \end{aligned}$$
(1)

are considered, where n is a positive integer, \(p_0,\dots ,p_{n+1}\) and \(q_0,\dots ,q_{n+1}\) are rational numbers, XY are linear spaces over the rationals and \(f_0,\dots ,f_{n+1}:X\rightarrow Y\) are unknown functions. Our aim is to present a computer program developed in the computer algebra system Maple,Footnote 1 which determines the solutions of functional equations and also solutions of systems of functional equations belonging to the class above.

It is easy to see that the class above contains several well-known functional equations, like the Cauchy, the square-norm (or quadratic, or parallelogram or Jordan-von Neumann), the Jensen and the Pexider equations as well as the so called polynomial and monomial equations as a special case (cf., among others, the books [1,2,3, 26, 27, 30]). Early studies of polynomial equations were made by Maurice Fréchet ( [14, 15]), while the class above was already considered by W. Harold Wilson ( [32]) in the first decades of the previous century. For recent investigations, we refer to the papers [20, 23,24,25, 31] and the references therein. Solutions of (1), in the general case when X and Y are certain Abelian groups and the products \(p_i x\) and \(q_i y\) in the arguments of the unknown functions are replaced by homomorphisms of X, were determined by László Székelyhidi in [29] (cf., also, [30]).

In the 1980s, János Aczél raised the question, whether it is possible to develop a computer program which determines the solutions of functional equations belonging to class (1) based on Székelyhidi’s method. With the application of such a program, the arduous (in several cases ‘hopeless’) calculations needed if someone applies the known theoretical results for solving equations of the type above can be avoided (more precisely, can be done by a computer).

The first programs dealing with the solution of the equations considered, were developed more than 20 years ago and were described in the Thesis [18] and in the paper [19]. Their improvement presented here is much more effective than those. Additionally, the new version is capable of treating not only single functional equations but also systems of them. Its structure fits the architecture of modern (‘module-based’) Maple packages. Due to this fact, the entire program is more transparent and, besides several further advantages, it can serve as the first part of a larger class of programs handling functional equations and inequalities. The next part of such a system could be a properly modified version of Attila Házy’s program also written in the computer algebra system Maple and described in [22]. Concerning further studies of functional equations, inequalities and related topics using computer algebra systems, we refer to the papers [4,5,6, 13, 16, 17] and [28].

We point out that our program operates with symbolic calculations provided by Maple. This means that it does not contain any numerical or approximate methods and it yields the ‘exact’ solutions of the equations considered. Since it determines solutions of equations, using the concept of ‘mathability’ introduced in [8], it ‘increases the level of mathability’ (or using another terminology, it ‘improves the mathability’) of the underlying system. (For further investigations connected to mathability we refer to the book [7] and to the papers [11, 12]).

We note that a previous version of the program was presented during the \(\mathrm 4^\mathrm{th}\) IEEE International Conference on Cognitive Infocommunications (CogInfoCom) in 2013 (cf.  [10]) and also a related Demo Presentation was performed at the same conference (cf.  [9]).

In the first part of the paper, we present the theoretical basis of our program, while, in Sect. 3, we describe the program itself.

2 Theoretical background

In this section, we present the theoretical background of our program. First we give some basic definitions.

Let X and Y be linear spaces, and let \(f:X\rightarrow Y\) be a function. Let, furthermore,

$$\begin{aligned} \Delta ^1_yf(x)=f(x+y)-f(x) \quad (x,y\in X) \end{aligned}$$

and, for a positive integer n,

$$\begin{aligned} \Delta ^{n+1}_yf(x)=\Delta ^1_y\Delta ^n_yf(x) \quad (x,y\in X). \end{aligned}$$

If n is a non-negative integer, a function \(f:X\rightarrow Y\) is said to be a polynomial function of degree n (with another terminology a polynomial function of degree at most n) if it fulfils

$$\begin{aligned} \Delta ^{n+1}_yf(x)=0 \quad (x,y\in X). \end{aligned}$$
(2)

It is well-known that, in the class of real functions (i.e., if \(X=Y=\mathbb {R}\)), functions of the form

$$\begin{aligned} f(x)=a_nx^n+\cdots +a_0 \quad (x\in \mathbb {R}) \end{aligned}$$
(3)

with (fixed) real coefficients \(a_0,\ldots ,a_n\) solve (2). It is also known, that, in the case when n is a positive integer, functional equation (2) has solutions which are different from (3). Thus, polynomial functions can be considered as generalized algebraic polynomials.

If n is a positive integer, a function \(f:X\rightarrow Y\) is called a monomial function of degree n if it satisfies

$$\begin{aligned} \Delta ^n_yf(x)-n!f(y)=0 \quad (x,y\in X). \end{aligned}$$
(4)

Similarly to the situation above, in the class of real functions, algebraic monomials, i. e. functions of the form

$$\begin{aligned} f(x)=cx^n \quad (x\in \mathbb {R}) \end{aligned}$$
(5)

with a (fixed) real constant c are solutions of functional equation (4). Here it is also valid that, in the case when \(n>1\), there exist functions which satisfy (4) but are not of the form given in (5), therefore, monomial functions are generalized algebraic monomials. (For real polynomial and monomial functions which are different from (3) and (5), respectively, we refer to Remark 1 below.)

There is an important connection between polynomial and monomial functions. If \(f_k:X\rightarrow Y\), \((k=0,\ldots ,n)\) are monomial functions of degree k, then their sum is a polynomial function of degree n. On the other hand, if \(f:X\rightarrow Y\) is a polynomial function of degree n, then there exist monomial functions \(f_k:X\rightarrow Y\) of degree k, \((k=0,\ldots ,n)\) such that their sum is f. This means that (analogously to algebraic monomials and algebraic polynomials) monomial functions serve as ‘building blocks’ for polynomial functions (cf., e.g. [26, 27] and, in a general setting, [30]).

A similar property is valid for the solutions of general linear functional equations considered in this paper, too. According to L. Székelyhidi’s results ( [29], cf., also, [30]), under some natural conditions, the solutions of equations of class (1) are also sums of certain monomial functions. Now, we formulate his corresponding theorems, which serve as a background for our program. In these statements and in the following parts of the paper, we will use the convention \(0^0=1\).

Theorem 1

Let X and Y be linear spaces over the rationals, let \(p_0, \dots ,p_{n+1}\), \(q_0, \dots ,q_{n+1}\) be rational numbers and assume that

$$\begin{aligned} M^{(i)}_k: X \rightarrow Y \quad (i=0, \dots ,n+1,\ k=0, \dots ,n) \end{aligned}$$
(6)

are monomial functions of degree k. The functions \(f_0, \dots ,f_{n+1}: X \rightarrow Y\),

$$\begin{aligned} f_i(x)= \sum _{k=0}^n {M}^{(i)}_k(x) \quad (x\in X,\ i=0, \dots ,n+1) \end{aligned}$$
(7)

solve functional equation (1) if and only if the monomials given in (6) fulfil

$$\begin{aligned} \sum _{i=0}^{n+1} p_i^j q_i^{k-j} {M}^{(i)}_k (x) =0 \quad (x\in X,\ k=0,\dots ,n,\ j=0,\dots ,k). \end{aligned}$$
(8)

Theorem 2

Let X and Y be linear spaces over the rationals and let \(p_0, \dots ,p_{n+1}\), \(q_0, \dots ,q_{n+1}\) be rational numbers such that

$$\begin{aligned} p_i q_j \not = p_j q_i \quad (i,j=0,\dots ,n+1,\ i \not =j). \end{aligned}$$
(9)

The functions \(f_0, \dots ,f_{n+1}: X \rightarrow Y\) solve functional equation (1) if and only if they are of the form

$$\begin{aligned} f_i(x)= \sum _{k=0}^n {M}^{(i)}_k(x) \quad (x\in X,\ i=0, \dots ,n+1) \end{aligned}$$
(10)

where

$$\begin{aligned} M^{(i)}_k: X \rightarrow Y, \quad (i=0, \dots ,n+1,\ k=0, \dots ,n) \end{aligned}$$

are monomial functions of degree k satisfying the equations

$$\begin{aligned} \sum _{i=0}^{n+1} p_i^j q_i^{k-j} {M}^{(i)}_k (x) =0 \quad (x\in X,\ k=0,\dots ,n,\ j=0,\dots ,k). \end{aligned}$$
(11)

Remark 1

According to a celebrated result of Georg Hamel presented in [21], there exist monomial functions \(f:\mathbb {R}\rightarrow \mathbb {R}\) of degree 1, such that the graph of f, i.e., the set

$$\begin{aligned} \{(x,y)\in \mathbb {R}^2\mid x\in \mathbb {R},\ y=f(x)\} \end{aligned}$$

is dense in \(\mathbb {R}^2\). A similar property is valid for monomial functions of higher order, too (cf., e.g., [26, 27]). As a consequence of the Theorems above, we obtain that equations belonging to class (1) can also have such ‘irregular’ solutions.

Remark 2

We note that, in the paper [29], L. Székelyhidi investigated a more general situation (cf., also, [30]). He considered the class of functional equations

$$\begin{aligned} f(x_0)+\sum _{i=1}^{n+1}f(\varphi _i(x)+\psi _i(y))=0 \quad (x,y\in G), \end{aligned}$$
(12)

where G is a divisible, S is a torsion free Abelian group, \(\varphi _i,\psi _i:G\rightarrow G\), \((i=1,\ldots ,n+1)\), are homomorphisms and \(f_i:G\rightarrow S\), \((i=0,\ldots ,n+1)\), are unknown functions. He proved that, in the case when \(\varphi _i,\psi _i\), \((i=0,\ldots ,n+1)\), are homomorphisms of G onto itself with the property

$$\begin{aligned} \mathrm{Rg}(\psi _i\circ \psi ^{-1}_j-\varphi _i\circ \varphi ^{-1}_j)=G \quad (i=1,\ldots ,n+1,\ i\ne j) \end{aligned}$$
(13)

then the solutions \(f_i:G\rightarrow S\), \((i=0,\ldots ,n+1)\) of (12) are of the form

$$\begin{aligned} f_i=\sum _{k=0}^n\mathrm{D}(A_k^{(i)}) \quad (i=0,\ldots ,n+1) \end{aligned}$$
(14)

where \(\mathrm{D}(A_k^{(i)})\) denote the diagonals

$$\begin{aligned} \mathrm{D}(A_k^{(i)})(x)=A_k^{(i)}(x,\ldots ,x) \quad (x\in G,\ i=0,\ldots ,n+1,\ k=0,\ldots ,n) \end{aligned}$$

of the k-additive symmetric functions \(A_k^{(i)}:G^k\rightarrow S\), (\(i=0,\ldots ,n+1\), \(k=0,\ldots ,n\)), which satisfy the equations

$$\begin{aligned} A_k^{(0)}(x\ldots ,x,0,\ldots ,0) +\sum _{i=0}^{n+1}A_k^{(i)}(\varphi _i(x),\ldots ,\varphi _i(x), \psi _i(y),\ldots ,\psi _i(y))=0 \end{aligned}$$
(15)

for each \(x,y\in G\), \(j=0,\ldots ,n\) and \(k=j,\ldots ,n\). He also showed that, if condition (13) does not hold, then functions \(f_i:G\rightarrow S\), \((i=0,\ldots ,n+1)\) of the form (14) solve (12) if and only if the k-additive symmetric functions \(A_k^{(i)}:G^k\rightarrow S\) fulfil the equations given in (15).

3 Description of the program

In this section, we describe the computer program which determines solutions of systems of functional equations belonging to class (1). The program was developed in the computer algebra system Maple. (It can be used in all versions of Maple between Maple 16 and Maple 2020. A copy of the program can be requested from the second author of the paper.) It uses formal calculations and provides the exact solutions of the equations considered. Its algorithm is based on the results presented in Sect. 2.

The name of the program is lfesolve and it is contained in the Maple package FunctionalEquations. Like Maple programs, it can be accessed by using either the long or the short form of the command name, i.e., one of the (long) forms

$$\begin{aligned} {\texttt {FunctionalEquations[lfesolve](arguments);}} \end{aligned}$$

or

$$\begin{aligned} {\texttt {FunctionalEquations:-lfesolve(arguments);}} \end{aligned}$$

or if the command

$$\begin{aligned} {\texttt {with(FunctionalEquations);}} \end{aligned}$$

has already been applied in the Maple session considered, then simply

$$\begin{aligned} {\texttt {lfesolve(arguments);}.} \end{aligned}$$

During the presentation of the program, we will use the last version only.

To use the program, we have to give at least two input parameters: the system of equations to be solved as a (Maple) list e and the list f of the unknown functions contained in the system. In addition, we may use some optional parameters. Thus, the input of the program should be of the form

$$\begin{aligned} {\texttt {lfesolve(e,f,options);}.} \end{aligned}$$

Obviously, the equations in e have to belong to class (1). In order for the program to work properly, the variables of the unknown functions of the system should be denoted by ‘x’ and ‘y’.

If any of the equations is given in a form with 0 on the right hand side—similarly to other solve functions in Maple—it is enough to give its left hand side in the input. If any of e or f contains one element only, then, analogously to other appearances of lists in Maple, it can be given without the brackets []. For the users’ convenience, if some functions contained in the system e are not given in f, then the program sends a warning message of this fact with the names of the missing functions, adds these functions automatically to the list f and continues the solution of the problem. (This ‘convenience service’ cannot cause any problems, since the use of parameter functions is not allowed in the system of equations considered.) On the other hand, if some functions appear in f which are not contained in the system e, then the program—without any warning or error message—simply omits them from f and solves the system without them.

As the output of the program, provided that the input is given in a correct form, we obtain the solutions of the system of functional equations given in parameter e. The solutions are presented, according to Theorems 1 and 2, as linear combinations of monomial functions. The monomial functions \(M^{(i)}_k\), \((i=0, \dots ,n+1,\ k=0, \dots ,n)\) contained in the Theorems above appear in the output in the form

$$\begin{aligned} \mathrm{M(i,k)}=M^{(i)}_k \quad (i=0, \dots ,n+1,\ k=0, \dots ,n). \end{aligned}$$

The program gives the solution functions in a set.

Let us consider, as an example, the well-known square-norm functional equation

$$\begin{aligned} f(x+y)+f(x-y)=2f(x)+2f(y) \quad (x,y \in X) \end{aligned}$$
(16)

(cf., e.g., the books [1, 2] and the references therein) and let now and in the following part of the paper X and Y denote linear spaces over the rationals. It is an easy consequence of Theorem 2 that a function \(f:X\rightarrow Y\) solves this functional equation if and only if

$$\begin{aligned} f(x)=M_2(x) \quad (x \in X), \end{aligned}$$

where \(M_2:X\rightarrow Y\) is a monomial function of degree 2.

If we would like to solve this equation with our program, we have to use the input

figure a

We obtain the output

figure b

If property (9) is not valid in any of the equations in e, then we receive a warning message.

Let us consider, for example, the simple functional equation

$$\begin{aligned} f(x)-f(y)=g(x)-g(y) \quad (x,y \in X), \end{aligned}$$
(17)

where \(f:X\rightarrow Y\) and \(g:X\rightarrow Y\) are unknown functions.

It is easy to see that this equation belongs to class (1) but does not satisfy condition (9). In such situations, Theorem 2 cannot be applied and, by Theorem 1, we can determine those solutions of the equation which can be written as a sum of certain monomial functions. Thus, assuming that

$$\begin{aligned} M^{(i)}_k: X\rightarrow Y \quad (i=0,1,\ k=0,1,2) \end{aligned}$$

are monomial functions of degree k, the functions \(f,g:X\rightarrow Y\)

$$\begin{aligned} f(x)= & {} M^0_2(x)+M^0_1(x)+M^0_0(x) \quad (x \in X)\\ g(x)= & {} M^1_2(x)+M^1_1(x)+M^1_0(x) \quad (x \in X), \end{aligned}$$

solve functional equation (17) if and only if they are of the form

$$\begin{aligned} \begin{array}{rcl} f(x)&{}=&{}M^0_2(x)+M^0_1(x)+M^0_0(x) \quad (x \in X)\\ g(x)&{}=&{}M^0_2(x)+M^0_1(x)+M^1_0(x) \quad (x \in X). \end{array} \end{aligned}$$
(18)

Obviously, functional equation (17) has solutions which are not contained in (18). For example, if \(f:X \rightarrow Y\) is an arbitrary function and \(g:X\rightarrow Y\) has the property \(g(x)=f(x)\), \((x\in X)\), then the pair (fg) satisfies (17).

Using our program, the input

figure c

yields

figure d

The output of the program can be modified by the application of two different types of options. The first type makes it possible to obtain the solutions in a more detailed and more informative form. If we use its default version brief, we get the solutions in the same form as it was described above. E.g., in the case of the square-norm equation (16), the input

figure e

yields

figure f

This output contains the solutions in an exact form, and they can also be used by other programs for further investigations.

However, in several cases, it is useful to get more information about the solutions in the output. This is possible with the application of the option verbose. If we use this, the program presents the unknown functions in the system considered as sums of monomial functions (similarly to (7) and (10) in Theorems 1 and 2, respectively), it yields the connections between these monomials (solving the systems of equations (8) or (11)), finally, it also gives the solutions as above. The solutions of the square-norm equation (16) with this option will be presented in the following form:

figure g
figure h

Considering the same thing for the linear functional equation (‘chosen randomly’)

$$\begin{aligned} f(x+y)+f(x-3y)=g(x-2y)-2f(y)+f(x+2y) \quad (x,y \in X), \end{aligned}$$

for the unknown functions \(f,g: X\rightarrow Y\), using the input

figure i

we obtain

figure j

while

figure k

gives

figure l

The program can also determine solutions of systems of functional equations of type (1). Performing calculations ‘by hand’, in the case of non-trivial linear equations, the solution of such systems could require lengthy or even infeasible computations. However, using computers, such situations can also be handled.

If a system of equations belonging to class (1) is given, where each equation contained in the system satisfies property (9) then, according to Theorem 2, the set of solutions of the system can be determined as the intersection of the sets of solutions of the single equations.

The situation is more problematic if there are some equations in the system which do not satisfy condition (9). In this case, Theorem 2 cannot be applied to these equations. If we determine their solutions (partly based on Theorem 1), we can ‘lose’ some solutions of the system which can be written as sums of monomial functions.

Let us illustrate this case with a simple example. Consider the system

$$\begin{aligned} \begin{array}{rcl} f(x+y)+f(x-y)&{}=&{}2f(x)+2f(y) \quad (x,y \in X)\\ f(x)&{}=&{}g(x) \quad (x \in X) \end{array} \end{aligned}$$
(19)

for unknown functions \(f,g:X\rightarrow Y\). If we apply Theorem 1 to determine the (polynomial) solutions of the second equation, we obtain that such solutions are of the form

$$\begin{aligned} \begin{array}{rcl} f(x)&{}=&{}M^0_0(x) \quad (x \in X)\\ g(x)&{}=&{}M^0_0(x) \quad (x \in X), \end{array} \end{aligned}$$

where \(M^0_0:X\rightarrow Y\) is a monomial function of degree 0. On the other hand, according to Theorem 2 (as it was also determined in connection with equation (16)), all solutions of the first equation in (19) are

$$\begin{aligned} f(x)=M_2(x) \quad (x \in \mathbb {R}), \end{aligned}$$

where \(M_2:\mathbb {R}\rightarrow \mathbb {R}\) is a monomial function of degree 2. If we determine the polynomial solutions of system (19) based on these facts, we obtain the functions \(f,g:\mathbb {R}\rightarrow \mathbb {R}\), \(f(x)=g(x)=0\) for all \(x\in \mathbb {R}\). Thus, we easily obtain that functions \(f,g:X\rightarrow Y\) solve the system of functional equation given in (19) if and only if they are of the form

$$\begin{aligned} f(x)= & {} M_2(x) \quad (x \in X),\\ g(x)= & {} M_2(x) \quad (x \in X), \end{aligned}$$

where \(M_2:X\rightarrow Y\) is a monomial function of degree 2.

This means that, based on the theoretical results described in Sect. 2, we can determine the polynomial solutions of such systems in two different ways with possibly different results. This fact has to be taken into consideration when developing a computer program which determines solutions of systems of linear functional equations of type (1).

The program can manage such situations completely. Using the (default) option strict it will apply Theorem 1 ‘literally’ for those equations which do not satisfy condition 9 and will determine the solutions of the system considered accordingly. With the option permissive, it will investigate polynomials of higher order than Theorem 1 would allow and will determine the (polynomial) solutions of the system among them. It is important to point out that, with the application of these options, the user may decide which class of solutions will be determined.

Now, we present the solution of system (19) provided by our program in the two different ways described above. In order to make the examples more informative, we consider them in verbose form. If the option strict is used

figure m

we get

figure n

Applying the option permissive

figure o

we obtain

figure p

The order of the options is given in the program: first brief or verbose and after that strict or permissive can be used. They can also be omitted (in this case always the default option is applied). Obviously, simultaneous application of the same type of options is not allowed.

In the case when the input is incorrect, the program yields an appropriate error message with a short hint at the problem (similarly to other error messages in Maple). For example,

figure q

gives

figure r

the input

figure s

yields

figure t

and

figure u

has the output

figure v

(We note that the functional equations considered in the last two examples above make sense if f is a real function. However, since the equations are not of the form (1), they can not be solved with our program.) Finally,

figure w

results in

figure x