I was able to find it myself: tan(x) > x 1169809367327212570704813632106852886389036911
I didn't give a proof though. Thus, I don't yet belive that it's smallest.
I was only checked everything up to 10^12 I guess (because precision loss may have issues, need to recheck). Everything beyond is under question.
Here is how I checked everything up to 10^12 (precision issues put aside).
I built up to MAXT = 10^7 remainders of whole numbers by pi. Then, iterating over segments of size MAXT:
[0, MAXT-1], [MAXT, MAXT*2 - 1]...
knowing that every number in the segment is beginning of segment + i from range 0 to MAXT-1, this means that I need to find number that has remainder close to pi/2, so I need to find:
beginning + x = pi/2 (mod pi)
rearranging you have x = pi/2-beginning (mod pi)
then you do binnary search and you find closest to pi/2 value.
Then because you have everything sorted, you just need to iterate from it downwards and search while tan(x) is greater that beginning of range.
Here is the code:
https://gist.github.com/realmonster/fa760625327db51528bc32c69fc6afad
It works up to 3083975227, even though tan values are wrong. Next number that it shows is 45190661509 is wrong because of wrong tan. And, because I have issues with precision of tan(), I did change it to gmp and it was able to find next one 902209779836. Which is approximately 9*10^11 (almost 10^12).
I let it to search until 9*10^18 (approximate limit of int64) because I didn't know how far we go. I don't show code because it's mess.
And, parallely I tried to use idea that it's closest to pi/2 but disregarding any other numbers that also may be close. So I represented equation as follows:
n - pi/2 -> m*pi
(where -> means tending to, close to)
rearrange
n - pi/2 - m * pi -> 0
enclose into brackets
n - pi*(1/2 + m) -> 0
n -> pi*(1/2 + m)
divide
n/(1/2 + m) -> pi
multiply numerator and denominator by 2:
2n/(1 + 2m) -> pi
Then, I used so called Stern–Brocot tree which I learned recently (few months ago).
And using it, I was generating all rations close to pi.
Then I was filtering only fractions that has even numerator and odd denominator. Then comparing n to tan(n) and output list of numbers. First prime among them was 1169809367327212570704813632106852886389036911.
How did I check for primes? I was using numberempire site. Also then verified by "is 1169809367327212570704813632106852886389036911 prime?" query on wolphram alpha. I have no idea how to verify it in other way.
Source of solution with tree:
https://gist.github.com/realmonster/c423b6a160dc34422653b12db9e51f85
run it with input 1000 1000
First number is precision, second number is number of fractions. I put output of it also there.
Now, the issue: It doesn't check any 2n/(2m+1) non-closest to pi fraction. Or may be I don't understand something. In other words: why you shouldn't search in fractions that are in same level of tree but a bit more left / right? This fraction is closest, but its numerator is bad (not prime) or wrong parity of numerator denominator, why not to check other? I don't know.