Question

In: Mechanical Engineering

You are required to develop a computer code that that can solve systems of ODE. The...

You are required to develop a computer code that that can solve systems of ODE. The code should request the user to choose one of the following methods for solving the system:

? Euler

? 4th Order Runge Kutta  

Solutions

Expert Solution

For ODE ...

1). EULAR'S METHOD C-CODE :

"

#include<stdio.h>

float fun(float x,float y)

{

    float f;

    f=x+y;

    return f;

}

main()

{

    float a,b,x,y,h,t,k;

    printf("\nEnter x0,y0,h,xn: ");

    scanf("%f%f%f%f",&a,&b,&h,&t);

    x=a;

    y=b;

    printf("\n  x\t  y\n");

    while(x<=t)

    {

        k=h*fun(x,y);

        y=y+k;

        x=x+h;

        printf("%0.3f\t%0.3f\n",x,y);

    }

} "

2). 4TH ORDER RUNGE KUTTA METHOD C-CODE :

"
#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("\n\nX\t\tY\n");
    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\t%f\n",x,y);
    }
}
float f(float x,float y)
{
    float m;
    m=(x-y)/(x+y);
    return m;
} "


Related Solutions

develop a vba computer code to solve the initial value first ODE:dy/dt =(4y)/t with the initial...
develop a vba computer code to solve the initial value first ODE:dy/dt =(4y)/t with the initial condition of y (1)=2 with a time step of 0.05 for the time interval 1 <=t<= 2 for the euler method,2nd order runge-kutta method and the 4th order runge-kutta method
Your consulting organization has been hired to develop computer systems for the United Nations in the...
Your consulting organization has been hired to develop computer systems for the United Nations in the Middle East. Create a Risk Information Sheet for at least five potential risks that should be considered. At least three of the risks you choose should be business continuity and IT disaster recovery related. As part of this, consider man-made and natural risks that might apply to this particular situation. Please note the following: The risk description should fully describe the risk The probability...
Code the game of Rock, Paper, Scissors between a human player and the computer. You can...
Code the game of Rock, Paper, Scissors between a human player and the computer. You can check out the game on Wikipedia if you are not familiar with it. Create a 4 option menu with the human player choices, plus the option of exiting the game. Randomly determine the computer’s choice (although a great deal of AI research has gone in to determining the best computer move). • Loop the game until the human player exits. • Count the number...
Develop a general computer program using MATLAB for the analysis of plane (2D) frames. You can...
Develop a general computer program using MATLAB for the analysis of plane (2D) frames. You can use Chapter 6 as a reference. The program should be able to: a. Analyze a frame subjected to different load types, such as joint load, member load, and support displacement; b. Analyze frames with different boundary conditions: pin, roller, and fixed support; c. Generate the results including joint displacements, member axial, shear and moment forces, and reactions
Discussion: (Minimum 1 page is required) (Please do not attempt to solve if you can not...
Discussion: (Minimum 1 page is required) (Please do not attempt to solve if you can not fulfill the requirement!!!!) Major threats facing the Vitamin Shoppe, and how these might be eliminated, diminished, or deflected. Frame each threat as something present in or emerging from outside of the Vitamin Shoppe. The same technological trend, the ever-increasing popularity of social media, might also suggest a threat: Current and emerging forms of social media offer increased risk for loss of reputation via negative...
subject:engineering mathematics solve [cos(x+y)-sin(x+y)]dx-sin(x+y)dy=0,is the ODE exact?Find an integrating factor and solve the ODE.
subject:engineering mathematics solve [cos(x+y)-sin(x+y)]dx-sin(x+y)dy=0,is the ODE exact?Find an integrating factor and solve the ODE.
The following 3 instances of code was provided by my embedded systems course. Can you explain...
The following 3 instances of code was provided by my embedded systems course. Can you explain what is happening in each code segment? === code 1 === void foo() { uint8_t a=2; uint8_t b[]={b0, b1, b2}; // They are the last three digits of your A# uint8_t* c=b; uint8_t* d=&a; } === code 2 === __extension__ typedef struct tagT1CONBITS { union { struct { unsigned :1; unsigned TCS:1; unsigned TSYNC:1; unsigned :1; unsigned TCKPS:2; unsigned TGATE:1; unsigned :6; unsigned TSIDL:1;...
Consider the equation: x2 y''-6y=0 A. Could you solve this ODE using Homogeneous Linear Equations with...
Consider the equation: x2 y''-6y=0 A. Could you solve this ODE using Homogeneous Linear Equations with Constant Coefficients? Explain. B. Note that y1=x3 is a solution of the ODE. Using reduction of order, find a solution y2 such that { y1, y2} is linearly independent. C. Prove that{y1, y2} is linearly independent. D.What is the general solution?
Solve the ODE y"+3y'+2y=(cosx)+(x^2)+(e^-1)
Solve the ODE y"+3y'+2y=(cosx)+(x^2)+(e^-1)
Use MATLAB DSOLVE to solve the folloing ODE and plot it: 300x'' + 60x' + 6840...
Use MATLAB DSOLVE to solve the folloing ODE and plot it: 300x'' + 60x' + 6840 = f(t)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT