Rather than guessing weights and checking the error, there's a direct formula for the best possible w: the normal equations.