12.07.2015 Views

Analytical Chem istry - DePauw University

Analytical Chem istry - DePauw University

Analytical Chem istry - DePauw University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 Equilibrium <strong>Chem</strong><strong>istry</strong>265+ − −[ HO ] = [ OH ] + [ F ]3From this point, we made two assumptions, simplifying the problem toone that was easy to solve.[ HO ] = KC = ( 68 . × 10 )( 10 . ) = 26 . × 10+ −4 −23 a HFAlthough we did not note this at the time, without making assumptionsthe solution to our problem is a cubic equation+ +[ HO ] + K [ HO ]3 23 a 3+− ( KC + K )[ HO ] − K K = 0a HA w 3 a wthat we can solve using the uniroot command. Of course, this assumes thatwe successfully complete the derivation!Another option is to use write a function to solve simultaneously thefour equations for the variables [HF], [F – ], [H 3 O + ], and [OH – ]. Here isthe code for this function, which we will call eval.> eval = function(pH){+ h3o =10^–pH+ oh = 1e–14/h3o+ hf = (h3o*f)/6.8e–4+ error = hf + f – 1+ output = data.frame(pH, error)+ print(output)+ }Let’s examine more closely how this function works. The function acceptsa guess for the pH and uses the definition of pH to calculate [H 3 O + ], K wto calculate [OH – ], the charge balance equation to calculate [F – ], and K ato calculate [HF]. The function then evaluates the solution using the massbalance expression for HF, rewriting it as−−[ HF] + [ F ] − C = [ HF] + [ F ] − 10 . = 0HFThe open { tells R that we intend to enterour function over several lines. When wepress enter at the end of a line, R changesits prompt from > to +, indicating thatwe are continuing to enter the same command.The close } on the last line indicatesthat we are done entering the function.The command data.frame combines twoor more objects into a table.You can adapt this function to other problemsby changing the variable you pass tothe function and the equations you includewithin the function.The function then gathers together the initial guess for the pH and the errorand prints them as a table.The beauty of this function is that the object we pass to it, pH, cancontain many values, allowing us to easily search for a solution. BecauseHF is an acid, we know that the solution must be acidic. This sets a lowerlimit of 7 for the pH. We also know that the pH of 1.0 M HF can be nolarger than 1.0 M as this would be the upper limit if HF was a strong acid.For our first pass, let’s enter the following code> pH = c(7, 6, 5, 4, 3, 2, 1)> func(pH)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!