Compile and link testdydt.cpp into a program called testdydt. The program only needs to do the test and nothing else. Report the rates from your program for these cases, dydt (0.5,0.04) and dvdt (0.3.0.3).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Could you explain in depth what the question is asking and have clear steps so I can understand the code, which should be in c++

Thank you!

This exercise will make use of numerical integration to get a solution to an ordinary differ-
ential equation (ODE). We will solve the ODE,
dy
dt
=
(1)
This particular equation could be a model for reactions in chemistry, biology and even
astrophysics. y would represent something that is being created from a finite supply of reactants.
For example, it might measure the end product of a chemical reaction like 2 H₂ + O₂ → 2 H₂O.
Here we would have y = nH₂O/nH₂,initial. The reaction rate is proportional to the remaining
reactants (1-y) nH₂/n2,ini
2,initial and other factors included in a. In practice a would be a
function of the environment (temperature, density, etc...) but for simplicity we will keep a
constant. We will start from y(0) = 0. This ODE then has the following exact, analytical
solution which is convenient for checking our answers,
y(t)=1-e
=
a(1 — y).
-a t
(2)
In general, numerical solvers can handle highly non-linear ODEs that do not have analytical
solutions. The choice of solver requires considering complexity, stability and accuracy (small
errors!). In general more accuracy requires smaller steps or a better method.
In this homework we will make use of the PGPLOT library. Please refer to the lecture notes
about PGPLOT for more information.
You can use ploty.cpp and its Makefile from /home/2G03/ploty as a basis to do this
exercise. Remember to change the names in the Makefile.
1.1 We will use the exact expression (equation 1) for din our code. Write a function called
dydt to evaluate it for specific input y and a values. Call it when you need the rate of change
of y throughout this homework. You can keep the function and the main program in one file
in all the exercises. The function declaration should look like:
double dydt ( double y, double a)
Note that the rate does not depend on explicitly on t so you do not need t as an argument,
just y and a.
In a file called testdydt.cpp, include your function code and also write a simple main
program that calls the function dydt. The main program should call it with the arguments
y = 0.5 and a = 0.04 and y = 0.2 and a = 0.4. Use cout to print the values to the terminal.
1
Compile and link testdydt.cpp into a program called testdydt. The program only needs to do
the test and nothing else. Report the rates from your program for these cases, dydt (0.5, 0.04)
and dydt (0.3,0.3).
Transcribed Image Text:This exercise will make use of numerical integration to get a solution to an ordinary differ- ential equation (ODE). We will solve the ODE, dy dt = (1) This particular equation could be a model for reactions in chemistry, biology and even astrophysics. y would represent something that is being created from a finite supply of reactants. For example, it might measure the end product of a chemical reaction like 2 H₂ + O₂ → 2 H₂O. Here we would have y = nH₂O/nH₂,initial. The reaction rate is proportional to the remaining reactants (1-y) nH₂/n2,ini 2,initial and other factors included in a. In practice a would be a function of the environment (temperature, density, etc...) but for simplicity we will keep a constant. We will start from y(0) = 0. This ODE then has the following exact, analytical solution which is convenient for checking our answers, y(t)=1-e = a(1 — y). -a t (2) In general, numerical solvers can handle highly non-linear ODEs that do not have analytical solutions. The choice of solver requires considering complexity, stability and accuracy (small errors!). In general more accuracy requires smaller steps or a better method. In this homework we will make use of the PGPLOT library. Please refer to the lecture notes about PGPLOT for more information. You can use ploty.cpp and its Makefile from /home/2G03/ploty as a basis to do this exercise. Remember to change the names in the Makefile. 1.1 We will use the exact expression (equation 1) for din our code. Write a function called dydt to evaluate it for specific input y and a values. Call it when you need the rate of change of y throughout this homework. You can keep the function and the main program in one file in all the exercises. The function declaration should look like: double dydt ( double y, double a) Note that the rate does not depend on explicitly on t so you do not need t as an argument, just y and a. In a file called testdydt.cpp, include your function code and also write a simple main program that calls the function dydt. The main program should call it with the arguments y = 0.5 and a = 0.04 and y = 0.2 and a = 0.4. Use cout to print the values to the terminal. 1 Compile and link testdydt.cpp into a program called testdydt. The program only needs to do the test and nothing else. Report the rates from your program for these cases, dydt (0.5, 0.04) and dydt (0.3,0.3).
Expert Solution
steps

Step by step

Solved in 6 steps with 3 images

Blurred answer
Knowledge Booster
Binary numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education