thegooglecodearchive / mpmath

Automatically exported from code.google.com/p/mpmath
Other
0 stars 0 forks source link

nice function picture #143

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
During my preparations for an exam in chemistry, I thought that the formula
for solubility of ionic compounds would give a nice picture. Here it is.

Given a dissociating ionic compound

A^+_mB^-_n <-> m A^+ + n B^-

the solubility is

L = (K_L / (m**m * n**n))**(1/(m+n))

where K_L is the solubility constant

K_L = c(A^+)**m * c(B^-)**n

where c is the concentration.

The attached picture was plotted with cplot using

f = lambda x: (1/(m**m * n**n))**(1/(m+n))

with m = x.real and n = x.imag.

Original issue reported on code.google.com by Vinzent.Steinberg@gmail.com on 2 May 2009 at 8:47

Attachments:

GoogleCodeExporter commented 9 years ago
It's pretty, although I'm not sure what it means...

We should perhaps add a function for 2d plotting without complex numbers?

Original comment by fredrik....@gmail.com on 3 May 2009 at 1:56

GoogleCodeExporter commented 9 years ago
The picture is just pretty and does not mean anything at all. :)

[I don't know how familiar you are with chemistry and things like [1], I'll 
just give
you an example where the formula for solubility is used. Skip it in case you 
are not
interested. :)

We have a saturated solution of Calcium hydroxide (Ca(OH)_2):

(1)  Ca(OH)_2 <-> Ca^{2+} + 2 OH^-

It's a chemical equilibrium, so we can write

(2)  K_L(Ca(OH)_2) = c(Ca^{2+}) * c(OH^-)**2

where K_L(Ca(OH)_2) is a constant we can get from literature and c(Ca^{2+}) is 
the
concentration of Ca^{2+} ions (in mol/l for instance). (This basically means 
that the
"chemical velocity" of the reaction is equal in both directions.) The lower this
constant is the harder is it to solve the compound in water. 

From (1) we know that

(3)  c(OH^-) = 2*c(Ca^{2+})

Inserting (3) in (2) gives

(4)  K_L(Ca(OH)_2) = 4*c(Ca^{2+})**3

Solving for c(Ca^{2+}):

(5)  c(Ca^{2+}) = nthroot(K_L(Ca(OH)_2) / 4, 3) = 1.1e-2 mol/l

(Because K_L(Ca(OH)_2) = 5.5e-6 (mol/l)**3.)

This is a special case with m = 1 and n = 2, more generally we get something 
like

nthroot(K_L / (m**m * n**n), m + n) where m and n are natural numbers.

I just replaced K_L with 1 (which is silly, because it depends on the particular
ionic compound.) and plotted it. :)

[1] http://en.wikipedia.org/wiki/Chemical_equilibrium]

> We should perhaps add a function for 2d plotting without complex numbers?

cplot(lambda x,y: ...) could just work without adding another function. We could
rename cplot to 2dplot. This would be more general.

Original comment by Vinzent.Steinberg@gmail.com on 3 May 2009 at 6:40

GoogleCodeExporter commented 9 years ago
rather 2dplot -> plot2d

Original comment by ondrej.c...@gmail.com on 3 May 2009 at 10:32