1 Introduction

Ulam [1] raised the following famous stability problem concerning functional equations in 1940: Under what conditions does there exist a homomorphism near an approximate homomorphism? This problem was solved by Hyers [2] in Banach spaces. The stability problems of various functional equations and functional inequalities have been extensively investigated by a number of authors (see [311]).

Alsina and Ger [12] first proved the Hyers–Ulam stability for differential equations: if \(\psi (t)\) is an approximate solution of \(x'= x\), then we can guarantee the existence of an exact solution of \(x'= x\) near to \(\psi (t)\). It was generalized by Takahasi et al. [13]. Later many researchers employed the Hyers–Ulam stability of higher-order homogeneous and nonhomogeneous differential equations (see [1424]).

The Hyers–Ulam stability of a system of first-order linear differential equations with constant coefficients was investigated by Jung [25] by using the matrix method in 2006. Wang, Zhou, and Sun [26] investigated the Hyers–Ulam stability of a class of first-order linear differential equations in 2007. In 2014, Rus [27] investigated various types of stability related to the Ulam problem for ordinary differential equations of the form \(u' (t) = A (u(t)) + f(t, u(t))\), \(t \in [a, b]\).

Using the Laplace transform method, Alqifiary and Jung [28] investigated the Hyers–Ulam stability of linear differential equations.

Motivated by the literature mentioned, in this paper, we investigate the Hyers–Ulam stability of the homogeneous and nonhomogeneous second-order linear differential equations

$$\begin{aligned} x''(t) + \mu ^{2} x(t) =0, \end{aligned}$$
(1.1)
$$\begin{aligned} x''(t) + \mu ^{2} x(t) = q(t) \end{aligned}$$
(1.2)

for \(t \in I\), \(x \in C^{2}(I)\), and \(q \in C(I)\), \(I = [\tau _{1},\tau _{2}]\), \(-\infty < \tau _{1}<\tau _{2}< \infty \), by using the Mahgoub transform method.

2 Preliminaries

In this paper, \(\mathbb{F}\) denotes the real field \(\mathbb{R}\) or complex field \(\mathbb{C}\). A function \(f:(0,\infty ) \rightarrow \mathbb{F}\) is said to be of exponential order if there exist constants \(A,B \in \mathbb{R}\) such that \(\vert f(t) \vert \leq A e^{tB}\) for all \(t>0\).

For each function \(f:(0,\infty ) \rightarrow \mathbb{F}\) of exponential order, consider the set

$$ \mathcal{A} = \bigl\{ f : \exists M, k_{1},k_{2}>0 \bigl\vert f(t) \bigr\vert < M e^{ \vert t \vert /{k_{j}}}, t \in (-1)^{j} \times [0, \infty ) \bigr\} , $$

where the constant M is finite, whereas \(k_{1}\) and \(k_{2}\) may be infinite.

The Mahgoub transform is defined by

$$ \mathcal{M} \bigl\{ f(t) \bigr\} =H[v]= v \int _{0}^{\infty } f(t) e^{-vt} \,dt, \quad t \geq 0, k_{1}\leq v \leq k_{2}, $$

where the variable v in the Mahgoub transform is used to factor the variable t in the argument of the function f, especially, for \(f\in \mathcal{A}\).

Definition 2.1

(Convolution of two functions)

Let f and g be Lebesgue-integrable functions on \((- \infty , +\infty )\). Let S denote the set of x for which the Lebesgue integral

$$ h(x) = \int _{-\infty }^{\infty } f(u) g(x-u) \,du $$

exists. This integral defines the function h on S called the convolution of f and g and denoted by \(h = f * g\).

Now we give some definitions related to the Hyers–Ulam stability of the differential equations (1.1) and (1.2).

Let \(I,J\subseteq \mathbb{R}\) be intervals. We denote the space of k continuously differentiable functions from I to J by \(C^{k}(I,J)\) and denote \(C^{k}(I,I)\) by \(C^{k}(I)\). Further, \(C(I,J)=C^{0}(I,J)\) denotes the space of continuous functions from I to J. In addition, \(\mathbb{R}_{+}:=[0,\infty )\). From now on, we assume that \(I=[\tau _{1},\tau _{2}]\), where \(-\infty <\tau _{1}<\tau _{2}<\infty \).

Definition 2.2

We say that the differential equation (1.1) has the Hyers–Ulam stability if there exists a constant \(L > 0\) satisfying the following condition: If for every \(\epsilon >0 \), there exists \(x \in C^{2}(I)\) satisfying the inequality

$$ \bigl\vert x''(t) + \mu ^{2} x(t) \bigr\vert \leq \epsilon $$

for all \(t \in I\), then there exists a solution \(y \in C^{2}(I)\) satisfying the differential equation \(y''(t) + \mu ^{2} y(t) = 0 \) such that

$$ \bigl\vert x(t) - y(t) \bigr\vert \leq L \epsilon $$

for all \(t \in I\). We call such L the Hyers–Ulam stability constant for (1.1).

Definition 2.3

We say that the differential equation (1.1) has the generalized Hyers–Ulam stability with respect to \(\phi \in C(\mathbb{R}_{+} , \mathbb{R}_{+} )\) if there exists a constant \(L_{\phi } > 0\) with the following property: If for every \(\epsilon > 0\), there exists \(x \in C^{2}(I)\) satisfying the inequality

$$ \bigl\vert x''(t) + \mu ^{2} x(t) \bigr\vert \leq \epsilon \phi (t) $$

for all \(t \in I\), then there exists a solution \(y \in C^{2}(I)\) satisfying the differential equation \(y''(t) + \mu ^{2} y(t) = 0 \) such that

$$ \bigl\vert x(t) - y(t) \bigr\vert \leq L_{\phi } \epsilon \phi (t) $$

for all \(t \in I\). We call such L the generalized Hyers–Ulam stability constant for (1.1).

Definition 2.4

We say that the differential equation (1.2) has the Hyers–Ulam stability if there exists a constant \(L > 0\) satisfying the following condition: If for every \(\epsilon >0\), there exists \(x \in C^{2}(I)\) satisfying the inequality

$$ \bigl\vert x''(t) + \mu ^{2} x(t) - q(t) \bigr\vert \leq \epsilon $$

for all \(t \in I\), then there exists \(y\in C^{2}(I)\) satisfying \(y''(t) + \mu ^{2} y (t) = q(t) \) such that

$$ \bigl\vert x(t) - y(t) \bigr\vert \leq L \epsilon $$

for all \(t \in I\). We call such L the Hyers–Ulam stability constant for (1.2).

Definition 2.5

We say that the differential equation (1.2) has the generalized Hyers–Ulam stability with respect to \(\phi \in C(\mathbb{R}_{+} , \mathbb{R}_{+} )\) if there exists a constant \(L_{\phi } > 0\) such that for every \(\epsilon > 0\) and for each solution \(x \in C^{2}(I)\) satisfying the inequality

$$ \bigl\vert x''(t) + \mu ^{2} x(t) - q(t) \bigr\vert \leq \epsilon \phi (t) $$

for all \(t \in I\), there exists \(y \in C^{2}(I)\) satisfying the differential equation \(y''(t) + \mu ^{2} y(t) = q(t) \) such that

$$ \bigl\vert x(t) - y(t) \bigr\vert \leq L_{\phi } \epsilon \phi (t) $$

for all \(t \in I\). We call such L the generalized Hyers–Ulam stability constant for (1.2).

3 Hyers–Ulam stability for (1.1)

In this section, we prove the Hyers–Ulam stability and generalized Hyers–Ulam stability of the differential equation (1.1) by using the Mahgoub transform.

Theorem 3.1

The differential equation (1.1) is Hyers–Ulam stable.

Proof

Let \(\epsilon >0\). Suppose that \(x \in C^{2}(I)\) satisfies

$$\begin{aligned} \bigl\vert x''(t) + \mu ^{2} x(t) \bigr\vert \leq \epsilon \end{aligned}$$
(3.1)

for all \(t \in I\). We will prove that there exists a real number \(L > 0\) such that \(\vert x(t) - y(t) \vert \leq L \epsilon \) for some \(y \in C^{2}(I)\) satisfying \(y''(t) + \mu ^{2} y(t) = 0 \) for all \(t \in I\). Define the function \(p: (0, \infty ) \rightarrow \mathbb{R}\) by \(p(t) =: x''(t) + \mu ^{2} x(t)\) for all \(t >0 \). By (3.1) we have \(|p(t)| \leq \epsilon \). Taking the Mahgoub transform of p, we have

$$\begin{aligned} \mathcal{M} \bigl\{ p(t) \bigr\} & = \bigl(v^{2}+ \mu ^{2}\bigr)\mathcal{M} \bigl\{ x(t) \bigr\} -v^{3}x(0)-v^{2}x'(0), \end{aligned}$$
(3.2)

and thus

$$ \mathcal{M} \bigl\{ x(t) \bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0) }{v^{2} + \mu ^{2}}. $$

By (3.2) a function \(x_{0}: (0, \infty ) \longrightarrow \mathbb{R}\) is a solution of (1.1) if and only if

$$\begin{aligned} \bigl(v^{2}+\mu ^{2}\bigr)\mathcal{M} \{ x_{0} \} -v^{3}x_{0}(0)-v^{2}x^{\prime }_{0}(0) = 0. \end{aligned}$$

If there exist constants a and b in \(\mathbb{F}\) such that \(v^{2} + \mu ^{2} = (v-a) (v-b)\) with \(a+b = 0\) and \(ab=\mu ^{2}\), then (3.2) becomes

$$\begin{aligned} \mathcal{M}\bigl\{ x(t) \bigr\} & = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)}. \end{aligned}$$
(3.3)

Set

$$ y(t) =x(0) \biggl( \frac{a e^{at} - b e^{bt}}{a-b} \biggr) + x'(0) \biggl( \frac{ e^{at} -e^{bt}}{a-b} \biggr). $$

Then we have \(y(0) = x(0)\) and \(y'(0) = x'(0)\). Taking the Mahgoub transform of y, we obtain

$$\begin{aligned} \mathcal{M}\bigl\{ y(t)\bigr\} = \frac{v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)}. \end{aligned}$$
(3.4)

On the other hand, \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t) \} = (v^{2}+\mu ^{2}) \mathcal{M} \{ y(t) \} -v^{3}y(0)-v^{2}y'(0)\). Using (3.4), we get \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t) \} = 0\). Since \(\mathcal{M}\) is a one-to-one linear operator, we have \(y''(t) + \mu ^{2} y(t) = 0\). This means that y is a solution of (1.1). It follows from (3.3) and (3.4) that

$$\begin{aligned} &\mathcal{M}\bigl\{ x(t) \bigr\} - \mathcal{M}\bigl\{ y(t)\bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)} - \frac{v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)} = \frac{\mathcal{M} \{ p(t) \} }{(v-a) (v-b)} , \\ &\mathcal{M}\bigl\{ x(t) - y(t) \bigr\} = \mathcal{M} \biggl\{ p(t) * \biggl( \frac{ e^{at} - e^{bt}}{a-b} \biggr) \biggr\} . \end{aligned}$$

These equalities show that

$$ x(t) - y(t) = p(t) * \biggl( \frac{ e^{at} - e^{bt}}{a-b} \biggr). $$

Taking the modulus on both sides and using \(|p(t)| \leq \epsilon \), we get

$$\begin{aligned} \bigl\vert x(t)-y(t) \bigr\vert & = \biggl\vert p(t) \ast \biggl( \frac{ e^{at} - e^{bt}}{a-b} \biggr) \biggr\vert \\ & \leq \biggl\vert \int _{-\infty }^{\infty } p(u) \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert \\ & \leq \epsilon \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert \end{aligned}$$

for all \(t> 0\), where

$$ L= \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert , $$

which exists. Hence \(\vert x(t) - y(t) \vert \leq L \epsilon \). By Definition 2.2 the linear differential equation (1.1) has the Hyers–Ulam stability. This finishes the proof. □

By using the same technique as in Theorem 3.1, we can also prove the following theorem, which shows the generalized Hyers–Ulam stability of the differential equation (1.1). The method of the proof is similar, but we include it for completeness.

Theorem 3.2

The differential equation (1.1) is generalized Hyers–Ulam stable.

Proof

Let \(\epsilon >0\), and let \(\phi \in C(\mathbb{R}_{+} , \mathbb{R}_{+} )\) be an integrable function. Assume that \(x \in C^{2}(I)\) satisfies

$$\begin{aligned} \bigl\vert x''(t) + \mu ^{2} x(t) \bigr\vert \leq \epsilon \phi (t) \end{aligned}$$
(3.5)

for all \(t \in I\). We will show that there exists \(L_{ \phi } > 0\) such that \(\vert x(t) - y(t) \vert \leq L_{ \phi } \epsilon \phi (t) \) for some \(y \in C^{2}(I)\) satisfying \(y''(t) + \mu ^{2} y(t) = 0 \) for all \(t \in I\). Consider the function \(p: (0, \infty ) \rightarrow \mathbb{R}\) defined by \(p(t) =: y''(t) + \mu ^{2} y(t)\) for \(t >0 \). By (3.5) we have \(|p(t)| \leq \epsilon \phi (t) \). Now taking the Mahgoub transform of p, we have

$$\begin{aligned} \mathcal{M} \bigl\{ x(t) \bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0) }{v^{2} + \mu ^{2}}. \end{aligned}$$
(3.6)

We know that a function \(x_{0}: (0, \infty ) \rightarrow \mathbb{R}\) is a solution of (1.1) if and only if

$$\begin{aligned} \bigl(v^{2}+\mu ^{2}\bigr)\mathcal{M} \{ x_{0} \} -v^{3}x_{0}(0)-v^{2}x^{\prime }_{0}(0) = 0. \end{aligned}$$

If there exist two constants a and b in \(\mathbb{F}\) such that \(v^{2} + \mu ^{2} = (v-a) (v-b)\) with \(a+b= 0\) and \(ab=\mu ^{2}\), then (3.6) becomes

$$\begin{aligned} \mathcal{M}\bigl\{ x(t) \bigr\} & = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)}. \end{aligned}$$
(3.7)

Let \(y(t) =x(0) ( \frac{a e^{at} - b e^{bt}}{a-b} ) + x'(0) ( \frac{ e^{at} - e^{bt}}{a-b} )\). Then \(y(0) = x(0)\) and \(y'(0) = x'(0)\). Taking again the Mahgoub transform of y, we obtain

$$\begin{aligned} \mathcal{M}\bigl\{ y(t)\bigr\} = \frac{v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)}. \end{aligned}$$
(3.8)

Furthermore, \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t) \} = (v^{2}+\mu ^{2}) \mathcal{M} \{ y(t) \} -v^{3}y(0)-v^{2}y'(0)\). Thus using (3.4), we get \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t) \} = 0\), and so \(y''(t) + \mu ^{2} y (t) = 0\). Applying (3.7) and (3.8), we have

$$\begin{aligned} &\mathcal{M}\bigl\{ x(t) \bigr\} - \mathcal{M}\bigl\{ y(t)\bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)} - \frac{v^{3}x(0)+v^{2}x'(0) }{(v-a) (v-b)} = \frac{\mathcal{M} \{ p(t) \} }{(v-a) (v-b)}, \\ &\mathcal{M}\bigl\{ x(t) - y(t) \bigr\} = \mathcal{M} \biggl\{ p(t) * \biggl( \frac{ e^{at} - e^{bt}}{a-b} \biggr) \biggr\} . \end{aligned}$$

Therefore \(x(t) - y(t) = p(t) * ( \frac{ e^{at} - e^{bt}}{a-b} )\). Taking the modulus of both sides and using \(|p(t)| \leq \epsilon \phi (t)\), we get

$$\begin{aligned} \bigl\vert x(t) - y(t) \bigr\vert & = \biggl\vert p(t) * \biggl( \frac{ e^{at} - e^{bt}}{a-b} \biggr) \biggr\vert \\ & \leq \biggl\vert \int _{-\infty }^{\infty } p(u) \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert \\ & \leq \epsilon \phi (t) \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert \\ & \leq L_{\phi } \epsilon \phi (t), \end{aligned}$$

where the integral \(L_{\phi }= \vert \int _{0}^{t} ( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} ) \,du \vert \) exists for all \(t>0\), and ϕ is an integrable function. □

4 Hyers–Ulam stability for (1.2)

In this section, we investigate the Hyers–Ulam stability and generalized Hyers–Ulam stability of the differential equation (1.2). Firstly, we prove the Hyers–Ulam stability of the nonhomogeneous linear differential equation (1.2).

Theorem 4.1

The differential equation (1.2) has the Hyers–Ulam stability.

Proof

For every \(\epsilon >0\) and for each solution \(x \in C^{2}(I)\) satisfying

$$\begin{aligned} \bigl\vert x''(t) + \mu ^{2} x (t) - q(t) \bigr\vert \leq \epsilon \end{aligned}$$
(4.1)

for all \(t \in I\), we will prove that there exists \(L > 0\) such that \(\vert x(t) - y(t) \vert \leq L \epsilon \) for some \(y \in C^{2}(I)\) satisfying \(y''(t) + \mu ^{2} y(t) = q(t) \) for all \(t \in I\). The function \(p: (0, \infty ) \rightarrow \mathbb{R}\) defined by \(p(t)=: x''(t) + \mu ^{2} x(t)-q(t) \) satisfies \(|p(t)| \leq \epsilon \). Taking the Mahgoub transform of p, we have

$$\begin{aligned} \mathcal{M} \bigl\{ x(t) \bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0)+ \mathcal{M} \{q(t) \} }{v^{2} + \mu ^{2}}. \end{aligned}$$
(4.2)

Equality (4.2) shows that a function \(x_{0}: (0, \infty ) \rightarrow \mathbb{F}\) is a solution of (1.2) if and only if

$$\begin{aligned} \bigl(v^{2}+\mu ^{2}\bigr)\mathcal{M} \{ x_{0} \} -v^{3}x_{0}(0)-v^{2}x^{\prime }_{0}(0) = \mathcal{M} \bigl\{ q(t) \bigr\} . \end{aligned}$$

If there exist constants a and b in \(\mathbb{F}\) such that \(v^{2} + \mu ^{2} = (v-a) (v-b)\) with \(a+b= 0\) and \(ab=\mu ^{2}\), then (4.2) becomes

$$\begin{aligned} \mathcal{M} \bigl\{ x(t) \bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0)+ \mathcal{M} \{q(t) \} }{(s-l) (s-m)}. \end{aligned}$$
(4.3)

Set \(r(t) = \frac{ e^{at} - e^{bt}}{a-b} \) and \(y(t) =x(0) ( \frac{l e^{lt} - m e^{mt}}{l-m} ) + x'(0) r(t) + [ (r * q) (t) ]\). So, \(y(0) = x(0)\) and \(y'(0) = x'(0)\). Once more, taking the Mahgoub transform of y, we have

$$\begin{aligned} \mathcal{M}\bigl\{ y(t)\bigr\} = \frac{v^{3}x(0)+v^{2}x'(0) \mathcal{M} \{q(t) \}}{(v-a) (v-b)}. \end{aligned}$$
(4.4)

On the other hand, \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t)\} =(v^{2}+\mu ^{2})\mathcal{M} \{ y(t) \} -v^{3}y(0)-v^{2}y'(0)\). Using (4.4), the last equality becomes

$$ \mathcal{M} \bigl\{ y''(t) + \mu ^{2} y(t) \bigr\} = \mathcal{M} \bigl\{ q(t) \bigr\} . $$

Since \(\mathcal{M}\) is a one-to-one linear operator, we have \(y''(t) + \mu ^{2} y(t) = q(t)\), which shows that y is a solution of (1.2). Now relations (4.3) and (4.4) necessitate that

$$\begin{aligned} \mathcal{M}\bigl\{ x(t) - y(t) \bigr\} = \mathcal{M}\bigl\{ x(t) \bigr\} - \mathcal{M}\bigl\{ y(t) \bigr\} & = \frac{\mathcal{M} \{ p(t) \} }{(v-a) (v-b)} = \mathcal{M} \bigl\{ p(t) * r(t) \bigr\} , \end{aligned}$$

and hence \(x - y = p * r\). Taking the modulus of both sides of the last equality and using \(|p(t)| \leq \epsilon \), we get

$$\begin{aligned} \bigl\vert x(t) - y(t) \bigr\vert & = \bigl\vert p * r(t) \bigr\vert \\ & \leq \biggl\vert \int _{-\infty }^{\infty } p(u) r(t-u) \,du \biggr\vert \\ & \leq \epsilon \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert \\ & \leq K \epsilon , \end{aligned}$$

where

$$ K= \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert , $$

which exists for all \(t>0\). Therefore the linear differential equation (1.2) has the Hyers–Ulam stability. □

Analogously to Theorem 4.1, we have the following result, which shows the generalized Hyers–Ulam stability of the differential equation (1.2).

Theorem 4.2

The differential equation (1.2) has the generalized Hyers–Ulam stability.

Proof

Let \(\epsilon >0\) and \(\phi \in C(\mathbb{R}_{+} , \mathbb{R}_{+} )\). Suppose that \(x \in C^{2}(I)\) satisfies the inequality

$$\begin{aligned} \bigl\vert x''(t) + \mu ^{2} x (t) - q(t) \bigr\vert \leq \epsilon \phi (t) \end{aligned}$$
(4.5)

for all \(t \in I\). We prove there exists \(L_{\phi } > 0\) such that \(\vert x(t) - y(t) \vert \leq L_{\phi } \epsilon \phi (t) \) for some \(y \in C^{2}(I)\) satisfying \(y''(t) + \mu ^{2} y(t) = q(t) \) for all \(t \in I\). Define the function \(p: (0, \infty ) \rightarrow \mathbb{F}\) by \(p(t) := x''(t) + \mu ^{2} x(t) - q(t) \) for each \(t >0 \). By (4.5) we have \(|p(t)| \leq \epsilon \phi (t)\). Now, taking the Mahgoub transform of \(p(t)\), we get

$$\begin{aligned} \mathcal{M} \bigl\{ x(t) \bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0)+ \mathcal{M} \{q(t) \} }{v^{2} + \mu ^{2}}. \end{aligned}$$
(4.6)

In addition, in light of relation (4.6), a function \(x_{0}: (0, \infty ) \rightarrow \mathbb{F}\) is a solution of (1.2) if and only if

$$\begin{aligned} \bigl(v^{2}+\mu ^{2}\bigr)\mathcal{M} \{ x_{0} \} -v^{3}x_{0}(0)-v^{2}x^{\prime }_{0}(0) = \mathcal{M} \bigl\{ q (t)\bigr\} . \end{aligned}$$

However, (4.6) becomes

$$\begin{aligned} \mathcal{M} \bigl\{ x(t) \bigr\} = \frac{\mathcal{M} \{ p(t) \}+v^{3}x(0)+v^{2}x'(0)+ \mathcal{M} \{q(t) \} }{(s-l) (s-m)}. \end{aligned}$$
(4.7)

Assume that there exist constants a and b in \(\mathbb{F}\) such that \(v^{2} + \mu ^{2} = (v-a) (v-b)\) with \(a+b= 0\) and \(ab=\mu ^{2}\). Putting \(r(t) = \frac{ e^{at} - e^{bt}}{a-b} \) and

$$ y(t) =x(0) \biggl( \frac{a e^{at} - b e^{bt}}{a-b} \biggr) + x'(0) r(t) + \bigl[ (r * q) (t) \bigr] , $$

we easily obtain \(y(0) = x(0)\) and \(y'(0) = x'(0)\). Taking the Mahgoub transform of \(y(t)\), we have

$$\begin{aligned} \mathcal{M}\bigl\{ y(t)\bigr\} = \frac{v^{3}x(0)+v^{2}x'(0) \mathcal{M} \{q(t) \}}{(v-a) (v-b)}. \end{aligned}$$
(4.8)

Furthermore, \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t)\} =(v^{2}+\mu ^{2})\mathcal{M} \{ y(t) \} -v^{3}y(0)-v^{2}y'(0)\). Now applying (4.4), we obtain \(\mathcal{M} \{ y''(t) + \mu ^{2} y(t) \} = \mathcal{M} \{q(t) \}\). The last equality implies that \(y''(t) + \mu ^{2} y(t) = q(t)\). This means that y is a solution of (1.2). Hence, plugging (4.7) into (4.8), we obtain

$$\begin{aligned} \mathcal{M}\bigl\{ x(t) - y(t) \bigr\} = \mathcal{M}\bigl\{ x(t) \bigr\} - \mathcal{M}\bigl\{ y(t) \bigr\} & = \frac{\mathcal{M} \{ p (t)\} }{(v-a) (v-b)} = \mathcal{M} \bigl\{ p(t) * r(t) \bigr\} . \end{aligned}$$

Thus \(x - y = p * r \). Taking the modulus of both sides and using \(|p(t)| \leq \epsilon \phi (t)\), we get

$$\begin{aligned} \bigl\vert x(t) - y(t) \bigr\vert & = \bigl\vert p * r(t) \bigr\vert \\ & \leq \biggl\vert \int _{-\infty }^{\infty } p(u) r(t-u) \,du \biggr\vert \\ & \leq \epsilon \phi (t) \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-u)}}{a-b} \biggr) \,du \biggr\vert \\ & \leq L_{\phi } \epsilon \phi (t), \end{aligned}$$

where

$$ L_{\phi }= \biggl\vert \int _{-\infty }^{\infty } \biggl( \frac{ e^{a(t-u)} - e^{b(t-b)}}{a-b} \biggr) \,du \biggr\vert , $$

which exists for all \(t>0\). This completes the proof. □

5 Conclusion

In this paper, we first initiated and proposed a new method for the investigation of Hyers–Ulam stability of differential equations by using the Mahgoub transform. Also, using this new idea, we investigated the Hyers–Ulam stability of second-order homogeneous and nonhomogeneous differential equations by using the Mahgoub transform.