a. Write a C program on omega.uta.edu to generate the following table of Rx) : x
ID: 3594299 • Letter: A
Question
a. Write a C program on omega.uta.edu to generate the following table of Rx) : x-216 +,1120 from x = 0 to x = 4.0 with an increment of 0.1 , and store the result to a separate file, table, dat. 0.000000 0.000000 0.100000 0.099833 3.500000 0.730990 3.600000 0.862848 3.700000 1.036497 3.800000 1.257597 .900000 1.532184 4.000000 1.866667 b. Transfer the above date file from omega.uta.edu to a local folder. Launch gnuplot to read the file, table.dat, and plot the data along with sin x can find out how good approximating sin x by the first three terms of Taylor series is. The graph should look like 05Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
double f(double x)
{
return x - (x*x*x)/6 + x*x*x*x*x/120;
}
int main()
{
FILE *fp = fopen("table.dat", "w");
double i = 0;
for (i = 0; i <= 4.1; i = i + 0.1) {
fprintf(fp, "%f %f ", i, f(i));
}
fclose(fp);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.