1 / 38

MA/CS 375

MA/CS 375. Fall 2002 Lecture 7. Explanations of Team Examples. Recall Monster #1. Consider: What should its behavior be as: Plot this function at 1000 points in: Plot this function at 1000 points in: Explain what is going on. Monster #1 ((large+small)-large)/small.

gotzon
Télécharger la présentation

MA/CS 375

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MA/CS 375 Fall 2002 Lecture 7 MA/CS375 Fall 2002

  2. Explanations of Team Examples MA/CS375 Fall 2002

  3. Recall Monster #1 • Consider: • What should its behavior be as: • Plot this function at 1000 points in: • Plot this function at 1000 points in: • Explain what is going on. MA/CS375 Fall 2002

  4. Monster #1((large+small)-large)/small MA/CS375 Fall 2002

  5. Monster #1((large+small)-large)/small when we zoom in we see that the large+small operation is introducing order eps errors which we then divide with eps to get O(1) errors !. MA/CS375 Fall 2002

  6. Monster #1((large+small)-large)/small Each stripe is a region where 1+ x is a constant (think about the gaps between numbers in finite precision) Then we divide by x and the stripes look like hyperbola. The formula looks like (c-1)/x with a new c for each stripe. when we zoom in we see that the large+small operation is introducing order eps errors which we then divide with eps to get O(1) errors !. MA/CS375 Fall 2002

  7. Recall Monster #2 • Consider: • What should its behavior be as: • Plot this function at 1000 points in: • Explain what is going on in a text box, label everything, print it out and hand it in. MA/CS375 Fall 2002

  8. Limit of MA/CS375 Fall 2002

  9. Monster #2(finite precision effects from large*small) As x increases past 30 we see that f deviates from 1 !! MA/CS375 Fall 2002

  10. Monster #2 cont(finite precision effects from large*small) As x increases past ~=36 we see that f drops to 0 !! MA/CS375 Fall 2002

  11. Recall Monster #3 • Consider: • What should its behavior be as: • Plot this function at 1000 points in: • Explain what is going on. What happens at x=54? MA/CS375 Fall 2002

  12. Monster 3(finite precision large*small with binary stripes) MA/CS375 Fall 2002

  13. Monster 3(finite precision large*small with binary stripes) As we require more than 52 bits to represent 1+2^(-x) we see that the log term drops to 0. MA/CS375 Fall 2002

  14. RecallMonster #4 • Consider: • What should its behavior be as: • Plot four subplots of the function at 1000 points in: for • Now fix x=0.5 and plot this as a function of for • Explain what is going on, print out and hand in. MA/CS375 Fall 2002

  15. Monster 4 cont Behavior as delta  0 : or if you are feeling lazy use the definition of derivative, and remember: d(sin(x))/dx = cos(x) MA/CS375 Fall 2002

  16. Monster 4cont(parameter differentiation, delta=1e-4) OK MA/CS375 Fall 2002

  17. Monster 4cont(parameter differentiation, delta=1e-7) OK MA/CS375 Fall 2002

  18. Monster 4cont(parameter differentiation, delta=1e-12) Worse MA/CS375 Fall 2002

  19. Monster 4cont(parameter differentiation, delta=1e-15) Bad When we make the delta around about machine precision we see O(1) errors !. MA/CS375 Fall 2002

  20. Monster 4cont(numerical instablitiy of parameter differentiation) As delta gets smaller we see that the approximation improves, until delta ~= 1e-8 when it gets worse and eventually the approximate derivate becomes zero. MA/CS375 Fall 2002

  21. Approximate Explanation of Monster #4 1) Taylor’s thm: 2) Round off errors 3) Round off in computation of f and x+delta 4) Put this together: MA/CS375 Fall 2002

  22. i.e. for or equivalently approximation error decreases as delta decrease in size. BUT for round off dominates!. MA/CS375 Fall 2002

  23. Ok – so these were extreme cases • Reiteration: the numerical errors were decreasing as delta decreased until delta was approximately 1e-8 MA/CS375 Fall 2002

  24. 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 MA/CS375 Fall 2002

  25. diff Using diff on F = x^3 diffdemo.m MA/CS375 Fall 2002

  26. MA/CS375 Fall 2002

  27. diff Using diff on F = sin(x) diffdemo.m MA/CS375 Fall 2002

  28. MA/CS375 Fall 2002

  29. gradient Using gradient on F = x^2 gradientdemo.m MA/CS375 Fall 2002

  30. MA/CS375 Fall 2002

  31. Using gradient on F = x^2+y^2 gradientdemo1.m MA/CS375 Fall 2002

  32. MA/CS375 Fall 2002

  33. Using gradient on F = (x^2)*(y^2) gradientdemo2.m MA/CS375 Fall 2002

  34. MA/CS375 Fall 2002

  35. Using gradient on F = (sin(pi*x))*(cos(pi*y)) gradientdemo3.m MA/CS375 Fall 2002

  36. MA/CS375 Fall 2002

  37. Comments • Next time we will revisit the accuracy of taking derivatives… MA/CS375 Fall 2002

  38. Summary • Ok – so in the far limits of the range of finite precision really dodgy things happen. • But recall, the formula for the derivative of sine worked pretty well for a large range of numbers. • Try to avoid working with two widely separated numbers. MA/CS375 Fall 2002

More Related