JAVA PROGRAMMING QUESTION Hello, I need a little bit of help. This is also a mat
ID: 3768076 • Letter: J
Question
JAVA PROGRAMMING QUESTION
Hello, I need a little bit of help. This is also a math problem. I need some help in finding out how to model the below equations in Java using the Euler Method and the 4th Order Runge-Kutta method. My biggest problem is that I do not understand how to set a step size for the initial condition that y(w)=0. How do I set a step size that moves from a beginning to an eventual variable? I also don't know how to place my constants vs and vr into my program.
Context for the equations can be found at http://www.cengage.com/math/book_content/0495108243_zill/projects_archive/de8e/Project3.pdf
I was trying to model my programming off of http://pastebin.com/tYYQuHph, but I couldn't work out my above issues. I have no clue what to do for the Runge-Kutta method.
I don't know where to start.
dx dy (-, cos , v,-, sin ), where the magnitudes Ivl - v, and lv,l are speeds. By using, the fact that the ing components in (1) are equal and that cos =x/u2 + y2, sin -y/VX2 + y2 we've constructed the system of first-order differential equations dt Because dy dyldr the solution curves of this system of differential equations dx dxldt satisfy the single first-order equationExplanation / Answer
#include<stdio.h>
#include <math.h>
#include<conio.h>
//dy/dx = vr-vs(y/sqrtroot(x*x+y*y)) F(x,y) x/sqrtroot(x*x+y*y)
void main()
{
double y0,x0,y1,n,h,f,k1,k2,k3,k4;
clrscr();
printf(" Enter the value of x0: ");
scanf("%lf",&x0);
printf(" Enter the value of y0: ");
scanf("%lf",&y0);
printf(" Enter the value of h: ");
scanf("%lf",&h);
printf(" Enter the value of last point: ");
scanf("%lf",&n);
for(; x0<n; x0=x0+h)
{
f=F(x0,y0);
k1 = h * f;
f = F(x0+h/2,y0+k1/2);
k2 = h * f;
f = F(x0+h/2,y0+k2/2);
k3 = h * f;
f = F(x0+h/2,y0+k2/2);
k4 = h * f;
y1 = y0 + ( k1 + 2*k2 + 2*k3 + k4)/6;
printf(" k1 = %.4lf ",k1);
printf(" k2 = %.4lf ",k2);
printf(" k3 = %.4lf ",k3);
printf(" k4 = %.4lf ",k4);
printf(" y(%.4lf) = %.3lf ",x0+h,y1);
y0=y1;
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.