base problems

Dec 1, 1990 - A comparison of three software programs to solve acid/base problems. Edgar H. Nagel. J. Chem. Educ. , 1990, 67 (12), p A302. DOI: 10.102...
0 downloads 14 Views 2MB Size
the computer bulletin board

The macro carries out an initialization Loop over the terms and computation of each term. Looping is carried out by the macro instruction FOR, which identifies a cell to be used as the counter, gives the starting value, s t e p a n d terminal value of t h e counter, and the cell location where the subroutine far calculating and summing each term begins. This subroutine in turn calls a second subroutine for calculating factorials, the variables being passed to the subroutine by giving the addresses where they are stored. In operation, n and r are loaded into designated cells and the macro executed by entering its name, the result appearing in another designated cell. By judicious use of a copy operation, the polynomial may be evaluated for a series of values of x and then plotted for inspection. Any of the commonly encountered polynomials (Hermite, Legendre, Laguerre, Chehyehev, etc.) as well as thespherical harmonies can be computed in this way. Concluslons For most of the calculations of interest to chemists, particularly for undergraduates, spreadsheets afford a simple (because menu driven) and flexible comuutinp "lanwage". Rather sophisticated programs can-behevised without resorting to more highly stylized compiled languages. In the crowded chemical curriculum, there is a real advantage to introducing entering students to spreadsheets and then continuing their use as the physical and mathematical problems grow more challenging. As shown here, it is not necessary to sacrifice computing power in this process.

A Comparison of Three Software Programs to Solve Acid/ Base Problems

set up of the problem, and they give results that are equivalent to those obtained from a spreadsheet. The two problems illustrated here involve finding the pH of a solution of acetic acid and the same problem illustrated hy Parker and Breneman. The three programs used to solve the problems are Quattro, a LOTUS 1-2-3 compatible spreadsheet from Borland', Eureka: The Solver also from Borland, and the Student Edition of MathCAD Version 2.0 from Addison-Wesleyz. All three of these programs run on PC-compatible computers, and the Borland programs are available at educational prices provided you are either a student or a faculty member at an educational institution. The simultaneous equations used to eald a t e the pH of monosodium sslt solutions of diprotic acids are illustrated in the article by Parker and Breneman and will not be reproduced here. The equations usedto calculate the pH of an aeetie acid solution are as follows:

K, = [H30t] [OH-]

+ [A-] [H30+]= [ A ] + [OH-] C, = [HA]

+ [OH-]) + K,))'.'

A302

Journal of Chemical Educatlon

(4)

(5)

S p r e a d s h e e t Solutlons The Quattro results for the monosodium sslt -~~ of malic acid are the same as in the article by Parker and Breneman. The results for aceucarid are calculated using the following equations. ~

B4: C4:

(6)

+ 04) + $KW)^0.5(7) (8) +$KAa(A4 - C4 + D4)/B4 ($KAS(A4 - C4

D4: +$KW/B4 A recent article by Parker and Breneman (9) suggests the use of a spreadsheet to generate numerical solutions for the pH of solutions of monosodium aalts of diprotic acids. Spreadsheetsare good at solving these types of problems. However, difficulties arise with circular logic and the authors are careful to point these out. Circular Logic arises when two different cells reference each other. Equation solvers allow you to type in the equations so that they look like the original

(3)

These equations are rearranged togive eq 5, used to make the successive approximation calculations for the spreadsheet solution to the problem.

A4: Initial Acid Concentration Edgar H. Nagel Valparalsa University Vslparaioo. IN 46383

(2)

E4: -@LOG(B4)

(9)

(10)

A P E 4 are cell references. Column B contains [H30t], C contains [A-], D contains [OH-], and E contains the pH. 5K.4 and

' BorIand imernatlonal. Inc., 4585 Scons Valley Drlve, Scom Valley, CA 95066. ZAddi~~n-WesIey Publishing Company. Inc.,

$KW are references to cell names that cantain the appropriate constants. An example of circular logic occurs in eq 7 since it uses the results of eqs 8 and 9, which use the results of eq 7. The spreadsheet calculation, for aeetie acid, fails when the initial concentration of acid is 10-5 or less. Quattro indicates failures by placing ERR in cells. When ERR occurs in eells that are used in circular calculations, the only way to continue is to erase the circular cells that have ERR in them, change the cell that caused the error, copy the equations back into the appropriate cells, and recalculate. Eureka Solutions The Eureka equations for solving the monosodium salt problem are similar to the defining relationships in the article hy Parker and Breneman and the results are identical to those of the spreadsheet for both high (0.10) and low (0.00001) concentrations. The differences between Eureka and the soreadsheet are that it is more difficult tu ohmin output lor a series of concentrntims in t a l d a r form and thr Eurekn Iterations are hidden from the user. In pen~ral. equation sblvers set u p their own internal iterations and spreadsheets require the user to set up the iterations. The acetic acid equations for Eureka are entered as they appear in eqs 1 to 4 except that subscripts and superscripts are not used, all [ ] are removed, and [HsOt] becomes H. Initial guesses of H = (K.*C.)O5, HA = C,, OH = K,IH, and A = K.*HAIH are added dong with the constraints H > 0 and OH > 0. The final results from Eureka may sometimes give physically impossible answers. The results depend on the initial guesses and on the "accuracy" setting under the Options menu. Eureka's first attempt gave amaaimum error of 2.83-07,pHof 2.84 and [OH-] = 2.963-4. Even though the maximum error is small, the value for [OH-] is impossible. After several iterations, the maximum error was reduced to 9.993-15 with a pH of 2.88. However, 1.323-17 for [OH-] is still impossible. If the OptionsSettine-Accuracv is chaneed to 1E-25. cor" " reet answers are obtained for all eoncentrations uf acetic acid. Eureka hap n tendency t u "remember" rpsults. If you use the default accuracy to solve a problem and then change the accuracy to get a better answer, you also have to rewrite one of the equations to force a new calculation. If that does not work, you may have to return to DOS, start Eureka, make changes to the options, and then solve the problem. ~~~~

~~~~

~

~

~

~

~

~

Student Edltlon of MsthCAD The monosadium sslt problem for the Student Edition of MsthCAD are the same as Eureka. The acetic acid equations for MathCAD are similar to the Eureka equa-

tions. The initial guesses appear first and eqs 1 to 4, along with constraints appear between the words Given and Find. The equations between the Given and Find constitute a solve block for the problem. No special settings were used in either of the calculations and the results were good for both types of problems. Thus MathCAD is more robust in obtainingfinal results than is Eureka.

Plotting All three of the programs can plot functions. Spreadsheets require that you produce columns of the X-Y data pain, while Eureka and MathCAD can plot the functions directly. In Eureka, a single function with automatic Y scaling can he plotted. MathCAD can plot multiple functions on a single graph with either automatic or specified X and Y sealing. MathCAD can also produce different plots in the same document, and it can do limited text editing along with the mathematical equations and plots. Examples of the types of plots from Eureka and MathCAD are in the figure. These examples show plots of the fraction of acid that is present in a specific form as a function of pH. The tahle gives an overall summary of the three programs. If yon are looking for a program to solve your problems, I think that the best buy would be the Student Edition of MathCAD. If you want to make 3-D plots, invest in the MathCAD Professional Version from MathSoft3 a t an educational discount.

Literature Clted Johnson. K. J. Numerical Methods in Chamisfw; Dekker: New Yark, 1980. 2. Johnston. M . D.. Jr. Chamicnl Computation: Elasvier: NowYork. 1988. 3. orr ria. A. C. ~ o m p u f o f i o n dChemistry: Wiley: New 1.

Comparison of Programs

Quatba Equation format Plots Results

Good Modifled X-Ydata pain Can get circular loglc errors

Tabular format Text edlting Time to proficiency Overall

Excellent Pow Longest Exosllent spreadsheet

Ease 01 use 1639. 7. press. W. H.: ~ l a ~ ~ e rP.; y Teukolsh. ,~. S. A.;Vetteriina, W. T. NumwicolRacipe8; Cambridge: New York, 1986: p 246. 8. orvia, W. J. I - 2 3 f o r Srimfisfs and Engineers:Syhex: Ssn Francisco, 1987; p 196. 9, p ~ k r0. , J.; Breneman, G.L. J. Chern. Edvc 1990.67, AS-A6.

Eureka

Gxd AS in a typical text

Gxd

Single function May have to change accuracy fOT good results Poor Poor Medium Fair equation solver

k'

As ina

,..

-. , .

--

~~~~~

V

L

\i E EIMIIUIII

W Y ~ L I Y I I WIV-I

Reading. MA. 3 ~amsolt.Inc.. One Kendall Square. Cam bridge. MA 02139. Comparison of MathCAD and Eureka Plots

Volume 67

Number 12

December 1990

A303