/* 習題 ex2-2.c is used for finding out the domains
* which exist the roots of f(x).
*/
#include <stdio.h>
#include <math.h>
#define f(x) (exp(x)-3*pow(x,2))
void main()
{
double a=-1.0,b=5.5,x;
int i;
x=a;
printf(" i x f(x)\n");
for(i=1;;i++)
{
printf("%2d %5.2lf %10.5lf\n",i,x,f(x));
if(x > b)
exit(0);
x=x+0.1;
//x=x+0.5;
}
}
i x(i) f(x)
1 -1.00 -2.63212 | |
2 -0.90 -2.02343 | |
3 -0.80 -1.47067 | |
4 -0.70 -0.97341 | |
5 -0.60 -0.53119 | |
6 -0.50 -0.14347 | 1 |
7 -0.40 0.19032 | |
8 -0.30 0.47082 | |
9 -0.20 0.69873 | |
10 -0.10 0.87484 | |
11 -0.00 1.00000 | |
12 0.10 1.07517 | |
13 0.20 1.10140 | |
14 0.30 1.07986 | |
15 0.40 1.01182 | |
16 0.50 0.89872 | |
17 0.60 0.74212 | |
18 0.70 0.54375 | |
19 0.80 0.30554 | |
20 0.90 0.02960 | 2 |
21 1.00 -0.28172 | |
22 1.10 -0.62583 | |
23 1.20 -0.99988 | |
24 1.30 -1.40070 | |
25 1.40 -1.82480 | |
26 1.50 -2.26831 | |
27 1.60 -2.72697 | |
28 1.70 -3.19605 | |
29 1.80 -3.67035 | |
30 1.90 -4.14411 | |
31 2.00 -4.61094 | |
32 2.10 -5.06383 | |
33 2.20 -5.49499 | |
34 2.30 -5.89582 | |
35 2.40 -6.25682 | |
36 2.50 -6.56751 | |
37 2.60 -6.81626 | |
38 2.70 -6.99027 | |
39 2.80 -7.07535 | |
40 2.90 -7.05585 | |
41 3.00 -6.91446 | |
42 3.10 -6.63205 | |
43 3.20 -6.18747 | |
44 3.30 -5.55736 | |
45 3.40 -4.71590 | |
46 3.50 -3.63455 | |
47 3.60 -2.28177 | |
48 3.70 -0.62270 | 3 |
49 3.80 1.38118 | |
50 3.90 3.77245 | |
51 4.00 6.59815 | |
52 4.10 9.91029 | |
53 4.20 13.76633 | |
54 4.30 18.22979 | |
55 4.40 23.37087 | |
56 4.50 29.26713 | |
57 4.60 36.00432 | |
58 4.70 43.67717 | |
59 4.80 52.39042 | |
60 4.90 62.25978 | |
61 5.00 73.41316 | |
62 5.10 85.99191 | |
63 5.20 100.15224 | |
64 5.30 116.06681 | |
65 5.40 133.92642 | |
66 5.50 153.94193 | |
67 5.60 176.34641 |
x=x+0.1; ---> x=x+0.5
i x f(x)
1 -1.00 -2.63212
2 -0.50 -0.14347 1
3 0.00 1.00000
4 0.50 0.89872 2
5 1.00 -0.28172
6 1.50 -2.26831
7 2.00 -4.61094
8 2.50 -6.56751
9 3.00 -6.91446
10 3.50 -3.63455 3
11 4.00 6.59815
12 4.50 29.26713
13 5.00 73.41316
14 5.50 153.94193
15 6.00 295.42879
沒有留言:
張貼留言