Definitions with := produce no output. To verify, call the function:
Tip: You can use = instead of := in most cases.
Apply Functions to Lists (Vectorization)
Functions automatically apply to each element of a list:
Use Grad to get all partial derivatives at once:
returns:
Key application: First-order conditions (FOC)
Solve: Simple syntax, general solutions only
Reduce: Handles assumptions and special cases
Tip: Use Solve for most economics problems. Use Reduce when you need parameter restrictions or complete case analysis.
| Simplify[x^2 + 2x + 1] | $\to (x+1)^2$ |
| N[1/3] | $\to 0.333333$ |
| x^2*y /. {x -> 3, y -> 7} | $\to 63$ |
Substitution syntax: Type -> for $\to$
For dynamic models, use brackets for indexing: $c_t \to$ c[t]
Generate sequences:
Combine and sum lists:
Cournot Duopoly
Define profit functions: $u_1(q_1, q_2) = (3 - q_1 - q_2)q_1$ and $u_2(q_1, q_2) = (2 - q_1 - q_2)q_2$
Click a card to reveal the answer.