Section0.5Parsing formulas¶ permalink
Consider the formula
\begin{align*} f(x) &= \frac{1+x}{1+2xx^2} \end{align*}This is an example of a simple rational function — that is, the ratio of two polynomials. When we start to examine these functions later in the text, it is important that we are able to understand how to evaluate such functions at different values of \(x\text{.}\) For example
\begin{align*} f(5) &= \frac{1+5}{1+1025} = \frac{6}{14} = \frac{3}{7} \end{align*}More important, however, is that we understand how we decompose this function into simpler pieces. Since much of your calculus course will involve creating and studying complicated functions by building them up from simple pieces, it is important that you really understand this point.
Now to get there we will take a small excursion into what are called parsetrees. You already implicitly use these when you evaluate the function at a particular value of \(x\text{,}\) but our aim here is to formalise this process a little more.
We can express the steps used to evaluate the above formula as a treelike diagram ^{ 1 } . We can decompose this formula as the following treelike diagram
Let us explain the pieces here.
 The picture consists of boxes and arrows which are called “nodes” and “edges” respectively.
 There are two types of boxes, those containing numbers and the variable \(x\text{,}\) and those containing arithmetic operations “\(+\)”,“\(\)”, “\(\times\)” and “\(/\)”.

If we wish to represent the formula \(3+5\text{,}\) then we can draw this as the following cherrylike configuration
which tells us to take the numbers “\(3\)” and “\(5\)” and add them together to get \(8\text{.}\)
evaluates to
 By stringing such little “cherries” together we can describe more complicated formulas. For example, if we compute “\((3+5)\times 2\)”, we first compute “\((3+5)\)” and then multiply the result by 2. The corresponding diagrams are
evaluates to
evaluates to
The tree we drew in Figure 0.5.1 above representing our formula has \(x\) in some of the boxes, and so when we want to compute the function at a particular value of \(x\) — say at \(x=5\) — then we replace those “\(x\)”s in the tree by that value and then compute back up the tree. See the example below
Start
\(\mapsto\)
\(\mapsto\)
\(\mapsto\)
\(\mapsto\)
and we are done.
This is not the only parse tree associated with the formula for \(f(x)\text{;}\) we could also decompose it as
We are able to do this because when we compute the denominator \(1+2xx^2\text{,}\) we can compute it as
\begin{align*} 1+2xx^2 &= \text{ either } (1+2x)x^2 \text{ or } = 1 + (2xx^2). \end{align*}Both ^{ 2 } are correct because addition is “associative”. Namely
\begin{align*} a+b+c &= (a+b)+c = a+(b+c). \end{align*}Multiplication is also associative:
\begin{align*} a \times b \times c &= (a \times b) \times c = a \times (b \times c). \end{align*}It is highly unlikely that you will ever need to explicitly construct such a tree for any problem in the remainder of the text. The main point of introducing these objects and working through a few examples is to realise that all the functions that we will examine are constructed from simpler pieces. In particular we have constructed all the above examples from simple “building blocks”
 constants — fixed numbers like \(1, \pi\) and so forth
 variables — usually \(x\) or \(t\text{,}\) but sometimes other symbols
 standard functions — like trigonometric functions (sine, cosine and tangent), exponentials and logarithms.
These simple building blocks are combined using arithmetic
 addition and subtraction — \(a + b\) and \(ab\)
 multiplication and division — \(a \cdot b\) and \(\frac{a}{b}\)
 raising to a power — \(a^n\)
 composition — given two functions \(f(x)\) and \(g(x)\) we form a new function \(f(g(x))\) by evaluating \(y=g(x)\) and then evaluating \(f(y) = f(g(x))\text{.}\)
During the rest of the course when we learn how to compute limits and derivatives, our computations require us to understand the way we construct functions as we have just described.
That is, in order to compute the derivative ^{ 3 } of a function we have to see how to construct the function from these building blocks (i.e. the constants, variables and standard functions) using arithmetic operations. We will then construct the derivative by following these same steps. There will be simple rules for finding the derivatives of the simpler pieces and then rules for putting them together following the arithmetic used to construct the function.