1 The Collocation Method



Similar documents
Verifying Numerical Convergence Rates

2 Limits and Derivatives

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 10

The EOQ Inventory Formula

Tangent Lines and Rates of Change

FINITE DIFFERENCE METHODS

f(x) f(a) x a Our intuition tells us that the slope of the tangent line to the curve at the point P is m P Q =

Research on the Anti-perspective Correction Algorithm of QR Barcode

An inquiry into the multiplier process in IS-LM model

by the matrix A results in a vector which is a reflection of the given

In other words the graph of the polynomial should pass through the points

Instantaneous Rate of Change:

Section 3.3. Differentiation of Polynomials and Rational Functions. Difference Equations to Differential Equations

Lecture 10: What is a Function, definition, piecewise defined functions, difference quotient, domain of a function

ACT Math Facts & Formulas

What is Advanced Corporate Finance? What is finance? What is Corporate Finance? Deciding how to optimally manage a firm s assets and liabilities.

Derivatives Math 120 Calculus I D Joyce, Fall 2013

Geometric Stratification of Accounting Data


2.1: The Derivative and the Tangent Line Problem

Numerical Methods for Differential Equations

SAT Math Must-Know Facts & Formulas

The Derivative as a Function

f(x + h) f(x) h as representing the slope of a secant line. As h goes to 0, the slope of the secant line approaches the slope of the tangent line.

SOLVING POLYNOMIAL EQUATIONS

OPTIMAL DISCONTINUOUS GALERKIN METHODS FOR THE ACOUSTIC WAVE EQUATION IN HIGHER DIMENSIONS

A Multigrid Tutorial part two

Can a Lump-Sum Transfer Make Everyone Enjoy the Gains. from Free Trade?

1.6. Analyse Optimum Volume and Surface Area. Maximum Volume for a Given Surface Area. Example 1. Solution

Catalogue no XIE. Survey Methodology. December 2004

SAT Subject Math Level 1 Facts & Formulas

Pressure. Pressure. Atmospheric pressure. Conceptual example 1: Blood pressure. Pressure is force per unit area:

Finite Difference Approach to Option Pricing

CHAPTER 8: DIFFERENTIAL CALCULUS

LINES AND PLANES CHRIS JOHNSON

Comparison between two approaches to overload control in a Real Server: local or hybrid solutions?

Compute the derivative by definition: The four step procedure

SAMPLE DESIGN FOR THE TERRORISM RISK INSURANCE PROGRAM SURVEY

MATHEMATICS FOR ENGINEERING DIFFERENTIATION TUTORIAL 1 - BASIC DIFFERENTIATION

A New Cement to Glue Nonconforming Grids with Robin Interface Conditions: The Finite Element Case

CITY UNIVERSITY LONDON. BEng Degree in Computer Systems Engineering Part II BSc Degree in Computer Systems Engineering Part III PART 2 EXAMINATION

Schedulability Analysis under Graph Routing in WirelessHART Networks

Section Continued

College Planning Using Cash Value Life Insurance

2.23 Gambling Rehabilitation Services. Introduction

Solutions by: KARATUĞ OZAN BiRCAN. PROBLEM 1 (20 points): Let D be a region, i.e., an open connected set in

CHAPTER 7. Di erentiation

Chapter 7 Numerical Differentiation and Integration

A Piggybacking Design Framework for Read-and Download-efficient Distributed Storage Codes

Shell and Tube Heat Exchanger

Math 113 HW #5 Solutions

Average and Instantaneous Rates of Change: The Derivative

How To Ensure That An Eac Edge Program Is Successful

Inner Product Spaces

6. Differentiating the exponential and logarithm functions

Projective Geometry. Projective Geometry

- 1 - Handout #22 May 23, 2012 Huffman Encoding and Data Compression. CS106B Spring Handout by Julie Zelenski with minor edits by Keith Schwarz

x = + x 2 + x

L 2 : x = s + 1, y = s, z = 4s Suppose that C has coordinates (x, y, z). Then from the vector equality AC = BD, one has

The Heat Equation. Lectures INF2320 p. 1/88

Lecture 14: Section 3.3

College of the Holy Cross, Spring 2009 Math 373, Partial Differential Equations Midterm 1 Practice Questions

WEEK #3, Lecture 1: Sparse Systems, MATLAB Graphics

Distances in random graphs with infinite mean degrees

Spline Toolbox Release Notes

A strong credit score can help you score a lower rate on a mortgage

Math Assignment 6

Chapter 10: Refrigeration Cycles

r (t) = 2r(t) + sin t θ (t) = r(t) θ(t) + 1 = 1 1 θ(t) Write the given system in matrix form x = Ax + f ( ) sin(t) x y z = dy cos(t)

Part II: Finite Difference/Volume Discretisation for CFD

1 Finite difference example: 1D implicit heat equation

CS3220 Lecture Notes: QR factorization and orthogonal transformations

3. INNER PRODUCT SPACES

1 Review of Least Squares Solutions to Overdetermined Systems

Determine the perimeter of a triangle using algebra Find the area of a triangle using the formula

tegrals as General & Particular Solutions

The finite element immersed boundary method: model, stability, and numerical results

Subspaces of R n LECTURE Subspaces

OPTIMAL FLEET SELECTION FOR EARTHMOVING OPERATIONS

To motivate the notion of a variogram for a covariance stationary process, { Ys ( ): s R}

THREE DIMENSIONAL GEOMETRY

Definition: A vector is a directed line segment that has and. Each vector has an initial point and a terminal point.

Student name: Earlham College. Fall 2011 December 15, 2011

Math Test Sections. The College Board: Expanding College Opportunity

G(s) = Y (s)/u(s) In this representation, the output is always the Transfer function times the input. Y (s) = G(s)U(s).

Solving partial differential equations (PDEs)

The Division Algorithm for Polynomials Handout Monday March 5, 2012

POISSON AND LAPLACE EQUATIONS. Charles R. O Neill. School of Mechanical and Aerospace Engineering. Oklahoma State University. Stillwater, OK 74078

Linearly Independent Sets and Linearly Dependent Sets

Second Order Linear Partial Differential Equations. Part I

Euler s Method and Functions

Applied Linear Algebra

Orthogonal Projections

Section 2.3 Solving Right Triangle Trigonometry

NOTES ON LINEAR TRANSFORMATIONS

Transcription:

CS410 Assignment 7 Due: 1/5/14 (Fri) at 6pm You must wor eiter on your own or wit one partner. You may discuss bacground issues and general solution strategies wit oters, but te solutions you submit must be te wor of just you (and your partner). If you wor wit a partner, you and your partner must first register as a group in CMS and ten submit your wor as a group. Points may be deducted for poor style and recless inefficiency. Topics: Metods for Boundary Value Problems, B-spline review, matrix set-up 1 Te Collocation Metod In tis problem you are to compute an approximate solution ũ(x) to te boundary value problem u (x) + q(x)u(x) = r(x) a x b (1) u(a) = u a u(b) = u b () using te metod of collocation. Te idea is to express ũ(x) as a linear combination of simple basis functions. Te coefficients tat define te linear combination are ten determined via a linear system tat is obtained by imposing certain conditions on ũ(x). For basis functions we will use te B-splines B 0 (x),..., B n+1 (x) tat were introduced in A3. In particular, we will see an approximate solution to (1) of te form ũ(x) = n+1 α B (x) =0 were wit = (b a)/(n 1) and ( ) x x B (x) = B x = a + ( 1) = 0:n + 1. Recall tat A3 was about interpolation wit B-splines. In tat assignment we also determined α 0,..., α n+1 via a linear system solve. Te linear equations enforced interpolation conditions ũ(x i ) = y i i = 1:n. and a pair of end conditions, e.g., u (a) = 0, u (b) = 0. For te BVP (1)-() we proceed similarly. As in A3, te linear equations stipulate te properties tat we want ũ(x) to satisfy. Te first of tese is te left boundary condition: ũ(a) = ũ(x 1 ) = u a Next, we insist tat te differential equation is satisfied by ũ(x) at te collocation points x 1,..., x n : ũ (x i ) + q(x i )ũ(x i ) = r(x i ) i = 1:n. (3) Lastly, we want to be sure tat te rigt boundary condition is satisfied: You job is to implement a function tat does tis: ũ(b) = ũ(x n ) = u b 1

function alpa = BVP_Collocation(a,ua,b,ub,q,r,n) a<b and ua and ub are scalars. q and r are andles to functions q(x) and r(x) defined on [a,b]. n is a positive integer, n >=. alpa is a column (n+)-vector wit te property tat if utilde(x) = alpa(1)b_0(x) +... + alpa(n+)*b_{n+1}(x) ten utilde(a) = ua -utilde (z(i)) + q(z(i))u(z(i)) = r(z(i)) i=1:n utilde(b) = ub were z = linspace(a,b,n) and B_{}(z) is te B-spline Bstar((z-x)/) were x = a+(-1) and = (b-a)/(n-1). (Sorry for te subscript-from-one annoyances.) A test script SowCollocation is provided tat can be used to compare your implementation wit an analogous procedure based on te metod of finite differences. (You will also need to download BVP FiniteDiff). In tis problem we are NOT concerned wit te efficient set up of te linear system tat specifies te α s. Assignment A3 gave you enoug practice wit tat, i.e., te exploitation of te local support feature of te B-spline basis. Clearly, tat tecnology can be exploited ere. Our goal is simply for you to appreciate te collocation framewor by using it to solve a simple problem. So tat you do not get bogged down in low-level details associated wit te evaluation of te B and teir derivatives, we supply te following function on te website: function [y,dy,ddy] = derbstar(z) z is a scalar y = Bstar(z) dy = Bstar (z) ddy = Bstar (z) (Note tat te equations in (3) involve second derivatives of te B evaluated at te x i.) Again, don t spend time vectorizing or exploiting te local support properties of te basis function just set up te linear system correctly and use \. Submit BVP Collocation to CMS. Te Cran-Nicolson Metod for te Heat Equation Here is a simple version of te eat equation: u(x, t) = u(x, t) + s(x, t) a x b, t 0 (4) t x Tin of u(x, t) as te temperature of a rod at time t were s(x, t) is a given eat-source function. Te temperature at te start is nown, u(x, t) = u (0) (x) a x b and remains te same at te endpoints u(a, t) = u (0) (a) = u a u(b, t) = u (0) (b) = u b t 0. (5) For us, te discretization of tis problem involves two parameters. One involves space and one involves time: = (b a)/(n 1) t > 0. Te goal is to produce approximations u(x, t j )

were x = a + ( 1) for = 1:n and t j = j t for j = 0, 1,,.... Since te value of u(x, t) is fixed at te endpoints (see equation (4)), we set 1 = u a n = u b j = 0, 1,,... Te Cran-Nicolson sceme relates te approximate solution at time t j+1 to te approximate solution at time t j as follows: = 1 t +1 u(j) u(j) u(j) 1 + +1 u(j+1) 1 ( + s x, t j + ) t Assume tat we now, = 1:n and want to compute u(j+1), = 1:n. Of course, te endpoint values are nown, 1 = 1 = u a n = n = u b so it is all about computing,..., n 1 from nown stuff. Using te giant Cran-Nicolson divided difference recipe above, sow tat we ave an (n )-by-(n ) linear system of te form T... n 1 = rs tat involves u(j) 1,..., u(j) n,, t, s-evaluations Complete te following function so tat it carries out a Cran-Nicolson step function unext = CranN(uNow,a,b,n,tc,deltaT,s) unow is a column n-vector. a < b n is a positive integer tc is te current time. deltat >0 is te time step. s is a andle to a function of te form s(x,t) unext is a column n-vector wose entries satisfy unext(1) = unow(1), unext(n) = unow(n), and unew() - unow() 1 (unew(+1)-*unew()+unew(-1)) ----------------- = --- ----------------------------- + deltat ^ 1 (unow(+1)-*unow()+unow(-1)) --- ----------------------------- + s(x(),tc+deltat/) ^ for =:n-1 were = (b-a)/(n-1); x = linspace(a,b,n); It is fine for you NOT to exploit T s sparse structure. Just set it up explicitly and use \. A test script SowHeat is provided. Submit CranN to CMS. 3

3 Te Sooting Metod for a Two-Point Boundary Value Problem Te function Cannon v0(v0) solves te A5 initial value problem ẋ = v(t) cos(θ(t)) ẏ = v(t) sin(θ(t)) θ = g/v(t) cos(θ(t)) v = D(t)/m g sin(θ(t)) were D(t) = cρs ((ẋ(t) + w) + ẏ ) and x(0) = 0, y(0) = 0, θ(0), and v(0) = v 0 are te given initial conditions. For a given input v0, te function displays a table tat reports just ow far te cannonball travels for various initial angles and constant wind speeds, e.g., v0 = 50.000 Cannonball Distance as a function of initial angle A (degrees) and eadwind w A w = -0 w = -10 w = 0 w = 10 w = 0 --------------------------------------------------------------------------- 10 83.496 80.871 77.674 74.008 69.970 15 119.756 114.473 108.154 101.090 93.474 0 151.314 143.057 133.35 1.41 111.09 5 177.530 166.358 153.130 138.60 13.540 30 197.84 184.134 167.840 150.07 131.618 35 11.767 196.44 177.446 156.887 135.705 40 19.044 0.618 18.094 159.575 136.83 45 19.433 03.0 18.118 158.356 133.79 50 1.964 198.61 177.480 153.4 18.359 55 199.771 187.671 168.31 144.95 10.099 60 180.184 171.603 154.651 13.81 109.077 65 154.354 150.089 136.694 117.485 95.906 70 14.483 14.475 115.04 99.6 80.450 Develop an analogous function Cannon d(d) tat determines te required initial velocity v 0 so tat te cannonball travels exactly distance d before landing. Sample output: Required travel distance = 00.000 Required initial velocity as a function of initial angle A (degrees) and eadwind w A w = -0 w = -10 w = 0 w = 10 w = 0 --------------------------------------------------------------------------- 10 8.41 85.0 88.44 9.584 97.557 15 67.41 69.858 73.5 77.549 8.915 0 58.850 61.341 64.743 69.14 74.987 5 53.638 56.048 59.478 64.174 70.367 30 50.36 5.667 56.161 61.083 67.771 35 48.317 50.607 54.06 59.389 66.698 40 47.331 49.58 53.89 58.84 66.879 45 47.58 49.484 53.347 59.348 68.90 50 48.119 50.88 54.386 60.961 71.097 55 50.035 5.181 56.575 64.015 75.496 60 53.465 55.55 60.43 68.819 8.458 65 59.164 61.11 66.178 76.804 93.710 70 69.047 70.784 77.34 89.973 113.175 4

To do tis you need to understand and mae use of te Matlab root-finder fzero. A simple example tells all. Suppose function z = MyF(x,a) z = a*x^ - 0; is available. We now tat if a = ten tis function as a single root in te interval [3,4]. Te following script assigns te root to r: a = ; L = 3; R = 4; Braceting_Interval = [L,R]; Contains te root of interest r = fzero(@(x) MyF(x,a),Braceting_Interval) Now ere is wat you do to compute te magic v 0, i.e., te initial velocity so tat wen te cannonball lands, x(t final ) = x final = d. Suppose F(v0,teta,w,d) is a function tat runs ode45 wit te same terminate-onlanding event function and wit initial condition [0;0;teta;v0]. If F returns te value of x final d, ten it evaluates to zero precisely wen v 0 is te required initial velocity, i.e., te initial velocity tat causes te terminating value of x to be d. Tus, to produce Cannon d(d) you need to adjust Cannon v0 so tat (a) it includes te subfunction F just described and (b) it replaces te function d = HowFar(teta,w,v0) wit a function v0 = HowFast(teta,w,d) tat returns te required initial velocity. HowFast is essentially a one-liner tat calls fzero. Tin a little bit about te required braceting interval tat you pass to fzero. Te smaller te interval te fewer te number of F-calls and tat means a reduced number of f-evaluations overall. Include comments on ow you pic te braceting interval. Note: fzero is unappy if tere is no root in te braceting interval. You may assume tat te incoming d satisfies 10 d 500. Submit Cannon d to CMS. 5