A string with exactly one meaning
Type 3 + 4 * 2 ** 2 into a Python prompt and into a JavaScript console. Both say 19. Not 196, not 49, but 19, every time, on every machine.
That agreement is not luck. It’s a grammar. And the grammar you half-remember as “PEMDAS” is the exact same thing a programming language uses to read your code.
Precedence is a parser
“Order of operations” gets taught as a slogan. Drop the slogan. Here is what it actually is: a set of precedence rules that take a flat string of symbols and decide, with no ambiguity, what groups with what.
Exponents bind tighter than and ; those bind tighter than and . “Binds tighter” means “groups first.” It’s the same precedence table printed in the C language reference. And the point of all of it is a single guarantee: every well-formed expression has exactly one value.
The shape behind the string
That grouping has a shape, a tree. Operators are the branch points; numbers are the leaves. The expression parses to a tree with at the root, on one side, and the whole subtree on the other.
Type an expression. The widget parses it into its tree, the same parse a JavaScript engine performs. Move the parentheses and watch the tree re-shape. The string is just the tree, flattened onto one line so it fits on a page.
Evaluating is climbing the tree
To get the value, you climb from the leaves upward. A branch can’t compute until both its children are known.
resolves to . Now resolves to . Now resolves to . Children before parents; computer scientists call that a post-order traversal. Press Step in the widget and watch it happen, one node at a time.
Climb the tree
Evaluate the tree for , deepest branch first.
What is the value?
Exponents are repeated multiplication
One node type in that tree was an exponent. , for a counting number , is just copies of multiplied together: . Nothing deeper than that.
And . Not zero, one. Walk the pattern downward: , , . Each step divides by . One more step lands on . The pattern forces it. (The full rulebook for exponents is module 2’s job; today you only need this much.)
A zero exponent
Evaluate, remembering what a zero exponent does:
What is the value?
One expression, one value: why it matters
The whole reason precedence rules exist is that guarantee from earlier: one expression, one value, no ambiguity.
That determinism is not a school nicety. It is the property that lets a computation be trusted at all: feed the same inputs to the same expression and you get the same output, every single run.
Where this goes
A neural network is an arithmetic expression. A very wide one, with billions of leaves and branch points instead of four, but the same kind of object: numbers at the bottom, operations stacked above.
Running the network to get a prediction is exactly what you just did to that little tree: climb from the leaves up, children before parents. That climb has a name you will hear constantly from module 16 onward. It’s called the forward pass. You just ran one.
Lesson complete