Question

**Use C++ in Solving Ordinary Differential Equations using
a
Fourth-Order Runge-Kutta of Your Own Creation**

Assignment:

Design and construct a computer program in C++ that will
illustrate the use of a fourth-order

explicit Runge-Kutta method of your own design. In other words, you
will first have to solve the Runge-Kutta equations of condition for
the coefficients

of a fourth-order Runge-Kutta method. See the
Mathematica notebook on solving the equations for 4th order RK
method.

That notebook can be found at rk4Solution.nb . PLEASE
DO NOT USE a[1] = 1/2 or a[2] =
1/2. In general,

you should pick a[1] and a[2] to be distinct values greater than
zero and less than one.

Then, you will use these coefficients in a computer program to
solve the ordinary differential equation below.

Be sure to follow the documentation and programming style policies
of the Computer Science Department.

The initial value problem to be solved is the following:

x'(t)
= 3 x^{2} cos(5 t)

subject to the initial condition: x(0) = 1.0

Obtain a numerical solution to this problem over the range from t=0.0 to t=2.0

for seven different values of the stepsize,

h=0.1, 0.05 , 0.025 , 0.0125 , 0.00625 , 0.003125 , and 0.0015625 .

In other words, make seven runs with 20, 40, 80, 160, 320, 640,
and 1280 steps, respectively.

For each run, print out the value of h, then a table of t and x,
and then the error at t=2. You may use the following

very precise value for your "true answer" in order to compute the
error at t=2:
**0.753913186469598763502963347**.

Hint: It is often helpful to test your program on simple
differential equations (such as x' = 1 or x'=t or x'=x) as a part
of the debugging process.

Once you have worked these simple cases, then try working the
nonlinear differential equation given above for the assignment
(with a small stepsize).

Also, check your coefficients to make sure that they satisfy the
equations of condition and that you have assigned these correct
values to the

variables or constants in your program properly. For example, a
common error is to write something like: a2 =
1/2; when you meant to write

a2 = 1.0/2.0; so please be careful.

Answer #1

#include <iostream>

using namespace std;

double diffOfy(double x, double y) {

return ((x*x)+(y*y)); //function x^2 + y^2

}

double rk4thOrder(double x0, double y0, double x, double h)
{

int iteration = int((x - x0)/h); //calculate number of
iterations

double k1, k2, k3, k4;

double y = y0; //initially y is f(x0)

for(int i = 1; i<=iteration; i++) {

k1 = h*diffOfy(x0, y);

k2 = h*diffOfy((x0+h/2), (y+k1/2));

k3 = h*diffOfy((x0+h/2), (y+k2/2));

k4 = h*diffOfy((x0+h), (y+k3));

y += double((1.0/6.0)*(k1+2*k2+2*k3+k4)); //update y using del
y

x0 += h; //update x0 by h

}

return y; //f(x) value

}

int main() {

double x0, y0, x, h;

cout << "Enter x0 and f(x0): "; cin >> x0 >>
y0;

cout << "Enter x: "; cin >> x;

cout << "Enter h: "; cin >> h;

cout << "Answer of differential equation: " <<
rk4thOrder(x0, y0, x, h);

}

Application of the first order differential equations, from
"Differential Equations", by Isabel Carmona.
2. A body with a mass of 9.7 kg is released from a height of 300 m
without initial speed. The body finds an air resistance
proportional to its speed.
If the speed limit must be 95 m/sec...
Find
A) body speed at a time t
B) the position of the body at a time t
The correct answers are:
A) v = 95 (1-e(- t /...

Use the method for solving Bernoulli equations to solve the
following differential equation.
(dy/dx)+4y=( (e^(x))*(y^(-2)) )
Ignoring lost solutions, if any, the general solution y=
______(answer)__________
(Type an expression using x as the variable)
THIS PROBLEM IS A DIFFERENTIAL EQUATIONS PROBLEM. Only people
proficient in differential equations should attempt to solve.
Please write clearly and legibly. I must be able to CLEARLY read
your solution and final answer. CIRCLE YOUR FINAL ANSWER.

10.16: Write a user-defined MATLAB function that solves a
first-order ODE by applying the midpoint method (use the form of
second-order Runge-Kutta method, Eqs(10.65),(10.66)). For function
name and arguments use [x,y]=odeMIDPOINT(ODE,a,b,h,yINI). The input
argument ODE is a name for the function that calculates dy/dx. It
is a dummy name for the function that is imported into odeMIDPOINT.
The arguments a and b define the domain of the solution, h is step
size; yINI is initial value. The output arguments, x...

Use the method for solving homogeneous equations to solve the
following differential equation.
(9x^2-y^2)dx+(xy-x^3y^-1)dy=0
solution is F(x,y)=C, Where C= ?

DIFFERENTIAL EQUATIONS
1. A force of 400 newtons stretches a spring 2 meters. A mass of
50 kilograms is attached to the end of the
spring and is initially released from the equilibrium position with
an upward velocity of 10 m/s. Find the equation of
motion.
2. A 4-foot spring measures 8 feet long after a mass weighing 8
pounds is attached to it. The medium through
which the mass moves offers a damping force numerically equal to
times the...

For this assignment you must use your knowledge of the
scientific method to design your own experiment. The first step of
the scientific method is observation. Answer the questions below
about how you would design your scientific experiment. Lab 1: Using
The Scientific Method Worksheet At A Local Town Meeting, One Of
Your Neighbors ... Question: Lab 1: Using the Scientific Method
Worksheet At a local town meeting, one of your neighbors compl...
Lab 1: Using the Scientific Method Worksheet:...

Important Instructions: (1) λ is typed as lambda. (2) Use
hyperbolic trig functions cosh(x) and sinh(x) instead of ex and
e−x. (3) Write the functions alphabetically, so that if the
solutions involve cos and sin, your answer would be
Acos(x)+Bsin(x). (4) For polynomials use arbitrary constants in
alphabetical order starting with highest power of x, for example,
Ax2+Bx. (5) Write differential equations with leading term
positive, so X′′−2X=0 rather than −X′′+2X=0. (6) Finally you need
to simplify arbitrary constants. For...

Important Instructions: (1) λ is typed as lambda. (2) Use
hyperbolic trig functions cosh(x) and sinh(x) instead of ex and
e−x. (3) Write the functions alphabetically, so that if the
solutions involve cos and sin, your answer would be
Acos(x)+Bsin(x). (4) For polynomials use arbitrary constants in
alphabetical order starting with highest power of x, for example,
Ax2+Bx. (5) Write differential equations with leading term
positive, so X′′−2X=0 rather than −X′′+2X=0. (6) Finally you need
to simplify arbitrary constants. For...

-Data Structure in C++ (Review for C++)
-using vector and class
In this assignment you’re going to build a simple “register
machine”, a kind of minimal computer that only supports storing a
fixed number of values (i.e., no randomly-accessible “main
memory”).
Your machine will consist of an input loop that reads lines of
input from the user and then executes them, stopping when the user
quits (by executing the stop command). Each line of input consists
of a command followed...

This is in java and you are not allowed to use Java API classes
for queues, stacks, arrays, arraylists and linkedlists. You have to
write your own implementations for them.
You should construct a BST by inserting node values starting
with a null tree. You can re-use the code for the insert method
given in the sample code from the textbook. -insert method is
provided below
Your code should have a menu driven user interface at the
command line with...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 48 seconds ago

asked 32 minutes ago

asked 35 minutes ago

asked 45 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago