Differentiation-Discrete Functions Civil Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates 4/13/2015 http://numericalmethods.eng.usf.edu 1 Differentiation –Discrete Functions http://numericalmethods.eng.usf.edu Forward Difference Approximation lim f x Δx f x f x Δx 0 Δx For a finite ' Δx' f x x f x f x x 3 http://numericalmethods.eng.usf.edu Graphical Representation Of Forward Difference Approximation f(x) x x+Δx Figure 1 Graphical Representation of forward difference approximation of first derivative. 4 http://numericalmethods.eng.usf.edu Example 1 To find the stress concentration around a hole in a plate under a uniform stress, a finite difference program has been written that calculates the radial and tangential displacements at different points in the plate. To find the stresses and hence the stress concentration factor, one needs to find the derivatives of these displacements. In Table 1 the radial displacements , u , are given along the y-axes. The radius of the hole is 1.0 cm. u a) At x 0 if the radial strain, r is given by r , find the radial r strain at r 1.1cm using forward divided difference method. b) If the tangential strain at r 1.1cm, 900 is given to you as 0 , find the hoop stress, , at r 1 . 1 cm , 90 0.0029733 E if ( r ), where E 200 GPa and 0.3 . 1 2 5 http://numericalmethods.eng.usf.edu Example 1 Cont. Table 1 Radial displacement as a function of location. r (cm) 6 u(cm) 1.0 −0.0010000 1.1 −0.0010689 1.2 −0.0011088 1.3 −0.0011326 1.4 −0.0011474 1.5 −0.0011574 1.6 −0.0011650 1.7 −0.0011718 1.8 −0.0011785 1.9 −0.0011857 http://numericalmethods.eng.usf.edu Example 1 Cont. Solution: u r ui 1 ui r ri 1.1 a) r ri 1 1.2 r ri 1 ri 1.2 1.1 0.1 ui 1 0.0011088 ui 0.0010689 7 http://numericalmethods.eng.usf.edu Example 1 Cont. ui 1 ui r 0.0011088 (0.0010689) 0.1 0.00039900 r b) E ( r ) 2 1 2 1011 (0.00039900 0.3 0.0029733) 2 1 0.3 108.35106 Pa 8 http://numericalmethods.eng.usf.edu Direct Fit Polynomials In this method, given ' n 1' data points x0 , y0 , x1 , y1 , x2 , y2 ,, xn , yn one can fit a n th order polynomial given by Pn x a0 a1x an 1xn 1 an xn To find the first derivative, Pnx dPn ( x ) a1 2a 2 x n 1a n 1 x n 2 na n x n 1 dx Similarly other derivatives can be found. 9 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials To find the stress concentration around a hole in a plate under a uniform stress, a finite difference program has been written that calculates the radial and tangential displacements at different points in the plate. To find the stresses and hence the stress concentration factor, one needs to find the derivatives of these displacements. In Table 2 the radial displacements, u , are given along y-axes. The radius of the hole is 1.0 cm. u a) At x 0 if the radial strain, r is given by r , find the radial r strain at r 1.1cm . Use a third order polynomial interpolant for calculating the radial strain. b) If the tangential strain at r 1.1cm, 900 is given to you as 0 , find the hoop stress, , at r 1 . 1 cm, 90 0.0029733 E if ( r ), where E 200 GPa and 0.3 . 1 2 10 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Table 2 Radial displacement as a function of location. r (cm) 11 u(cm) 1.0 −0.0010000 1.1 −0.0010689 1.2 −0.0011088 1.3 −0.0011326 1.4 −0.0011474 1.5 −0.0011574 1.6 −0.0011650 1.7 −0.0011718 1.8 −0.0011785 1.9 −0.0011857 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Solution: For the third order polynomial (also called cubic interpolation), we choose the displacement given by ur a0 a1r a2 r 2 a3 r 3 Since we want to find the radial strain at r 1.1 cm , and we are using a third order polynomial, we need to choose the four points closest to r 1.1 and that also bracket r 1.1 to evaluate it. The four points are r0 1.0, r1 1.1, r2 1.2, and r3 1.3 ro 1.0, uro 0.0010000 r1 1.1, ur1 0.0010689 r2 1.2, ur2 0.0011088 r3 1.3, ur3 0.0011326 12 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. such that u1.0 0.0010000 a0 a1 1 a2 1 a3 1 2 3 u1.1 0.0010689 a0 a1 1.1 a2 1.1 a3 1.1 2 3 u1.2 0.0011088 a0 a1 1.2 a2 1.2 a3 1.2 2 3 u1.3 0.0011326 a0 a1 1.3 a2 1.3 a3 1.3 2 3 Writing the four equations in matrix form, we have 1 1 a 0 0.0010000 1 1 1 1.1 1.21 1.331 a 0.0010689 1 1 1.2 1.44 1.728 a 2 0.0011088 a 1 1 . 3 1 . 69 2 . 197 0 . 0011326 3 13 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Solving the above four equations gives a0 0.0041220 a1 -0.0011517 a2 0.0085450 a3 -0.0021500 Hence ur a0 a1r a2 r 2 a3 r 3 0.0041220 0.0011517r 0.0085450r 2 0.0021500r 3 , 1 r 1.3 14 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. Figure 2 Graph of Radial Displacement vs. Location 15 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. The derivative of radial displacement at u ' 1.1 Given that r 1.1cm is given by d u r r 1.1 dr ur 0.0041220 0.0011517r 0.0085450r 2 0.0021500r 3 , 1 r 1.3 d u ' r u r dr d 0.0041220 0.0011517r 0.0085450r 2 0.0021500r 3 dr 0.0011517 0.017090r 0.0064500r 2 , 1 r 1.3 u ' 1.1 0.0011517 0.017090(1.1) - 0.0064500 (1.1) 2 0.00052250 cm/cm r 0.00052250cm/cm 16 http://numericalmethods.eng.usf.edu Example 2-Direct Fit Polynomials cont. b) E ( r ) 2 1 2 1011 (0.00052250 0.3 0.0029733) 1 0.32 81.207106 Pa 17 http://numericalmethods.eng.usf.edu Lagrange Polynomial In this method, given x1, y1 ,, xn , yn , one can fit a n 1th order Lagrangian polynomial given by f n ( x) where ‘ n ’ in n L ( x) f ( x ) i 0 i i f n (x) stands for the n th order polynomial that approximates the function y f (x) given at (n 1) data points as x0 , y0 , x1 , y1 ,......,xn1 , yn1 , xn , yn , and n Li ( x) j 0 j i x xj xi x j Li (x) a weighting function that includes a product of (n 1) terms with terms of ji 18 omitted. http://numericalmethods.eng.usf.edu Lagrange Polynomial Cont. Then to find the first derivative, one can differentiate f n x once, and so on for other derivatives. For example, the second order Lagrange polynomial passing through x0 , y0 , x1, y1 , x2 , y2 f 2 x is x x1 x x2 f x x x0 x x2 f x x x0 x x1 f x x0 x1 x0 x2 0 x1 x0 x1 x2 1 x2 x0 x2 x1 2 Differentiating equation (2) gives 19 http://numericalmethods.eng.usf.edu Lagrange Polynomial Cont. 2 x x0 x2 2 x x0 x1 2 x x1 x2 f 2 x f x0 f x1 f x x0 x1 x0 x2 x1 x0 x1 x2 x2 x0 x2 x1 2 Differentiating again would give the second derivative as f 2x 20 2 x0 x1 x0 x2 f x0 2 x1 x0 x1 x2 f x1 2 x2 x0 x2 x1 f x2 http://numericalmethods.eng.usf.edu Example 3 To find the stress concentration around a hole in a plate under a uniform stress, a finite difference program has been written that calculates the radial and tangential displacements at different points in the plate. To find the stresses and hence the stress concentration factor, one needs to find the derivatives of these displacements. In Table 3 the radial displacements u , are given along the y-axes. The radius of the hole is 1.0 cm u a) At x 0, if the radial strain, r , is given by r , find the radial r strain at r 1.1cm . Use a second order Lagrange polynomial interpolant for calculating the radial strain. b) If the tangential strain at r 1.1cm, 900 is given to you as 0 , find the hoop stress, , at r 1 . 1 cm, 90 0.0029733 E if ( r ) , where E 200 GPa and 0.3 . 1 2 21 http://numericalmethods.eng.usf.edu Example 3 Cont. Table 3 Radial displacement as a function of location. r (cm) 22 u(cm) 1.0 −0.0010000 1.1 −0.0010689 1.2 −0.0011088 1.3 −0.0011326 1.4 −0.0011474 1.5 −0.0011574 1.6 −0.0011650 1.7 −0.0011718 1.8 −0.0011785 1.9 −0.0011857 http://numericalmethods.eng.usf.edu Example 3 Cont. Solution: For second order Lagrangian interpolation, we choose the radial displacement given by r r1 r r2 r r0 r r2 r r0 r r1 u (r0 ) u (r1 ) u (r2 ) u (r ) r r r r r r r r r r r r 0 1 0 2 1 0 1 2 2 0 2 1 Since we want to find the rate of change in the radial displacement at r 1.1 cm , and we are using second order Lagrangian interpolation, we need to choose the three points closest to r 1.1 cm that also bracket r 1.1 cm to evaluate it. The three points are r0 1.0, r1 1.1, and r2 1.2 . r0 1.0, ur0 0.0010000 r1 1.1, ur1 0.0010689 r2 1.2, ur2 0.0011088 23 http://numericalmethods.eng.usf.edu Example 3 Cont. The change in the radial displacement at r 1.1 cm is given by du 1.1 d u (r ) r 1.1 dr dr Hence u ' r 2r r0 r2 2r r0 r1 2r r1 r2 ur0 ur1 ur2 r0 r1 r0 r2 r1 r0 r1 r2 r2 r0 r2 r1 u ' 1.1 21.1 1.1 1.2 0.0010000 21.1 1.0 1.2 0.0010689 1.0 1.11.0 1.2 1.1 1.01.1 1.2 21.1 1.0 1.1 0.0011088 1.2 1.01.2 1.1 5 0.0010000 0 0.0010689 5 0.0011088 0.00054400 cm/cm 24 http://numericalmethods.eng.usf.edu Example 3 Cont. b) E ( r ) 2 1 2 1011 (0.00054400 0.3 0.0029733) 2 1 0.3 76.481106 Pa 25 http://numericalmethods.eng.usf.edu Additional Resources For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/discrete_02 dif.html THE END http://numericalmethods.eng.usf.edu