project mosaic m casts
play

Project MOSAIC M-CASTS Whats an M-CAST A regularly scheduled but - PowerPoint PPT Presentation

Project MOSAIC M-CASTS Whats an M-CAST A regularly scheduled but informal way to share ideas about teaching and develop collaborations for further development of those ideas. Broadcast via Internet. Most are presentations, but some


  1. Project MOSAIC M-CASTS What’s an M-CAST • A regularly scheduled but informal way to share ideas about teaching and develop collaborations for further development of those ideas. • Broadcast via Internet. • Most are presentations, but some will be conversations and discussions. • Scheduled for the 2nd and 4th Friday of each month. Special event when there is a 5th Friday. • Video and audio is recorded for posting on the Internet. Experience is that many more people see the recording than participate in the live event. We encourage you to lead your own M-CAST or propose a topic that you would like to hear more about. See the sign-up sheet at the MOSAIC Wiki: www.mosaic-web.org . Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 1 / 30

  2. Upcoming M-CASTS The 2nd and 4th Friday of each month. Time of day varies slightly: see www.mosaic-web.org . Aug 13, 2010 (today!) Danny Kaplan, Finite differences as derivatives Aug 27, 2010 Eric Marland, Animating Bifurcations , Sept 10, 2010 Vittorio Addona, Helping Students Understand Regression Coefficients: An Example of Modeling Body Fat Percentage Sept. 24, 2010 Nicholas Horton, Being Warren Buffet Oct. 8, 2010 Randall Pruim, Golfballs in the Yard Oct. 22, 2010 Eric Cytrynbaum, Science One at UBC Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 2 / 30

  3. Finite Differences as Derivatives Daniel Kaplan Macalester College August 13, 2010 Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 3 / 30

  4. Background • For students, differentiation in an traditional calculus course appears as a series of rules for symbolic manipulation: for instance x 2 → 2 x , sin x → cos x , the product rule, the quotient rule, the chain rule, etc. • Students work out derivatives in terms of limits, e.g. x 2 + 2 xh + h 2 − x 2 ( x + h ) 2 − x 2 d dx x 2 = lim = lim h h h → 0 h → 0 = h → 0 2 x + h = 2 x lim • In reform calculus courses, derivatives are also presented using graphs and tables, e.g. a student may be asked to sketch the derivative of a function given only in graphical form. Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 4 / 30

  5. Motivation • Connect the derivative more formally to the idea of a function. • Generalize the derivative beyond the particular symbolic rules learned and encourage greater numerical computing fluency. • Emphasize that the inputs to functions can be different kinds of things than the outputs. • Streamline calculation of the derivative to make 2nd and high-order derivatives more accessible. • Permit derivatives to be computed on new types of functions, e.g., splines. • Allow exploration of limits in a non-algebraic way. • Support the idea of comparing two functions: how similar are they? But mainly ... To let students work with and explore derivatives without having to master algebraic techniques. Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 5 / 30

  6. Outline of this M-CAST 1 Computational background for instructors and for students 2 The finite-difference operator 3 Applications with the finite-difference operator: • Graphing derivatives. • The exponential function is its own derivative. • What’s the derivative of sin( x )? 4 Extensions after the M-CAST: How far wrong is the finite-difference derivative, one-sided versus centered derivatives, numerics and very small h ,“what kind of thing is this?” Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 6 / 30

  7. Computational Background: Instructor The examples here are done in R. A very similar syntax would apply in packages such as Mathematica, Maple, Matlab, or SAGE. Basic capabilities needed in the computation package: 1 Define a function from the command line. 2 Return a function from a function. 3 Graphing a function over an interval. Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 7 / 30

  8. Defining a Function on the Command Line R > f = function(x) { x^2 + 3 } Matlab f = @(x) x^2 + 3 This function handle syntax is unknown to most Matlab users. Much superior to the older“in-line”functions based on character strings. Mathematica f[x_] := x^2 + 3 Each of these languages has its own syntax for identifying the arguments to the function and provides for the implicit return of values. Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 8 / 30

  9. A Little More about Functions in R Optional arguments and default values Functions can take optional arguments with default values, e.g. > g = function(x, a=3) { a*x } > g(2) [1] 6 > g(2,a=10) [1] 20 We will use this syntax in defining the finite-difference derivative operator, but not in defining mathematical objects. Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 9 / 30

  10. Still More about Functions in R Unassigned parameters are captured from outside You can use parameters that are not arguments and not defined inside the function. The values are captured from outside. Lexical Scoping > h = function(x) {b + x} > b = 10 > h(3) [1] 13 > b=1000 > h(3) [1] 1003 Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 10 / 30

  11. Computational Background: Student Skills • Define a function, e.g. > f = function(x) { x^2 - 3 } • Apply a function to an input, e.g. > f(3) [1] 6 • Plot a function over an interval: > x = seq(0,2,length=100) > plot( x, f(x) ) Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 11 / 30

  12. Streamlining Plotting As a convenience it’s nice to let the computer handle the generation of the x points. 6 The curve operator in R: 4 f (x) 2 > curve(f, from=0, to=3) −2 0.0 1.0 2.0 3.0 x Note that the first argument to curve is the name of the function to be plotted. You can also write curve( f(x), from=0, to=3 ) You could have your students write mycurve so that they see that curve doesn’t do anything magical. (See Extensions at end.) Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 12 / 30

  13. • By default, curve creates a new set of axes. You can set the vertical scale with ylim and insert a line to mark the x axis: > curve(f, from=0, to=3, ylim=c(-10,10)) > abline(0,0) • For comparing functions, you can add new curves to an existing set of axes and choose a color: > g = function(x) {4*x - 5} > curve( g, add=TRUE, col="blue") Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 13 / 30

  14. Computational Background: Student Critical Computational Concepts • An operator an object that can be applied to an input to return an output. • Applying an operator to an input gives the output. It’s important to distinguish between the operator and the output generated by the operator when applied to an input. • A function can itself be an input to an operator. • Graphs are generated by evaluating a function f at a set of points x and plotting out the pairs f(x) versus x . Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 14 / 30

  15. Constructing New Functions from Old When you want to construct a new function, you need to use the function operator: 6 4 > curve( f, from=0, to=3 ) f (x) 2 > g = function(x){ f(x) / 2 } −2 > curve( g, add=TRUE, col="blue") 0.0 1.0 2.0 3.0 x For Discussion: The“friendlier”syntax curve also lets you write > curve( f(x)/2, from=0, to=3 ) The argument must be x . Topic for discussion: Is this compact notation a good thing for beginners? Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 15 / 30

  16. The Finite-Difference Derivative Operator > D = function(f, h=0.0001) { function(x) { (f(x+h) - f(x))/h } } • D takes a function as an input and returns a new function (of x ) as an output. • h has been set to a“small”value. Working out what“small”should be is an issue for student investigation. • I give this operator to my students, rather than having them try to develop it on their own. The built-in D operator R already has a D operator that has some symbolic properties. But it’s very hard to use. I replace it with this one by giving my students an R workspace with D redefined. Better to use a package? The MOSAIC R package. Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 16 / 30

  17. Using the Operator • Define a function to be differentiated: > g = function(x) { exp(-.2*x)*sin(2*pi*x/10) } > g(0) [1] 0 > g(2) [1] 0.6375122 Note the choice of name for the new function, to remind us whence it was derived. • Take the derivative by applying D to the function. Give the result a name. > gprime = D(g) > gprime(0) [1] 0.628306 > gprime(2) [1] 0.002633719 Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 17 / 30

  18. 0.6 Plot a function: 0.4 g (x) 0.2 > curve(g,from=0,to=20) 0.0 −0.2 0 5 10 15 20 0.6 x Plot the derivative 0.4 gprime (x) 0.2 > curve(gprime,from=0,to=20) 0.0 −0.2 0 5 10 15 20 x Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 18 / 30

  19. The 2nd Derivative 0.1 Plot a function: 0.0 gpp (x) −0.1 > gpp = D( D( g ) ) −0.2 > curve(gpp,from=0,to=20) −0.3 0 5 10 15 20 x Some Questions for Students • At the x values where gprime is zero, what’s happening in g ? • At the x values where gpp is zero, what’s happening in g ? Daniel Kaplan () Finite-Difference Derivatives August 13, 2010 19 / 30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend