What is the exact mathematical relationship between the p-values and t-stat/degrees of freedom? Let's say, for whatever ungodly reason, I want to precisely calculate p-values by hand, without looking up tables for approximate values.
What is the exact specific formula for arriving at a p-value, given a t-stat and degrees of freedom?

Let $X\sim t_{df}$ be a t-distributed random variable with degrees of freedom $df$, and let $F_X(x)$ be the CDF of $X$.
A p-value comes from evaluating $F$ at the t-stat $t$: $F_X(t)$. We the either take that value as the p-value, subtract that value from $1$, double that value (two-sided), or subtract that value from $1$ and then double the difference (two-sided).
$$F_X(t)\\
1-F_X(t)\\
2F_X(t)\\
2(1-F_X(t))
$$
Unfortunately, there is not an analytic expression for $F_X(x)$, so we would obtain these values by calculating them in software (such as the pt function in R), consulting a table, or doing numerical integration with pencil and paper.
