1 Introduction

The question concerning the stability of functional equations has been originally raised by Ulam [1]: Given a metric group \((G, \cdot, d)\), a positive number ε, and a function \(f : G \to G\) that satisfies the inequality \(d ( f(xy), f(x)f(y) ) \leq\varepsilon\) for all \(x, y \in G\), do there exist an homomorphism \(a : G \to G\) and a constant δ depending only on G and ε such that \(d ( a(x), f(x) ) \leq\delta\) for all \(x \in G\)?

If the answer to this question is affirmative, then the functional equation \(a(xy) = a(x)a(y)\) is said to be stable. A first answer to this question was given by Hyers [2] in 1941, who proved that the Cauchy additive equation is stable in Banach spaces. In general, a functional equation is said to be stable in the sense of Hyers and Ulam (or the equation has the Hyers-Ulam stability) if for each solution to the perturbed equation, there exists a solution to the equation that differs from the solution to the perturbed equation with a small error. We recommend the reader to refer [3] for the exact definition of Hyers-Ulam stability and an excellent survey on that subject.

After Hyers’ result, mathematicians extended and generalized Hyers’ theorem in various directions. Aoki [4] and Rassias [5] provided a generalization of the Hyers theorem for additive and linear mappings, respectively. Găvruţa [6] generalized it by considering a general control function instead of ε.

Obloza [7, 8] investigated the Hyers-Ulam stability for the linear differential equations. Thereafter, Alsina and Ger [9] considered a differentiable function \(f : I \to{\mathbf{R}}\) that satisfies the differential inequality \(| y'(t) - y(t) | \leq\varepsilon\) and proved that there exists a solution \(f_{0} : I \to{\mathbf{R}}\) of the differential equation \(y'(t) = y(t)\) such that \(| f(t) - f_{0}(t) | \leq3\varepsilon\) for any \(t \in I\). In this paper, we prove that \(| f(t) - f_{0}(t) | \leq\varepsilon\) for any \(t \in I\). So, our result is a better estimation. Miura et al. [10, 11], Takahasi et al. [12, 13], and Jung [14] also generalized their results.

Furthermore, the Hyers-Ulam stability for the nonhomogeneous linear differential equations of the form \(y'(t) + g(t)y(t) + h(t) = 0\) has been investigated by many mathematicians (see [13, 1518]).

In particular, Wang et al. [18] used the method of integrating factor to prove the Hyers-Ulam stability of the nonhomogeneous linear differential equations of the form

$$ p(t)y'(t) - q(t)y(t) - r(t) = 0. $$
(1)

Proposition 1.1

([18])

Let \(I = (a,b)\) be an interval with \(-\infty\leq a < b \leq\infty\). Assume that \(p, q, r : I \to{\mathbf{R}}\) are continuous real functions such that \(p(t) \neq0\) and \(| q(t) | \geq\mu\) for all \(t \in I\) and some constant \(\mu> 0\). If a continuously differentiable function \(y : I \to{\mathbf{R}}\) satisfies the differential inequality

$$ \bigl\vert p(t)y'(t) - q(t)y(t) - r(t) \bigr\vert \leq\varepsilon\quad \textit{for all } t \in I, $$
(2)

then there exist a constant \(K > 0\) and a solution \(z : I \to{\mathbf{R}}\) of differential equation (1) such that

$$ \bigl\vert y(t) - z(t) \bigr\vert \leq K \varepsilon \quad \textit{for all } t \in I, $$
(3)

where K is called a Hyers-Ulam constant.

In the proof of the proposition, Wang et al. assumed that \(|q(t)| \geq1\) by saying without the loss of generality. Indeed, their proof is just for the case of \(|q(t)| \geq1\), and they said nothing about general cases. In this paper, we clearly generalize their assumption for the proof.

It seems that in Proposition 1.1, Wang et al. denoted a Hyers-Ulam constant K as \(2\exp \{ |\int_{a}^{b}\frac{q(s)}{p(s)}\,ds | \}-1\). In this case, the constant K is very big when \(b-a\) is a big number. Here, we find a Hyers-Ulam constant K that is independent of a and b.

After we introduce two examples, we will prove that, under the same assumptions of Proposition 1.1, we have a Hyers-Ulam constant K in (3) equal to \(\frac{1}{\mu}\), where μ is a lower bound of the function \(|q(t)|\).

2 Motivation

In this section, we assume that a and b are given real numbers with \(a < b\). Before we prove our main theorem, in the following two examples, we will see the reason why we try to obtain our main theorem.

Example 2.1

Let us consider the inequality

$$ \biggl\vert y'(t) - \bigl( 1 + e^{-t} \bigr) y(t) + \frac{3}{2} \biggr\vert < 1 =: \varepsilon, $$
(4)

where \(p(t) = 1\), \(q(t) = 1 + e^{-t} \geq1\), and \(r(t) = -\frac{3}{2}\). Then the function \(y(t) = e^{t}\) satisfies

$$ \biggl\vert y'(t) - \bigl( 1 + e^{-t} \bigr) y(t) + \frac{3}{2} \biggr\vert = \frac{1}{2} < 1 = \varepsilon. $$

The general solution of the differential equation \(z'(t) - ( 1 + e^{-t} ) z(t) + \frac{3}{2} = 0\) is of the form \(z(t) = c \exp\{ -e^{-t} + t \} + \frac{3}{2} e^{t}\). Therefore, we have

$$ \bigl\vert y(t) - z(t) \bigr\vert = \biggl\vert \frac{1}{2} e^{t} + c \exp \bigl\{ -e^{-t} + t \bigr\} \biggr\vert < 1 = \varepsilon \quad \mbox{for all } t \in(a,b) $$
(5)

if and only if

$$ \biggl( \frac{-1}{e^{t}} - \frac{1}{2} \biggr) \exp \bigl\{ e^{-t} \bigr\} < c < \biggl( \frac{1}{e^{t}} - \frac{1}{2} \biggr) \exp\bigl\{ e^{-t} \bigr\} \quad \mbox{for all } t \in(a,b). $$
(6)

Now, an upper bound of the left side of (6) is \(- ( \frac{1}{e^{b}} + \frac{1}{2} ) \exp\{ e^{-b} \}\), and a lower bound of the right side of (6) is \(( \frac{1}{e^{b}} - \frac{1}{2} ) \exp\{ e^{-b} \}\). So, for any \(b \in{\mathbf{R}}\), we can find a constant \(c \in{\mathbf{R}}\) such that

$$ - \biggl( \frac{1}{e^{b}} + \frac{1}{2} \biggr) \exp \bigl\{ e^{-b} \bigr\} < c < \biggl( \frac{1}{e^{b}} - \frac{1}{2} \biggr) \exp \bigl\{ e^{-b} \bigr\} . $$
(7)

If we choose a constant c satisfying (7), then it follows from (5) and (6) that

$$ \bigl\vert y(t) - z(t) \bigr\vert < 1 \quad \mbox{for all } t \in(a,b). $$

Hence, we may expect to have a Hyers-Ulam constant less than that in Proposition 1.1. Meanwhile, if we use the estimation in Proposition 1.1 for Example 2.1, then we have

$$ K := 2 \exp \biggl\{ \biggl\vert \int_{a}^{b} \frac{q(s)}{p(s)}\, ds \biggr\vert \biggr\} - 1 > 2 e^{b-a} - 1 > 1\quad \mbox{for any } a, b \in{ \mathbf{R}}, $$
(8)

so that the left side of (8), the Wang estimation, goes to ∞ as \(b-a\) goes to ∞, whereas our estimation is expected to be bounded as we see in Theorem 3.1.

Example 2.2

Let us consider the inequality

$$ \bigl\vert y^{\prime}(t) - \delta y(t) \bigr\vert \leq1 =: \varepsilon\quad \mbox{for a small } \delta> 0. $$
(9)

Then the function \(y(t) = -\frac{1}{\delta} + \frac{1}{\delta} e^{\delta t}\) satisfies inequality (9). The general solution of the differential equation \(z^{\prime}(t) - \delta z(t) = 0\) is of the form \(z(t) = ce^{\delta t}\) for some constant c. So, we have

$$ \bigl\vert y(t) - z(t) \bigr\vert = \biggl\vert \biggl( c - \frac{1}{\delta} \biggr) e^{\delta t} + \frac{1}{\delta} \biggr\vert \geq \frac{1}{\delta} \quad \mbox{if } c \geq\frac{1}{\delta}. $$

Therefore, if K is a constant such that \(0 < K < \frac{1}{\delta}\), then there is no solution of \(z^{\prime}(t) - \delta z(t) = 0\) that satisfies

$$ \bigl\vert y(t) - z(t) \bigr\vert \leq K = K \varepsilon,\quad \mbox{where } c \geq\frac{1}{\delta}. $$

Hence, if there exists a constant \(K < \frac{1}{\delta}\) such that

$$ -K < z(t) - y(t) = \biggl( c - \frac{1}{\delta} \biggr) e^{\delta t} + \frac{1}{\delta} < K \quad \mbox{for all } t \in(a,b), $$

then we should have \(c - \frac{1}{\delta} < 0\). In this case, it follows from the last inequality that

$$ - \biggl( K + \frac{1}{\delta} \biggr) e^{-\delta t} < c - \frac{1}{\delta} < \biggl( K - \frac{1}{\delta} \biggr) e^{-\delta t} < 0 \quad \mbox{for all } t \in(a,b). $$

This means that we should have c such that

$$ - \biggl( K + \frac{1}{\delta} \biggr) e^{-\delta b} \leq c - \frac{1}{\delta} \leq \biggl( K - \frac{1}{\delta} \biggr) e^{-\delta a} < 0, $$

which implies

$$ \biggl( K - \frac{1}{\delta} \biggr) e^{-\delta a} \geq- \biggl( K + \frac{1}{\delta} \biggr) e^{-\delta b}, $$

where \(K < \frac{1}{\delta}\). So, we have

$$ \frac{1}{\delta} > K \geq\frac{1}{\delta} \frac{e^{-\delta a} - e^{-\delta b}}{ e^{-\delta a} + e^{-\delta b}} \nearrow\frac{1}{\delta} \quad \mbox{as } b-a \to\infty. $$
(10)

Therefore, a Hyers-Ulam constant K that is independent of a and b might be less than \(\frac{1}{\delta}\). However, by our main theorem in the next section we will see that \(K := \frac{1}{\delta}\) is the optimal Hyers-Ulam constant, which is a better estimation than that in [9].

3 Main theorem

In this section, let \(I = (a,b)\) be an arbitrary interval, where \(-\infty\leq a < b \leq\infty\). Now, we are in the position to introduce our main theorem.

Theorem 3.1

Let \(p, q, r : I \to{\mathbf{R}}\) be continuous real functions such that \(p(t) \neq0\) and \(| q(t) | \geq\mu\) for all \(t \in I\) and some \(\mu> 0\). Moreover, assume that \(\frac{q(t)}{p(t)}\) and \(\frac{r(s)}{p(s)} \exp \{ -\int_{a}^{s} \frac{q(u)}{p(u)} \, du \}\) are integrable on \((a,c)\) for each \(c \in I\). If a continuously differentiable function \(y : I \to{\mathbf{R}}\) satisfies the differential inequality (2) for all \(t \in I\), then there exists a solution \(z : I \to{\mathbf{R}}\) of the differential equation (1) such that

$$ \bigl\vert y(t) - z(t) \bigr\vert \leq\frac{\varepsilon}{\mu}\quad \textit{for all } t \in I. $$
(11)

Proof

We use the method of integrating factor of Wang et al. [18].

Case 1: Assume that \(p(t) > 0\) and \(q(t) \geq\mu> 0\). In view of (2), we have

$$ -\varepsilon\leq p(t)y'(t) - q(t)y(t) - r(t) \leq\varepsilon\quad \mbox{for all } t \in I. $$

Multiplying the formula by \(\frac{1}{p(t)} \exp\{ -\int^{t}_{a} \frac{q(s)}{p(s)}\, ds \}\), we get

$$\begin{aligned}& {-\frac{\varepsilon q(t)}{\mu p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} } \\& \quad \leq \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} y'(t) - \frac{q(t)}{p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} y(t) -\frac{r(t)}{p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} \\& \quad \leq \frac{\varepsilon q(t)}{\mu p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} \quad \mbox{for all } t \in I. \end{aligned}$$
(12)

Since y is continuous, we can choose \(t_{0} \in I\) such that \(y(t_{0})\) is finite. For any \(t \in I\), integrating (12) from \(t_{0}\) to t and then multiplying by \(\exp \{ \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \}\), we get

$$\begin{aligned}& {-\frac{\varepsilon}{\mu} \biggl\vert 1 - \exp \biggl\{ \int_{t_{0}}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \biggr\vert } \\& \quad \leq y(t) - \exp \biggl\{ \int_{t_{0}}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} y(t_{0}) \\& \qquad {} -\exp \biggl\{ \int_{a}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \int_{t_{0}}^{t} \frac{r(s)}{p(s)} \exp \biggl\{ - \int_{a}^{s} \frac{q(u)}{p(u)} \,du \biggr\} \,ds \\& \quad \leq \frac{\varepsilon}{\mu} \biggl\vert 1 - \exp \biggl\{ \int_{t_{0}}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \biggr\vert \quad \mbox{for all } t \in I. \end{aligned}$$
(13)

Since \(\int_{t_{0}}^{b} \frac{q(s)}{p(s)} \,ds \to0\) as \(t_{0} \to b\), we can choose \(t_{0} \in I\) such that \(\int_{t_{0}}^{b} \frac{q(s)}{p(s)} \,ds < \ln2\). Therefore, by (13) we obtain

$$\begin{aligned}& \biggl\vert y(t) - y(t_{0}) \exp \biggl\{ \int_{t_{0}}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \\& \qquad {}-\exp \biggl\{ \int_{a}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \int_{t_{0}}^{t} \frac{r(s)}{p(s)} \exp \biggl\{ - \int_{a}^{s} \frac{q(u)}{p(u)} \,du \biggr\} \,ds \biggr\vert \\& \quad \leq \frac{\varepsilon}{\mu} \quad \mbox{for all } t \in I. \end{aligned}$$
(14)

If we define the function \(z : I \to{\mathbf{R}}\) by

$$\begin{aligned} z(t) := & y(t_{0}) \exp \biggl\{ \int_{t_{0}}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \\ &{} +\exp \biggl\{ \int_{a}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \int_{t_{0}}^{t} \frac{r(s)}{p(s)} \exp \biggl\{ - \int_{a}^{s} \frac{q(u)}{p(u)} \,du \biggr\} \,ds, \end{aligned}$$
(15)

then inequality (14) implies the validity of (11). Moreover, it is easy to see that z is a solution of the differential equation (1).

Case 2: Let \(p(t) > 0\) and \(q(t) \leq-\mu< 0\). In this case, we have \(\frac{-q(t)}{\mu} \ge1\). Then, instead of (12), we have the inequality

$$\begin{aligned}& {\frac{\varepsilon q(t)}{\mu p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} } \\& \quad \leq \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} y'(t) - \frac{q(t)}{p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} y(t) \\& \qquad {} -\frac{r(t)}{p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} \\& \quad \leq -\frac{\varepsilon q(t)}{\mu p(t)} \exp \biggl\{ - \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \biggr\} \quad \mbox{for all } t \in I. \end{aligned}$$

Then, we can choose \(t_{0} \in I\) such that \(y(t_{0})\) is finite. For each \(t \in I\), we integrate the last inequality from \(t_{0}\) to t and then multiply by \(\exp \{ \int^{t}_{a} \frac{q(s)}{p(s)} \,ds \}\) to obtain inequality (13) for all \(t \in I\).

Since \(\int_{a}^{t_{0}} ( -\frac{q(s)}{p(s)} ) \,ds \to0\) as \(t_{0} \to a\), we can choose \(t_{0} \in I\) such that \(\int_{a}^{t_{0}} ( -\frac{q(s)}{p(s)} ) \,ds < \ln2\). Similarly as in Case 1, by using (13) we obtain

$$\begin{aligned}& \biggl\vert y(t) - y(t_{0}) \exp \biggl\{ \int_{t_{0}}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \\& \quad -\exp \biggl\{ \int_{a}^{t} \frac{q(s)}{p(s)} \,ds \biggr\} \int_{t_{0}}^{t} \frac{r(s)}{p(s)} \exp \biggl\{ - \int^{s}_{a} \frac{q(u)}{p(u)} \,du \biggr\} \,ds \biggr\vert \\& \quad \leq \frac{\varepsilon}{\mu} \quad \mbox{for all } t \in I. \end{aligned}$$
(16)

If we define the function \(z : I \to{\mathbf{R}}\) by formula (15), then z is a solution of the differential equation (1), and (16) implies the validity of (11).

Case 3: For the cases \(p(t) < 0\), \(q(t) \geq\mu> 0\) and \(p(t) < 0\), \(q(t) \leq-\mu< 0\), we can prove our assertion by similar calculations. □

Remark 3.2

In Theorem 3.1, the right side of (11) is the optimal Hyers-Ulam constant, which is independent of the interval \((a,b)\) for \(a, b \in{\mathbf{R}}\). This means that there is no α, \(0 < \alpha< 1\), such that (11) becomes

$$ \bigl\vert y(t) - z(t) \bigr\vert \leq\alpha \frac{\varepsilon}{\mu}\quad \mbox{on any interval } (a,b). $$
(17)

In (10) of Example 2.2 with \(\mu= \delta\), if we have

$$ \frac{1}{\delta} > \biggl( K = \frac{\alpha}{\mu} = \biggr) \frac{\alpha}{\delta} > \frac{1}{\delta} \frac{e^{-\delta a} - e^{-\delta b}}{ e^{-\delta a} + e^{-\delta b}}, $$

then we should have \(b-a < \frac{1}{\delta} \ln\frac{1 + \alpha}{1 - \alpha}\). So, we cannot have (17) if \(b-a > \frac{1}{\delta} \ln\frac{1 + \alpha}{1 - \alpha}\). Hence, our Hyers-Ulam constant is an optimal Hyers-Ulam constant for any interval \((a,b)\) with \(a, b \in{\mathbf{R}}\).