To what extent can values of $n$ such that $n^2-n+41$ is composite be predicted?

For any $p$, $E(x+p) \equiv E(x)\mod p$. Moreover, $E(x) - E(y) = (x-y)(x+y-1)$. If $p < 41$, $E(x)$ is not divisible by $p$ for $0 \le x \le 40$, so $E(x)$ is never divisible by $p$. Thus $E(x)$ is never divisible by a prime $< 41$. For moderately sized integers, that rules out a lot of the composites.

On the other hand, if $p = E(b)$, then $E(a p + b) \equiv E(b) \equiv 0 \mod p$. That's your $f_1(a,b)$. Since $E(x) - E(y) = (x- y)(x + y - 1)$, if $p = E(b)$ is prime the only other $x < p$ for which $E(x) \equiv 0 \mod p$ is $p + 1 - b$, and then also $E(a p + 1 - b) \equiv 0 \mod p$. Note that $p + 1 - b = f_1(1,b-1)$, $2p + 1 - b = f_3(1,b-1)$, and $3p + 1 - b = f_4(2, b-1)$. I don't see how to get $4 p + 1 - b$ from your polynomials though. For example, how do you account for $E(594) = 151 \times 2333$, where $594 = 4 E(11) - 10$?


I was able to derive your $f_2(a,b)$ (and a new polynomial) as follows. Suppose we look for $f(b) = c_2 b^2 + c_1 b + c_0$ such that $E(f(b))$ is divisible by $e_2 b^2 + e_0$ (as polynomials in $b$ with coefficients in the field generated by the parameters) . The remainder on division of $E(f(b))$ by $e_2 b^2 + e_0$ is $$ {\frac {c_{{1}} \left( 2\,e_{{2}}c_{{0}}-e_{{2}}-2\,e_{{0}}c_{{2}} \right) b}{e_{{2}}}}+{\frac {41\,{e_{{2}}}^{2}+{e_{{0}}}^{2}{c_{{2}}} ^{2}+{e_{{2}}}^{2}{c_{{0}}}^{2}-e_{{0}}e_{{2}}{c_{{1}}}^{2}-{e_{{2}}}^ {2}c_{{0}}-2\,e_{{0}}e_{{2}}c_{{2}}c_{{0}}+e_{{0}}e_{{2}}c_{{2}}}{{e_{ {2}}}^{2}}}$$

Solving for the coefficients of this to be 0, the solution Maple provides that doesn't involve irrationals is $$c_0 = \frac{1}{2} + \frac{163 c_2}{4 c_1^2}, \ e_0 = \frac{163 e_2}{4 c_1^2}$$

One possibility is for $c_2$ to be a multiple of $c_1^2$: considering the first equation mod 4, we get $c_1 = s$, $c_2 = (4 t + 2) s^2$, $c_0 = 82 + 163 t$. The result is $f(b) = (4t + 2) (s b)^2 + sb + 82 + 163 t$, where $E(f(b))$ is divisible by $4 b^2 + 163$. With $t=a$ and $s=-1$ this is your $f_2(a,b)$. Note that $s=-1$ is no loss of generality since $f(b)$ depends on $b$ only through $sb$.

The other possibility is for $c_2$ to be a multiple of $163 s^2$: we get $c_1 = 163 s$, $c_2 = 163 (4t + 2) s^2$, $c_0 = t+1$. The result is $f(b) = 163 (4 t + 2) (sb)^2 + 163 sb + t + 1$, where $E(f(b))$ is divisible by $1 + 652 (sb)^2$.
Again we may take $s=1$. This case includes $n = 490$ (for $t=0,b=1$), $n=817$ (for $t=1,b=-1$), and $n=979$ (for $t=0, b=-2$).


Maybe we should separate two parts of the problem.

a) for what quadratic polynomials $f(b)$ with rational coefficients does $E(f(b))$ have a quadratic factor?

b) when does $f(b)$ from (a) take integers to integers?

For a) the general answer appears to be

$$f(b) =c_2 b^2 + c_1 b + \frac{1}{2} - \frac{d^4 - c_1^2 d^2 - 163 c_2^2}{4 c_2 d^2} $$

for arbitrary rational $d, c_1, c_2$ such that $c_2 d \ne 0$. This includes as special cases $f_1(a,b)$ with $d=1, c_1 = 1-a, c_2 = a$, $f_2(a,b)$ with $d=1, c_1 = -1, c_2 = 4a+2$, $f_3(a,b)$ with $d=1, c_1 = 1+a-a^2, c_2 = (a+1) a$, $f_4(a,b)$ with $d=1, c_1 =\frac{2+3a-a^2}{2}, c_2 = \frac{a^2+a}{2}$, and my previous answer $c_2 b^2 + c_1 b + \frac{1}{2} + \frac{163 c_2}{4 c_1^2}$ with $d=c_1$.

For (b) we need $\frac{1}{2} - \frac{d^4 - c_1^2 d^2 - 163 c_2^2}{4 c_2 d^2}$ to be an integer and $c_1$ and $c_2$ either both integers or both half-odd-integers. I don't know the general solution to this one.