ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo029.c File Reference
#include <stdio.h>
Include dependency graph for Ejemplo029.c:

Go to the source code of this file.

Functions

double exp1 (double x, int n)
double exp3 (double x, int n)
double exp4 (double x, int n)
double exp5 (double x, int n)
double potencia (double x, int n)
long int factorial (int n)
double potencia2 (double x, int n)
long int factorial2 (int n)
double fct (double x, int n)
int main (int argc, char *argv[])

Function Documentation

◆ exp1()

double exp1 ( double x,
int n )

Definition at line 62 of file Ejemplo029.c.

63{
64 int i;
65 double ex;
66 for(i=0, ex=0; i<n; i++)
67 ex += potencia(x, i)/factorial(i);
68 return ex;
69}
long int factorial(int n)
Definition Ejemplo029.c:80
double potencia(double x, int n)
Definition Ejemplo029.c:71
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exp3()

double exp3 ( double x,
int n )

Definition at line 50 of file Ejemplo029.c.

51{
52 int i;
53 double ex, fct;
54 for(i=0, ex=0, fct=1; i<n; i++)
55 {
56 ex += fct;
57 fct *= x/(i+1);
58 }
59 return ex;
60}
double fct(double x, int n)
Definition Ejemplo029.c:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exp4()

double exp4 ( double x,
int n )

Definition at line 89 of file Ejemplo029.c.

90{
91 if(n>0)
92 return exp4(x, n-1)+potencia2(x,n)/factorial2(n);
93 else
94 return 1;
95}
double potencia2(double x, int n)
Definition Ejemplo029.c:97
long int factorial2(int n)
Definition Ejemplo029.c:105
double exp4(double x, int n)
Definition Ejemplo029.c:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exp5()

double exp5 ( double x,
int n )

Definition at line 42 of file Ejemplo029.c.

43{
44 if(n)
45 return exp5(x, n-1)+fct(x, n);
46 else
47 return 1;
48}
double exp5(double x, int n)
Definition Ejemplo029.c:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ factorial()

long int factorial ( int n)

Definition at line 80 of file Ejemplo029.c.

81{
82 int i;
83 long int fn;
84 for(i=0, fn=1; i<n; i++)
85 fn *= (i+1);
86 return fn;
87}
Here is the caller graph for this function:

◆ factorial2()

long int factorial2 ( int n)

Definition at line 105 of file Ejemplo029.c.

106{
107 if(n>0)
108 return factorial2(n-1)*n;
109 else
110 return 1;
111}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fct()

double fct ( double x,
int n )

Definition at line 34 of file Ejemplo029.c.

35{
36 if(n!=1)
37 return fct(x, n-1)*(x/n);
38 else
39 return x;
40}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 13 of file Ejemplo029.c.

14{
15 double x, ex, ex2, ex3, ex4;
16 int n;
17 printf("Ingrese el valor de x: ");
18 scanf("%lf", &x);
19 do{
20 printf("Ingrese le numero de terminos: ");
21 scanf("%d", &n);
22 }while(n<1);
23 ex = exp1(x, n);
24 ex2 = exp3(x, n);
25 ex3 = exp4(x, n);
26 ex4 = exp5(x, n);
27 printf("exp(%lf) = %lf\n", x, ex);
28 printf("exp(%lf) = %lf\n", x, ex2);
29 printf("exp(%lf) = %lf\n", x, ex3);
30 printf("exp(%lf) = %lf\n", x, ex4);
31 return 0;
32}
double exp3(double x, int n)
Definition Ejemplo029.c:50
double exp1(double x, int n)
Definition Ejemplo029.c:62
Here is the call graph for this function:

◆ potencia()

double potencia ( double x,
int n )

Definition at line 71 of file Ejemplo029.c.

72{
73 int i;
74 double xn;
75 for(i=0, xn=1; i<n; i++)
76 xn *= x;
77 return xn;
78}
Here is the caller graph for this function:

◆ potencia2()

double potencia2 ( double x,
int n )

Definition at line 97 of file Ejemplo029.c.

98{
99 if(n>0)
100 return potencia2(x, n-1)*x;
101 else
102 return 1;
103}
Here is the call graph for this function:
Here is the caller graph for this function: