Skip to main content

Section 0.5 Parsing Formulas

Consider the formula

\begin{align*} f(x) &= \frac{1+x}{1+2x-x^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+10-25} = \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 parse-trees. 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 tree-like diagram  1 Such trees appear in many areas of mathematics and computer science. The reason for the name is that they look rather like trees — starting from their base they grow and branch out towards their many leaves. For some reason, which remains mysterious, they are usually drawn upside down.. We can decompose this formula as the following tree-like diagram

Figure 0.5.1 A parse tree of the function \(\frac{1+x}{1+2x-x^2}\text{.}\)

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 cherry-like 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+2x-x^2\text{,}\) we can compute it as

\begin{align*} 1+2x-x^2 &= \text{ either } (1+2x)-x^2 \text{ or } = 1 + (2x-x^2). \end{align*}

Both  2 We could also use, for example, \(1+2x-x^2 = (1-x^2)+2x\text{.}\) 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*}

Consider the formula

\begin{align*} g(t) &= \left(\frac{t+\pi}{t-\pi} \right) \cdot \sin\left( \frac{t+\pi}{2} \right). \end{align*}

This introduces a new idea — we have to evaluate \(\frac{t+\pi}{2}\) and then compute the sine of that number. The corresponding tree can be written as

If we want to evaluate this at \(t = \pi/2\) then we get the following…

Start

\(\mapsto\)

\(\mapsto\)

\(\mapsto\)

\(\mapsto\)

and we are done.

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 \(a-b\)
  • 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 We get to this in Chapter 2 — don't worry about exactly what it is just now. 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.