# Serial of year 31

You can find the serial also in the yearbook.

*We are sorry, this serial has not been translated.*

## Text of serial

## Tasks

### (10 points)1. Series 31. Year - S. Taking Off

- Modify the expression $\sqrt {x+1}-\sqrt {x}$, so that it isn't so prone to the problems of cancellation, ordering and smearing. Which of these problems would have originally caused a trouble with the expression and why? What is the difference between the original and the corrected expression when we evaluate it using double precision with $x=1{.}0 \cdot 10^{10}$?
- Describe the effects of the following code. What is the difference between the functions
`a()`

and`b()`

? With which values of`x`

can they be evaluated? Don't be afraid to run the code and play with different values of the variable`x`

. What is the asymptotic computation time complexity as a function of the variable`x`

?def a(n): if n == 0: return 1 else: return n*a(n-1) def b(n): if n == 0: return 1.0 else: return n*b(n-1) x=10 print("{} {} {}".format(x, a(x), b(x)))

- Let's designate $o_k$ and $O_k$ as the circumference of a regular k-sided polygon inscribed and circumscribed respectively in a circle. The following recurrent relationships then apply: \[\begin{equation*} O_{2k}=\frac {2o_k O_k}{o_k + O_k} ,\; o_{2k}=\sqrt {o_k O_{2k}} . \end {equation*}\] Write a program that can calculate the value of $\pi $ using these relations. Start with an inscribed and a circumscribed square. How accurately can you approximate $\pi $ using this method? (A similar method has been originally used by Archimedes for this purpose.)
- Lukas and Mirek play a game. They toss a fair coin: when it's tails (reverse) Mirek gives Lukas one Fykos t-shirt when it's heads (obverse) Lukas gives one to Mirek. Together they have $t$ t-shirts of which $l$ belongs to Lukas and $m$ to Mirek. When one of them runs out of t-shirts the game ends.
- Let $m = 3$ and Lukas's supply be infinite. Determine
*the most probable*length of the game, i.e. the number of tosses after which the game ends (because Mirek runs out of t-shirts). - Let $m = 10$, $l = 20$. Simulate the game using pseudorandom number generator a find the probability of Mirek winning all of Lukas's t-shirts. Use at least 100 games (more games means more precise answer).
- How will the result of the previous task change in case Mirek „improves“ the coin and heads now occur with the probability of $5/9$?

*Bonus:*Calculate the probability analytically and compare the result with the simulation.

- Consider a linear congruential generator with parameters $a = 65539$, $m = 2^{31}$, $c = 0$.
- Generate at least $1{,}000$ numbers and determine their mean and variance. Compare it to the mean and variance of a uniform distribution over the same interval.
- Find the relationship that gives the next number in the generated sequence as a linear combination of the two preceding numbers. I.e. find the coefficients $A$, $B$ in the recurrence relationship $x_{k+2} = Ax_{k+1} + Bx_k$. If we consider each three sequential numbers as the coordinates of a point in 3D, how does the recurrence relationship influence the spatial distribution of these points?

*Bonus:*Generate a sequence of at least $10{,}000$ numbers and plot the points on a 3D graph that will illustrate the significance of the given recurrence relationship.

Mirek and Lukas dusted off some old textbooks.

### (10 points)2. Series 31. Year - S. derivatives and Monte Carlo integration

- Plot the error as a function of step size for the method \[\begin{equation*} f'(x)\approx \frac {-f(x+2h)+f(x-2h)+8f(x+h)-8f(x-h)}{12h} \end {equation*}\] derived using Richardson extrapolation. What are the optimal step size and minimum error? Compare with forward and central differences. Use $\exp (\sin (x))$ at $x=1$ as the function you are differentiating.

*Bonus:*Use error estimate to determine the theoretical optimal step size. - There is a file with experimentally determined $t$, $x$ and $y$ coordinates of a point mass on the website. Using numerical differentiation, find the time dependence of components of speed and acceleration and plot both functions. What is the most likely physical process behind this movement? Choose your own numerical method but justify your choice.

*Bonus:*Is there a better method for obtaining velocity and acceleration, then direct application of numerical differentiation? - We have an integral $\int _0^{\pi } \sin ^2 x \d x$.
- Find the value of the integral from a geometrical construction using Pythagoras theorem.
- Find the value of the integral using a Monte Carlo simulation. Determine the standard deviation.

*Bonus:*Solve the Buffon's needle problem (an estimate of the value of $\pi $) using MC simulation.

- Find the formula for the volume of a six-dimensional sphere using Monte Carlo method.

*Hint:*You can use the Pythagoras theorem to measure distances even in higher dimensions.

Mirek and Lukáš read the Python documentation.

### (10 points)3. Series 31. Year - S. going for a walk with integrals

* We are sorry, this task is not yet translated… *

Mirek and Lukáš random-walk to school.

### (10 points)5. Series 31. Year - S. Differential equations are growing well

Mirek and Lukáš have already grown their algebra, now they have different seeds.

### (10 points)6. Series 31. Year - S. Matrices and populations

Mirek and Lukáš fill matrices with atto-foxes.