CS 261 Fall 2011 Solutions to Assignment #4



Similar documents
Math 104A - Homework 2

G.A. Pavliotis. Department of Mathematics. Imperial College London

Math Numerical Analysis Homework #2 Solutions

Homework # 3 Solutions

correct-choice plot f(x) and draw an approximate tangent line at x = a and use geometry to estimate its slope comment The choices were:

Inverse Functions and Logarithms

I. Pointwise convergence

Section 3.7. Rolle s Theorem and the Mean Value Theorem. Difference Equations to Differential Equations

Nonlinear Algebraic Equations. Lectures INF2320 p. 1/88

Continuity. DEFINITION 1: A function f is continuous at a number a if. lim

AC : MATHEMATICAL MODELING AND SIMULATION US- ING LABVIEW AND LABVIEW MATHSCRIPT

1. Then f has a relative maximum at x = c if f(c) f(x) for all values of x in some

5.1 Derivatives and Graphs

Section 2.7 One-to-One Functions and Their Inverses

1 if 1 x 0 1 if 0 x 1

Roots of Equations (Chapters 5 and 6)

Roots of equation fx are the values of x which satisfy the above expression. Also referred to as the zeros of an equation

Numerical Methods for Solving Systems of Nonlinear Equations

Taylor and Maclaurin Series

B Answer: neither of these. Mass A is accelerating, so the net force on A must be non-zero Likewise for mass B.

Lectures 5-6: Taylor Series

To differentiate logarithmic functions with bases other than e, use

Example of the Glicko-2 system

NUMERICAL ANALYSIS PROGRAMS

Objective: Use calculator to comprehend transformations.

Intermediate Value Theorem, Rolle s Theorem and Mean Value Theorem

6.4 Logarithmic Equations and Inequalities

Introduction to Numerical Math and Matlab Programming

Approximating functions by Taylor Polynomials.

( ) = ( ) = {,,, } β ( ), < 1 ( ) + ( ) = ( ) + ( )

Find all of the real numbers x that satisfy the algebraic equation:

x a x 2 (1 + x 2 ) n.

MATH 381 HOMEWORK 2 SOLUTIONS

Math 241, Exam 1 Information.

Review of Matlab for Differential Equations. Lia Vas

Average rate of change of y = f(x) with respect to x as x changes from a to a + h:

Physics Notes Class 11 CHAPTER 3 MOTION IN A STRAIGHT LINE

Solutions to Homework 5

100. In general, we can define this as if b x = a then x = log b

A QUICK GUIDE TO THE FORMULAS OF MULTIVARIABLE CALCULUS

4.3 Lagrange Approximation

SMT 2014 Algebra Test Solutions February 15, 2014

WORKBOOK. MATH 30. PRE-CALCULUS MATHEMATICS.

Section 12.6: Directional Derivatives and the Gradient Vector

The Heat Equation. Lectures INF2320 p. 1/88

Lecture 3 : The Natural Exponential Function: f(x) = exp(x) = e x. y = exp(x) if and only if x = ln(y)

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

Homework #1 Solutions

Introduction to Numerical Methods and Matlab Programming for Engineers

FIRST YEAR CALCULUS. Chapter 7 CONTINUITY. It is a parabola, and we can draw this parabola without lifting our pencil from the paper.

Review Solutions MAT V (a) If u = 4 x, then du = dx. Hence, substitution implies 1. dx = du = 2 u + C = 2 4 x + C.

2 Integrating Both Sides

Rootfinding for Nonlinear Equations

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

a cos x + b sin x = R cos(x α)

PRACTICE FINAL. Problem 1. Find the dimensions of the isosceles triangle with largest area that can be inscribed in a circle of radius 10cm.

Solutions to old Exam 1 problems

y cos 3 x dx y cos 2 x cos x dx y 1 sin 2 x cos x dx y 1 u 2 du u 1 3u 3 C

Roots of Polynomials

Lecture 14: Section 3.3

Critical points of once continuously differentiable functions are important because they are the only points that can be local maxima or minima.

Part I Matlab and Solving Equations

FINAL EXAM SECTIONS AND OBJECTIVES FOR COLLEGE ALGEBRA

PROBLEM SET. Practice Problems for Exam #1. Math 1352, Fall Oct. 1, 2004 ANSWERS

Rolle s Theorem. q( x) = 1

The Mean Value Theorem

12.6 Logarithmic and Exponential Equations PREPARING FOR THIS SECTION Before getting started, review the following:

MATH 425, PRACTICE FINAL EXAM SOLUTIONS.

6 Further differentiation and integration techniques

Finding Equations of Sinusoidal Functions From Real-World Data

Coverage Characteristics of Earth Satellites

SOLUTIONS. f x = 6x 2 6xy 24x, f y = 3x 2 6y. To find the critical points, we solve

Chapter. Numerical Calculations

Solutions to Homework 10

y cos 3 x dx y cos 2 x cos x dx y 1 sin 2 x cos x dx

Practice Final Math 122 Spring 12 Instructor: Jeff Lang

Implicit Differentiation

t := maxγ ν subject to ν {0,1,2,...} and f(x c +γ ν d) f(x c )+cγ ν f (x c ;d).

The Steepest Descent Algorithm for Unconstrained Optimization and a Bisection Line-search Method

Calculus 1: Sample Questions, Final Exam, Solutions

Principles of Scientific Computing Nonlinear Equations and Optimization

Lecture 6. Weight. Tension. Normal Force. Static Friction. Cutnell+Johnson: , second half of section 4.7

Techniques of Integration

MATLAB LECTURE NOTES. Dr. ADİL YÜCEL. Istanbul Technical University Department of Mechanical Engineering

Course outline, MA 113, Spring 2014 Part A, Functions and limits Functions, domain and ranges, A Review (9 problems)

4.5 Chebyshev Polynomials

Name: ID: Discussion Section:

APPLIED MATHEMATICS ADVANCED LEVEL

RAJALAKSHMI ENGINEERING COLLEGE MA 2161 UNIT I - ORDINARY DIFFERENTIAL EQUATIONS PART A

1.(6pts) Find symmetric equations of the line L passing through the point (2, 5, 1) and perpendicular to the plane x + 3y z = 9.

Semester 2, Unit 4: Activity 21

MAT12X Intermediate Algebra

MA 408 Computer Lab Two The Poincaré Disk Model of Hyperbolic Geometry. Figure 1: Lines in the Poincaré Disk Model

LIMITS AND CONTINUITY

Calculus with Parametric Curves

1.3. DOT PRODUCT If θ is the angle (between 0 and π) between two non-zero vectors u and v,

Section 9.5: Equations of Lines and Planes

Transcription:

CS 61 Fall 011 Solutions to Assignment #4 The following four algorithms are used to implement the bisection method, Newton s method, the secant method, and the method of false position, respectively. In order to apply these algorithms, an extra file named f.m needs to be created for each problem. Moreover, a second file named fp.m is needed for the Newton s method problems. Bisection Algorithm function p=bisect(a,b,tol,n) % Output: p estimate of root % Input: Interval [a,b], Tolerance tol, Max Interations n % Evaluates a user written function f() %Check intervals are opposite signs if f(a)*f(b) >=0 error( f(a) and f(b) do not have opposite signs ) % Initialize Variables i=1; fa=f(a) ; while i < n p = a+(b-a)/; fp=f(p); if fp==0 (b-a)/<tol i = i+1; if fa*fp > 0 a=p; fa=fp; else b=p; if i== n error( Max Iterations Reached, Method Failed )

Newton s Method Algorithm function p = newton(p0,tol,n) % Output p: estimate of root % Input Initial Point p0, Tolerance tol, Max Interations N % Evaluates user functions f and fp i=1; while i < N p = p0 - f(p0)/fp(p0); if abs(p-p0) < tol i = i+1; p0=p; i if i== N error( Method Failed. Secant Method Algorithm Maximum Interations Reached ) function p = secant(p0,p1,tol,n) %Output Approximate root p %Input initial values: p0, p1; Tolerance: tol; Max Interations: N % Evaluates user functions f i=; q0=f(p0); q1=f(p1); while i < N p = p1-q1*(p1-p0)/(q1-q0); if abs(p-p1) < tol i=i+1; p0=p1; q0=q1; p1=p; q1=f(p); if i== N error( Method Failed. Maximum Interations Reached )

False Position Method Algorithm function p = falsepos(p0,p1,tol,n) %Output Approximate root p %Input initial values: p0, p1; Tolerance: tol; Max Interations: N % Evaluates user functions f i=; q0=f(p0); q1=f(p1); while i < N p = p1-q1*(p1-p0)/(q1-q0); if abs(p-p1) < tol i=i+1; q = f(p); if q*q1 <0 p0=p1; q0=q1; p1=p; q1=q; if i== N error( Method Failed. Maximum Interations Reached )

1. (Exercise #6 on page 54) % y = 3*x - e.^(x); % y = *x + 3*cos(x) - e.^(x); % y = x.^ - 4*x + 4 - log(x); % y = x + 1 - *sin(pi*x); (a) If f(x) = 3x e x, then the bisection method yields that the value of x with 1 x for which f(x) = 0 is 1.51138366699. (b) NOTE: There is an error in the textbook since the function f(x) = x + 3 cos x e x does not have a root in [0, 1]. This function does, however, have a root in [1, ]. Therefore, if f(x) = x + 3 cos x e x, then the bisection method yields that the value of x with 1 x for which f(x) = 0 is 1.3970794677734. (c) If f(x) = x 4x + 4 ln x, then the bisection method yields that the value of x with 1 x for which f(x) = 0 is 1.413916659766, and the value of x with x 4 for which f(x) = 0 is 3.05710601806641. (d) If f(x) = x+1 sin(πx), then the bisection method yields that the value of x with 0 x 0.5 for which f(x) = 0 is 0.06031799316406, and the value of x with 0.5 x 1 for which f(x) = 0 is 0.681968688964844.. (Exercise #0 on page 55) y = -3.17 * ( ( e.^(x) - e.^(-x) )/ - sin(x) ) - 3.4 * x.^; Suppose that x(t), the position of the object moving down the smooth inclined plane at time t, is given by x(t) = g ( e ωt e ωt ) ω sin ωt where g = 3.17 is acceleration due to gravity and ω < 0 is the constant rate of change of angle. (Note that we are told in the problem that ω < 0.) If it is known that x(1) = 1.7, then 1.7 = 3.17 ( e ω e ω ) ω sin ω so that ω < 0 satisfies ( e ω e ω ) 0 = 3.17 sin ω 3.4ω. In other words, we need to find the value of ω < 0 that is a root of the function ( e ωt e ωt ) f(ω) = 3.17 sin ωt 3.4ω. Note that while ω = 0 is a root; we want the value of ω < 0 that is a root. Using the bisection method we find the required value of ω is -0.317066978454590.

3. (Exercise #6 on page 75) % y = e.^x +.^(-x) + * cos(x) - 6; % y = log(x-1) + cos(x-1); % y = e.^x - 3*x.^; % file fp.m % y = e.^x + -*log()*.^(-x) - * sin(x) ; % y = 1/(x-1) - sin(x-1); % y = e.^x - 6*x; (a) If f(x) = e x + x + cos x 6, then Newton s method yields that the value of x with 1 x for which f(x) = 0 is 1.8938367659478. (b) If f(x) = ln(x 1)+cos(x 1), then Newton s method yields that the value of x with 1.3 x for which f(x) = 0 is 1.39774630379610. (e) If f(x) = e x 3x, then Newton s method yields that the value of x with 0 x 1 for which f(x) = 0 is 0.91000757488714, and the value of x with 3 x 5 for which f(x) = 0 is 3.7330790865469. 4. (Exercise #6 on page 77) y = (1+x).^40-1 -500*x; % file fp.m y = 40*(1+x).^39-500; Consider the annuity due formula A = P i [(1 + i)n 1]. If A = 750 000, P = 1500 per month, and n = 0 1 = 40 months, then i satisfies 750000 = 1500 [ (1 + i) 40 1 ] i or, equivalently, 500i = (1 + i) 40 1. Therefore, consider the function f(i) = (1 + i) 40 1 500i. Note that i = 0 is a root of this equation, although the annuity due formula is not well-defined at i = 0. This means that we need to find a positive value of i with f(i) = 0. Using the Newton s method algorithm gives i = 0.0055507819040801. Thus, the minimal monthly interest rate that the engineer needs is 0.5551%. Note that Newton s method requires an initial position. You should try several to verify that your answer is correct, say p 0 = 0.1, p 0 = 0.5, and p 0 = 1; all three appear to converge to the same answer. An equivalent way to express your answer is as the annual interest rate which is 1 i = 0.066609388489841, or roughly 6.67%.

5. (Exercise #8 on page 75) % y = *x *cos(*x) - (x-).^; % y = (x-).^ - log(x); % y = sin(x) -e.^(-x); (c) If f(x) = x cos x (x ), then the secant method yields that the value of x with x 3 for which f(x) = 0 is.3706869176630, and the value of x with 3 x 4 for which f(x) = 0 is 3.711773404. (d) If f(x) = (x ) ln x, then the secant method yields that the value of x with 1 x for which f(x) = 0 is 1.41391170398, and the value of x with e x 4 for which f(x) = 0 is 3.0571035500380. (f) If f(x) = sin x e x, then the secant method yields that the value of x with 0 x 1 for which f(x) = 0 is 0.5885374347889, the value of x with 3 x 4 for which f(x) = 0 is 3.0963639343154, and the value of x with 6 x 7 for which f(x) = 0 is 6.85049733881. 6. (Exercise #1 on page 76) % y = x.^ - 4*x + 4 - log(x); % y = x + 1 - *sin(pi * x); (a) If f(x) = x 4x + 4 ln x, then the method of false position yields that the value of x with 1 x for which f(x) = 0 is 1.41393981915, and the value of x with x 4 for which f(x) = 0 is 3.0570993653003. Note that this is the same function as in (d) of the previous problem. (b) If f(x) = x + 1 sin πx, then the method of false position yields that the value of x with 0 x 1/ for which f(x) = 0 is 0.0603610714860, and the value of x with 1/ x 1 for which f(x) = 0 is 0.68197659174388.