A logic gate is a physical device or theoretical concept that performs a Boolean function, operating on binary inputs to produce binary outputs based on a set of logic rules. A function in mathematics is a relation between a set of inputs and outputs, where each input is related to exactly one output, and can involve a broader range of operations and complexities, not limited to binary values.