Step 1: Understanding the Concept
For the function $f(x)$ to be a surjection (or an onto function) from a domain $D$ to the codomain $\mathbb{R}$, its range must be equal to the codomain $\mathbb{R}$.
Step 2: Key Formula or Approach
Let $y = f(x)$. We will express $x$ in terms of $y$. Since $x$ must be a real number, the discriminant of the resulting quadratic equation in $x$ must be non-negative ($D \ge 0$). This will give us an inequality in $y$, which defines the range of the function. For the function to be surjective onto $\mathbb{R}$, this inequality must hold true for all $y \in \mathbb{R}$.
Step 3: Detailed Explanation
Let $y = f(x) = \frac{x^2+x+a}{x^2-x+a}$.
To find the range, we rearrange the equation to form a quadratic in $x$:
\[ y(x^2 - x + a) = x^2 + x + a \]
\[ yx^2 - yx + ya = x^2 + x + a \]
\[ (y-1)x^2 - (y+1)x + (ya-a) = 0 \]
\[ (y-1)x^2 - (y+1)x + a(y-1) = 0 \]
For $x$ to be a real number, the discriminant of this quadratic equation must be greater than or equal to zero.
The discriminant $D_x = b^2 - 4ac \ge 0$.
\[ (-(y+1))^2 - 4(y-1)(a(y-1)) \ge 0 \]
\[ (y+1)^2 - 4a(y-1)^2 \ge 0 \]
For the function to be a surjection onto $\mathbb{R}$, this inequality must be true for all $y \in \mathbb{R}$.
Let's expand the inequality:
\[ (y^2 + 2y + 1) - 4a(y^2 - 2y + 1) \ge 0 \]
\[ y^2 + 2y + 1 - 4ay^2 + 8ay - 4a \ge 0 \]
\[ (1-4a)y^2 + (2+8a)y + (1-4a) \ge 0 \]
This is a quadratic expression in $y$. For this expression to be non-negative for all real values of $y$, two conditions must be met:
1. The coefficient of $y^2$ must be positive: $1 - 4a>0$.
2. The discriminant of this quadratic in $y$, let's call it $D_y$, must be less than or equal to zero: $D_y \le 0$.
From condition 1:
\[ 1 - 4a>0 \implies 1>4a \implies a<\frac{1}{4} \]
From condition 2:
\[ D_y = (2+8a)^2 - 4(1-4a)(1-4a) \le 0 \]
\[ (2(1+4a))^2 - 4(1-4a)^2 \le 0 \]
\[ 4(1+4a)^2 - 4(1-4a)^2 \le 0 \]
\[ (1+4a)^2 - (1-4a)^2 \le 0 \]
Using the difference of squares formula, $A^2 - B^2 = (A-B)(A+B)$:
\[ ((1+4a) - (1-4a))((1+4a) + (1-4a)) \le 0 \]
\[ (1+4a-1+4a)(1+4a+1-4a) \le 0 \]
\[ (8a)(2) \le 0 \]
\[ 16a \le 0 \implies a \le 0 \]
To satisfy both conditions, we need to find the intersection of $a<\frac{1}{4}$ and $a \le 0$.
The intersection is $a \le 0$.
Let's check the boundary case $a=0$.
If $a=0$, $f(x) = \frac{x^2+x}{x^2-x} = \frac{x(x+1)}{x(x-1)} = \frac{x+1}{x-1}$ (for $x \ne 0$).
Let $y = \frac{x+1}{x-1} \implies y(x-1) = x+1 \implies yx-y = x+1 \implies x(y-1) = y+1 \implies x = \frac{y+1}{y-1}$.
The range is all real numbers except $y=1$. So, the range is $\mathbb{R} - \{1\}$, which is not $\mathbb{R}$. Hence $a \ne 0$.
So, we must have $a<0$.
Step 4: Final Answer
The condition for the function to be a surjection onto $\mathbb{R}$ is $a<0$.
Therefore, '$a$' lies in the interval $(-\infty, 0)$.