Prosiding Seminar Kebangsaan Aplikasi Sains dan Matematik 2013 (SKASM2013) Batu Paat, Joor, 29 30 Oktober 2013 NUMERICAL DIFFERENTIATIONS SPREADSHEET CALCULATOR Kim Gaik ~ a ~ (Sie ', Lo~ig KekZ & Rosmila Abdul Kaar') '~acult~ of Electrical and Electronics, Universiti Tun Hussein Onn Malaysia, 86400 Pavit Raja, Joor, Malaysia tay@,utm. edz~.nty '"~e~artment of Matematics & Statistics, Faculty of Science,Tecnology & Human Development, Universiti T~in Hzissein Onn Malaysia, 86400 Pavit Raja, Joor, Malaysia slkek@,utm. edu.mv rosnzila@z~tnz.edu.my In tis paper, we ave developed a spreadseet calculator for numerical differentiations. In tis spreadseet calculator, users may select eiter a given function or a given data to approximate te numerical differentiation. For a given function option, users are only required to key in te value of x, te functionflx) and te step size. Te spreadseet calculator will ten tabulate te (x, Ax)) data into a given table. On te oter and, for a given data option, users only ave to key in te (x, y) data into te given table. For bot options, te first derivative at te specified value of x will be approximated by using 2 point forward, 2point backward, 3point central, 3point forward, 3point backward and 5point formulas, wereas te second derivative at te specified value of x will be calculated by using 3point central and 5point formulas. Wit tis numerical differentiations spreadseet calculator, we ope to elp educators to prepare teir marking sceme easily and to assist students in cecking teir answers. Keywords: numerical differentiation, 2point forward, 2point backward, 3point central, 3point forward, 3point backward and 5point formulas 1. INTRODUCTION Many pysical problems involving te rate of cange need differentiation. For example, velocity is te rate of cange of distance wit respect to time, wile acceleration is te rate of cange of velocity wit respect to time. Te rate of cange of y wit respect to x can be calculated from te gradient of te curve in a grap of y against x. For a function tat is not easily differentiated analytically or wen only a set of data is given, numerical differentiation can be used. Normally, te derivative off at a specified value of x can be approximated using te formulae based on Taylor's series expansions, for example te first derivative at te specified value of x can be approximated by using 2point backward, 2point forward, 3point central, 3point forward, 3point backward and 5point formulas, wereas te second derivative at te specified value of x can be approximated by 111
using 3point central and 5point formulas. Approximating te definite differentiation numerically based on te above formulas is straigt forward, but for' educators and students wo ave already mastered its calculation skills and require a quick solution, recalculating it may be a boring and timewasting process. Hence, tere is a need to design a numerical differentiation spreadseet calculator to elp students and educators wo need immediate solutions. A series of papers working on solving numerical metods in classroom and examination situations using spreadseet wic focus on systems of nonlinear and linear equations, approximation of interpolation, computing of eigenvalues, ordinary differential equations (ODES) by te Fourtorder RungeKutta (RK4) and te Laplace equation can be seen in [l 91. Recently, a Ricardson's extrapolation spreadseet calculator up to level 4 was developed in [lo] to approximate definite differentiation numerically. However, literature works dealing wit spreadseet calculator for approximating definite differentiation by using te formulas in Excel ave not been explored as yet. Tus, in tis paper, we ave developed a spreadseet calculator to approximate te first derivative at te specified value of x by using 2point backward, 2point forward, 3point central, 3point forward, 3point backward and 5point formulas, wereas te second derivative can be approximated at te specified value of x by using 3point central and 5point formulas. Wit ts numerical differentiations spreadseet calculator, we ope to elp educators in preparing teir marking sceme and assisting students to ceck teir answers automatically. Tis paper is organized as follows. Section 2 provides te background of numerical differentiation. Numerical examples are given in Section 3. Te spreadseet calculator is given in Section 4. Finally, a conclusion is given in te final part of tis paper., Section 5. 2. NUMERICAL DIFFERENTIATION In tis section, we give first and second derivatives formulas wit its truncation error based on finite formula as given in Table 1. Te detail of derivation of tese formulas can be referred to using any numerical metods books or numerical analysis books. Table 1 :;Te Difference Formula First derivative, 2point forward 2point backward 3point central 3 point forward f '(x> f '(XI % f '(XI % f '(XI % f '(XI % f (x + ) f (4 f (4f(x) f (x+if (x) 2 3f(x)+4f(x+) f(x+2) 2 Truncatio n Error O() O() O(2) O(2)
Prosiding Seminar Kebangsaan Aplikasi Sains dan Matematik 2013 (SKASM2013) Batu Paat, Joor, 29 30 Oktober 2013 3point backward 5point central f(x2)4f(x)+3f(x) f '(XI = 2 f '(4 = f(x2)8f(x)+8f(x+) 12 f(x+2) O(2) O(4) Second derivatives, 3 point central f "(XI f(x)2f(x)+f (x+) f "(x) = O(2 5point central f(x2)+16f(x)30f(x)+16 f(x+) f(x+2) f "(x)% 122 O(4) 3.0 NUMERICAL EXAMPLE In tis section, we provide two numerical examples to calculate te first and second derivatives based on te formula in Table 1. 3.1. Numerical Example 1 Given f (x) = sin(x). Approximate f '(0.8) and f "(0.8) by using all appropriate formulas in Table 1 wit = 0.1 and = 0.05. State wic gives better approximation. Do in four decimal places calculation. Solution 2point forward f (x + ) f (x) sin(x + ) sin(x) f '(4 = 2point backward f (x) f (x ) sin(x) sin(x ) f '(4 =
3point central 3point forward 3 f (x) + 4 f (x + ) f (x + 2) 3 sin(x) + 4 sin(x + ) sin(x + 2) f '(4 = 2 3 sin(0.8) + 4sin(0.8 + 0.1) sin(0.8 + 2(0.1)) f '(0.8) x = 0.6988 2(0.1) 3point backward 2 5 point formula 3point central for second derivatives. 5point formula for second derivatives
Prosiding Seminar Kebangsaan Aplikasi Sains dan Matematik 2013 (SKASM2013) Batu Paat, Joor, 29 30 Oktober 2013 We sow te solution wit = 0.1 manually, but te solution wit = 0.05 will be sown directly fiom te spreadseet calculator in Section 4. By comparing Figure 2 and 3 in Section 4, we notice tat a smaller gives smaller errors and ence gives better approximation. 3.1. Numerical Example 2 Given te following set of discrete data in Table 2. x f (x) 0.2 1.0832 0.3 1.1972 0.4 1.3771 Table 2 0.5 1.6487 0.6 2.0544 0.7 2.6644 Find te approximate values of f '(0.4) and f "(0.4) using all te appropriate formulas in Table 1. Solution 2point forward 2point backward 3point central
3point forward 3point backward 5point formula 3point central for second derivatives f "(x) = f(.)2f(x)+f 2 (x+) 5point formula for second derivatives f(x2)+16f(x)30f(x)+l6f(x+) f "(x) = 122 f(x+2)
Prosiding Seminar Kebangsaan Aplikasi Sains dan Matematik 2013 (SKASM2013) Batu Paat, Joor, 29 30 Oktober 2013 4. SPREADSHEET CALCULATOR Figure 1 illustrates te numerical differentiation spreadseet calculator. Tere are two options wic are Given Function and Given Data respectively in tis spreadseet calculator. Figure 1 sows te first option, tat is te Given Function option as solved in Numerical Example 1 in Section 3.1. For option 1, users only need to enter te function wic is needed to find its first and second derivatives in cell C7, te specified value of x is needed to obtain its derivatives in cell C6 wile step size needs to be keyed into cell E6. Finally, users need to click te APPLY button. Te APPLY button is associated wit te macro option in Excel spreadseet wic records te action of copying cell C7 to cells C11:Gll. Once te APPLY button is clicked, te first derivative at te specified value of x will be approximated by using 2point forward, 2point backward, 3point central, 3point forward, 3point backward and 5 point formulas in cells D14:D19 respectively, wereas te second derivative at te specified value of x will be calculated using 3point central and 5point formulas in cells H14: H15. Users can select one decimal place, two decimal places up to nine decimal places calculation from te pull down menu in cell H6. To get te absolute error, users can enter te exact functions of first derivative and second derivative in cell E7:F7 respectively. Figure 2 gives te solution of Numerical Example 1 wit = 0.05. 1 A L B c D E I F I G ~ H 1 Differentiation & Integration 2 Menu I 5 ~ 1 6 7 Input 8 9 I 10. 11 12 13 14 1 Output 15 1 16 17 18 19 Given Data x 0.8 0.1 (Exactf" ~ c c u r a c ~ ~ ~ f(x) 1 0.71736 1 Exactf 1 0.69671 1 0.71736 Figure 1 : Numerical Differentiation Spreadseet Calculator: Given Function Option (Solution of Numerical Example 1 wit = 0.1) I
* _ I 0 1 c D E I F G I H _ I I ~ 1 Differentiation & Integration 2 Menu 3 Given Data 4 I 5 I I 6 x 0.8 I 0.05 I Exactf' 7 Input f[x) 1 0.71736 1 Exactf 1 0.69671 ( 0.71736 Q 1 ~ccurac~iu]~ 10 11 1 12 13 14 Output 15 16 17 Figure 2: Numerical Differentiation Spreadseet Calculator: Given Function Option (Solution of Numerical Example 1 wit = 0.05) Figure 3 illustrates te Given Data Option in Numerical Differentiation Spreadseet Calculator as solved in Numerical Example 2. In tis option, users need to enter 5 data points wit te same step size into cell C7: G8 and its into 18, te first derivative at te specified value of x will ten be approximated by using 2point forward, 2point backward, 3point central, 3point forward, 3point backward and 5point formulas in cells Dll:D16 respectively, wereas te second derivative at te specified value of x will be calculated by using 3point central and %point formulas in cells H11: H12. Users can select one decimal place, two decimal places up to nine decimal places calculation from te pull down menu in cell H6. 1 Differentiation & Integration 2 Menu 3 Given Function A I Input 8 9 10 11 12 13 Output *I 15 16 Second derivatives 3polnt central 5point 9.0317 Fig. 3: Numerical Differentiation Spreadseet Calculator: Given Data Option (Solution of Numerical Example 2) 118
Prosiding Seminar Kebangsaan Aplikasi Sains dan Matematik 2013 (SKASM2013) Batu Paat, Joor, 29 30 OMober 2013 5. CONCLUSION We ave developed a numerical differentiations spreadseet calculator wit two options, wic are Given Function and Given Data respectively. For a given function option, users only need to key in te value of x, te functionflx) and te step size followed by clicking te APPLY button. Te spreadseet calculator will ten tabulate te (x,flx)) data into a given table. On te oter and, for a given data option, users are only required to key in te five data point of (x, y) data wit te same increment and its step size into te given table. For bot options, te first derivative at te specified value of x will be approximated by using 2 point forward, 2point backward, 3point central, 3point forward, 3point backward and 5 point formulas, wereas te second derivative at te specified value of x will be calculated by using 3point central and 5point formulas. Users may select a certain number of decimal places calculation from te pull down menu in tis spreadseet calculator. Wit tis numerical differentiations spreadseet calculator, we ope to elp educators to prepare teir marking sceme wit ease and to facilitate students in cecking teir answers. 6 ACKNOWLEDGEMENT T~s project is financially supported by UTHM MDR researc grant sceme vote 1109. References [I] Tay, K. G., Kek, S. L. & AbdulKaar, R. (2009). Solving NonLinear Systems by Newton's Metod Using Spreadseet Excel. Proceeding of te 3rd International Conference on Science and Matematics Education (CoSMED 2009). Pg. 452456. [2] Kek, S. L. & Tay, K. G. (2008). Solver for System of Linear Equations. Proceeding of te National Symposium on Application of Science Matematics 2008 (SKASM 2008). Pg 605615. Batu Paat: Penerbit UTHM. [3] Kek, S.L. & Tay, K. G. (2009). Design of Spreadseet Solver for Polynomial Interpolation. National Seminar on Science and Tecnology 2009 (PKPST 2009): Pg. 6973. [4] Tay, K. G., Kek, S. L. & AbdulKaar, R. (2010). Langrange Interpolating Polynomial Solver Using Spreadseet Excel. Proceeding of te National Symposium on Application of Science Matematics 2010 (SKASM 2010) and 18" Matematical Science National Symposium (SKSM 2010). Pg. 331337. [5] Tay, K. G & Kek, S. L. (2008). Approximating Te Dominant Eigenvalue Using Power Metod Troug Spreedseet Excel. Proceeding of te National Symposium on Application of Science Matematics 2008 (SKASM 2008). Pg 599604. Batu Paat: Penerbit UTHM.
[6] Tay, K. G. & Kek, S. L. (2009). Approximating te Smallest Eigenvalue Using Inverse Metod Troug Spreadseet Excel. Proceeding of te 17~ National Symposium on Matematical Science (SKSM 2009). Pg. 653658. [7] Tay, K. G. & Kek, S. L. (2009). Fourt Order RungeKutta Metod Using Spreadseet Excel. Proceedings of te 4L International Conference on Researc and Education in Matematics (ICREM4). Pg. 666672. [8] Tay, K. G, Kek, S. L & AbdulKaar, R. (2012). A Spreadseet Solution of a System of Ordinary Differential Equations Using te FourtOrder RungeKutta Metod. Spreadseets in Education (ejsie): 5(2): Pg. 110. ISSN 14486156. [9] Tay, K. G., Kek, S. L. & AbdulKaar, R. (2009). Solutions of Laplace's Equations Using Spreadseet Excel. National Seminar on Science and Tecnology 2009 (PKPST 2009). Pg. 4045. [lo] Tay, K.G, Kek, S. L., AbdulKaar, R., Azlan, M. A. & Lee, M. F. (20 13) A Ricardson's Extrapolation Spreadseet Calculator for Numerical Differentiation," Spreadseets in Education (ejsie): 6(2): 15. ISSN 14486156. [l 11 Rao, S.S., (2002). Applied Numerical Metods For Engineers and Scientists. Upper Saddle fiver, New Jersey: Prentice Hall.