Professional Documents
Culture Documents
#include <iostream>
#include <math.h>
#include <stdio.h>
int main(){
float x1,h1;
cout << "masukan nilai h :";
cin >> h1;
cout << "masukan nilai x :";
cin >> x1;
cout << "selisih tengahan fungsi x^x^x :";
cout << tengahan(x1,h1);
return 0;
}
#include <stdio.h>
#include <math.h>
double a,b,x,ft,fek,fx,error,sigma=0,total_error,h;
int i=0;
double f(double x)
return(exp(-x)*sin(2*x)+1);
double f_eksak(double x)
return(-exp(-x)*sin(2*x)+exp(-x)*2*cos(2*x));
return((f(x+h)-f(x-h))/(2*h));
void tengah()
{
scanf("%lf",&b);
scanf("%lf",&a);
scanf("%lf",&h);
puts("==========================================================================");
puts("==========================================================================");
for(x=a;x<=b;x+=h)
{ i++;
fx=f(x);
ft=fungsi_tengah(x,h);
fek=f_eksak(x);
error=fabs(fek-ft);//mencari error
sigma=sigma+error;
total_error=sigma/i;//rata-rata error
main()
{ puts("\t====================");
puts("\t DIFFERENSIAL");
puts("\t====================\n\n");
tengah();