# Difference between “empirical” and “theoretical” explained variance in PCA

In prcomp library in R for instance, the "empirical" and "theoretical" explained variances for PCA are given by:

res.pca = prcomp(X, center = TRUE)
res.pca$x[,-1] = 0 var.empirical = (1 - sum( (res.pca$x %*% t(res.pca$rotation) - X)**2 ) / sum(X**2))*100 var.theoretical = (1 - (res.pca$sdev[1]**2 / sum(res.pca\$sdev**2)))*100


I would like to understand the difference between the two quantities and which one does PCA tries to optimize. Could anyone help me here please?