Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #define e 2.73
- #define E 0.000001
- double F(double x);
- double S(double x);
- double ch(double x);
- int main(void)
- {
- printf(" x \t|\t S(x)\n");
- for(double x = 0; x < 5.5; x += 0.5)
- {
- double value = S(x);
- printf("%.1lf\t|\t%.5lf\n", x, value);
- }
- system("pause");
- return 0;
- }
- double F(double x)
- {
- double x_k = 2 * x; double sum = x_k; int k = 2;
- while(fabs(x_k) > E)
- {
- x_k = x_k * (pow(-1, k) * pow(x, 2)) / (k * (2*k + 1));
- sum += k; k++;
- }
- return sum;
- }
- double ch(double x)
- {
- return (pow(e, x) + pow(e, -x)) / 2;
- }
- double S(double x)
- {
- return F(x) - sin(x) * ch(x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement