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

A mathematical relationship between x and y is described bythe following express

ID: 3631588 • Letter: A

Question

A mathematical relationship between x and y is described bythe following expressions:
y=A*exp(x^2)-B*x^3+x-1     if  x<=0      (Case 1)
y=A*log10(x)-B*x^4+1.5     if  0<x<=10   (Case 2)
y=A/log(x)-B/x+C           if  x>10      (Case 3)
where A, B, and C are constants. Write a C program that readsthe double values of the constants A,B,C, and the argument x(by using scanf), and computes the corresponding value of y.Print x by using %f format with 4 decimal places,and print y by using %f format with 5 decimal places.
Use the pow(a,b) function to calculate x^2, x^3 and x^4, and if/elsestatements to choose the proper expression for y, correspondingto selected x.
After reading A,B,C, your program should use a do/while loop toevaluate y for scanned x in each of the above three cases. If youscan x from the same interval again, your program should ask youscan x from the same interval again, your program should ask youto scan x from another interval, until you scan x once from eachinterval.
When you enter the case 2, evaluate the integral of y=y(x)numerically from x=1 to x=5. Use the program based on the trapezoidal rule(Problem w4-10.c in the lecture notes week4.txt), appropriately modifed.Use the do/while statement to continue calculations for different n_trap until you aresatisfied with the accuaracy in evaluating the integral. Print the value of theintegral with the %.3f format.
*****************************************************
Your output should look like:
Enter (double) A, B, C:

-1.5 2.5 0.125


Enter (double) x:

-3.5

Case 1

x value is = -3.5000 and y value is =  -313369.24580
Enter (double) x:

-5

Enter x from another interval!
Enter (double) x:

1.85

Case 2

x value is = 1.8500 and y value is = -28.18452
Enter the number of trapezoids:

1000

n_trap =1000    del_x =0.004

Integral = -1558.638
Do you want new n_trap: y=1/n=0

1
Enter the number of trapezoids:

10000

n_trap =10000    del_x =0.0004

Integral = -1558.637
Do you want new n_trap: y=1/n=0

0
Enter (double) x:

12

Case 3

x value is = 12.0000 and y value is = -0.68698
*/


Explanation / Answer

#include <stdio.h>
#include <math.h>
main()
{
int smaller0=0, smaller1=0, greater1=0;
double A, B, C, x, y;
printf(" Enter (double) A, B, C: ");
scanf("%lf %lf %lf", &A, &B, &C);
do{

printf(" Enter (double) x: ");
scanf("%lf", &x);

if(x<=0){
y =(A * pow(x,3.)) - (B * x) + 0.75;
printf("Case 1 ");
}
else{
if(0<x, x<1){
y = 1 - B - C * pow(x,4.);
printf("Case 2 ");}
else{
if(x>=1){
y = A * log10(x) + B / x;
printf("Case 3 ");}
}
}
printf("x value is = %.3f and y value is = %.5f ", x, y);

} while(smaller0 == 1, smaller1 == 1, greater1 == 1);
exit(0);
}

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