Question

From the following code, define a new structure and use it to define the upper and...

From the following code, define a new structure and use it to define the upper and lower limits of the trapezoidal and simpsons functions.

#include<stdio.h>
#include "math.h"
#include <stdlib.h>
double F1(double x)
{
return 1000 * exp(7*x) * cos(0.3*M_PI*x);
}
double F2(double x)
{
return pow(x,3) - (0.23*x) + 30.67;
}
void calculateIntegeralBySimpson(int n) {
FILE *fp = fopen("data_Simpson_method.txt", "w");
  
int i;
/* Calculating for first half of the interval */
double lowerLimit = -5, upperLimit = 0, x[n+1], y[n+1];
double h = (upperLimit - lowerLimit) / n;
for(i=0; i<=n; i++) {
x[i]=lowerLimit + (i*h);
y[i]=F1(x[i]); /* Call first function */
fprintf(fp,"x, y = (%f, %f)\n",x[i],y[i]);
}
double sumOfOdds=0;
double sumOfEvens=0;
for(i=1; i<n; i++) {
if(i%2==1) {
sumOfOdds=sumOfOdds+y[i];
}
else {
sumOfEvens=sumOfEvens+y[i];
}
}
double firstIntervalSol = (h/3) * (y[0] + y[n] + 4*sumOfOdds + 2*sumOfEvens);
/*
* Calculating for second half interval
*/
lowerLimit = 0, upperLimit = 5;
h = (upperLimit - lowerLimit) / n;
for(i=0; i<=n; i++) {
x[i]=lowerLimit + (i*h);
y[i]=F2(x[i]); /* Call second function */
fprintf(fp,"x, y = (%f, %f)\n",x[i],y[i]);
}
sumOfOdds=0;
sumOfEvens=0;
for(i=1; i<n; i++) {
if(i%2==1) {
sumOfOdds=sumOfOdds+y[i];
}
else {
sumOfEvens=sumOfEvens+y[i];
}
}
double secondIntervalSol = (h/3) * (y[0] + y[n] + 4*sumOfOdds + 2*sumOfEvens);
double solution = firstIntervalSol + secondIntervalSol;
fprintf(fp,"solution to the given integration function is %.10f \n\n\n\n",solution);
fclose(fp);
}

void calculateIntegeralByTrapezoidal(int n) {
FILE *fp = fopen("data_Trapezoidal_method.txt", "w");
int i;
/* Calculating for first half of the interval */
double lowerLimit = -5, upperLimit = 0, x[n+1], y[n+1];
double h = (upperLimit - lowerLimit) / n;
double sum = 0;
for(i=0; i<=n; i++) {
x[i]=lowerLimit + (i*h);
y[i]=F1(x[i]); /* Call first function */
fprintf(fp,"x, y = (%f, %f)\n",x[i],y[i]);
sum = sum+y[i];
}
double firstIntervalSol = (y[0] + y[n] + 2*sum)*(h/2.0) ;
/*
* Calculating for second half interval
*/
lowerLimit = 0, upperLimit = 5;
h = (upperLimit - lowerLimit) / n;
sum = 0;
for(i=0; i<=n; i++) {
x[i]=lowerLimit + (i*h);
y[i]=F2(x[i]); /* Call second function */
fprintf(fp,"x, y = (%f, %f)\n",x[i],y[i]);
sum = sum+y[i];
}
double secondIntervalSol = (y[0] + y[n] + 2*sum)*(h/2.0);
double solution = firstIntervalSol + secondIntervalSol;
fprintf(fp,"solution to the given integration function is %.10f \n",solution);
fclose(fp);
}
void main() {
calculateIntegeralBySimpson(40);
calculateIntegeralByTrapezoidal(100);
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

typedef struct limit {
double upperLimit;
double lowerLimit;
} limit;

double F1(double x) {
return 1000 * exp(7 * x) * cos(0.3 * M_PI * x);
}
double F2(double x) {
return pow(x, 3) - (0.23 * x) + 30.67;
}

void calculateIntegeralBySimpson(int n) {
FILE * fp = fopen("data_Simpson_method.txt", "w");

int i;
/* Calculating for first half of the interval */
limit l;
l.lowerLimit = -5;
l.upperLimit = 0;
  
double x[n + 1], y[n + 1];
double h = (l.upperLimit - l.lowerLimit) / n;
for (i = 0; i <= n; i++) {
x[i] = l.lowerLimit + (i * h);
y[i] = F1(x[i]); /* Call first function */
fprintf(fp, "x, y = (%f, %f)\n", x[i], y[i]);
}
double sumOfOdds = 0;
double sumOfEvens = 0;
for (i = 1; i < n; i++) {
if (i % 2 == 1) {
sumOfOdds = sumOfOdds + y[i];
} else {
sumOfEvens = sumOfEvens + y[i];
}
}
double firstIntervalSol = (h / 3) * (y[0] + y[n] + 4 * sumOfOdds + 2 * sumOfEvens);
/*
* Calculating for second half interval
*/
l.lowerLimit = 0;
l.upperLimit = 5;
h = (l.upperLimit - l.lowerLimit) / n;
for (i = 0; i <= n; i++) {
x[i] = l.lowerLimit + (i * h);
y[i] = F2(x[i]); /* Call second function */
fprintf(fp, "x, y = (%f, %f)\n", x[i], y[i]);
}
sumOfOdds = 0;
sumOfEvens = 0;
for (i = 1; i < n; i++) {
if (i % 2 == 1) {
sumOfOdds = sumOfOdds + y[i];
} else {
sumOfEvens = sumOfEvens + y[i];
}
}
double secondIntervalSol = (h / 3) * (y[0] + y[n] + 4 * sumOfOdds + 2 * sumOfEvens);
double solution = firstIntervalSol + secondIntervalSol;
fprintf(fp, "solution to the given integration function is %.10f \n\n\n\n", solution);
fclose(fp);
}

void calculateIntegeralByTrapezoidal(int n) {
FILE * fp = fopen("data_Trapezoidal_method.txt", "w");
int i;
/* Calculating for first half of the interval */
limit l;
l.lowerLimit = -5;
l.upperLimit = 0;
  
double x[n + 1], y[n + 1];
double h = (l.upperLimit - l.lowerLimit) / n;
double sum = 0;
for (i = 0; i <= n; i++) {
x[i] = l.lowerLimit + (i * h);
y[i] = F1(x[i]); /* Call first function */
fprintf(fp, "x, y = (%f, %f)\n", x[i], y[i]);
sum = sum + y[i];
}
double firstIntervalSol = (y[0] + y[n] + 2 * sum) * (h / 2.0);
/*
* Calculating for second half interval
*/
l.lowerLimit = 0;
l.upperLimit = 5;
h = (l.upperLimit - l.lowerLimit) / n;
sum = 0;
for (i = 0; i <= n; i++) {
x[i] = l.lowerLimit + (i * h);
y[i] = F2(x[i]); /* Call second function */
fprintf(fp, "x, y = (%f, %f)\n", x[i], y[i]);
sum = sum + y[i];
}
double secondIntervalSol = (y[0] + y[n] + 2 * sum) * (h / 2.0);
double solution = firstIntervalSol + secondIntervalSol;
fprintf(fp, "solution to the given integration function is %.10f \n", solution);
fclose(fp);
}

void main() {
calculateIntegeralBySimpson(40);
calculateIntegeralByTrapezoidal(100);
}



Output:
data_Simpson_method.txt:

x, y = (-5.000000, -0.000000)
x, y = (-4.875000, -0.000000)
x, y = (-4.750000, -0.000000)
x, y = (-4.625000, -0.000000)
x, y = (-4.500000, -0.000000)
x, y = (-4.375000, -0.000000)
x, y = (-4.250000, -0.000000)
x, y = (-4.125000, -0.000000)
x, y = (-4.000000, -0.000000)
x, y = (-3.875000, -0.000000)
x, y = (-3.750000, -0.000000)
x, y = (-3.625000, -0.000000)
x, y = (-3.500000, -0.000000)
x, y = (-3.375000, -0.000000)
x, y = (-3.250000, -0.000000)
x, y = (-3.125000, -0.000000)
x, y = (-3.000000, -0.000001)
x, y = (-2.875000, -0.000002)
x, y = (-2.750000, -0.000004)
x, y = (-2.625000, -0.000008)
x, y = (-2.500000, -0.000018)
x, y = (-2.375000, -0.000037)
x, y = (-2.250000, -0.000076)
x, y = (-2.125000, -0.000145)
x, y = (-2.000000, -0.000257)
x, y = (-1.875000, -0.000389)
x, y = (-1.750000, -0.000375)
x, y = (-1.625000, 0.000451)
x, y = (-1.500000, 0.004308)
x, y = (-1.375000, 0.017930)
x, y = (-1.250000, 0.060641)
x, y = (-1.125000, 0.185739)
x, y = (-1.000000, 0.535991)
x, y = (-0.875000, 1.484871)
x, y = (-0.750000, 3.990244)
x, y = (-0.625000, 10.466658)
x, y = (-0.500000, 26.906066)
x, y = (-0.375000, 67.962352)
x, y = (-0.250000, 168.972556)
x, y = (-0.125000, 413.972523)
x, y = (0.000000, 1000.000000)
x, y = (0.000000, 30.670000)
x, y = (0.125000, 30.643203)
x, y = (0.250000, 30.628125)
x, y = (0.375000, 30.636484)
x, y = (0.500000, 30.680000)
x, y = (0.625000, 30.770391)
x, y = (0.750000, 30.919375)
x, y = (0.875000, 31.138672)
x, y = (1.000000, 31.440000)
x, y = (1.125000, 31.835078)
x, y = (1.250000, 32.335625)
x, y = (1.375000, 32.953359)
x, y = (1.500000, 33.700000)
x, y = (1.625000, 34.587266)
x, y = (1.750000, 35.626875)
x, y = (1.875000, 36.830547)
x, y = (2.000000, 38.210000)
x, y = (2.125000, 39.776953)
x, y = (2.250000, 41.543125)
x, y = (2.375000, 43.520234)
x, y = (2.500000, 45.720000)
x, y = (2.625000, 48.154141)
x, y = (2.750000, 50.834375)
x, y = (2.875000, 53.772422)
x, y = (3.000000, 56.980000)
x, y = (3.125000, 60.468828)
x, y = (3.250000, 64.250625)
x, y = (3.375000, 68.337109)
x, y = (3.500000, 72.740000)
x, y = (3.625000, 77.471016)
x, y = (3.750000, 82.541875)
x, y = (3.875000, 87.964297)
x, y = (4.000000, 93.750000)
x, y = (4.125000, 99.910703)
x, y = (4.250000, 106.458125)
x, y = (4.375000, 113.403984)
x, y = (4.500000, 120.760000)
x, y = (4.625000, 128.537891)
x, y = (4.750000, 136.749375)
x, y = (4.875000, 145.406172)
x, y = (5.000000, 154.520000)
solution to the given integration function is 447.4457464763



data_Trapezoidal_method.txt:
x, y = (-5.000000, -0.000000)
x, y = (-4.950000, -0.000000)
x, y = (-4.900000, -0.000000)
x, y = (-4.850000, -0.000000)
x, y = (-4.800000, -0.000000)
x, y = (-4.750000, -0.000000)
x, y = (-4.700000, -0.000000)
x, y = (-4.650000, -0.000000)
x, y = (-4.600000, -0.000000)
x, y = (-4.550000, -0.000000)
x, y = (-4.500000, -0.000000)
x, y = (-4.450000, -0.000000)
x, y = (-4.400000, -0.000000)
x, y = (-4.350000, -0.000000)
x, y = (-4.300000, -0.000000)
x, y = (-4.250000, -0.000000)
x, y = (-4.200000, -0.000000)
x, y = (-4.150000, -0.000000)
x, y = (-4.100000, -0.000000)
x, y = (-4.050000, -0.000000)
x, y = (-4.000000, -0.000000)
x, y = (-3.950000, -0.000000)
x, y = (-3.900000, -0.000000)
x, y = (-3.850000, -0.000000)
x, y = (-3.800000, -0.000000)
x, y = (-3.750000, -0.000000)
x, y = (-3.700000, -0.000000)
x, y = (-3.650000, -0.000000)
x, y = (-3.600000, -0.000000)
x, y = (-3.550000, -0.000000)
x, y = (-3.500000, -0.000000)
x, y = (-3.450000, -0.000000)
x, y = (-3.400000, -0.000000)
x, y = (-3.350000, -0.000000)
x, y = (-3.300000, -0.000000)
x, y = (-3.250000, -0.000000)
x, y = (-3.200000, -0.000000)
x, y = (-3.150000, -0.000000)
x, y = (-3.100000, -0.000000)
x, y = (-3.050000, -0.000001)
x, y = (-3.000000, -0.000001)
x, y = (-2.950000, -0.000001)
x, y = (-2.900000, -0.000001)
x, y = (-2.850000, -0.000002)
x, y = (-2.800000, -0.000003)
x, y = (-2.750000, -0.000004)
x, y = (-2.700000, -0.000005)
x, y = (-2.650000, -0.000007)
x, y = (-2.600000, -0.000010)
x, y = (-2.550000, -0.000013)
x, y = (-2.500000, -0.000018)
x, y = (-2.450000, -0.000024)
x, y = (-2.400000, -0.000032)
x, y = (-2.350000, -0.000043)
x, y = (-2.300000, -0.000057)
x, y = (-2.250000, -0.000076)
x, y = (-2.200000, -0.000099)
x, y = (-2.150000, -0.000128)
x, y = (-2.100000, -0.000164)
x, y = (-2.050000, -0.000207)
x, y = (-2.000000, -0.000257)
x, y = (-1.950000, -0.000311)
x, y = (-1.900000, -0.000365)
x, y = (-1.850000, -0.000409)
x, y = (-1.800000, -0.000423)
x, y = (-1.750000, -0.000375)
x, y = (-1.700000, -0.000213)
x, y = (-1.650000, 0.000151)
x, y = (-1.600000, 0.000859)
x, y = (-1.550000, 0.002129)
x, y = (-1.500000, 0.004308)
x, y = (-1.450000, 0.007924)
x, y = (-1.400000, 0.013790)
x, y = (-1.350000, 0.023138)
x, y = (-1.300000, 0.037825)
x, y = (-1.250000, 0.060641)
x, y = (-1.200000, 0.095744)
x, y = (-1.150000, 0.149317)
x, y = (-1.100000, 0.230508)
x, y = (-1.050000, 0.352798)
x, y = (-1.000000, 0.535991)
x, y = (-0.950000, 0.809078)
x, y = (-0.900000, 1.214370)
x, y = (-0.850000, 1.813438)
x, y = (-0.800000, 2.695627)
x, y = (-0.750000, 3.990244)
x, y = (-0.700000, 5.883955)
x, y = (-0.650000, 8.645555)
x, y = (-0.600000, 12.661184)
x, y = (-0.550000, 18.484250)
x, y = (-0.500000, 26.906066)
x, y = (-0.450000, 39.055569)
x, y = (-0.400000, 56.539766)
x, y = (-0.350000, 81.641099)
x, y = (-0.300000, 117.594135)
x, y = (-0.250000, 168.972556)
x, y = (-0.200000, 242.229054)
x, y = (-0.150000, 346.446650)
x, y = (-0.100000, 494.381441)
x, y = (-0.050000, 703.905798)
x, y = (0.000000, 1000.000000)
x, y = (0.000000, 30.670000)
x, y = (0.050000, 30.658625)
x, y = (0.100000, 30.648000)
x, y = (0.150000, 30.638875)
x, y = (0.200000, 30.632000)
x, y = (0.250000, 30.628125)
x, y = (0.300000, 30.628000)
x, y = (0.350000, 30.632375)
x, y = (0.400000, 30.642000)
x, y = (0.450000, 30.657625)
x, y = (0.500000, 30.680000)
x, y = (0.550000, 30.709875)
x, y = (0.600000, 30.748000)
x, y = (0.650000, 30.795125)
x, y = (0.700000, 30.852000)
x, y = (0.750000, 30.919375)
x, y = (0.800000, 30.998000)
x, y = (0.850000, 31.088625)
x, y = (0.900000, 31.192000)
x, y = (0.950000, 31.308875)
x, y = (1.000000, 31.440000)
x, y = (1.050000, 31.586125)
x, y = (1.100000, 31.748000)
x, y = (1.150000, 31.926375)
x, y = (1.200000, 32.122000)
x, y = (1.250000, 32.335625)
x, y = (1.300000, 32.568000)
x, y = (1.350000, 32.819875)
x, y = (1.400000, 33.092000)
x, y = (1.450000, 33.385125)
x, y = (1.500000, 33.700000)
x, y = (1.550000, 34.037375)
x, y = (1.600000, 34.398000)
x, y = (1.650000, 34.782625)
x, y = (1.700000, 35.192000)
x, y = (1.750000, 35.626875)
x, y = (1.800000, 36.088000)
x, y = (1.850000, 36.576125)
x, y = (1.900000, 37.092000)
x, y = (1.950000, 37.636375)
x, y = (2.000000, 38.210000)
x, y = (2.050000, 38.813625)
x, y = (2.100000, 39.448000)
x, y = (2.150000, 40.113875)
x, y = (2.200000, 40.812000)
x, y = (2.250000, 41.543125)
x, y = (2.300000, 42.308000)
x, y = (2.350000, 43.107375)
x, y = (2.400000, 43.942000)
x, y = (2.450000, 44.812625)
x, y = (2.500000, 45.720000)
x, y = (2.550000, 46.664875)
x, y = (2.600000, 47.648000)
x, y = (2.650000, 48.670125)
x, y = (2.700000, 49.732000)
x, y = (2.750000, 50.834375)
x, y = (2.800000, 51.978000)
x, y = (2.850000, 53.163625)
x, y = (2.900000, 54.392000)
x, y = (2.950000, 55.663875)
x, y = (3.000000, 56.980000)
x, y = (3.050000, 58.341125)
x, y = (3.100000, 59.748000)
x, y = (3.150000, 61.201375)
x, y = (3.200000, 62.702000)
x, y = (3.250000, 64.250625)
x, y = (3.300000, 65.848000)
x, y = (3.350000, 67.494875)
x, y = (3.400000, 69.192000)
x, y = (3.450000, 70.940125)
x, y = (3.500000, 72.740000)
x, y = (3.550000, 74.592375)
x, y = (3.600000, 76.498000)
x, y = (3.650000, 78.457625)
x, y = (3.700000, 80.472000)
x, y = (3.750000, 82.541875)
x, y = (3.800000, 84.668000)
x, y = (3.850000, 86.851125)
x, y = (3.900000, 89.092000)
x, y = (3.950000, 91.391375)
x, y = (4.000000, 93.750000)
x, y = (4.050000, 96.168625)
x, y = (4.100000, 98.648000)
x, y = (4.150000, 101.188875)
x, y = (4.200000, 103.792000)
x, y = (4.250000, 106.458125)
x, y = (4.300000, 109.188000)
x, y = (4.350000, 111.982375)
x, y = (4.400000, 114.842000)
x, y = (4.450000, 117.767625)
x, y = (4.500000, 120.760000)
x, y = (4.550000, 123.819875)
x, y = (4.600000, 126.948000)
x, y = (4.650000, 130.145125)
x, y = (4.700000, 133.412000)
x, y = (4.750000, 136.749375)
x, y = (4.800000, 140.158000)
x, y = (4.850000, 143.638625)
x, y = (4.900000, 147.192000)
x, y = (4.950000, 150.818875)
x, y = (5.000000, 154.520000)
solution to the given integration function is 507.7692103416

Add a comment
Know the answer?
Add Answer to:
From the following code, define a new structure and use it to define the upper and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlocale (LC ALL,") double...

    Convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlocale (LC ALL,") double x(Nm) , y [ Nm],yo Nml®(0.0); int m; FILE dosyal-fopen("D:/veri/673.txtr FILE dosya2-fopen("D:/veri/data2.txt int i-0 while( feof (dosyal)) fscanf (dosyal, " ",xi sytil) fclose (dosyal) int Nij printf("Pencere Genişligi scanf() 3 filtre(x,y.Yo,m,N) for(int k-0keNkt+)fprintf (dosya2, 10.41 10.411 0.41fn",x[k],y[k].yo[k]) fclose(dosya2) void filtre (double x double y. double yoll, int m, int...

  • convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double...

    convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlocale (LC ALL,") double x(Nm) , y [ Nm],yo Nml®(0.0); int m; FILE dosyal-fopen("D:/veri/673.txtr FILE dosya2-fopen("D:/veri/data2.txt int i-0 while( feof (dosyal)) fscanf (dosyal, " ",xi sytil) fclose (dosyal) int Nij printf("Pencere Genişligi scanf() 3 filtre(x,y.Yo,m,N) for(int k-0keNkt+)fprintf (dosya2, 10.41 10.411 0.41fn",x[k],y[k].yo[k]) fclose(dosya2) void filtre (double x double y. double yoll, int m, int...

  • Help with my code: The code is suppose to read a text file and when u...

    Help with my code: The code is suppose to read a text file and when u enter the winning lotto number it suppose to show the winner without the user typing in the other text file please help cause when i enter the number the code just end without displaying the other text file #include <stdio.h> #include <stdlib.h> typedef struct KnightsBallLottoPlayer{ char firstName[20]; char lastName[20]; int numbers[6]; }KBLottoPlayer; int main(){ //Declare Variables FILE *fp; int i,j,n,k; fp = fopen("KnightsBall.in","r"); //...

  • Below is a basic implementation of the Linux command "cat". This command is used to print...

    Below is a basic implementation of the Linux command "cat". This command is used to print the contents of a file on the console/terminal window. #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) {FILE *fp; if(2 != argc) {priritf ("Usage: cat <filename>\n"); exit(1);} if ((fp = fopen(argv[1], "r")) == NULL) {fprintf (stderr, "Can't. open input file %s\n", argv[1]); exit (1);} char buffer[256]; while (fgets(X, 256, fp) != NULL) fprintf(Y, "%s", buffer); fclose(Z); return 0;} Which one of the following...

  • create case 4 do Method 1:copy item by item and skip the item you want to...

    create case 4 do Method 1:copy item by item and skip the item you want to delete after you are done, delete the old file and rename the new one to the old name. #include int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1:...

  • so in this code, it computes the sum 1+2+....+n but i want it to compute 2*(1+2+....+n)...

    so in this code, it computes the sum 1+2+....+n but i want it to compute 2*(1+2+....+n) using semaphores implement solution to the critical section problem #include #include int sum; /* this data is shared by the thread(s) */ void *runner(void *param); /* threads call this function */ int main(int argc, char *argv[]) { pthread_t tid; /* the thread identifier */ pthread_attr_t attr; /* set of thread attributes */ if (argc != 2) { fprintf(stderr,"usage: a.out \n"); return -1; } if...

  • Would u help me fixing this CODE With Debugging Code with GDB #include <stdio.h> #include <stdlib.h>...

    Would u help me fixing this CODE With Debugging Code with GDB #include <stdio.h> #include <stdlib.h> #define SIZE (10) typedef struct _debugLab { int i; char c; } debugLab; // Prototypes void PrintUsage(char *); void DebugOption1(void); void DebugOption2(void); int main(int argc, char **argv) { int option = 0; if (argc == 1) { PrintUsage(argv[0]); exit(0); } option = atoi(argv[1]); if (option == 1) { DebugOption1(); } else if (option == 2) { DebugOption2(); } else { PrintUsage(argv[0]); exit(0); } }...

  • Original question is above, and is for C programming. As you will see in my code...

    Original question is above, and is for C programming. As you will see in my code below, I am not sure how to properly implement the functions I made for g(x) and h(x) (I call them g_x and h_x) into my function called trap. I know that in my main function in my function call to trap, I have to put something in the parentheses of g_x() and h_x() since they both take a type double argument, however I'm not...

  • Write a C language program that will prompt for 12 different resistor values, entered one at...

    Write a C language program that will prompt for 12 different resistor values, entered one at a time via the keyboard, expressed in Ohms. Valid values are 0.01 Ohm up to 10,000,000,000 Ohms. Write each entry to a text file on the disk thus: Resistor 1 Ohmic value = 2200. Update the resistor number for each of the 12 entries. Do not repeat any resistance value. Write a second C language program to read the 12 entries from the text...

  • The first two parts should be solved by Matlab. This is from an intro to Numerical...

    The first two parts should be solved by Matlab. This is from an intro to Numerical Analysis Class and I have provided the Alog 3.2 in below. Please write the whole codes for me. Alog3.2 % NEWTONS INTERPOLATORY DIVIDED-DIFFERENCE FORMULA ALGORITHM 3.2 % To obtain the divided-difference coefficients of the % interpolatory polynomial P on the (n+1) distinct numbers x(0), % x(1), ..., x(n) for the function f: % INPUT: numbers x(0), x(1), ..., x(n); values f(x(0)), f(x(1)), % ...,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT