How To Write A Linear Cost Function