Review for test 1 in MTH229

Test 1 will be March 7th.

The test will be on paper. You will have to write out all your answers and in some cases your Julia commands to receive full credit.

On the test you can use the computer and the internet, but you can not use your phone during the test or communicate with others or any artificial intelligence sites in any way during the test.

Here are some sample questions. Many of these are designed for immediate feedback. The actual test questions will definitely be different. The following should be helpful nonetheless.

As in class, we use the following packages. In class you also add a plotly() command after loading the Plots package. (Unfortunately, plotly() doesn’t work within this HTML page, so our graphics are static.)

using MTH229
using Plots

Expressions

For the next several questions there is some math expression and a Julia expression. You are asked if the Julia code expresses the same calculation. Both are written as though \(a\) was some value.

Question

Math code:

\[ \sin(\cos(a)) \]

Julia code:

sin(cos(a))

Does the Julia code do what the math formula expects?

Question

Math code:

\[ 1 + \frac{1}{2} + \frac{1}{2\cdot 3} + \frac{1}{2 \cdot 3 \cdot 4} \]

Julia code:

1 + 1/2 + 1/2*3 + 1/2*3*4

Does the Julia code do what the math formula expects?

Question

Math code:

\[ \cos^2(a - \pi) \]

Julia code:

cos^2(a - pi)

Does the Julia code do what the math formula expects?

Question

Math code:

\[ \ln(\frac{1 -a}{a}) \]

Julia code:

ln( (1-a) / a)

Does the Julia code do what the math formula expects?

Question

Math code:

\[ 1 - \frac{1 -a^2}{1 + a^2} \]

Julia code:

(1 - (1 - a^2)) / (1 + a^2)

Does the Julia code do what the math formula expects?

Question

Math code:

\[ \frac{1}{2a} \]

Julia code:

1 / 2a

Does the Julia code do what the math formula expects?

Question

Which of these is actually a Julia function for some common mathematical function:

Question

Suppose for specific \(a,b,\) and \(c\) values you were to solve for \(C\) in

\[ a^2 + b^2 -2ab\cos(C) = c^2 \]

Does the following set of Julia commands compute this expression for the given values.

a, b, c = 3, 5, 6
cosC = (c^2 - (a^2 + b^2)) / (-2a*b)
acos(cosC)

Question

Suppose for specific \(R_t\) and \(R_1\) you have to solve for \(R_2\) from:

\[ \frac{1}{R_t} = \frac{1}{R_1} + \frac{1}{R_2} \]

Does the following set of Julia commands compute this expression for the given values.

R1, Rt = 10, 8
1 / (1/Rt - 1/R1)

Question

A graphic showing a funny take on PEMDAS

pemdas

Is the above image funny or informative?

Functions

Question

Write a Julia function to compute

\[ f(x) = x - \frac{x^3}{6} + \frac{x^5}{120} \]

Use your formula to identify which is greater \(f(2)\) or \(\sin(2)\)?

Question

Write a Julia function to compute

\[ f(x) = x - \sin(x^2) \]

Which value is bigger \(f(1)\), \(f(2)\), or \(f(3)\)?

Question

The piece-wise defined function \(f\) is given below:

\[ f(x) = \begin{cases} 2x + 3 & x < 1 \\ 5 & x \geq 1 \end{cases} \]

It can be entered into Julia using the ternary operator by:

f(x) = x < 1 ? 2x + 3 : 5

Which values is biggest?

Question

Consider the function \(f(x) = x^x\) over the interval \([1/2, 2]\). The secant line between these points is defined by

f(x) = x^x
a, b = 1/2, 2
g(x) = f(b) + (f(b) - f(a))/(b-a) * (x - b)

At the value of \(x=1\) which is bigger?

Question

Consider the function \(f(x) = x^x\) over the interval \([1/2, 2]\). The tangent line at \(x=1/2\) is given by

using MTH229
f(x) = x^x
g(x) = tangent(f, 1/2)(x)

At the value of \(x=1\) which is bigger?

Plots

For these questions, you are expected to read the values from the graph to 1 decimal point.

Question

Consider the following plot of \(f(x) = \cos(x)\) and \(g(x) = x/10\). Where do they intersect within \([0, \pi/2]\)?

f(x) = cos(x)
g(x) = x/10
plot(f, 0, pi/2)
plot!(g)

Question

Consider the following plot of \(f(x) = \ln(x)\) and its tangent line at \(x=1/2\).

f(x) = log(x)
plot(f, 1/10, 2)
plot!(tangent(f, 1/2))
plot!(zero)

When does the tangent line cross the \(x\) axis?


Question

The continuous function \(f(x) = x^2 e^{-x}\) has a maximum value over the interval \([0, 4]\). What is it. (The \(y\) value)

f(x) = x^2 * exp(-x)
plot(f, 0, 4)

Question

Two lines will intersect unless they are parallel. Consider this plot of \(f(x) = x^x\) over \([1/2, 2]\) along with its secant line over \([1/2, 2]\) and its tangent line at \(x=1\).

Where do they intersect? Use Inf if they do not.

f(x)  = x^x
plot(f, 1/4, 4; ylim = (0, 4.1), legend=false)
plot!(secant(f, 1/2, 2))
plot!(tangent(f, 1))

Finding zeros

For these zero-finding problems, you can’t get enough accuracy for a correct answer just from reading the graph. You will need to use bisection, fzero, or fzeros.

Question

Consider \(f(x) = x^5 - x - 1\). The interval \([a_0, b_0] = [1,2]\) is a bracketing interval. From the output of bisection( f, 1, 2), you should be able to see that \([a_1, b_1] = [1, 1.5]\). What is \([a_3, b_3]?\)

\(a_3\) is equal to?


\(b_3\) is equal to?


What value is the zero of \(f(x)\) in \([1,2]\) guaranteed by the intermediate value theorem?


Question

Consider the following plot of some special function

plot(besselj0, -5, 5)
plot!(zero)

Which of the following intervals is a bracketing interval for besselj0?

Using the bracketing interval and fzero, find the zero.


Question

The functions \(f(x) = xe^{-x^2}\) and \(g(x) = x + 1\) over the interval \([-2,2]\) intersect just once. Find the \(x\) value of the point of intersection using fzero.

f(x) = x * exp(-x^2)
g(x) = x + 1
plot(f, -2, 2)
plot!(g)

Question

f(x) = x^5 - x - 0.534
plot(f, -2, 2)
plot!(zero)

How many zeros of \(f\) does fzeros find over the interval \([-2, 2]\)?


Question

Consider the functions \(g(x) = \sin(x)\) and \(f(x) = \sin(x + \sin(x + \sin(x)))\). Do these two functions have the same zeros? (Guess by using fzeros over the interval (-20, 20).

Select an item