Solutions to Assignment #8

Similar documents
Numerical Integration

Lecture 14: Quadrature

NUMERICAL INTEGRATION. The inverse process to differentiation in calculus is integration. Mathematically, integration is represented by.

The Regulated and Riemann Integrals

Math& 152 Section Integration by Parts

CMDA 4604: Intermediate Topics in Mathematical Modeling Lecture 19: Interpolation and Quadrature

6.5 Numerical Approximations of Definite Integrals

AP Calculus Multiple Choice: BC Edition Solutions

n f(x i ) x. i=1 In section 4.2, we defined the definite integral of f from x = a to x = b as n f(x i ) x; f(x) dx = lim i=1

7.2 The Definite Integral

Polynomial Approximations for the Natural Logarithm and Arctangent Functions. Math 230

Best Approximation. Chapter The General Case

Abstract inner product spaces

UNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3

10. AREAS BETWEEN CURVES

Unit #9 : Definite Integral Properties; Fundamental Theorem of Calculus

How can we approximate the area of a region in the plane? What is an interpretation of the area under the graph of a velocity function?

NUMERICAL INTEGRATION

The Fundamental Theorem of Calculus. The Total Change Theorem and the Area Under a Curve.

Section 17.2 Line Integrals

Lecture 4: Piecewise Cubic Interpolation

MORE FUNCTION GRAPHING; OPTIMIZATION. (Last edited October 28, 2013 at 11:09pm.)

APPROXIMATE INTEGRATION

Improper Integrals. Type I Improper Integrals How do we evaluate an integral such as

20 MATHEMATICS POLYNOMIALS

Numerical Analysis: Trapezoidal and Simpson s Rule

DOING PHYSICS WITH MATLAB MATHEMATICAL ROUTINES

Riemann Sums and Riemann Integrals

Chapter 5. Numerical Integration

Review of Calculus, cont d

Lecture 17. Integration: Gauss Quadrature. David Semeraro. University of Illinois at Urbana-Champaign. March 20, 2014

Exam 2, Mathematics 4701, Section ETY6 6:05 pm 7:40 pm, March 31, 2016, IH-1105 Instructor: Attila Máté 1

Riemann Sums and Riemann Integrals

Theoretical foundations of Gaussian quadrature

Math 131. Numerical Integration Larson Section 4.6

Z b. f(x)dx. Yet in the above two cases we know what f(x) is. Sometimes, engineers want to calculate an area by computing I, but...

1 The Riemann Integral

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

Orthogonal Polynomials

different methods (left endpoint, right endpoint, midpoint, trapezoid, Simpson s).

Numerical integration

Overview of Calculus I

3.4 Numerical integration

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER /2019

Lecture 20: Numerical Integration III

1. Gauss-Jacobi quadrature and Legendre polynomials. p(t)w(t)dt, p {p(x 0 ),...p(x n )} p(t)w(t)dt = w k p(x k ),

Lecture 19: Continuous Least Squares Approximation

Advanced Calculus: MATH 410 Notes on Integrals and Integrability Professor David Levermore 17 October 2004

Riemann Integrals and the Fundamental Theorem of Calculus

Math 1B, lecture 4: Error bounds for numerical methods

Disclaimer: This Final Exam Study Guide is meant to help you start studying. It is not necessarily a complete list of everything you need to know.

III. Lecture on Numerical Integration. File faclib/dattab/lecture-notes/numerical-inter03.tex /by EC, 3/14/2008 at 15:11, version 9

Definite integral. Mathematics FRDIS MENDELU. Simona Fišnarová (Mendel University) Definite integral MENDELU 1 / 30

Discrete Least-squares Approximations

Sections 5.2: The Definite Integral

THE EXISTENCE-UNIQUENESS THEOREM FOR FIRST-ORDER DIFFERENTIAL EQUATIONS.

ODE: Existence and Uniqueness of a Solution

Definite integral. Mathematics FRDIS MENDELU

Lecture Note 4: Numerical differentiation and integration. Xiaoqun Zhang Shanghai Jiao Tong University

1 Part II: Numerical Integration

Numerical Analysis. 10th ed. R L Burden, J D Faires, and A M Burden

Advanced Computational Fluid Dynamics AA215A Lecture 3 Polynomial Interpolation: Numerical Differentiation and Integration.

f(x) dx, If one of these two conditions is not met, we call the integral improper. Our usual definition for the value for the definite integral

Chapter 3 Polynomials

We know that if f is a continuous nonnegative function on the interval [a, b], then b

Convex Sets and Functions

Lecture 1. Functional series. Pointwise and uniform convergence.

The First Fundamental Theorem of Calculus. If f(x) is continuous on [a, b] and F (x) is any antiderivative. f(x) dx = F (b) F (a).

4.4 Areas, Integrals and Antiderivatives

Math Advanced Calculus II

p(t) dt + i 1 re it ireit dt =

Chapter 0. What is the Lebesgue integral about?

Reversing the Chain Rule. As we have seen from the Second Fundamental Theorem ( 4.3), the easiest way to evaluate an integral b

Section 5.1 #7, 10, 16, 21, 25; Section 5.2 #8, 9, 15, 20, 27, 30; Section 5.3 #4, 6, 9, 13, 16, 28, 31; Section 5.4 #7, 18, 21, 23, 25, 29, 40

Integration Techniques

Orthogonal Polynomials and Least-Squares Approximations to Functions

Undergraduate Research

Anonymous Math 361: Homework 5. x i = 1 (1 u i )

Numerical Integration

AM1 Mathematical Analysis 1 Oct Feb Exercises Lecture 3. sin(x + h) sin x h cos(x + h) cos x h

We divide the interval [a, b] into subintervals of equal length x = b a n

Improper Integrals, and Differential Equations

THE HANKEL MATRIX METHOD FOR GAUSSIAN QUADRATURE IN 1 AND 2 DIMENSIONS

Lecture 1: Introduction to integration theory and bounded variation

c n φ n (x), 0 < x < L, (1) n=1

We partition C into n small arcs by forming a partition of [a, b] by picking s i as follows: a = s 0 < s 1 < < s n = b.

Indefinite Integral. Chapter Integration - reverse of differentiation

and that at t = 0 the object is at position 5. Find the position of the object at t = 2.

1 The Lagrange interpolation formula

Recitation 3: More Applications of the Derivative

4181H Problem Set 11 Selected Solutions. Chapter 19. n(log x) n 1 1 x x dx,

Week 10: Line Integrals

Euler, Ioachimescu and the trapezium rule. G.J.O. Jameson (Math. Gazette 96 (2012), )

Math 8 Winter 2015 Applications of Integration

Definite Integrals. The area under a curve can be approximated by adding up the areas of rectangles = 1 1 +

Integral points on the rational curve

A REVIEW OF CALCULUS CONCEPTS FOR JDEP 384H. Thomas Shores Department of Mathematics University of Nebraska Spring 2007

Lecture 6: Singular Integrals, Open Quadrature rules, and Gauss Quadrature

B.Sc. in Mathematics (Ordinary)

Goals: Determine how to calculate the area described by a function. Define the definite integral. Explore the relationship between the definite

Transcription:

Mth 1 Numericl Anlysis (Bueler) December 9, 29 Solutions to Assignment #8 Problems 64, exercise 14: The nswer turns out to be yes, which mens tht I hve to be orgnized in writing it up There re lot of fcts to check; I count 8 Let s strt with the first nd second derivtives: 2 + (x + 1) 2 [ 1, ] 6(x + 1) [ 1, ] f (x) = 5 + 6x [, 1] f (x) = 6 [, 1] 11 + 6(x 1) (x 1) 2 [1, 2] 6 6(x 1) [1, 2] Next, note f ( 1) = nd f (2) = so we it is nturl Furthermore the second derivtive is continuous t x = (f () = 6) nd t x = 1 (f (1) = 6) The first derivtive is continuous t x = (f () = 5) nd t x = 1 (f (1) = 11) Finlly the function itself is continuous t x = (f() = ) nd t x = 1 (f(1) = 11) The function is, therefore, the unique nturl cubic spline through the points ( 1, ), (, ), (1, 11), (2, 24) (Checking continuity t n x-vlue mens plugging tht vlue into the polynomil on ech side nd checking tht results gree) Problems 64, exercise 17: This is good one to do by hnd, but I will only show here how to check your nswer with ncsplinem The progrm ncsplinem only computes the coefficients internlly, without displying them, so I copied it to new file ncspline dumpm, nd uncommented the line %[b c d] I modified just bit more to disply clen tble of coefficients Then I rn it, with result >> ncspline_dump([-1 1],[1 7 9],); tble [ b c d] of coefficients: ns = 1-8 2 7-2 6-2 Thus the nturl cubic spline with these vlues nd knots is { 1 8(x + 1) + 2(x + 1), x [ 1, ] S(x) = 7 2x + 6x 2 2x x [, 1] On the other hnd, producing clen plot is exctly the job for which ncsplinem ws built, so: >> x=[-1 1]; y=[1 7 9]; xf=-1:1:1; yf=ncspline(x,y,xf); plot(x,y, o,xf,yf) (The result is not shown) Computer Problems 64, exercise 1: (Sorry, I overlooked the severl test cses phrse I should hve sid tht one test cse is fine) My curve on grph pper looked like the script letter v It generted two lists of x(t) nd y(t) vlues, nd ech list generted cubic spline (with indepent vrible t in ech cse) The function ncsplinem generted finely-interpolted x nd y vlues, nd plotting these, without ny reference to t, gve bck the figure The rest is detils: lettervm % LETTERV Use nturl cubic splines (ncsplinem) to plot script letter % "v", using points tken from written letter on grph pper t = :1:1; % 11 points xy = [ 7; % I found it esiest to enter coordintes of points 4 79; % this wy, s list of (x y) pirs 48 6; 51 4;

2 5 26; 6 2; 71 ; 79 5; 82 6; 9 74; 1 76]; x = xy(:,1) ; y = xy(:,2) ; % extrct just x nd y seprtely tf = :1:1; % fine grid for plotting (on t-vs-x nd t-vs-y xes) xf = ncspline(t,x,tf); yf = ncspline(t,y,tf); % t-versus-x nd t-versus-y plots, using subplot: figure(1) subplot(2,1,1), plot(t,x, o,tf,xf), grid on, xlbel t, ylbel x title("prmeterized curve in pieces") subplot(2,1,2), plot(t,y, o,tf,yf), grid on, xlbel t, ylbel y % plot in x,y plne; prmeter "t" is never mentioned! figure(2), plot(x,y, o,xf,yf) xis equl, grid on, xlbel x, ylbel y, title("the letter v") Figure 1 The script letter v by cubic splines through by-hnd identified points This is figure(2) from the code lettervm Problems 72, exercise 1: Somewht tedious, but the method is cler Write down the Lgrnge polynomils l (x),, l (x) nd integrte them to find A,, A, respectively, in the integrtion rule f(x) dx A f() + A 1 f( 1 ) + A 2f( 2 ) + A f(1) Here is n lternte wy tht exploits our vilble tool, Mtlb/Octve The rule should be ble to integrte cubic polynomils exctly (Why?) This gives 4 equtions in the unknown

A i : 1 = 1/2 = 1/ = 1/4 = 1 dx = A + A 1 + A 2 + A, This system of equtions hs numericl solution: x dx = A + (1/)A 1 + (2/)A 2 + 1A x 2 dx = A + (1/9)A 1 + (4/9)A 2 + 1A x dx = A + (1/27)A 1 + (8/27)A 2 + 1A >> formt rt >> [1 1 1 1; (1/) (2/) 1; (1/9) (4/9) 1; (1/27) (8/27) 1] \ [1 (1/2) (1/) (1/4)] ns = 1/8 /8 /8 1/8 So Problems 72, exercise 14: Problems 72, exercise 1: pge 482 is f(x) dx 1 8 The derivtives of the integrnd re [f() + f( 1 ) + f(2 ) + f(1) ] Similr to previous This is firly similr to Exercise 2 below The error term on (b ) h 2 f (ξ) 12 f (x) = 1 2xe x2, f (x) = ( 2 + 4x 2 )e x2 The mximum of f (x) on the intervl is bounded: f (x) = 2 + 4x 2 e x2 14e 1 = 515 (This is quite pessimistic becuse the mgnitude of f is in fct less thn 1 on the intervl [1, 2] But it suffices) Require the error to be smller thn the given number: (b ) h 2 f (ξ) 12 = h2 12 f (ξ) 515h2 5 1 7 12 This equivlent to h 1165 1 7 = 4 1 4 which sys n = 1/h 29298 so I get n = 29 subintervls Exercise 1: () Keeping the nme x 1 for the center point (+b)/2, the Lgrnge polynomils simplify to l (x) = (x x 1)(x b) ( x 1 )( b) = 2 (b ) 2 ( x 2 (x 1 + b)x + x 1 b ), l 1 (x) = (x )(x b) (x 1 )(x 1 b) = 4 ( x 2 (b ) 2 ( + b)x + b ), l 2 (x) = (x )(x x 1) (b )(b x 1 ) = 2 (b ) 2 ( x 2 ( + x 1 )x + x 1 )

4 The right-hnd expressions re one of severl forms in which the Lgrnge polynomils re reltively esy to integrte The result of integrtion is given in the problem sttement These integrls were needed to compute the coefficients A, A 1, A 2 in Simpson s rule, b f(x) dx 2 i= A if(x i ) (b) Z b I ll give some detil here: Z b» (x )(b x) dx = x 2 x ( + b)x + b dx = = b + ( + b) b2 2 b2 + b x2 ( + b) 2 + bx ( + b) 2 2 + 2 b = 1 ( b)(2 + b + b 2 ) + 1 2 (b )(2 + b 2 ) = 1 6 (b ) ˆ 2 2 2b 2b 2 + 2 + b 2 = 1 6 (b )(b (b )2 ) = 6 This integrl ws necessry to complete the error formul for the trpezoid rule, Exercise 2: b f(x) dx = b 2 [f() + f(b)] f (ξ) 12 (b ) The error formul for the composite Simpson s rule on pge 484 sys b f(x) dx = S n b 18 h4 f(4)(ξ) for S n the composite Simpson s pproximtion nd h = (b )/n In our cse f(x) = π + sin(x) so f (4) (x) = 81 sin(x) Thus f(x) dx S n = 1 18 h4 81 sin(ξ) 9 2 h4, using the stndrd inequlity sin θ 1 Reclling h = 1/n, we wnt to choose 9 2 h4 1 8 9 1 4 2 n 4 1 8 n 4 45 1 12 n 1456475 But n must be n even integer, so n = 1458 is the smllest vlue we expect to get tht ccurcy Does it get tht ccurcy? On the one hnd, the exct nswer is On the other hnd, π + sin(x) dx = 1π + 1 (1 cos()) >> f=@(x) pi + sin(*x); >> n=1458; h=1/n; xi=:h:1; >> Sn = (h/) * sum([1 repmt([4 2],1,n/2-1) 4 1] * f(xi)) Sn = 16978427195495 >> exct = 1*pi+(1/)*(1-cos()) exct = 16978427192687 >> bs(sn - exct) ns = 2875675118888e-1 Thus the error of 28 1 1 is smller thn 1 8 Why the gp? Tht is, why is it tht when we used n = 1458 the error ws quite bit less thn 1 8? Becuse of sin(ξ) 1, which is true but not precise In fct I find tht the smllest n for which the error is less thn 1 8 is n = 598; this comes from Mtlb/Octve progrm-t-the-commnd line: >> for n=8:2:1458 > h=1/n; xi=:h:1; Sn=(h/)*sum([1 repmt([4 2],1,n/2-1) 4 1]*f(xi)); > if bs(exct-sn)<1e-8, n, brek, > n = 598

5 Witness the power of super-clcultor eh? Exercise : From the sttement of the problem I immeditely ws ble to set up equtions for the coefficients In prticulr, s with cubic splines, for j =,, n 1 let h j = t j+1 t j nd m j = y j+1 y j h j The requirement Q j (t j ) = y j implies j = y j The other two requirements immeditely become y j + b j h j + c j h 2 j = y j+1 j =,, n 1, b j + 2c j h j = b j+1 j =,, n 2 This is 2n 1 equtions in the 2n unknowns b j, c j (for j =,, n 1), so the dditionl requirement c = is enough to hope for unique solution In prticulr, tke the first of the bove equtions nd solve it for b j : b j = y j+1 y j c j h 2 j h j = m j c j h j Substitute this into the second set of equtions, for ech of b j nd b j+1, to get or, equivlently, m j c j h j + 2c j h j = m j+1 c j+1 h j+1 h j c j + h j+1 c j+1 = m j+1 m j for j =,, n 2 This lst is set of n 1 equtions in the n unknowns c j, j =,, n 1, so the dditionl condition c = is needed We cn now write mtrix eqution for the c j : 1 h h 1 h 1 h 2 h n 2 h n 1 c c 1 c 2 c n 1 m 1 m = m 2 m 1 m n 1 m n 2 This is lower-tringulr nd bidigonl system As long hs h 1,, h n 1 re non-zero, which they re merely becuse we require distinct nodes, the solution c j is unique Once c j re found we cn find b j immeditely The solution cn be found by firly-obvious forwrd substitution, s in the first for loop in the following code: qsplinem function yi = qspline(t,y,xi) % QSPLINE yi = qspline(t,y,xi) % Computes not-prticulrly-nturl qudrtic spline through points % t = t(1),,t(n+1) % y = y(1),,y(n+1) % nd evlutes t the x-vlues in xi, to give result yi Requires % t(1) < t(2) < < t(n+1) nd xi in [t(1),t(n+1)], nd finds % qudrtic polynomils in this form: % Q_i(x) = y_i + b_i (x - t_i) + c_i (x - t_i)ˆ2 % Try: >> x=:; y=exp(x); xp=:1:; yq = qspline(x,y,xp); % >> plot(x,y, o,xp,exp(xp),xp,yq) % >> leg( dt, underlying function, qudrtic spline ) % Compre to ncsplinem for nturl cubic splines t = t(:); y = y(:); % force t nd y to be column vectors % check tht inputs mke sense if (length(t) = length(y)), error( t,y must be vectors of sme size ), n = length(t) - 1; if n <=, error( must hve t lest two points to produce spline ),

6 if ny(xi < t(1)) ny(xi > t(n+1)) error( xi must be in interior (intervl [t(1),t(n+1)]) ) h = diff(t); % gps: h(i) = t(i+1) - t(i) m = diff(y) / h; % slopes: m(i) = (y(i+1) - y(i)) / h(i) % directly solve bidigonl system for coeffs c_i, by forwrd substitution c = zeros(size(h)); % c_ = lredy for j=2:n c(j) = ( m(j)- m(j-1) - h(j-1)*c(j-1) ) / h(j); % determine other coeffs from c: b = m - h * c; % evlute qudrtics; requires finding intervl in which xi lies xi = xi(:); yi = zeros(size(xi)); for k = 1:length(xi) i = 1; while xi(k) > t(i+1) i = i + 1; % now xi(k) is in [t(i),t(i+1)], so pply Hoerner to evlute Q_i(x): dx = xi(k) - t(i); yi(k) = y(i) + dx * (b(i) + dx * c(i)); The geometric consequences of the choice c = re tht the left-most qudrtic is stright line, which is somewht ugly, while the lgorithmic consequence is lredy mentioned: the system of equtions is lower tringulr Another, possibly better choice is to require c = c 1, implying extr smoothness t the first interior node This condition cn be esily delt-with, but it does brek the literl lower-tringulrness of the system But both of these suggestions re obviously flwed in tht they re symmetric, becuse they tret the left of the spline differently from the right And, t this point, I don t hve relly gret suggestion