Not n->zero but n-> + infinite
I really know nothing about advanced math, so I wrote a C program to help me:
(BTW, I guess the result would be ln2.)
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- # include <math.h>
- int main()
- {
- double result;
- double n;
- printf("input n, followed by the enter key.\n");
- scanf("%lf", &n);
- result = log(2+sqrt(atan(n)*sin(1/n)));
- printf("The result for number %f is: %f", n, result);
- result = log(2.00);
- printf("The result for ln2 is: %f", result);
- return 0;
- }
bash-3.2$ gcc calculation.c
/tmp/ccyzzqks.o: In function `main':
calculation.c:(.text+0x37): undefined reference to `atan'
calculation.c:(.text+0x49): undefined reference to `sin'
calculation.c:(.text+0x70): undefined reference to `sqrt'
calculation.c:(.text+0x86): undefined reference to `log'
calculation.c:(.text+0xb1): undefined reference to `log'
collect2: ld returned 1 exit status
I googled for the error message and some expert said to use the -lm parameter to compile.
Yeah, this time it worked and I got the results.
But why?
PS. I tried to issue this commands:
bash-3.2$ gcc -lm calculation.c
bash-3.2$ ./a.out
input n, followed by the enter key.
0.0000
The result for number 0.000000 is: nanThe result for ln2 is: 0.693147
input n, followed by the enter key.
0.000001
The result for number 0.000001 is: nanThe result for ln2 is: 0.693147
input n, followed by the enter key.
9999999999999999
The result for number 10000000000000000.000000 is: 0.693147The result for ln2 is: 0.693147
nan = Not a Number ?!
Again, why? (If that is a math question, ignore it plz...)