Some sample questions for test 1.

using MTH229
plotly()
Plots.PlotlyBackend()

calculator

Evaluate each expression. For each, write the answer and the julia commands you used to produce the answer:

10^9 / 8 * 7 - 6 + 5
8.74999999e8
sin(pi/3) * sin(pi/4)^2 * asin(pi/5)
0.2941844678207861
cosd(75) - cos(75), cos(75*pi/180) - cos(75)   ## either way
(-0.6629322246222286,-0.6629322246222286)
exp(1/2 * (3-1)^2)
7.38905609893065

*

$$~ \frac{\sin(x) + \cos(x)}{\sin(x) - \cos(x)}, \text{ when } x = 1. ~$$
x = 1
(sin(x) + cos(x)) / (sin(x) - cos(x))
4.588037824983901

For each function, write a function in julia and compute $f(1/2)$. For each, your answer should have the command to define the function and the value at $1/2$.

f(x) = sqrt(x / (x + 1))
f(1/2)
0.5773502691896257
f(x) = log(x + 1) - x
f(1/2)
-0.09453489189183562
f(x) = acos(x)
f(1/2)
1.0471975511965979

Plotting

f(x) = x * (x-1) / (x -2) / (x-3)
plot(f, -5, 5)

There are vertical asymptotes at $2$ and $3$

Plotting on a wider scale shows slant of horizontal asymptotes:

plot(f, -20, 20)

There is a horizontal asymptote $y=1$.

f(x) = cos(x) * cosh(x)
g(x) = 1
plot([f,g], 1, 5)

There is clearly an answer out near $4.5$:

plot([f,g], 4.5, 5)

It is around $4.73$.

Is there a value near $1$?

plot([f,g], 1, 2)

Clearly none, now that we have resized our viewing window.

f(x) = sin(x)
g(x) = x - x^3/6
plot([f,g], -pi/2, pi/2)

Hmm, hard to separate the two graphs.

Trying to plot the difference we have:

h(x) = f(x) - g(x)
plot(h, -pi/2, pi/2)

We still can't tell. But if we knew the graph is increasing, then there can be only 1.

f(x) = x^5 - x + 1
plot(f, -5, 5)

Clearly, any decrease happens between $[-2,2]$. Here we regraph:

plot(f, -2, 2)

Looks like it decreases between $-1$ and $1$. (We will see later how to determine that the decrease happens between $[-0.66874, 0.66874]$.)

Zeros

f(x) = x^5 - x + 1
fzeros(f)
1-element Array{Real,1}:
 -1.1673

There is just one, as we could tell from the previous graphs.

f(x) = x^3 - 9x^2 + 26x - 24
plot(f, 0,6)

We can see one in $[3.5,4.5]$ which has the value:

fzero(f, 3.5, 4.5)
4.0

As for any more, we plot over $[1.8, 3.2]$ to look more closely:

plot(f, 1.8, 3.2)

We see $[1.8, 2.4]$ and $[2.4, 3.2]$ are bracketing intervals, so we have two more zeros returned by:

fzero(f, 1.8, 2.4), fzero(f, 2.4, 3.2)
(2.0,3.0)
f(x) = sin(x) - (x - x^3/6)
fzeros(f, -pi/2, pi/2)
1-element Array{Float64,1}:
 -1.59446e-155

That answer is basically 0 – the mathematically precise answer.

f(x) = sin(20*pi*x)
fzeros(f, 0, 1)
20-element Array{Float64,1}:
 0.0 
 0.05
 0.1 
 0.15
 0.2 
 0.25
 0.3 
 0.35
 0.4 
 0.45
 0.5 
 0.55
 0.6 
 0.65
 0.7 
 0.75
 0.8 
 0.85
 0.9 
 0.95

This is missing 1, so there are $21$.