Write program in Java *attached is the programming assignment* please also inclu
ID: 3705244 • Letter: W
Question
Write program in Java *attached is the programming assignment* please also include a typed final conclusion about the program
Solving Ordinary Differential Equations using Runge-Kutta Assignment: Design and construct a computer programin one of the approved languages (C, C++, C#, Java, Pascal, Python, etc.) that will illustrate the use of a third-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 third-order Runge-Kutta method. 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: r(t)+sin(12 t) x() 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 and then a table of t and x. The true solution of this differential equation resembles the following plot of x(t) as a function of t x(t) 3.0 2.5 2.0 0.5 1.0 1.5 2.0
Explanation / Answer
#include<stdio.h>
#include<math.h>
float f(float x,float y);
int main()
{
float x0,y0,m1,m2,m3,m4,m,y,x,h,xn;
printf("Enter x0,y0,xn,h:");
scanf("%f %f %f %f",&x0,&y0,&xn,&h);
x=x0;
y=y0;
printf(" X Y ");
while(x<xn)
{
m1=f(x0,y0);
m2=f((x0+h/2.0),(y0+m1*h/2.0));
m3=f((x0+h/2.0),(y0+m2*h/2.0));
m4=f((x0+h),(y0+m3*h));
m=((m1+2*m2+2*m3+m4)/6);
y=y+m*h;
x=x+h;
printf("%f %f ",x,y);
}
}
float f(float x,float y)
{
float m;
m=(x-y)/(x+y);
return m;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.