SageTeX

In this preview: press Run to run the code with Sagebrush’s Sage, in this browser, in page order; until then each \sage{...} shows as a placeholder. The results are kept beside this file (sagebrush latex run on a computer makes the same file); after an edit, press Run again.
The derivative of f(x)=x3−2x+1f(x) = x^3 - 2x + 1 is f′(x)=3 x2−2f'(x) = {3 \, x^{2} - 2}, and ∫01f(x) dx=14\int _0^1 f(x)\,dx = {\frac{1}{4}}.
The 10th prime is 29{29}, and 2100=12676506002282294014967032053762^{100} = {1267650600228229401496703205376}.
Code runs in page order, so a name can be defined again: from here on f(x)=sin⁡(x)f(x) = {\sin\left(x\right)}.
a plot