Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdbool.h>
- #include <math.h>
- const double IZP_E = 2.7182818284590452354;
- double absol(double x, double y){
- return(x-y<0)?y-x: x-y;
- }
- int main()
- {
- double vstup=0;
- double sigdig=0.0001;
- double s=1;
- double pom=0,lnx=0;
- printf("Zadejte x pro lnx:");
- scanf("%lf",&vstup);
- while(vstup<-1 || vstup>1){
- vstup=vstup/IZP_E;
- pom++;
- }
- double starylnx=0;
- double dalsilnx=0;
- do{
- starylnx=dalsilnx;
- dalsilnx=(((pow(-1,s+1))*(pow((vstup-1),s)))/s);
- lnx=lnx+dalsilnx;
- s++;
- }while((fabs(starylnx+dalsilnx))>=sigdig);
- lnx=lnx+pom;
- printf("%.10e\n", lnx);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement