Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part I. Use Maple to calculate the values of the analytical solutions for the following ODEs. You do NOT need to solve the differential equations;

image text in transcribedimage text in transcribedimage text in transcribed

Part I. Use Maple to calculate the values of the analytical solutions for the following ODEs. You do NOT need to solve the differential equations; solutions are given here. 1) x'= with x(0)=1 Find x(2). (Analytical solution: x=t+1) 1 +t 2) x' = t + x with x(0) = 1. Find x(2). (Analytical solution: x=-t+2e -1) 3) x' = t - x with x(2) = 4. Find x(4). (Analytical solution: x =t+3e2-- 1) 4) t- x with x(2)=1 Find x(4). (Analytical solution: 127 +1 -1) x'= x = t + x 1. Create a C++ program and name it YourLastName3.cpp. 2. Write a driver that tests the three methods to find numerical solutions to the ODE's given in Part I. 3. Write a separate function for each of the three methods: Euler's method, Heun's Method, Runge-Kutta's Method 4. Write a separate function for each of the ODE's (four functions in total) given in Par I, 1), 2), 3), and 4). 5. All floating point arithmetic will be double precision. 6. Input to the main program: See the sample run on the next page for details. Choice of an ODE and its analytical solution Interval, [a, b] = [to, IN] Initial value, x(a) = x(to) Integer N, the number of sub intervals Note: The analytical solution can be hardcoded in the program. 7. Program output: 1) A table containing 10 rows with the following values (first nine and the last). General format N=10 N= 100 x(to) x(to) to x(to) x(t1) x(ti) x(ti) X(t2) 12 x(t2) t2 t3 x(t3) t3 x(+3) X(t) X(t) X(t) t4 x(14) x(ts) x(ts) ts x(ts) x(to) x(to) to X(t) X(t) 17 ta x(1) x(ts) x(ts) ts x(ts) X(t) X(to) to x(to) IN T10 x(t10) T100 x(t100) to to ti ti t2 ta t4 14 ts ts 16 to t7 ts t9 to 2) The relative error with x(tn) 8. Test the three methods on the four ODE's with 1) N= 10 and 2) N= 100 (eight runs in total). Analyze your output and write a short report including the following For each of the ODE's Program input Program output o o Sample Run Which ODE would you like to use? 1. x' = x/ (1 + t) 2. x' = t + x 3. x' = t - X 4. x' = (t - x) / (t + x) (This can be hardcoded.) Choice: 3 Enter the analytical solution: 3.406005850 Enter the lower bound of the interval (a): 2 Enter the upper bound of the interval (b): 4 Enter the initial value: 4 Enter the number of sub intervals: 100 Euler's Method: 2.0200000000 3.9600000000 2.0400000000 3.9212000000 2.0600000000 3.8835760000 2.0800000000 3.8471044800 2.1000000000 3.8117623904 2.1200000000 3.7775271426 2.1400000000 3.7443765997 2.1600000000 3.7122890677 2.1800000000 3.6812432864 4.0000000000 3.3978586677 Relative Error: 0.0023920048 Heun's Method: 2.0200000000 3.9606000000 2.0400000000 3.9223761200 2.0600000000 3.8853050728 2.0800000000 3.8493640324 2.1000000000 3.8145306245 2.1200000000 3.7807829182 W.. 2.1400000000 3.7480994164 2.1600000000 3.7164590480 2.1800000000 3.6858411588 4.0000000000 3.4060608060 Relative Error: 0.0000161350 Runge-Kutta Method: 2.0200000000 3.9605960200 2.0400000000 3.9223683176 2.0600000000 3.8852936010 2.0800000000 3.8493490395 2.1000000000 3.8145122545 2.1200000000 3.7807613106 2.1400000000 3.7480747067 2.1600000000 3.7164313675 2.1800000000 3.6858106348 4.0000000000 3.4060058508 Relative Error: 0.0000000002 Press any key to continue Part I. Use Maple to calculate the values of the analytical solutions for the following ODEs. You do NOT need to solve the differential equations; solutions are given here. 1) x'= with x(0)=1 Find x(2). (Analytical solution: x=t+1) 1 +t 2) x' = t + x with x(0) = 1. Find x(2). (Analytical solution: x=-t+2e -1) 3) x' = t - x with x(2) = 4. Find x(4). (Analytical solution: x =t+3e2-- 1) 4) t- x with x(2)=1 Find x(4). (Analytical solution: 127 +1 -1) x'= x = t + x 1. Create a C++ program and name it YourLastName3.cpp. 2. Write a driver that tests the three methods to find numerical solutions to the ODE's given in Part I. 3. Write a separate function for each of the three methods: Euler's method, Heun's Method, Runge-Kutta's Method 4. Write a separate function for each of the ODE's (four functions in total) given in Par I, 1), 2), 3), and 4). 5. All floating point arithmetic will be double precision. 6. Input to the main program: See the sample run on the next page for details. Choice of an ODE and its analytical solution Interval, [a, b] = [to, IN] Initial value, x(a) = x(to) Integer N, the number of sub intervals Note: The analytical solution can be hardcoded in the program. 7. Program output: 1) A table containing 10 rows with the following values (first nine and the last). General format N=10 N= 100 x(to) x(to) to x(to) x(t1) x(ti) x(ti) X(t2) 12 x(t2) t2 t3 x(t3) t3 x(+3) X(t) X(t) X(t) t4 x(14) x(ts) x(ts) ts x(ts) x(to) x(to) to X(t) X(t) 17 ta x(1) x(ts) x(ts) ts x(ts) X(t) X(to) to x(to) IN T10 x(t10) T100 x(t100) to to ti ti t2 ta t4 14 ts ts 16 to t7 ts t9 to 2) The relative error with x(tn) 8. Test the three methods on the four ODE's with 1) N= 10 and 2) N= 100 (eight runs in total). Analyze your output and write a short report including the following For each of the ODE's Program input Program output o o Sample Run Which ODE would you like to use? 1. x' = x/ (1 + t) 2. x' = t + x 3. x' = t - X 4. x' = (t - x) / (t + x) (This can be hardcoded.) Choice: 3 Enter the analytical solution: 3.406005850 Enter the lower bound of the interval (a): 2 Enter the upper bound of the interval (b): 4 Enter the initial value: 4 Enter the number of sub intervals: 100 Euler's Method: 2.0200000000 3.9600000000 2.0400000000 3.9212000000 2.0600000000 3.8835760000 2.0800000000 3.8471044800 2.1000000000 3.8117623904 2.1200000000 3.7775271426 2.1400000000 3.7443765997 2.1600000000 3.7122890677 2.1800000000 3.6812432864 4.0000000000 3.3978586677 Relative Error: 0.0023920048 Heun's Method: 2.0200000000 3.9606000000 2.0400000000 3.9223761200 2.0600000000 3.8853050728 2.0800000000 3.8493640324 2.1000000000 3.8145306245 2.1200000000 3.7807829182 W.. 2.1400000000 3.7480994164 2.1600000000 3.7164590480 2.1800000000 3.6858411588 4.0000000000 3.4060608060 Relative Error: 0.0000161350 Runge-Kutta Method: 2.0200000000 3.9605960200 2.0400000000 3.9223683176 2.0600000000 3.8852936010 2.0800000000 3.8493490395 2.1000000000 3.8145122545 2.1200000000 3.7807613106 2.1400000000 3.7480747067 2.1600000000 3.7164313675 2.1800000000 3.6858106348 4.0000000000 3.4060058508 Relative Error: 0.0000000002 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

1. Where will you recommend that she hold the focus group?

Answered: 1 week ago

Question

3. What might you have done differently

Answered: 1 week ago