Selasa, 14 Januari 2014

Metode Numerik Diferensiasi Metode Selisih Tengahan Dengan C++

Metode selisih tengahan merupakan metode yang mengambil nilai dari dua titik sekitar dari titik yang akan diukur. Rumus metode selisih tengahan :
Tafsiran geometri metode selisih tengahan :
Contoh kode program C++ penyelesaian metode selisih tengahan untuk persamaan f = x^x^x.
 
#include <iostream>
#include <math.h>
#include <stdio.h>


using namespace std;
float tengahan(float x, float 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;
}


float tengahan(float x, float h){
float f,f1,f2,f3,f4,f5,f6;
f = x+h;
f1 =pow(f,f);
f2 =pow(f,f1);
f3= x-h;
f4 =pow(f3,f3);
f5 =pow(f3,f4);
f6= (f2 - f5)/(2*h);
return f6;
}

keluaran program :
Categories:

0 komentar:

Posting Komentar