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
Embedded computer systems: Configure and code clock for Pic24e referring to the example C code given...
Embedded computer systems: Configure and code clock for Pic24e referring to the example C code given below. a) Write code on how to configure bits that uses its fast RC oscillator with PLL to run at 40MHz. Assume the RC's frequency is 7.5MHz. b) Write code on how to configure bits that uses its primary crystal (XT) with PLL to run at 40MHz. Assume the external clock is a crystal oscillator of 8MHz. ====== Given C Code ======= #include "ConfigurationBits.h"...
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...
Develop a flowchart showing the steps required to set up and test a newly purchased computer...
Develop a flowchart showing the steps required to set up and test a newly purchased computer system that includes the computer, a mouse, keyboard, speakers, and an Internet connection.
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.
Problem Description Students in Computer Information Systems (CIS) department at a local university are required to...
Problem Description Students in Computer Information Systems (CIS) department at a local university are required to do some group-projects in their classes because their instructors believe the skills and competence to work as an effective team are important to assure a successful IT project. Group project helps IT students apply system design knowledge, solve real world business problems, enhance learning effective team skills, improve students’ business communication skills, and serve back to the community. In order to ensure an effective...
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;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT