Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following IVP {y\'(t) = -20y + 20t^2 + 2t, 0 lessthanorequalto t le

ID: 3794803 • Letter: C

Question

Consider the following IVP {y'(t) = -20y + 20t^2 + 2t, 0 lessthanorequalto t lessthanorequalto 1; y(0) = 1/3 with the exact solution y(t) = t^2 + 1/3e^-20t. Use the time stop sizes h = 0.2, 0.125, 0.1, 0.02 for all methods. Solve the IVP using the following methods Euler's method Runge-Kutta method of order four Adams fourth order predictor-corrector method {see ALGORITHM 5.4 p.311) Milne-Simpson predictor-corrector method which combine?. the explicit Milne's method w_i+1 = w_i - 3 + 4h/3 [2f(t_1, w_1)-f(t_i-1, w_i-1) + 2f(t_i-2, w_i-2) and the implicit Simpson's method w_i+1 = w_i - 1 + h/3 [f(t_i+1, w_i+1)-4f(t_i, w_i) + f(t_i-1, w_i-1) Compare the results to the actual solution in plots, compare [w_i - y-i], and specify which method become unstable. Based on the values of h that were chosen, can you make a statement about the region of absolute stability for Euler's method and Runge-Kutta method of order four? A MATLAR function abm4.m that implements Adams fourth-order predictor-corrector method, a MATLAB function ms.m that implements Milne -Simpson predictor-corrector method, and MATLAB script main.m that solves the given IVP and plots the approximated solutions versus the exact one. A PDF report that shows the plots and answer the above questions.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
struct process
{
int no;
int at,et,wt,tt;
int tet;
int t;
};

void main()
{
process p[99];
int i,j,k;
cout<<" Enter No of Processes:";
int np;
cin>>np;

for (i=0;i<np;i++)
{
cout<<" Enter Execution time of process"<<i+1<<":";
cin>>p[i].et;
p[i].tet=p[i].et;
p[i].at=p[i].t=p[i].tt=p[i].wt=0;
p[i].no=i+1;
}

cout<<" Enter Time Quantum:";
int q;
cin>>q;

cout<<" Entered Data";
cout<<" Process ET";
for(i=0;i<np;i++)
{
cout<<" "<<p[i].no<<" "<<p[i].et;
}

int totaltime=0;
for(i=0;i<np;i++)
{
totaltime+=p[i].et;
}

i=0;
k=0;

int rrg[99];
for(j=0;j<totaltime;j++)
{
if((k==0)&&(p[i].et!=0))
{
p[i].wt=j;
if((p[i].t!=0))
{
p[i].wt-=q*p[i].t;
}
}
if((p[i].et!=0)&&(k!=q))
{
rrg[j]=p[i].no;
p[i].et-=1;
k++;
}
else
{
if((k==q)&&(p[i].et!=0))
{
p[i].t+=1;
}
i=i+1;
if(i==np)
{
i=0;
}

k=0;
j=j-1;
}
}

/*
for(j=0;j<totaltime;j++)
{
cout<<" "<<rrg[j];
}
*/

int twt=0;
int ttt=0;
cout<<" Result Of Round Robin";
cout<<" PNo ET WT TT";
for(i=0;i<np;i++)
{
p[i].tt=p[i].wt+p[i].tet;
ttt+=p[i].tt;
twt+=p[i].wt;
cout<<" "<<p[i].no<<" "<<" "<<p[i].tet<<" "<<p[i].wt<<" "<<p[i].tt;
}

cout<<" Average Waiting Time:"<<(float)twt/np;
cout<<" Average Turn Around Time:"<<(float)ttt/np;

getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote