What's the difference between a relation and a function?
Every time you check a weather app, you're looking at a function in action , one specific time of day maps to one specific temperature reading. But imagine if 3:00 PM gave you two different temperatures simultaneously. That would be useless, and mathematically, it would mean the app is showing you a relation, not a function.
A relation is any rule or collection of pairings that connects values from one set (the inputs) to values from another set (the outputs). You can think of it like a group chat where anyone can message anyone , there are no restrictions on who replies to whom. Formally, a relation is written as a set of ordered pairs , where is an input and is the corresponding output.
Relation: A collection of ordered pairs that associates elements from an input set with elements of an output set, with no restriction on how many outputs a single input may have.
A function is a relation with one strict rule attached: every input is allowed to produce exactly one output , no exceptions. It's the difference between a vending machine where pressing B3 always gives you the same snack, versus a broken one where B3 sometimes gives crisps and sometimes gives chocolate.
Function: A relation in which every input value has one and only one corresponding output value.
The counterintuitive part? Multiple inputs can share the same output and it's still a function. What's forbidden is one input producing two different outputs.
7 more sections in this topic
Pick this up in your Library: it holds the whole topic, notes, cheatsheet and questions.