Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- int faktorial(int N)
- {
- if (N==0) return 1;
- else return N*faktorial(N-1);
- }
- using namespace std;
- int main()
- {
- ///MENGERJAKAN SOAL cos MCLaurin
- double zigma = 0.;
- double x = 0.5;
- int N = 5;
- double y = cos(0.5);
- double galat;
- for (int i = 0; i<=N; i++)
- {
- zigma = zigma + (pow(-1,i)*pow(x,2*i+1)/faktorial(2*i+1));
- galat = y - zigma;
- // cout<<zigma<<endl;
- printf("Sigma: %.20f\nGalat: %.20f\n", zigma, galat);
- // cout<<galat<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment