## [answered] MATH125 FALL 2016 COMPUTER ASSIGNMENT DUE: In particular, y

I need help writing these questions in code according to Matlab (mainly questions 3 and 4).?

MATH125

FALL 2016

COMPUTER ASSIGNMENT

DUE: NOV 17 In this assignment we use MATLAB to perform numerical computations and generate graphics. In order to complete this assignment, you need to know the basic

syntax of MATLAB (to be covered in the discussion class on Nov 3). In particular,

you need to know how to define and plot functions and to write simple loops. Your

submitted assignment should contain all codes and outputs of the programs, as well

as necessary explanation. While you are encouraged to discuss with fellow students,

1. (Warm up) Consider the function f (x) = sin x. Also consider the following

polynomials:

p1 (x) = x

x3

6

x5

x3

+

p5 (x) = x ?

6

120

p3 (x) = x ? These polynomials are approximations of the sine curve. Plot f , p1 , p3 and

p5 on the same graph over the interval [??, ?].

2. (Simple loop, complicated behaviors) The computer allows us to simulate

the dynamics of many systems (e.g. weather). As an example, write a loop

that performs the following computation:

(ii) Given xn , define xn+1 by xn+1 = 3.6xn (1 ? xn ). For example, x1 =

3.6x0 (1 ? x0 ), x2 = 3.6x1 (1 ? x1 ), and so on.

(iii) Repeat (ii) until we get x100 .

Plot a single output sequence (xn versus n for n = 0, 1, 2, . . . , 100) for your

choice of x0 in (0, 1). You will see that the output changes a lot even if

you change the condition x0 just a little bit. This is a classic example of

chaotic behavior.

3. (Method of bisection) The method of bisection is a method to find a root

of the equation f (x) = 0, where f is continuous. It is based on the intermediate value theorem. We will use the method as described here:

https://en.wikipedia.org/wiki/Bisection method#The method

The input of the method is the following: a continuous function f , and an

interval [a, b] for each f (a) and f (b) have opposite signs.

(a) Consider the cubic polynomial f (x) = x3 ? x ? 2 and [a, b] = [1, 2]

(this is the example in Wikipedia). Try to reproduce the table there,

and find an approximate root x? of f (x) = 0 in [1, 2] which is accurate

up to 2?10 .

Date: October 25, 2016.

1 2 MATH125 (b) Consider the function f (x) = sin x?x?0.5, and [a, b] = [?2, ?1]. Run

the method of bisection with 20 iterations. For each iteration, record

the value of the midpoint as well as the value of f at the midpoint.

4. (Numerical integration) In this problem we compute the Riemann sums

corresponding to the definite integral

Z 1p

1 ? x2 dx.

0 ?

The exact value of this integral is ?4 . Write f (x) = 1 ? x2 .

(a) Write a script that performs the following:

? Input: a positive integer n, such as n = 100.

Pn

? Output: the value of the Riemann sum i=1 f (xi ) n1 , where xi

is chosen according to the midpoint rule.

(b) Compute the Riemann sum for n = 5, 10, 25, 50, 100, 200, 500, 1000.

Arrange your results in a table form.

(c) Recall that the exact value of the integral is ?4 . For each n, let In be

the Riemann sum with n terms and ? En = ? In 4

be the error of the approximation. Plot En against n, and log10 En

against log10 n. Briefly comment on the results.

Solution details:
STATUS
QUALITY
Approved

This question was answered on: Sep 18, 2020

Solution~0001013685.zip (25.37 KB)

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website www.aceyourhomework.com (Deadline assured. Flexible pricing. TurnItIn Report provided)

STATUS

QUALITY

Approved

Sep 18, 2020

EXPERT

Tutor