Download presentation
Presentation is loading. Please wait.
Published byMilton Nash Modified over 9 years ago
1
MA/CS375 Fall 2002 1 MA/CS 375 Fall 2002 Lecture 8
2
MA/CS375 Fall 2002 2 Matlab Built-in Derivative Routines diff takes the derivative of a function of one variable sampled at a set of discrete points gradient takes the x and y derivatives of a function of two variables
3
MA/CS375 Fall 2002 3 diffdemo.m Using diff on F = x^3 diff
4
MA/CS375 Fall 2002 4
5
5 diff diffdemo.m Using diff on F = sin(x)
6
MA/CS375 Fall 2002 6
7
7 Explanation of Error Curve We can find good reason for the shape of the error curve..
8
MA/CS375 Fall 2002 8 Recall: Taylor’s Theorem With Cauchy Remainder 1) Taylor’s theorem with Cauchy Remainder: Here R n is the Cauchy Remainder
9
MA/CS375 Fall 2002 9 Recall: Taylor’s Theorem With Cauchy Remainder 2) Using a first order expansion (n=1)
10
MA/CS375 Fall 2002 10 Introducing Finite Precision Errors 3) round off due to finite precision representation of x and delta 4) round off due to finite precision computation of f
11
MA/CS375 Fall 2002 11 Putting It All Together
12
MA/CS375 Fall 2002 12 Final Result
13
MA/CS375 Fall 2002 13 Analysis of Final Result In words: the error created by approximating the derivative of f by the first order formula is given by two terms First term proportional to delta times the second derivative of f at some point between x and (x plus delta) Second term is due to finite precision representation of f, x, delta
14
MA/CS375 Fall 2002 14 Finding the Gradient of Two- dimensional Functions
15
MA/CS375 Fall 2002 15 Definition of Partial Derivatives Given a function f of two variables x,y We define the two partial derivatives by
16
MA/CS375 Fall 2002 16 Using gradient on F = x^2 gradientdemo.m gradient
17
MA/CS375 Fall 2002 17
18
MA/CS375 Fall 2002 18 Using gradient on F = x^2+y^2 gradientdemo1.m
19
MA/CS375 Fall 2002 19
20
MA/CS375 Fall 2002 20 Using gradient on F = (x^2)*(y^2) gradientdemo2.m
21
MA/CS375 Fall 2002 21
22
MA/CS375 Fall 2002 22 Using gradient on F = (sin(pi*x))*(cos(pi*y)) gradientdemo3.m
23
MA/CS375 Fall 2002 23
24
MA/CS375 Fall 2002 24 Individual Class Exercise Part 1 1) Using the following formula compute the approximate derivative of: f=x.^5 at 1000 points between x=-1 and 1 with delta = 1e-4 Do not use diff
25
MA/CS375 Fall 2002 25 Individual Class Exercise Part 2 2) Plot the error defined by: actualerror = abs(dfdx-5*x.^4); 3) On the same graph plot the error defined by: guesserror = abs(delta*(5*4*x.^3)/2); 4) Write comments on the graph about what you see. 5) Label the axes. Add a title to the graph. Add a legend to the graph.
26
MA/CS375 Fall 2002 26 Individual Class Exercise Part 3 Repeat on separate graphs for: delta = 1e-6, 1e-8, 1e-10, 1e-15 Explain what you see on each graph. Hand this in at the start of next lecture (Monday 09/09/02). This will be graded. Remember to include your name and staple.
27
MA/CS375 Fall 2002 27 Summary We have narrowed down the error term to two concretely defined terms Next time we will use these ideas to find edges in images.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.