\[\newcommand{\vect}[1]{\vec{\boldsymbol{#1}}}
\newcommand{\uvect}[1]{\hat{\boldsymbol{#1}}}
\newcommand{\abs}[1]{\lvert#1\rvert}
\newcommand{\norm}[1]{\lVert#1\rVert}
\newcommand{\I}{\mathrm{i}}
\newcommand{\ket}[1]{\left|#1\right\rangle}
\newcommand{\bra}[1]{\left\langle#1\right|}
\newcommand{\braket}[1]{\langle#1\rangle}
\newcommand{\Braket}[1]{\left\langle#1\right\rangle}
\newcommand{\op}[1]{\boldsymbol{#1}}
\newcommand{\mat}[1]{\boldsymbol{\underaccent{\bar}{#1}}} % For LaTeX
\renewcommand{\mat}[1]{\boldsymbol{#1}}
\providecommand{\d}{\mathrm{d}}
\renewcommand{\d}{\mathrm{d}}
\newcommand{\T}{\mathrm{T}} % For transpose
\newcommand{\D}[1]{\mathcal{D}[#1]\;}
\newcommand{\pdiff}[3][]{\frac{\partial^{#1}#2}{\partial{#3}^{#1}}}
\newcommand{\diff}[3][]{\frac{\d^{#1} #2}{\d{#3}^{#1}}}
\newcommand{\ddiff}[3][]{\frac{\delta^{#1} #2}{\delta{#3}^{#1}}}
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
\newcommand{\ceil}[1]{\left\lceil#1\right\rceil}
\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\erf}{erf}
\DeclareMathOperator{\erfi}{erfi}
\DeclareMathOperator{\sech}{sech}
\DeclareMathOperator{\sinc}{sinc}
\DeclareMathOperator{\sn}{sn}
\DeclareMathOperator{\cn}{cn}
\DeclareMathOperator{\dn}{dn}
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\order}{O}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\span}{span}
\DeclareMathOperator{\GP}{\mathcal{GP}}
\DeclareMathOperator{\N}{\mathcal{N}}
\newcommand{\mylabel}[1]{\label{#1}\tag{#1}}
\newcommand{\degree}{\circ}
% These replace SIunitx. They should not be defined in LaTeX.
\newcommand{\SI}[2]{#1\;\mathrm{#2}}
\newcommand{\si}[1]{\mathrm{#1}}
\let\qty\SI
\let\unit\si
\newcommand{\squared}{{^{2}}}
\newcommand{\cubed}{{^{3}}}
\newcommand{\per}{/}
\newcommand{\tera}{T}
\newcommand{\giga}{G}
\newcommand{\mega}{M}
\newcommand{\kilo}{k}
\newcommand{\milli}{m}
\newcommand{\micro}{μ}
\newcommand{\nano}{n}
\newcommand{\kilogram}{\text{kg}\,}
\newcommand{\meter}{\text{m}\,}
\newcommand{\second}{\text{s}\,}
\newcommand{\ampere}{\text{A}\,}
\newcommand{\kelvin}{\text{K}\,}
\newcommand{\mol}{\text{mol}\,}
\newcommand{\candela}{\text{cd}\,}
\newcommand{\newton}{\text{N}\,}
\newcommand{\hertz}{\text{Hz}\,}
\newcommand{\pascal}{\text{Pa}\,}
\newcommand{\volt}{\text{V}\,}
\newcommand{\watt}{\text{W}\,}
\newcommand{\joule}{\text{J}\,}
\newcommand{\henry}{\text{H}\,}
\newcommand{\farad}{\text{F}\,}
\newcommand{\coulomb}{\text{C}\,}
\newcommand{\ohm}{\Omega\,}
\newcommand{\weber}{\text{Wb}\,}
\newcommand{\tesla}{\text{T}\,}
\newcommand{\degree}{\text{deg}\,}
\]
Back to top
phys_581.assignment_1
Assignment 1
Module Contents
play_monty_hall ( switch = False )
Return True if the contestant wins one round of Monty Hall.
Parameters:
switch (bool ) – If True , then switch doors, otherwise stick with the original door.
fib ( n )
Return the nth Fibonacci number.
lambertw ( z , k = -1 )
Return \(w\) from the k ’th branch of the LambertW function.
\[z = we^w, \qquad
w = W_k(z).\]
Parameters:
z (float , array_like ) – Argument. You can assume that z >= -exp(-1) and that z <= 0 if
k == -1 . Raise ValueError otherwise (unless your code correctly extends
\(W(z)\) to the complex plane).
k ([ 0 , -1 ] ) – Branch. If k == 0 , then return the solution \(w>-1\) , otherwise if
k == -1 , return the solution \(w < -1\)
Notes
Do not use a canned implementation, even if you find one in SciPy. Write your own
version.
zeta ( s )
Return the Riemann zeta function at s .
\[\zeta(s) = \sum_{1}^{\infty} \frac{1}{n^{s}}.\]
Parameters:
s (float ) – Argument of the zeta function.
derivative ( f , x , d = 0 )
Return the d ’th derivative of f(x) at x .
Parameters:
f (function ) – The function to take the derivative of.
x (float ) – Where to take the derivative.
d (int ) – Which derivative to take. d=0 just evaluates the function.