logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Isaiah RobertsComputer science
(5/5)

637 Answers

Hire Me
expert
Violeta BaoMarketing
(5/5)

517 Answers

Hire Me
expert
Stevan DuignanMathematics
(4/5)

799 Answers

Hire Me
expert
Ritesh GrewalBusiness
(5/5)

741 Answers

Hire Me
Linear Programming
(5/5)

Most of the examples of differential equations we have seen so far have been of the form x˙ = f (x)

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Most of the examples of differential equations we have seen so far have been of the form x˙ = f (x). That is, the right hand side of the equation does not explicitly depend on t. Such equations are called autonomous. However, all of the numerical methods we have seen work just as well with non-autonomous equations (which do explicitly depend on t).

PROBLEM 1

Solve the following initial value problem:

x˙(t) = cos(t) − x with x(0) = 1. (1) It is easy to check that the true solution to this equation is xtrue (t) = 1 cos(t) + sin(t) + e−t . (2)

We will use this true solution to calculate the error of our approximations.

(1) Solve equation (1) from t = 0 to t = 10 with a time step of ∆t = 0.1 using the forward Euler method. Make a 1 101 row vector containing all of your approximations of x and save it in a variable named A1. (Don’t forget to use reshape in python.)

For each approximation xn that you found with the forward Euler method, calculate the error xn xtrue(tn) between your approximation and the true solution at the corresponding time and create a 1 101 row vector of these errors. Save this row vector in a variable named A2. (Don’t forget to use reshape in python.)

(2) Solve equation (1) from t = 0 to t = 10 with a time step of ∆t = 0.1 using the backward Euler method. At each step, you will have to solve an implicit equation for xn+1. This equation should be easy to solve by hand. Make a 1 101 row vector containing all of your approximations of x and save it in a variable named A3. (Don’t forget to use reshape in python.)

For each approximation xn that you found with the backward Euler method, calculate the error xn xtrue(tn) (notice the absolute value) between your approximation and the true solution at the corresponding time and create a 1 101 row vector of these errors. Save this row vector in a variable named A4. (Don’t forget to use reshape in python.)

(3) Solve equation (1) from t = 0 to t = 10 using ode45 (in MATLAB) or solve_ivp (in Python). Specify that the solver should produce approximations for the points tspan = [0:0.1:10] (in MATLAB) or using the t_eval = np.arange(0, 10 + 0.1, 0.1) option (in python). Make a 1 101 row vector containing all of your approximations of x and save it in a variable named A5. (Don’t forget to use reshape in python.)

For each approximation xn that you found with ode45 or solve_ivp, calculate the error xn xtrue(tn) between your approximation and the true solution at the corresponding time and create a 101-row vector of these errors. Save this row vector in a variable named A6. (Don’t forget to use reshape in python.)

Consider the initial value problem

PROBLEM 2

x˙(t) = a sin(x) with x(0) = π/4, (3)

where a is a constant. You can check that the solution to this differential equation is xtrue(t) = 2 arctan eat 1 + √2. (4)

We will use this problem to explore the accuracy of the forward and backward Euler methods.

Throughout this problem, use a = 8.

(1) Solve equation (3) from t = 0 to t = 2 with a time step of ∆t = 0.01 using the forward Euler method. Make a 1 201 row vector containing all of your approximations of x and save it in a variable named A7. (Don’t forget to use reshape in python.)

Find the maximum error between your approximations and the true solution. That is, find max( xn xtrue(tn) ). Save this maximum error in a variable named A8. Repeat for ∆t = 0.001, and save the ratio of the old maximum error to the new maximum error as A9.

(2) Solve equation (3) from t = 0 to t = 2 with a time step of ∆t = 0.01 using the backward Euler method. At each step of the backward Euler method, you will need to solve an equation of the form xn+1 = xn + a∆t sin(xn+1). This equation cannot be solved by hand, but we can use forward Euler to calculate (or more accurately “predict”) xn+1. This is called the predictor-corrector method. In one iteration, first approximate xn+1 using forward Euler, then use it to approximate sin(xn+1), finally, use xn+1 = xn + a∆t sin(xn+1) to approximate the corrected xn+1. Make a 1 201 row vector containing all of your approximations of x and save it in a variable named A10. (Don’t forget to use reshape in python.)

Find the maximum error between your approximations and the true solution. That is, find max( xn xtrue(tn) ). Save this maximum error in a variable named A11. Repeat for ∆t = 0.001, and save the ratio of the old maximum error to the new maximum error as A12.

(3) Solve equation (3) from t = 0 to t = 2 using ode45 or solve_ivp. Specify that the solver should produce approximations for the points tspan = [0:0.01:2] (in MATLAB) or using the

t_eval = np.arange(0, 2 + 0.01, 0.01) option (in python). Make a 1 201 row vector containing all of your approximations of x and save it in a variable named A13. (Don’t forget to use reshape in python.)

Find the maximum error between your approximations and the true solution. That is, find max( xn xtrue(tn) ). Save this maximum error in a variable named A14. Repeat for ∆t = 0.001, and save the ratio of the old maximum error to the new maximum error as A15.

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme