1) Make an IPython notebook with common lab formulae

N.B.: Examples ported from my grad laptop scripts folder. I haven't done bench work in over ten years, so the example values may not be sane, but the math should still be correct.

Nucleotide quantification

In [1]:
# Absorbance
A = 1
# Sample volume (uL)
v = 5
# Solvent volume (uL)
V = 100
# Length/bp
L = 1000

Double Stranded DNA (50ug/mL per OD Maniatis E.5)

Molality (mg/mL)

$\frac{.05AV}{v}$

In [2]:
.050 * A * V/v
Out[2]:
1.0

Molarity (M)

$\frac{.05AV}{v}\frac{660}{L}$

In [3]:
.050 * A * V/v / 660 / L
Out[3]:
1.5151515151515152e-06

Single Stranded DNA or RNA (40ug/mL per OD Maniatis E.5)

Molality (mg/mL)

$\frac{.04AV}{v}$

In [4]:
.040 * A * V/v
Out[4]:
0.8

Molarity (M)

$\frac{.05AV}{v}\frac{660}{L}$

In [5]:
.040 * A * V/v / 660 / L
Out[5]:
1.2121212121212122e-06

Single Stranded oligos (20ug/mL per OD Maniatis E.5)

Molality (mg/mL)

$\frac{.02AV}{v}$

In [6]:
.020 * A * V/v
Out[6]:
0.4

Molarity (M)

$\frac{.05AV}{v}\frac{660}{L}$

In [7]:
.020 * A * V/v / 660 / L
Out[7]:
6.060606060606061e-07

pHing a buffer

N.B.: This example uses the log and sqrt functions from the math module. This isn't covered in the primer, but we'll go over it in class.

In [8]:
# pKa of the (weak acid) buffer
pka = 3.8
# target pH (N.B.: if abs(pka-pH) > 1, consider picking a different buffer)
pH = 4.2
# total concentration of the buffer (molar)
total = .01

Expected initial pH:

$protonated_i = k_a + 2*total - \sqrt{\frac{k_a^2+4*total*k_a}{2}}$

$deprotonated_i = total - protonated_i$

$pH_i = -\log_{10}{deprotonated_i}$

In [9]:
from math import log, sqrt

ka = 10**(-pka)

# Calculate initial concentrations using the quadratic equation

protonated_i = (ka + 2 * total - sqrt((ka**2) + 4*total*ka))/2
deprotonated_i = total - protonated_i
pH_i = -log(deprotonated_i)/log(10)

pH_i
Out[9]:
2.9273191973481283

Add strong base to this concentration:

$deprotonated_f = total \left(1 - \frac{1}{1+10^{pH - pKa}}\right)$

$base = deprotonated_f - deprotonated_i$

In [10]:
# Calculate final concentrations using Henderson-Hasselbach

deprotonated_f = total * (1 - 1/(1 + 10**(pH - pka)))
protonated_f = total - deprotonated_f

# Calculate the concentrations of protons that we need to suck up
# (by adding this concentration of strong base) in order to arrive
# at the target pH

base = deprotonated_f - deprotonated_i

base
Out[10]:
0.0059703551460742665

2) Try evaluating this series:

$1+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\frac{1}{4!}\ldots$

In [11]:
x=1
y=1
z=1
In [12]:
y*=z
x+=1/y
z+=1
x,y,z
Out[12]:
(2.0, 1, 2)
In [13]:
y*=z
x+=1/y
z+=1
x,y,z
Out[13]:
(2.5, 2, 3)
In [14]:
y*=z
x+=1/y
z+=1
x,y,z
Out[14]:
(2.6666666666666665, 6, 4)
In [15]:
y*=z
x+=1/y
z+=1
x,y,z
Out[15]:
(2.708333333333333, 24, 5)
In [16]:
y*=z
x+=1/y
z+=1
x,y,z
Out[16]:
(2.7166666666666663, 120, 6)
In [17]:
y*=z
x+=1/y
z+=1
x,y,z
Out[17]:
(2.7180555555555554, 720, 7)
In [18]:
y*=z
x+=1/y
z+=1
x,y,z
Out[18]:
(2.7182539682539684, 5040, 8)
In [19]:
y*=z
x+=1/y
z+=1
x,y,z
Out[19]:
(2.71827876984127, 40320, 9)
In [20]:
y*=z
x+=1/y
z+=1
x,y,z
Out[20]:
(2.7182815255731922, 362880, 10)

Here we use the math module to check that the series approximates $e$, the base of the natural logarithm.

In [21]:
from math import exp
In [22]:
exp(1)
Out[22]:
2.718281828459045
In [23]:
exp(1)-x
Out[23]:
3.0288585284310443e-07
In [ ]: