Elo Rating Calculator
Octave, 106 bytes

This assumes the history never contains a zero.



@(h,r,s)(h=[1e3,h])(n=nnz(h))+((40-(20*(n&gt;30)))-(10*((n&gt;30)&amp;(max(h)&gt;2401))))*(s-(1/(1+10^((r-h(n))/400))))


This outputs (after some formatting):

Correct - Calculated
1038    - 1037.87
1705    - 1705.3
2497    - 2496.51


Try it online!



Note: According to the FIDE-scoring system: If you play 41 games against a player having a score of 5000 (more than 2000 points higher than the highest achieved score ever), you'll end up with a score of 2400. I believe that fewer scores than 30, and a maximum score higher than 2400 should be considered invalid input (but that's OP's decision).

Check it here