Develop a C-code to meet the requirements below: 1) Find the solution of the dif
ID: 3706485 • Letter: D
Question
Develop a C-code to meet the requirements below: 1) Find the solution of the differential equation below by using Euler's method. The range of x is 3 to 4. dy/dx-x+2x with y-3 at x-3 2) Find the appropriate step size for this specific problem. 3) Pri all the y values within the range of x-3 to x 4. 4) Solve the differential equation analytically and compare with the Euler's method 5) Obtain a linear regression y ax+b and show the r2 value Your C-code must contain the following features: (1) use of arrays, (2) use of pointers, (3) use of structure, (4) use of union, (5) use of functions and function calls, (6 formatted output on screen and (7) saving of the same output on a file.Explanation / Answer
static int i=1;
double f(double x,double y)
{
return x*x+2*x;
}
void solution(double x,double y, double h,int n)
{
y=y+h*(f(x,y));
x=x+h;
if(i<=n)
printf("y ("+x+") = %d",y);
else
exit(0);
i++;
solution(x, y, h, n);
}
public static void main(String[] args)
{
float x,y,h;
int t;
printf(" Enter your initial value of x,y");
scanf("%f%f",&x,&y);
printf(" Enter the value of increment");
scanf("%f",&h);
printf(" What is your itteration");
scanf("%d",&t);
solution(x, y, h, t);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.