The error of an estimate or prediction is its deviation from the true value, which may be unobservable (e.g., regression parameters), or observable (e.g., future realizations). Use the [error-message] tag to ask about software errors.
In statistics and optimization, statistical errors and residuals are two closely related and easily confused measures of the deviation of an observed value of an element of a statistical sample from its "theoretical value". The error of an observed value is the deviation of the observed value from the (unobservable) true function value, while the residual of an observed value is the difference between the observed value and the estimated function value.
The distinction is most important in regression analysis, where it leads to the concept of studentized residuals.
Reference: Wikipedia.