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 pow(10, -6)
- double F(double x);
- double S(double x);
- double ch(double x);
- int main(void)
- {
- printf(" x \t|\t S(x) \t\t|\t F(x)\n");
- for(double x = 0.5; x < 5.5; x += 0.5)
- {
- double s = S(x);
- double f = F(x);
- printf("%.1lf\t|\t%.6lf\t|\t%.5lf \n", x, s, f);
- }
- system("pause");
- return 0;
- }
- double F(double x)
- {
- double x_k = x; double sum = x_k; int k = 2;
- while(fabs(x_k) > E)
- {
- x_k *= (pow(-1, k) * (x*x) / (k * (2*k+1)));
- sum += x_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