Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define N 10
- double exponential(double x, int y){
- double number = 1;
- int i;
- for(i = 1; i<=y; i++){
- number *= x;
- }
- return number;
- }
- double expression(double x, int n){
- double num,den;
- num = exponential((x-1)/(x+1), (2*n)-1);
- den = (2*n) - 1;
- return (num/den);
- }
- double sum(double x, int n){
- int i;
- double suma = 0;
- for(i=1; i<=n; i++){
- suma += expression(x,i);
- }
- return 2*suma;
- }
- int main(int argc, char* argv[]){
- double x;
- do{
- printf("Enter x: ");
- scanf("%lf", &x);
- if(x<=0 || x > 6){
- printf("Invalid value!\n");
- }
- }while(x<= 0 || x > 6);
- printf("\nseries ln(%.3lf): %.15lf", x, sum(x,N));
- printf("\nmath ln(%.3lf): %.15lf\n", x, log(x));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement