[Tex/LaTex] Using calc in TikZ


How to use function calc in TikZ?

For example, suppose I have a function f(x)=x^2.

Now, I want to find f(1) and f(2), and
then I want \draw f(1) -- f(2);.

Best Answer

A possibility with pgf 2.1


    \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,8.1);
    \draw[->] (-0.2,0) -- (3.2,0) node[right] {$x$};
    \draw[->] (0,-0.2) -- (0,4.2) node[above] {$f(x)$};
    \draw[domain=0:3] plot (\x,{square(\x)-1}) node[below right] {$f(x) = x^2$};

enter image description here

Related Question