Gradient
Lesson 1.2Code~50 min

Functions: little machines

Inputs in, output out. Write functions, make them decide, and compose them.

Module 1 · 0/8 done

Little machines

A function is a machine with a rule inside. You drop an input in, it applies the rule, and an output comes out. Same input, same output, every time.

input3
the machinef(x)=2x+1f(x) = 2x + 1x => 2 * x + 1
output7
Fig 1.2Pick a machine and feed it different inputs. The rule never changes — only what goes in.

Mathematicians write this as f(x)=2x+1f(\blue{x}) = 2\blue{x} + 1: “the function called f, given x, gives back 2 times x plus 1”. It’s exactly the same idea in code — and it’s the single most important idea in this course, because a machine-learning model is just a function whose rule was learned instead of written.