Analytical Toolbox Differential calculus By Dr J.P.M. Whitty Learning objectives • After the session you will be able to: • Define the derivative in terms of a imitating function • Differentiate simple algebraic functions from first principles • Apply rules of differentiation • Use math software to solve simple differentiation problems 2 Differential Calculus • Calculus is the mathematics of change A point in three dimensions needs six pieces of information to be fully described. • We use the Derivative Function , f , to describe the rate of change of the original function f. y f (a+h) rise f(a) f ( a h) f ( a ) f (a ) lim h h0 y = f x() run a a+h x 3 Example Find the derivative (using first principles) of f (x) = x2 - 8x + 9. Here we use the definition: f ( a h) f ( a ) h h0 f (a ) lim f (a h) (a h) 2 8(a h) 9 Where: f (a h) a 2 2ah h 2 8a 8h 9 Giving: a 2 2ah h 2 8a 8h 9 a 2 8a 9 f ' (a) lim h 0 h 4 Example Cont: Simplifying the denominator: 2ah h 2 8h f ' (a) lim h2 0 h a 2 2ah h 2 8a 8h 9 a 8a 9 f ' (a) lim h 0 h 2 2ah h 8h f ' (a) lim That is: h 0 h 0 f ' (a) lim 2a h 8 Cancel out the h’s h 0 letting h 0 : let a 3 gives f ' (3) : f ' ( a ) 2a 8 f ' (3) 2 3 8 14 5 Differentiation of standard functions It is usual in calculus textbooks that to see tables of standard functions and their respective differential coefficients. • For this introductory course you will only require the following y dy dx c 0 ax n anx n 1 sin ax acos ax cos ax asin ax e ax exp ax ae ax a exp ax 6 Class Examples Time Copy and complete the following table. y dy dx 5c 0 3x 3 4x 2 8x 5x 4 20x 3 3x 2 x 1 3 9x2 2 7 Class examples Differentiate the following: a) y 3x 6 x x 5 4 3 dy 3 4 x 3 6 3x 2 1x 0 dx dy ans) 12 x 3 18 x 2 1 dx b) y x 3x 2 x 7 x 9 4 3 2 dydy 4 4 x43x3 3 3 3x32x2 222x21 x1771x 01x 0 dxdx dy ans ) 4 x3 9 x 2 4 x 7 dx 8 Another example Find the first and second derivatives of: f ( x) 2 x 4 3sin 3x 5e 2 x cos x f ' ( x) 8x3 9 cos 3x 10e 2 x sin x f ' ' ( x) 24 x 2 18 sin 3x 20e 2 x cos x 9 Class Examples Time Find the first and second derivative of: f ( x) 2 exp( 9 x) 3x 2 cos 2 x 2 sin 3x e x f ' ( x) 18 exp( 9 x) 6 x 2 sin 2 x 6 cos 3x e x f ' ' ( x) 162 exp( 9 x) 6 4 cos 2 x 18 sin 3x e x 10 Differentiation Formulae Several ‘short-cut’ rules exist for differentiation, eliminating the need for tedious and repetitive use of limit expressions. Proofs of these can be found in most calculus books. Description Constant General Power Rule Function f (x) = c f (x) = xn Addition/Subtraction f (x) = g (x) h (x) f ( x ) nx n1 f ( x ) g ( x ) h ( x ) Product Rule f (x) = g (x) h (x) f ( x ) g ( x ) h ( x ) g ( x ) h( x ) Quotient Rule f (x) = g( x) h( x ) Derivative f ( x ) 0 f ( x ) g ( x ) h( x ) g ( x ) h ( x ) (h( x)) 2 11 Revision Questions 1. Complete the following table: y dy dx c x x2 4x 3 x4 2x 5 2x3 x 2 12 More Revision Qs 1. Differentiate the following: a) y 2 x 4 5 x 3 2 x 4 b) y 3x 4 2 x 3 4 x 2 5 x 1 2. Find the first and second derivatives of: f ( x) 3x 3 4 sin 2 x 3e x cos 4 x f ( x) 9 exp( 4 x) 2 x 3 2 cos 3x 3 sin 4 x 7e 4 x 13 Revision Qs (solutions) 1. Complete the following table: y dy dx c x 0 1 x2 2x 4x 3 12x 2 x4 4x 3 2x 5 10x 4 2x3 x 2 6x2 1 14 More Revision Qs (Solutions) 1. Differentiate the following: dy 8 x 3 15 x 2 2 dx dy 12 x 3 6 x 2 8 x 5 dx 2. The first and second derivatives f ' ( x) 9 x 2 8 cos 2 x 3e x 4 sin 4 x f ' ' ( x) 18x 16 sin 2 x 3e x 16 cos 4 x f ' ( x) 36 exp( 4 x) 6 x 2 6 sin 3x 12 cos 4 x 28e 4 x f ' ( x) 144 exp( 4 x) 12 x 18 cos 3x 48 sin 4 x 112e 15 4x The Product rule: This is used when we have two primitive functions multiplied together. If f ( x) g ( x)h( x) uv then f ( x) g ( x)h ( x) g ( x)h( x) u dv du v dx dx 16 The Product rule: Proof Here we employ the definition of the derivative thus: g ( x x)h( x x) g ( x)h( x) f ' ( x) lim x 0 x Re-writing this gives f ' ( x) g ( x x)h( x x) h( x) g ( x x) h( x) g ( x x) g ( x)h( x) lim x 0 x h( x x) h( x) g ( x x) g ( x) f ' ( x) lim g ( x x) h( x) x 0 x x 17 The Product rule: Proof h( x x) h( x) g ( x x) g ( x) f ' ( x) lim g ( x x) h( x) x 0 x x Now use the fact that the terms in parenthesis are derivatives of the individual functions, to complete the proof, i.e.: g ( x x) g ( x) h( x x) h( x) g ' ( x) lim and h' ( x) lim x 0 x 0 x x Hence Substitution gives: f ' ( x) lim g ( x x)h' ( x) h( x) g ' ( x) x 0 Evaluation of the limit renders the required result 18 The Product rule: Proof (Alternative nomenclature) In many calculus text books, the less formal functions of u and v are used. This makes the preceding proof a little less tedious, as follows If f ( x ) uv then (u u )(v v) uv f ' ( x) lim x 0 x (uv vu uv uv) uv f ' ( x) lim x 0 x 0 v uv vu uv uv u f ' ( x) lim lim v u x 0 x 0 x x x x dy du u v f ' ( x) v lim u lim u v x 0 x x 0 x dx dx 19 Lemma 1: When using the calculus we rarely resort to using formulae, we tend to remember a mechanism of a pattern, these leads us to the lemma. Lemma 1:The first times the diff. of the second-plus-the second times the diff. of the first 20 Example If y x e First dy dx find 3 5x Second dy x 3 5e5 x 5e5 x dx Diff of the second Diff of the first 21 Another Example: If y e cos(3x) find 2x dy dx dy e 2 x (3 sin( 3 x)) cos(3x) 2e 2 x dx Ans: dy 3e 2 x sin( 3x) 2e 2 x cos(3x) dx 22 The quotient rule: This is used when we have two primitive functions dividend by one another if g ( x) u f ( x) h( x ) v h( x ) g ' ( x ) g ( x ) h' ( x ) Then f ' ( x) 2 g ( x) or du dv v u dy dx 2 dx dx v 23 Lemma 2: Again we tend to remember a mechanism of a pattern, this leads us to the lemma. Lemma 1:The bottom times the diff. of the top-minus-the top times the diff. of the bottom – ALL OVER THE BOTTOM SQUARED In a sense this is simply the reverse of the product rule and then dividing by the square of the bottom! 24 Example If y x / e 3 5x dy dx find bottom top bottom squared dy 3 5x e5 x 3x 2 x 5e dx Diff of the top e 5x 2 Diff of the bottom dy 3e5 x x 2 5e5 x x 3 dx e10 x x 2 3 5 x e5 x 25 Alternative approach An alternative approach is to use logarithmic differentiation as follows: y x 3 / e5 x Take logs ln y 3 ln x 5x Differentiate using the chain rule as appropriate: 3 dy x ln y 3 ln x 5x 5x dx e 2 dy x 3 5 x 5x dx e 3 5 x 26 Alternative approach The logarithmic approach is especially useful when the primitive functions are themselves products (or quotients), the details of the method are left to P7 of the recommended reading. But here we shall consider another quick example, i.e.: x 1 x3 dy if y find 2 1 x dx 27 Logarithmic differentiation The approach is always the same take natural logs, remembering ever primitive above the line is positive and everything below is negative. Then differentiate the resulting primitive functions, remembering that the RHS is equal to the 1/y multiplied by the differential coefficient. The rest is just algebra! 28 Logarithmic differentiation Example Taking logs of both sides gives: ln y ln x ln 1 x ln 1 x 3 2 Differentiate: 3 1 dy 1 3x 2x 3 y dx x 1 x 1 x 2 Substitute: dy x 1 x 3 1 3x 3 2x 2 3 2 dx 1 x x 1 x 1 x 29 Use of mathematic Software As the expressions get more and more complicated the methods stay the same but the algebra gets more and more tedious. Thankfully these days MATLAB has the answer that is the symbolic toolbox we have been using in previous lessons can be used to differentiate complicated functions such as that in the last example. 30 MATLAB: Differentiation The process is the same as usual. i.e. easy as ABC! A. B. C. Set up your symbolics in MATLAB using the syms command Type in the expression remembering the rules of BIDMAS Use the appropriate MATLAB function in this case diff( ), making pretty if required. x 1 x3 dy if y find 2 1 x dx MATLAB Commands : syms x y y ( x * (1 x ^3)) /(1 x ^ 2) diff(y) pretty(ans ) 31 MATLAB Solution The commands are very straight forward but you may have to do a little bit of algebra at the end to get the result in the same form alternatively use the MATLAB commands to do it for you!! 32 MATLAB Solution cont… For instance try factorizing the resulting expression using the factor function we have used in class previously, thus 33 Summary Have we met our learning objectives? Specifically: are you able to: • Define the derivative in terms of a imitating function • Differentiate simple algebraic functions from first principles • Apply rules of differentiation • Use math software to solve simple differentiation problems 34 Homework Find the derivative of 3 2 x 2 x 5x 6 2. Find the derivative of 1. ( x 5 6x 2 2)( x 3 x 1) 3. Find the derivative of x2 1 x2 1 35 Examination type questions 1. Differentiate the following with respect to x. a. e cos 2 x b. ln(cos x) e 3 x / sin 2 x c. d. 4x Explain how you would use math software to verify your results 36 Examination type questions 2. Evaluate the tangent to the curve y x 2 x 3x 3 2 at a point P(2,6) and find the equation of the tangent of that line. Given that the product of the normal and tangential line gradients is minus unity find the equation of the normal. 37 More Calculus WELL DONE!! You have now completed the first part of this learning pack. Have a break and then you can try the next part where you will be introduced to the inverse process to differentiation, namely: Integration 38