Advertisement
rfq

sinus hiperbolik (2)

rfq
Feb 13th, 2023
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3.  
  4. using namespace std;
  5.  
  6. int faktorial(int N) {
  7.     if (N == 0 || N == 1) return 1;
  8.     return N * faktorial(N-1);
  9. }
  10.  
  11. double myexp(double x, int n) {
  12.     double e = 0.;
  13.    
  14.     for (int i=0; i<=n; i++)
  15.         e += pow(x, i) / faktorial(i);
  16.    
  17.     return e;
  18. }
  19.  
  20. int main() {
  21.    
  22.     int N = 10;
  23.  
  24.     double x = 0.5;
  25.    
  26.     // mencari sinh 0.5 - built-in function vs manual
  27.     double yx = sinh(0.5);
  28.    
  29.     // sinh x = (e^x - e^-x) / 2;
  30.     double y = (myexp(x, N) - myexp(-x, N)) / 2;
  31.     printf("%.20f\n%.20f\n", yx, y);
  32.    
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement