Advertisement
Guest User

gergeg

a guest
Feb 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<Math.h>
  3. #include "stdafx.h"
  4. long double Fx_count(double x, double eps = 1e-10) {
  5.  
  6.     long double sum = -1.0*x;
  7.     long double Current = 3*x*x;
  8.     int Number = 1;
  9.     int iteration= 1;
  10.     while (fabs(Current)>eps) {
  11.         if (iteration % 3 == 0) {
  12.             printf_s("\n\tNumber=%d\n\tsum=%lg\n\tCurrent=%lg\n", Number, sum, Current);
  13.         }
  14.         sum += Current;
  15.         Current = Current * (-1.0)*(x*x*x*x*x*x*9)/((Number+1)*(Number+2));
  16.         Number += 2;
  17.         iteration++;
  18.     }
  19.     return sum;
  20.  
  21. }
  22.  
  23. int main() {
  24.     double x;
  25.     printf_s("Write argument\nx=");
  26.     scanf_s("%lg", &x);
  27.     printf_s("\nResult is:\n\ConsoleApplication4 %lg \n\tBy C functions= %lg\n", Fx_count(x), sin(3*x*x*x)/x - x+1);
  28.  
  29.  
  30.     int stoppie;
  31.     scanf_s("%d", &stoppie);
  32.     return 0;
  33.  
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement