Using Mathcad's cubic spline functions for ... - ACS Publications

MathBrowser: Web-Enabled Mathematical Software with Application to the Chemistry Curriculum, v 1.0 (MathSoft). Jack G. Goldsmith. Journal of Chemical ...
0 downloads 0 Views 2MB Size
edited by

RUSSELLH. BAT^ Kenyon College Garnbier. OH 43022

Using Mathcad's Cubic Spline Functions for Numerical Fitting of Data to Tabulated Functions Valle ~ l o n s o 'and Luis carnacho' Universidad de Cordoba Avda San Aibeno Magno s/n E-14004 Cordoba, Spain Cubic spline functions are interpolation expressions derived on the assumption that two successive points in a data set are related via a third-order polynomial (1,2).The simolicitv " of the almrithm reauired to calculate the coeEcients of such a polynomial allows cubic spline functions to be routinelv used for resolvine a varietv of mathematical and complex problems ;elated to both daia function handling. Cubic spline functions can readily be incorporated into a computer program a s subroutines. Thus, commercially available software such a s Mathematica (3) or MathCAD (4) incorporates both this algorithm and the wrresponding interpolation function a s user functions. I n this work, we used MathCAD, which offers three choices for defining cubic splines, viz. the function Ispline(X,n, which handles natural splines, and the functions pspline(X,n and cspline(X,n, which are applied to curves whose initial and final points fit a parabola or a cubic function, respectively. The interpolation functions obtained from these polynomials can be user analytical functions for any computational purpose. The sole constraints in this respect are not to exceed the interpolation limits and have a large enough initial data set to ensure correct interpolation. These functions are used for a variety of purposes, particularly in relation to data processing (e.g., numerical derivation and intemation, determination of curve maxima and minima) (5-?I. We shall concentrate on a lesser known aoolication, which, however, has a meat potential for res&ing some mathematical problem; posed by some chemical systems. This application is the numerical fitting of data to tabulated or nonanalytical functions. A

-

Use of Cubic Spline Functions for Numerical Fitting in Linear Sweep Voltammetry (LSV) The theoretical Faradic current for a n irreversible electron transfer in linear sweep voltammetry (LSV) was tabulated by Nicholson and Shain (8).This technique often involves Volterra integral equations, which must be solved numerically. Therefore, using tabulated equations avoids the need to do any calculations, yet entails fitting experimental data to tabulated values. One way of solving these problems is to define interpolation functions. Table 2 in ref. 8 lists the values of functions x(bt)(n)ln and $(bt) uersusV (mV). V is defined a s

'Departamento de lngenieria Quimica y Quimica Inorghnica, Facultad de Ciencias. 2Departamento de Quimica Fisica y Termodinamica Aplicada, Facuitad de Ciencias. A312

Journal of Chemical Education

where an denotes the transfer coefficient for the process, E is the potential, and EM is given by

Eo being the standard reduction potential (mV), k, the standard rate constant, D (cm2/s)the diffusion coefficient, and b a parameter defined a s

) with v the sweep rate (in mV/s). Finally, functions ~ ( b tand $(bt) are related to the Faradic current by the following equation:

where n is the number of electrons exchanged per molecule, A (cm2) and r (cm) are the area and radius, respectively, of the spherical electrode, and CAis the depolarizer concentration (in mM). Let us defme Y = X(bt)(rr)'lz

and use them to define the interpolation polynomials a s W = lspline(V,Y) and Q = lspline(V,Z) Let us also define the interpolation functions a s (Fig. 1) f i I = interp(W,V,Xxl and

&I

= interp(Q,V,Z,x)

The relation between the tabulated potential function, V, and the experimental potential, E,was derived through the function given in eq 1.I n addition, since b is also function of a n , let us define the function b(an) a s in eq 3. Finally, the theoretical expression for the current a s a function of parameters D, an,and EM,and variable E,can be written as i(D,an,EM,E)=

The selected parameters for the previous function can be different if, for example, one is very accurately known. Thus, if D is determined by a different method, it can be included as another constant rather than a n unknown oarameter in eq 5. The function defined bv . ea. 5 can be used as a user function for the numerical fitting of the parameters on which it deoends. For this ouroose. we run on LSV rccordine for a 0.5 mM solution of:m&~oeth~l fumarate a t pH 4.5 agd 298 K, a s well a s in 0.1 M acetic, boric, and phosphoric acid a t I = 0.6 M, adjusted with NaN03. The sweep rate was u =

the computer bulletin board 98.6 mVls and the area and radius of the hanging mercury drop electrode (HMDE)used were A = 0.0225 cm2 and r = 0.0423 cm, respectively. AU other conditions and apparatus used are described in detail elsewhere (9).Under these experimental conditions, monoethyl fumarate gives an LSV reduction peak that is typical of a fully irreversible process taking into account that no oxidation peak was obtained. Figure 1 shows the numerical fitting performedMathCAD uses the Marquardt-Laveuger algorithm (1,2). Boxes denote experimental data and the solid line the value of eq 5 for the parameters obtained in the fitting, uiz. an = 1.48 f 0.06, D = 1.01 0.04 x lo4 cm2/sa n d E =~-684 f 1mV. The first two were obtained by DC polarography under the same conditions and turned out to be an = 1.5 and D = 1.1x lo4 cm2/s,respectively (9). This procedure can he applied to other electrode reduction mechanisms with tabulated solutions (8) and, in gen-

eral, to any non-analytical function whose calculation is rather laborious.

Implementation of Fourier Transform Rapid Scan NMR S~ectrosco~v Techniaues in Continuous Wave NMR ~~ectiometers G. Moyna, J. Cernadas, L. Mussio ,and G. Hernandez NMR Laboratory, Facultad de Quimica

Avda. General Flores 2124 Montevideo, Uruguay

*

Introduction Old continuous wave N M R spectrometers (i.e., Varian T-60, Varian A-60, etc.) are usually used only for very simple NMR analysis or student training. Connection to an IBM PC compatible computer through an ADDAconverter and simpie programming can make these machines useful in a ORIGIN := 1 wide range of experiments.

* CONSTANTS: T ---------------

:= 298.15

v := 98.6

R :=

8.314

n := 2

** INITIAL F m I N G PARmmERS: ** .................................. FIT: ------------------+ NUMERICAL

Given

:= fi-(D,m,W)

rm

:= 1.5

D

Journal of Chemical Education

> 0

D :=

CA := 0.5

r := 0.0423

1.10

m

:= -690

s s ~ ( ~ , r m , n*) 0

-5

D =

1.01.10

Figure 1. MathCAD document for the numerical finingin LSV. A314

96487

A := 0.0225

a! < -500

[i]

F :=

m = 1.48

W = -683.7

Hardware and Software Considerations In our particular case, a Varian T-60 (10) was upgraded to Fourier transform rapid scan capabilities. A Data Translation DT2801 ADDA converter board (11) and a simple home-made voltage-controlled current source were used to scan and co-add the spectra with the PC. In order to scan the spectra, the voltage-controlled current source was driven with one of the ADIDA converter analog outputs (12). This current source supplies a current proportional to the output voltage of the ADDA analog output and is used to sweep the magnetic field of the T60 spectrometer. At the same time, NMR data are obtained with one of the AD/DA analoe inputs, and kept in the PC memory for later co-addine with data from successive scans. To correct magnetic field drift, spectra are accumulated using the field cure technique, in which the spectra to be co-added are shifted left or right in the computer memory using one of the spectrum peaks as a reference (13). Continuous wave spectra with improved sensitivity a r e obtained in this way They are still affected by well-known continuous wave artifacts, such a s strong ringing present after sharp peaks. These artifacts can be removed by processing the spectra in the computer with Fourier transform and cross-correlation algorithms (13, 14, 15).

-

-

(Continued on page A3l6)