Review for test 2 in MTH 229

Test 2 will cover the 4th and 5th packages: zeros of functions and limits. Some features we used are only available once the MTH229 package is loaded:

using MTH229
using SymPy

Zeros

The MTH229 package loads the Roots package which provides functions to return zeros of a function.

Polynomials

For polynomials functions we have the following:

For an $n$th degree polynomial, there are exactly $n$ roots when multiplicities are accounted for and complex numbers are used. There are $n-2k$ real roots, for some integer $k$, as complex roots come in pairs.

For example:

f(x) = x^5 - x - 1
roots(f)
5-element Array{Complex{Float64},1}:
    1.1673+0.0im     
  0.181232+1.08395im 
  0.181232-1.08395im 
 -0.764884+0.352472im
 -0.764884-0.352472im

(There are 5 complex roots to match the degree of the polynomial). Yet, only one is real, which you can check with fzeros(f):

fzeros(f)
1-element Array{Real,1}:
 1.1673

The following facts about polynomial zeros (roots in this case) are mentioned in the project:

General functions

Polynomials are special enough, that one doesn't need to specify where to look for zeros. This is not so in general. We used two functions to find zeros:

For example. Find a solution to $cos(x) = x/2$. We reframe this to be find a zero of $f(x) = \cos(x) - x/2$ and not that $f(0)=1$ and $f(pi/2) = -pi/4$, so $[0, \pi/2]$ is a bracket. Using this we have:

f(x) = cos(x) - x/2
fzero(f, 0, pi/2)
1.0298665293222589

Are there others? We can check. Since $|x/2| > 1$ when $|x| > 2$ and $\cos(x)$ is between $[-1,1]$, any solution must lie in $[-2,2]$. So we ask:

fzeros(f, -2, 2)
1-element Array{Float64,1}:
 1.02987

And we see that is it. Not so for a "flatter" line, say $x/10$:

f(x) = cos(x) - x/10
fzeros(f, -10, 10)
7-element Array{Float64,1}:
 -9.67888
 -8.96602
 -4.2711 
 -1.74633
  1.42755
  5.26712
  7.06889

These functions only solve for answers to $f(x) = 0$. You may have to rearrange your problem to fit that. For example, to find out when $\sinh(x) = 1/2$, we can solve for when $\sinh(x) - 1/2 = 0$:

f(x) = sinh(x) - 1/2
fzeros(f, -2, 2)  # one answer here
1-element Array{Float64,1}:
 0.481212

Limits

We discussed three ways to investigate the answer (if it exists) to

$$~ \lim_{x \rightarrow c} f(x) ~$$$$~ f(t) = \frac{t - \sqrt{3t+4}}{4-t}, \text{ as } t \rightarrow 4 ~$$

Can be investigated by creating a graph around $c=4$:

f(t) = (t - sqrt(3t+4)) / (4-t)
plot(f, 3, 5)

The answer looks to be about $-0.625$.

With this, making a table to investigate a limit is as easy as:

lim(f, 4, dir="+") ## going to 4 from right
6x2 Array{Float64,2}:
 4.1      -0.626742
 4.01     -0.625176
 4.001    -0.625018
 4.0001   -0.625002
 4.00001  -0.625   
 4.0      -0.625   
limit(f, 4)
-5/8

In this case, all three give the same answer – the limit is $-5/8 = -0.625$.

Other questions may include finding the distinction between left and right limits, limits of functions with jumps, or whether a limit can be found just by "plugging in".

For example, to find the left limit at $0$ of $\sin(|x|)/x$ we have:

f(x) = sin(abs(x))/x
limit(f, 0, dir="-")
-1