Part 5 Capter 19 Numercal Derentaton PowerPonts organzed by Dr. Mcael R. Gustason II, Duke Unversty Revsed by Pro. Jang, CAU All mages copyrgt Te McGraw-Hll Companes, Inc. Permsson requred or reproducton or dsplay.
Capter Objectves Understandng d te applcaton o g-accuracy numercal derentaton ormulas or equspaced data. Knowng ow to evaluate dervatves or unequally spaced data. Understandng ow Rcardson etrapolaton s appled or numercal derentaton. Recognzng te senstvty o numercal derentaton to data error. Knowng ow to evaluate dervatves n MATLAB wt te d and gradent unctons. Knowng ow to generate contour plots and vector elds wt MATLAB.
Introducton to Derentaton Te one dmensonal orms o some consttutve laws commonly used Law Equaton Pyscal Area Gradent Flu Fourer s law dt qk d Heat conducton Temperature Heat Proportonal constant Termal conductvty t dc Fck s law J D d Mass duson Concentraton Mass Dusvty D Arcy s law d qk d Flow troug porous meda Head Flow Hydraulc conductvty Om s dv J Electrcal l Current low Voltage Current law d conductvty Newton s du vscosty t Fluds Vl Velocty Sear stress d law Hooke s law L E L Elastcty Deormaton Stress Dynamc vscosty Young s modulus
Derentaton Te matematcal denton o a dervatve begns wt a derence appromaton: y and as : ndependent varable s allowed to approac zero, te derence o or y: dependent varable becomes a dervatve: dy d lm 0
Hg-Accuracy Derentaton Formulas Taylor seres epanson can be used to generate g-accuracy ormulas or dervatves by usng lnear algebra to combne te epanson around several ponts. l l d Tree categores or te ormula nclude orward nte-derence, backward ntederence, and centered nte-derence.
Derentaton Tere are also backward derence and centered derence appromatons, dependng on te ponts used: Forward: ' 1 Backward: ' 1 1 Centered: O O ' 1 1 2 O 2
Derentaton cont te rst order dervatve Forward derence appromaton o 1 2 1 O O te rst order dervatve Backward derence appromaton o 1 2 1 O O te rst order dervatve Centered derence appromaton o 2 2 1 1 2 1 2 1 O O O Hger-Accuracy
Forward Fnte-Derence Hger-Accuracy
Backward Fnte-Derence
Centered Fnte-Derence
Eample 19.1 1/2 Q. Recall tat n E. 4.4 we estmated te dervatve o at =0.5 usng orward derences and a step sze o =0.25. Te results are summarzed n te table below. Te eact value o 0.5= -0.9125. 4 3 2 0.1 0.15 0.5 0.251.2 Repeat te computaton wt g accuracy ormulas. Backward O Centered O 2 Forward O Estmate -0.714-0.934-1.155 t 21.7% -2.4% -26.5%
Sol. 2 2 Eample 19.1 2/2 0 1.2 1 0.25 1 1.1035156 05 0.5 0925 0.925 1 0.75 1 0.6363281 2 1 2 0.2 Forward derence o O 2 s computed as 0.2 40.6363281 30.925 0.5 0.859375 t =5.82 % 20.25 Backward derence o O 2 s computed as 30.925 41.1035156 1.2 0.5 0.878125 t =3.77 % 20.25 Centered derence o O 4 s computed as 0.2 80.6363281 81.1035156 1035156 1.2 0.5 0.9125 t =0 % 120.25 Backward Centered Forward O O 2 O t 21.7% -2.4% -26.5%
Rcardson Etrapolaton As wt ntegraton, te Rcardson etrapolaton can be used to combne two lower-accuracy estmates o te dervatve to produce a ger-accuracy estmate. For te cases were tere are two O 2 estmates and te nterval s alved = /2, an mproved O 4 2 1 estmate may be ormed usng: D 4 3 D 2 1 3 D 1 For te cases were tere are two O 4 estmates and te nterval s alved 2 = 1 /2, an mproved O 6 estmate may be ormed usng: D 16 15 D 1 2 15 D 1 For te cases were tere are two O 6 estmates and te nterval s alved 2 = 1 /2, an mproved O 8 estmate may be ormed usng: D 64 D 1 2 63 63 D 1
Eample 19.2 Q. Usng te same uncton as n E.19.1, estmate te rst dervatve at =0.5 or a step sze o 1 =0.5, and 2 =0.25. Use te Rcardson etrapolaton to compute mproved estmate. Te eact soluton s -0.9125. 4 3 2 0.1 0.15 0.5 0.25 1.2 Sol. Te rst dervatve wt centered derence 0.2 1.2 D 0.5 1.0 t = 9.6% 1 0.63632811.103516 D 0.25 0.934375 t = 2.4% 05 0.5 Usng te Rcardson etrapolaton, te mproved Estmate s 4 1 D D 2 D 1 3 3 0 1.2 2 2 0.25 1.10351561035156 1 1 0.5 0.925 0.75 0.6363281 1 1 1 0.2 2 2 4 1 D 0.934375 1 0.9125 3 3
Unequally Spaced Data One way to calculated dervatves o unequally spaced data s to determne a polynomal l t and take ts dervatve at a pont. As an eample, usng a second-order Lagrange polynomal to t tree ponts and takng ts dervatve yelds: 0 2 1 2 0 1 0 2 2 0 2 2 0 1 1 1 0 1 2 2 2 0 2 1
Eample 19.3 Q. A temperature s measured nsde te sol as sown below. Compute te eat lu nto te ground at te ar-sol nterace. q z 0 dt k dz z 0 were q=eat lu W/m2, k=termal conductvty or sol =0.5 W/m K, T=TemperatureK, z=dstance measured rom te surace nto te sol. 20 0.0125 0.0375 20 0 0.0375 0 13.5 12 0 0.01250 0.0375 0.0125 00.0125 0.0375 20 0 0.0125 10 1440 1440 133.333 133.333 K / m 0.0375 00.0375 0.0125 W W W qz 0 0.5 133.333 66.667 mk m m 2
Dervatves and Integrals or Data wt Errors A sortcomng o numercal derentaton s tat t tends to amply errors n data, wereas ntegraton tends to smoot data errors. One approac or takng dervatves o data wt errors s to t a smoot, derentable uncton to te data and take te dervatve o te uncton. a Data wt no error b Resultng numercal derentaton o curve a c Data moded slgtly d Resultng numercal derentaton o curve a > Small data errors are ampled -> Small data errors are ampled by numercal derentaton.
Numercal Derentaton wt MATLAB MATLAB as two bult-n unctons to elp take dervatves, d and gradent: d Returns te derence between adjacent elements n dy./d Returns te derence between adjacent values n y dvded by te correspondng derence n adjacent values o
Numercal Derentaton wt MATLAB = gradent, Determnes te dervatve o te data n at eac o te ponts. Te program uses orward derence or te rst pont, backward derence or te last pont, and centered derence or te nteror ponts. s te spacng between ponts; omtted =1. Te major advantage o gradent over d s gradent s result s te same sze as te orgnal data. Gradent can also be used to nd partal dervatves or matrces: [, y] = gradent,
Vsualzaton MATLAB can generate contour plots o unctons as well as vector elds. Assumng and y represent a mesgrd o and y values and z represents a uncton o and y, contour, y, z can be used to generate a contour plot [, y]=gradentz, can be used to generate partal dervatves and quver, y,, y can be used to generate vector elds