Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- using namespace std;
- int faktorial(int N) {
- if (N == 0 || N == 1) return 1;
- return N * faktorial(N-1);
- }
- double myexp(double x, int n) {
- double e = 0.;
- for (int i=0; i<=n; i++)
- e += pow(x, i) / faktorial(i);
- return e;
- }
- int main() {
- int N = 10;
- double x = 0.5;
- // mencari sinh 0.5 - built-in function vs manual
- double yx = sinh(0.5);
- // sinh x = (e^x - e^-x) / 2;
- double y = (myexp(x, N) - myexp(-x, N)) / 2;
- printf("%.20f\n%.20f\n", yx, y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement