Skip to content

Numerical Differentiation Homework Online

Math 128A: Numerical Analysis (Summer 2015)


Description: Basic concepts and methods in numerical analysis: Solution of equations in one variable; Polynomial interpolation and approximation; Numerical differentiation and integration; Initial-value problems for ordinary differential equations; Direct methods for solving linear systems. Prerequisites: Math 53 and 54, basic programming skills.
Piazza: Piazza Link (All announcements and resources are posted here)
Lecturer: Qiuyi (Richard) Zhang, qiuyi@math.berkeley.edu
Lectures: MTuWTh 12-1:00pm, 289 Cory
Discussions: TuTh 1-2:00pm, 289 Cory (Bring your own laptop with MATLAB installed!)
Office Hours: Tuesday 2-3:30pm and Monday 1-2:30pm, 848 Evans
Textbook: R. L. Burden and J. D. Faires, Numerical Analysis, 9th edition, Brooks-Cole, 2010. ISBN-13: 978-0-538-73351-9; ISBN-10: 0-538-73351-9
MATLAB: The commercial software MATLAB will be used in the class, and there are various alternatives for using it: MATLAB Books
J. Dorfman, Introduction to MATLAB Programming, Decagon Press, Inc. Available at Krisha Copy Center on University Avenue, on demand for about $20 + tax. Please email them your order at orders@krishnacopy.com, with name and phone number, and it will be available for pick up later.
Otto and Denier, An Introduction to Programming and Numerical Methods in MATLAB (online version)
Quarteroni and Saleri, Scientific Computing with MATLAB and Octave (online version)
K. Sayood, Learning programming using MATLAB (online version)

Instructions for setting up a UC Berkeley Library Proxy Server for off-campus access to online books

Grading and policies:Homework: Weekly homework is posted on this course page, and it is in general due in each Tuesday discussion section. Group discussions about the homework are encouraged, but each student must write his/her own solutions and not copy them from anyone else. Late homework will not be accepted, but the lowest score will be dropped when computing the grade.

Programming Assignments: There will be a total of 2 programming assignments, based on the MATLAB programming language. Group discussions about the assignments are encouraged, but each student must write his/her own computer codes and report, and not copy them from anyone else. Late submissions will not be accepted, and both assignments will count towards the grade.

Exams: There will be two in-class midterm exams and one final exam. The first midterm exam will be given on the third week and the second will be on the sixth week. The final is on the last day of class and your final exam grade may replace one of your midterm grades.

Grade corrections: The grades for exams will be changed if problems are brought to the attention immediately after the exams are returned.

Grades: The final grade will be based on weekly homework assignments (20%), the programming assignments (10%), the midterm exams (20% each), and the final exam (30%). If it improves your grade, we will count one of the midterm exam (0%) and the final exam (50%). This allows you to miss one of the two midterm exams, but your chances are improved if you take both.

Special arrangements: If you are a student with a disability registered by the Disabled Student Services (DSS) on UCB campus and if you require special arrangements during exams, you must provide the DSS document and make arrangements via email or office hours prior to each exam, explaining your circumstances and what special arrangements need to be done.

MATLAB Codes:1: bisection.m, bisection_table.m
2: fixedpoint.m, fixedpoint_table.m, fixedpoint_plot.m, fixedpoint_demo.m, newton.m, newton_table.m, newton_plot.m
3: steffensen.m, steffensen_table.m, horner.m, muller.m, muller_table.m, muller_plot.m
4: neville.m, ncspline.m, ccspline.m, splineeval.m, diffsplineeval.m, spline_demo.m
5: diff_demo.m, rich_demo.m, romberg.m, adaptive_demo.m, gaussquad.m
6: rk4.m, rkf.m
Relevant Resources:1: Programming Assignment 1
2: Sample Midterm 1, Solutions
3: Midterm 1, Solutions
4: Sample Midterm 2, Solutions
5: Programming Assignment 2
6: Midterm 2, Solutions
Homework Assignments:
HWDue DateProblems, 9th Ed
1Tue 06/301.1: 1b, 4ab, 5, 9abcd, 19, 28b
1.2: 1ag, 4c, 5a, 12
1.3: 1a, 6, 7, 16
2.1: 1, 10, 14, 17
2Tue 07/72.2: 3abd, 11abf
2.3: 6a, 8a
2.4: 2a, 4a, 7a, 8
2.5: 1d, 14a
3.1: 5a, 7a
3Tue 07/143.2: 1a
3.4: 2a, 4a, 9
3.5: 4c, 6c, 8c
4.1: 6a, 8a, 22, 29
4Tue 07/214.2: 1d, 2d, 5, 9
4.3: 2a, 4a, 6a, 8a, 16, 18
4.4: 2a, 4a, 13ab, 16
4.5: 2a, 4a, 10
4.6: 1a, 9
4.7: 1a, 2a, 6, 8
5Tue 07/285.1: 1a, 4ac, 6
5.2: 2b, 4b, 9
5.3: 2b, 4b
5.4: 2b, 6b, 14b, 30
6Tue 08/45.6: 1a, 12
5.9: 1c, 3a
5.10: 1, 2, 5, 8
7Tue 08/116.1: 5d, 10, 20ab
6.3: 6a, 10, 18
6.4: 2b, 6, 8, 11
6.6: 2b
7.1: 1a, 2, 4c, 7
7.2: 2d, 4a, 10d, 12
Syllabus (Tentative):
Lec9th Ed Section, Topic
11.1: Review of Calculus
21.1: Review of Calculus
31.2: Round-off Errors and Computer Arithmetic
41.3: Algorithms and Convergence
2.1: The Bisection Method
52.2: Fixed-Point Iteration
62.3: Newton's Method and Its Extensions
2.4: Error Analysis for Iterative Methods
72.5: Accelerating Convergence
2.6: Zeros of Polynomials and Müller's Method
83.1: Interpolations and the Lagrange Polynomial
9 3.2: Data Approximation and Neville's Method
3.4: Hermite Interpolation
103.5: Cubic Spline Interpolation
11 (Practice Exam on Website/Piazza) Midterm Exam - In class
124.1: Numerical Differentiation
134.2: Richardson's Extrapolation
4.3: Elements of Numerical Integration
144.3: Elements of Numerical Integration
4.4: Composite Numerical Integration
154.5: Romberg Integration
4.6: Adaptive Quadrature Methods
164.7: Gaussian Quadrature
4.8: Multiple Integrals
175.1: The Elementary Theory of Initial-Value Problems
18 5.2: Euler's Method
195.2: Euler's Method
5.3: Higher-Order Taylor Methods
205.4: Runge-Kutta Methods
5.5: Error Control and the Runge-Kutta-Fehlberg Method
21 5.6: Multistep Methods
5.7: Variable Step-Size Multistep Methods
225.9: Higher-Order Equations and Systems of Differential Equations
5.10: Stability
23(Practice Exam on Website/Piazza) Midterm Exam - In class
245.10: Stability
5.11: Stiff Differential Equations
256.1: Linear Systems of Equations
6.3: Linear Algebra and Matrix Inversion
26 6.4: The Determinant of a Matrix
6.6: Special Types of Matrices
276.6: Special Types of Matrices
7.1: Norms of Vectors and Matrices
287.2: Eigenvalues and Eigenvectors
297.3: Jacobi and Gauss-Siedel Iterative Techniques
Review
30Review
31NO CLASS
32Final Exam - In class

MATLAB has a diff command that takes a list of numbers and calculates the difference between each adjacent number.

Example: y = [1,3,8]; dy = diff(y) → [2,5].
(Note that the result has one less value than the original list.)

Numerical derivative - if you have lists of x and y values, diff(y)./diff(x) will give the slope of each interval.

Example: x = [0,1,3]; y=[1,5,4]; dydx=diff(y)./diff(x) → [4,-1] ./ [1,2] → [4,-0.5]

When using yp=diff(y)./diff(x) you need to map it to an associated x value. Since you are, in essence, calculating the slope of a line segment, you can map the slope to one of three x values:

  • forward difference - map the slope to the beginning point
    use xp=x(1:end-1)
  • backward difference - map the slope to the end point
    use xp=x(2:end)
  • central difference - map the slope to the midpoint
    use xp=x(1:end-1) + diff(x)./2

Note: numerical differentiation will magnify noise and experimental error in your data. It is usually necessary to filter the data or curve fit it to obtain better results.

Run diff_ex1.m for a simple example.

File(s):
diff_ex1.m

Practice: Create a program to numerically differentiate this data set. Plot the original data set and its derivative (central difference) on the same plot.

t=0:0.1:5;
y=[ 40.0 41.2 42.2 43.2 44.0 44.8 45.4 46.0 46.5 46.8 47.1 47.3 47.3 47.3 47.2 47.0 46.7 46.2 45.7 45.1 44.4 43.6 42.7 41.7 40.6 39.4 38.1 36.7 35.2 33.6 31.9 30.1 28.2 26.2 24.2 22.0 19.7 17.3 14.8 12.3 9.6 6.8 4.0 1.0 -2.1 -5.2 -8.5 -11.8 -15.3 -18.8 -22.5 ];

File(s):
diff_ex2_sameplot.m, diff_ex2_subplot.m