Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ a) r'= with x(0)=1 Find x(2). (Analytical solution: x =1+1) b) c) d) x'= 1 + x with x(0) = 1. Find x(2).(Analytical solution:

C++

image text in transcribed

image text in transcribed

a) r'= with x(0)=1 Find x(2). (Analytical solution: x =1+1) b) c) d) x'= 1 + x with x(0) = 1. Find x(2).(Analytical solution: x = -1 +2e-1) x=1-with x(1) = 2. Find x(3). (Analytical solution: x = 1 +2el-4-1) -!- with x(2)=1 Find x(4). (Analytical solution: x = V21 +1-) Part II. 1. Create a CH console application project in Visual Studio 2015 and name your project Your LastNameOLA2. 2. Write a program that implements the Euler's, the Heun's, and the Runge-Kutta Methods to find numerical solutions to the ODE's given in Part I. 3. Write a separate function for each of the following. 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). 5. All floating point arithmetic will be double precision. 6. Input to the main program Choice of an ODE and its analytical solution Initial value, x(a) = x(10) Interval, [a, b] = [to, n] Integer N, the number of sub intervals 7. Program output: 1) A table containing 10 rows with the following values (first nine and the last). to X(to) x(11) x(2) X(13) x(14) x(ts) x(16) x(17) x(18) 19 x(N) 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 IN Sample Run Which ODE would you like to use? 1. X' = x / (1 + t) 2. x' t + X 3. x' - - X 4. x' = (t - x) / (t + x) (This can be hardcoded Choice: 3 Enter the analytical solution: 2.270670566 Enter the lower bound of the interval (a): 1 Enter the upper bound of the interval (b): 3 Enter the initial value: 2 Enter the number of sub intervals: 100 Euler's Method: 1.0200000000 1.9800000000 1.0400000000 1.9608000000 1.0600000000 1.9423840000 1.0800000000 1.9247363200 1.1000000000 1.9078415936 1.1200000000 1.8916847617 1.1400000000 1.8762510665 1.1600000000 1.8615260452 1.1800000000 1.8474955243 3.0000000000 2.2652391118 Relative Error: 0.0023920045 Heun's Method: 1.0200000000 1.9804000000 1.0400000000 1.9615040800 1.0600000000 1.9435367152 1.0800000000 1.9262426883 1.1000000000 1.9096870830 1.1200000000 1.893855278B 1.1400000000 1.8787329443 1.1600000000 1.8643060320 1.1800000000 1.8505607725 3.0000000000 2.2707072040 Relative Error: 0.0000161353 Runge-Kutta Method: 1.0200000000 1.9803973467 1.0400000000 1.9615788784 1.0600000000 1.9435290673 1.0800000000 1.9262326930 1.1000000000 1.9096748363 1.1200000000 1.8938408737 1.1400000000 1.8787164711 1.1600000000 1.8642875783 1.1800000000 1.8505404232 3.0000000000 2.2706705672 Relative Error: 0.0000000005 a) r'= with x(0)=1 Find x(2). (Analytical solution: x =1+1) b) c) d) x'= 1 + x with x(0) = 1. Find x(2).(Analytical solution: x = -1 +2e-1) x=1-with x(1) = 2. Find x(3). (Analytical solution: x = 1 +2el-4-1) -!- with x(2)=1 Find x(4). (Analytical solution: x = V21 +1-) Part II. 1. Create a CH console application project in Visual Studio 2015 and name your project Your LastNameOLA2. 2. Write a program that implements the Euler's, the Heun's, and the Runge-Kutta Methods to find numerical solutions to the ODE's given in Part I. 3. Write a separate function for each of the following. 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). 5. All floating point arithmetic will be double precision. 6. Input to the main program Choice of an ODE and its analytical solution Initial value, x(a) = x(10) Interval, [a, b] = [to, n] Integer N, the number of sub intervals 7. Program output: 1) A table containing 10 rows with the following values (first nine and the last). to X(to) x(11) x(2) X(13) x(14) x(ts) x(16) x(17) x(18) 19 x(N) 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 IN Sample Run Which ODE would you like to use? 1. X' = x / (1 + t) 2. x' t + X 3. x' - - X 4. x' = (t - x) / (t + x) (This can be hardcoded Choice: 3 Enter the analytical solution: 2.270670566 Enter the lower bound of the interval (a): 1 Enter the upper bound of the interval (b): 3 Enter the initial value: 2 Enter the number of sub intervals: 100 Euler's Method: 1.0200000000 1.9800000000 1.0400000000 1.9608000000 1.0600000000 1.9423840000 1.0800000000 1.9247363200 1.1000000000 1.9078415936 1.1200000000 1.8916847617 1.1400000000 1.8762510665 1.1600000000 1.8615260452 1.1800000000 1.8474955243 3.0000000000 2.2652391118 Relative Error: 0.0023920045 Heun's Method: 1.0200000000 1.9804000000 1.0400000000 1.9615040800 1.0600000000 1.9435367152 1.0800000000 1.9262426883 1.1000000000 1.9096870830 1.1200000000 1.893855278B 1.1400000000 1.8787329443 1.1600000000 1.8643060320 1.1800000000 1.8505607725 3.0000000000 2.2707072040 Relative Error: 0.0000161353 Runge-Kutta Method: 1.0200000000 1.9803973467 1.0400000000 1.9615788784 1.0600000000 1.9435290673 1.0800000000 1.9262326930 1.1000000000 1.9096748363 1.1200000000 1.8938408737 1.1400000000 1.8787164711 1.1600000000 1.8642875783 1.1800000000 1.8505404232 3.0000000000 2.2706705672 Relative Error: 0.0000000005

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

Step: 3

blur-text-image

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

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

ISBN: 1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago