phys_581.assignment_1
=====================

.. py:module:: phys_581.assignment_1

.. autoapi-nested-parse::

   Assignment 1



Functions
---------

.. autoapisummary::

   phys_581.assignment_1.play_monty_hall
   phys_581.assignment_1.fib
   phys_581.assignment_1.lambertw
   phys_581.assignment_1.zeta
   phys_581.assignment_1.derivative


Module Contents
---------------

.. py:function:: play_monty_hall(switch=False)

   Return ``True`` if the contestant wins one round of Monty Hall.

   :param switch: If `True`, then switch doors, otherwise stick with the original door.
   :type switch: bool


.. py:function:: fib(n)

   Return the nth Fibonacci number.


.. py:function:: lambertw(z, k=-1)

   Return :math:`w` from the `k`'th branch of the LambertW function.

   .. math::
     z = we^w, \qquad
     w = W_k(z).

   :param z: Argument.  You can assume that ``z >= -exp(-1)`` and that ``z <= 0`` if
             ``k == -1``.  Raise ``ValueError`` otherwise (unless your code correctly extends
             :math:`W(z)` to the complex plane).
   :type z: float, array_like
   :param k: Branch.  If ``k == 0``, then return the solution :math:`w>-1`, otherwise if
             ``k == -1``, return the solution :math:`w < -1`
   :type k: [0, -1]

   .. admonition:: Notes

      Do not use a canned implementation, even if you find one in SciPy.  Write your own
      version.


.. py:function:: zeta(s)

   Return the Riemann zeta function at `s`.

   .. math::
     \zeta(s) = \sum_{1}^{\infty} \frac{1}{n^{s}}.

   :param s: Argument of the zeta function.
   :type s: float


.. py:function:: derivative(f, x, d=0)

   Return the `d`'th derivative of `f(x)` at `x`.

   :param f: The function to take the derivative of.
   :type f: function
   :param x: Where to take the derivative.
   :type x: float
   :param d: Which derivative to take.  `d=0` just evaluates the function.
   :type d: int


