───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───

A function is a special relationship from 𝐴 to 𝐵, where 𝐴 and 𝐵 are both sets, where elements of 𝐴 relate to exactly one element of 𝐵.

Each element in the domain (set 𝐴) maps to at least one element in the codomain (set 𝐵). No element in the domain can be mapped to more than one element in the codomain.

Terms

  • Domain → the values that 𝑥 can be in 𝑓(𝑥)=𝑦
  • Codomain → the set of values 𝑦 that can be in 𝑓(𝑥)=𝑦
  • Range → all values of 𝑦 that 𝑓(𝑥)=𝑦 produces for a given 𝑥

Examples

  • Valid Function → 𝑓:BankAccountNumberBankAccountInfo
  • Invalid Function → 𝑓:°F°C±5

Total Functions

  • Also known as “defined everywhere functions”
  • Every element in the domain is mapped to an element in the codomain, such as
  • Total Function → 𝑓(𝑥)=𝑥2 (𝑓:)
  • Partial Function → 𝑓(𝑥)=1𝑥 (𝑓:) → only defined for 0, not

Onto Function

  • Every element in the codomain is mapped to at least one element in the domain

One to One Function

  • Every element in the codomain is mapped to at most one element in the domain

Inverse of a Function

  • A function 𝑓 is invertible if and only if 𝑓 is both one-to-one and onto.
    • Given 𝑦, one can deduce 𝑥
  • 𝑓(𝑥)=𝑥+2𝑓1(𝑦)=𝑦2
    • 𝑓(5)=5+2=7𝑓1(7)=72=5

One Way Function

  • Given 𝑦, one cannot deduce 𝑥

Hashing Functions

  • Encryption can be decrypted (two-way function)
  • Hashed passwords cannot be decrypted (one-way function)

Function Composition

  • Functions can be combined/nested with the syntax 𝑓(𝑔(𝑥)) or (𝑓𝑔)(𝑥)
  • 𝑔(𝑓(𝑥)):𝐴𝐶,𝑓(𝑥):𝐴𝐵,𝑔(𝑥):𝐵𝐶

───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───