Ex2: review exercises - functions2

These exercises are mostly taken from: Calculus Volume 1 from OpenStax, Print ISBN 193816802X, Digital ISBN 1947172131, https://www.openstax.org/details/calculus-volume-1


E1. Evaluate the function \(f(x) = |x^2 - 8\sqrt{x} -5|\) for a. \(f(9)\), b.\(f(4)\)


E3. We can plot inequalities on the real line as in these examples

  1. Plot on the real line the inequality \(|x - 2| < 3\)

  2. What are the boundary points of the interval for \(x\)?

  3. What is the meaning of the numbers \(2\) and \(3\) (when looking at the plot)?

In case you need a little hint.


E3. For the following pairs of functions solve for \(x\) the equation \(f(x)=g(x)\) (that is find the solution \(x=?\))

  1. \(f(x) = |5-2x|-1, g(x) = 2\)
  2. \(f(x) = |2x-6|-3, g(x) = \frac{x}{2}+2\)
  3. \(f(x) = 4|x-2|+3, g(x) = -3x + 1\)

In case you need a little hint.

Then use the following graphing tool Geogebra to plot the pairs of functions \(f\) and \(g\) into the same graph (the tool is fairly intuitive, I’m sure you will figure out how to use it). A few hints for Geogebra are here.

What is the relation between the plots and the solutions for \(x\)?


E4. Determine for which values of \(x\) the following inequalities hold

  1. \(-\frac{1}{2}|4x-5| + 3 < 0\)
  2. \(-2|x-4| \leq -6\)
  3. \(|3x-5| \leq 11\)

Use the graphing tool Geogebra to plot the functions and relate the solutions of your calculations to the plot.


E5. Convert these radian measures of an angle \(\theta\) into degrees (e.g. \(\pi/2 = 90^{\circ}\))

  1. \(\frac{\pi}{6}\)
  2. \(3\)
  3. \(\frac{5\pi}{2}\)

In case you need a little hint.


E6. Convert these degree measures of an angle \(\theta\) into radians (e.g. \(90^{\circ} = \pi/2\))

  1. \(45^{\circ}\)
  2. \(-60^{\circ}\)
  3. \(210^{\circ}\)

In case you need a little hint.


E7. Use the unit circle (don’t use a calculator) to get the values of the functions \(g(x) = \sin(x)\) and \(h(x) = \cos(x)\) for these values of the angle \(x\)

  1. \(\frac{3}{2}\pi\)
  2. \(\frac{7\pi}{6}\)
  3. \(-\pi\)
  4. \(\frac{11\pi}{4}\)

Hints for some special angles: \(\sin(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}\), \(\sin(\frac{\pi}{6}) = \frac{1}{2}\), \(\cos(\frac{\pi}{6}) = \frac{\sqrt{3}}{2}\). Use the symmetries along the circle to derive the other values.


E8. There is an important relationship between the functions \(\sin(\theta)\) and \(\cos(\theta)\) that you should be able to derive yourself when you think carefully about the unit circle and the way we get the values of the two functions. For any angle \(\theta\) we have

\[(\sin \theta)^2 + (\cos \theta)^2 = \ ? \] Replace the question mark in the above with your answer and explain how you derived it.

In case you need a little hint.


E9. Use the graphing tool Geogebra to plot the functions below and find their values for the angles \(x = \pi\) and \(x = 5\)

  1. \(f(x) = \cos(x + 5)\)
  2. \(f(x) = 3\sin(x)\)
  3. \(f(x) = \cos(2x + 4)\)
  4. \(f(x) = 4\sin(0.5x -1)\)

Hint for Geogebra: you can put as input \(x = 5\) to draw a vertical line at \(5\).


E10. Find the maxima and minima for the functions in E9.

  1. What are the maximum \(\max f(x)\) and minimum \(\min f(x)\) values of the functions?
  2. At which points \(x\) do the functions have the maxima \(\text{argmax } f(x)\) and minima \(\text{argmin } f(x)\)?

Note the difference between \(\max f(x)\) and \(\text{argmax } f(x)\), we will see this a lot in the course!


E11. Find the inverse \(f^{-1}\) for the following functions

  1. \(f(x) = \frac{3x}{x - 2}\)
  2. \(f(x) = 3x^2 + 2, \ x \geq 0\)
  3. \(f(x) = 4\sin(x)\)

In case you need a little hint.


Important: In all the exercises (and generally in the course) I use \(\log\) without specifying the base as the natural logorithm with base \(e\). That is \(\log(x) = \ln(x) = \log_e(x)\).

E12. Use the graphing tool Geogebra to explore the graphs of the following pairs of functions:

  1. \(h(x) = x^4, \ g(x) = 4^x\)
  2. \(h(x) = x^{1/2}, \ g(x) = (\frac{1}{2})^x\)
  3. \(h(x) = e^x, \ g(x) = x!\)
  4. \(h(x) = \log(x), \ g(x) = x \quad\)
  5. \(h(x) = \sqrt{x}, \ g(x) = \log_2(x)\)

In which regions (for which intervals of \(x\)) is \(h(x) \geq g(x)\) and where is \(h(x) \leq g(x)\)?

What happens as \(x \to \infty\)?

A few hints for Geogebra are here.


E13. The probability density function of the normal distribution has the form

\[f(x) = \frac{1}{\sigma \sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} \enspace ,\] where \(\mu\) is the mean of the distribution and \(\sigma^2\) is the variance. The normal probability distribution is usually denoted as \(N(\mu, \sigma^2)\).

Find the density of the normal distribution \(N(3,4)\) at \(x=2.5\). Use python as a calculator to get the result. (There are more exercises later asking you to use this function so you may want to save your code for later reuse.)

Use Geogebra to plot the distribution function and verify your result.

Note: We will be using the normal probability distribution in the course a lot so it is important that you are at ease working with its density function.


E14. Solve the following equations for \(x\):

  1. \(5^x = 2\)
  2. \(e^x e^{-2} = 3/2\)
  3. \(e^{3x} - 15 = 0\)
  4. \(\log(1/x) = 4\)

In case you need a little hint.


E15. Use the properties of logarithms (listed in section 2.6.2.2 here) to write the expressions below as sums or differences of logarithms and simple numbers.

  1. \(\log x^4 y\)
  2. \(\log \frac{e^2 a^3}{b}\)
  3. \(\log \sqrt{x y^3}\)

E16. Solve the following equations for \(x\):

  1. \(\log_4(x+2) - \log_4(x-1) = 0\)
  2. \(\log x + \log(x-2) = \log 4\)

E17. The normal probability density function is in some situations called likelihood. As you can see, it is not so easy to work with, because the input variable \(x\) is within the exponent of \(e\).

Therefore in machine learning we often times work with its logarithm \(\log f(x)\) called the log likelihood.

Use the properties of logarithms to simplify the log likelihood function into sums or differences of terms for the probability distributions

  1. \(N(0, 1)\)
  2. \(N(3, 4)\)

Get the values of the log likelihood functions at point \(x = 2.5\).


E18. Write the first few terms (at least 5) of the sequences below:

  1. \(a_1 = 3, \ a_n = 2a_{n-1} + n \text{ for } n \geq 2\)
  2. \(a_1 = 1, \ a_2 = 1, \ a_n = a_{n-1} + a_{n-2} \text{ for } n \geq 3 \text{ (Fibonacci)}\)
  3. \(a_1 = 2, \ a_n = \frac{1}{4}a_1 + \frac{3}{4} \text{ for } n \geq 2\)
  4. \(a_1 = 1, \ a_2 = 1/2, \ a_n = \frac{a_{n-2}}{a_{n-1}} \text{ for } n \geq 3\)

What is the limit behavour of the series as \(n \to \infty\)?

Are the series converging or diverging?

Note: A rigorous mathematical approach would be to find the algebraic form of the sequence and then find the limit (if it exists). We are in a machine learning course so we can cheat a little and rely on our intuition.


E19. For the Fibonacci sequence from above, use python to calculate

\[\prod_{n=1}^{10} a_n\]


E20. We have four independent random normal variables distributed as \(X_1 \sim N(0,1)\), \(X_2 \sim N(3,4)\), \(X_3 \sim N(1,2)\), \(X_4 \sim N(2.5,9)\).

How do you calculate the joint probability density for all the variables taking the value \(2.5\)? \[f(X_1 = 2.5, X_2 = 2.5, X_3 = 2.5, X_4 = 2.5) = \ ?\] Replace the question mark with the correct way to calculate the joint probability density using the correct mathematical notation. You should use the letter \(X\) only once in the whole term.

Use python and the normal probability density function from E13 to evaluate the joint probability density.

In case you need a little hint.


E21. Imagine an experiment (such as tossing a coin) with only two possible outcomes (e.g. success/failure, yes/no, true/false, heads/tails) and the probability of a positive outcome \(p\) (e.g. when tossing a coin, the probability of getting head is \(p = 0.5\))

The binomial distribution gives the probability of the number of successes \(k\) if you repeat the same experiment \(n\) times in a row (e.g. \(k\) is the number of heads you will get if you toss a coin \(n\) times.).

\[P(k) = {n \choose k} p^k (1-p)^{n-k}\] What is the probability \(P(k)\) of getting 3 positive outcomes when repeating 8 times an experiment with the success probability \(p=0.7\)? Use python as a calculator.