{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Input" 2 19 "" 0 1 255 0 0 1 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 256 "" 1 16 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT 256 25 "Exponential curve fitting " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 170 "We u se linear least squares fitting to observe the exponential behaviour i n the voltage of a capacitor as it charges or discharges in an RC circ uit as a function of time." }}{PARA 0 "" 0 "" {TEXT -1 134 "The fittin g of an exponential function can be accomplished through linear least \+ squares (LLSQ) after taking the logarithm of the data." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(p lots):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "We define a linear leas t squares procedure: (developed in the worksheet " }{TEXT 19 16 "DataA nalysis.mws" }{TEXT -1 1 ")" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "addme:=arg->evalf(Sum(arg[_i],_i=1..nops(arg)));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "addpr:=(arg1,arg2)->evalf(Sum(arg1[_i]*ar g2[_i],_i=1..nops(arg1)));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "LLSQ:=proc(xv,yv) local _i,N,a,b,c,d,Delta,A,B,sq,sigsq,dA,dB;" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "N:=nops(xv);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "if nops(yv) " 0 "" {MPLTEXT 1 0 16 "c:=addpr(xv,xv);" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "d:=addme(xv);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "a:=addpr(xv,yv);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "b:=addme(yv);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "Delta:=evalf(N *c-d^2);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "A:=(c*b-d*a)/Delta;" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "B:=(N*a-d*b)/Delta;" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 40 "sq:=[]; _i:='_i': for _i from 1 to N do:" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "sq:=[op(sq),evalf(yv[_i]-A-B*xv[_i] )]: od:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "sigsq:=addpr(sq,sq)/(N-2 );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "dA:=sigsq*c/Delta;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "dB:=evalf(N*sigsq)/Delta;" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 27 "print(`[A,B,sigma,dA,dB]`);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "[A,B,evalf(sqrt(sigsq),4),evalf(sqrt(dA),4),evalf( sqrt(dB),4)];" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "The time at which the capacitor voltage was measured (in second s):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "Times:=[]:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "for i from 1 to 21 do:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "Time:=(i-1)*10: Times:=[op(Times),Time]: od:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "Times;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 145 "The voltage across a big electrolytic capacitor whi le being connected to 8.1 Volts through a 1000 Ohm resistor at these t imes was measured to be:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 116 "V_Cchg:=[0.025,0.555,1.04,1.47,1.85,2.16,2.43,2.66,2.83,3.05,3.22 ,3.38,3.52,3.66,3.79,3.9,3.97,4.15,4.25,4.34,4.43];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 300 "The battery voltage was 8.1 Volts. The capacit or charged maximally to 7.4 Volts when fed through a 1000 Ohm resistor ! A leaking current of 0.7 mA accounting for the voltage drop across t he resistor in the steady-state regime was observed for the electrolyt ic capacitor. A non-ideal world after all..." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 94 "We generate a graph of the data points. First for the charging regime, then for the discharge." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "i:='i': PL_c:=[seq([Times[i] ,V_Cchg[i]],i=1..nops(Times))]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "P_c:=plot(PL_c,style=point,symbol=cross,color=red): display(P_ c);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 119 "The capacitor was dischar ged through the same resistor. We reset time to zero and use the same \+ time interval as before." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 112 "V_Cdis:=[4.29,3.96,3.67,3.42,3.19,2.98,2.79,2.62,2.45,2.3,2.15,2. 02,1.9,1.78,1.67,1.57,1.47,1.39,1.3,1.23,1.15];" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 59 "i:='i': PL_d:=[seq([Times[i],V_Cdis[i]],i=1..n ops(Times))]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "P_d:=plot( PL_d,style=point,symbol=cross,color=green):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "display(P_d);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 154 "The discharge regime is easy to analyze, we have an exponential d ecay. Taking the log of the data allows to extract the decay constant \+ using LLSQ fitting:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "ln_o f_V_Cdis:=map(ln,V_Cdis);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "i:='i': PL_dl:=[seq([Times[i],ln_of_V_Cdis[i]],i=1..nops(Times))]: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "P_dl:=plot(PL_dl,style= point,symbol=cross,color=blue):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "display(P_dl);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "This lo oks perfectly linear, and thus we have confidence in the fit." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "i:='i': sol_d:=LLSQ(Times,ln _of_V_Cdis);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "tau:=-1/sol _d[2];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "We discharged the capac itor with a 1 kOhm resistor." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalf(tau/1000);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "e valf(%*10^6);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 122 "The capacitor w as actually rated at 110 000 microFarads. We graph the fit together wi th the original voltage measurements:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "y_d:=exp(sol_d[1]+sol_d[2]*t);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 39 "P_dfit:=plot(y_d,t=0..200,color=black):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "display(\{P_d,P_dfit\},scali ng=unconstrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "The chargin g regime is described by the expression" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "V[C] = U[0]*(1-exp(-t/(R*C)));" "6#/&%\"VG6#%\"CG*&&%\"UG6#\"\"! \"\"\",&F-F--%$expG6#,$*&%\"tGF-*&%\"RGF-F'F-!\"\"F7F7F-" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 386 "To analyze the charging data we need a map that first \+ divides out the final voltage (the one reached for asymptotic times, w hich in our case is 7.4V and not the battery voltage due to the leakag e) from the datapoints, and computes the difference to 1. Then we tak e the logarithm of the voltages. The real part in the map below is tak en to avoid a wrong complex-valued choice of branch." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "myfun:=x->Re(ln(1-x/7.4));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "ln_of_V_Cchg:=map(myfun,V_Cchg);" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "i:='i': PL_cl:=[seq([Times [i],ln_of_V_Cchg[i]],i=1..nops(Times))]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "P_cl:=plot(PL_cl,style=point,symbol=cross,color=blue) :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "display(P_cl,scaling=u nconstrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 167 "We observe tha t the data points behave linearly for the first third, and then turn o ver to a different slope. Thus, we pick out a part of the data set for the fitting." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "nops(Times);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "Times1:=[seq(Times[i],i=1..7)]: ln_of_V_Cchg1:=[seq(l n_of_V_Cchg[i],i=1..7)]:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "sol_c:=LLSQ(Times1,ln_of_V_Cchg1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "tau_c:=-1/sol_c[2];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "C_c:=evalf(tau_c/1000);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "evalf(C_c*10^6*mu*F);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 100 "The value of the capacitance is apparently quite close t o the one obtained from the discharge cycle." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 257 10 "Exercise: " }}{PARA 0 "" 0 "" {TEXT -1 164 "Use the uncertainty on the slopes for the charge and dis charge cycles to determine whether the two determinations of the capac itance are consistent with each other." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT 258 10 "Exercise: " }}{PARA 0 "" 0 "" {TEXT -1 123 "Use Maple's built-in LLSQ procedure (use ?fit to determine its usage) to perform a fit for which the intercept is fixed as " }{TEXT 259 1 "A" }{TEXT -1 89 "=0 (only the slope is determined from the fit) . Compare your results for the capacitance." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 260 16 "Systematic Error" }}{PARA 0 " " 0 "" {TEXT -1 168 "If we had used all the data points from the charg ing cycle, we would have obtained a smaller slope in the linear fit, a nd as a result a substantially larger capacitance" }}{PARA 0 "" 0 "" {TEXT -1 596 "(about 30% higher, but also a much larger uncertainty). \+ To use such a fit blindly (without checking whether the data to be fit ted look like a straight line with statistical scatter) would result i n the introduction of a systematic error. The physical reason for this systematic error is the strange behaviour in the charge cycle, whereb y the capacictor never charges up to the full voltage, and a leakage c urrent persists in the asymptotic time regime. The capacitor we used w as an old specimen (garage sale purchase), and is likely to be faulty, i.e., probably performed better when it was new. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 85 "We compare the fit result with the data over the full charge time that was observed." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "y_c:=7.4*(1-exp(-t/tau_c)); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "P_cfit:=plot(y_c,t=0..2 00,color=black):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "display (\{P_cfit,P_c\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {MARK "0 0 0" 23 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }