(2018) 2018 7 5
f(x) [ 1, 1] 3 3 1 3 f(x) dx c i f(x i ) 1 0 i=1 = 5 ) ( ) 3 ( 9 f + 8 5 9 f(0) + 5 3 9 f 5 1 1 + sin(x) θ ( 1 θ dx = tan 1 + sin x 2 π ) + 1 4
1 3 [a, b] f a, b double G3(double (*f)(), double a, double b) 2 tfunc double tfunc(double x) 3 θ 50 1Y17B123 θ = 246 $ /hw2018-2 q = 2460, I1 = 1475, I2 = 1476
[a, b] [ 1, 1] [ ] ux + v = ξ u = 2/(b a), v = (b + a)/(b a) b f(x) dx = 1 1 ( ) ξ v f dξ u u a 1
double G3(double (*f)(), double a, double b) { double x[] = {-sqrt(06), 0, sqrt(06), c[] = {50/9, 80/9, 50/9, u = 2/(b - a), v = (b + a)/(a - b), s = 0; int i; for (i = 0; i < 3; i++) s += c[i]*f((x[i] - v)/u); return s / u; double tfunc(double x) { return 1/(1+sin(x)); int main(int argc, char **argv) { double q = 246; printf("q = %3f, I1 = %3f, I2 = %3f\n", q, G3(tfunc, 0, q), tan(q/2 - M_PI/4) + 1); return 0;
double G3(double (*f)(), double a, double b) { double x[] = {-sqrt(06), 0, sqrt(06), c[] = {50/9, 80/9, 50/9, u = 2/(b - a), v = (b + a)/(a - b), s = 0; int i; for (i = 0; i < 3; i++) s += c[i]*f((x[i] - v)/u); return s / u; f cos double tfunc(double x) { return 1/(1+sin(x)); int main(int argc, char **argv) { double q = 246; printf("q = %3f, I1 = %3f, I2 = %3f\n", q, G3(tfunc, 0, q), tan(q/2 - M_PI/4) + 1); return 0;
double G3(double (*f)(), double a, double b) { double x[] = {-sqrt(06), 0, sqrt(06), c[] = {50/9, 80/9, 50/9, u = 2/(b - a), v = (b + a)/(a - b), s = 0; int i; for (i = 0; i < 3; i++) s += c[i]*f((x[i] - v)/u); return s / u; f cos double tfunc(double x) { return 1/(1+sin(x)); int main(int argc, char **argv) { double q = 246; printf("q = %3f, I1 = %3f, I2 = %3f\n", q, G3(tfunc, 0, q), tan(q/2 - M_PI/4) + 1); return 0; tfunc 0, q
int main(int argc, char **argv){ double foo = 10; int num = 10; if (argc > 1) if (argc > 2) foo = atof(argv[1]); num = atoi(argv[2]); printf("ac = %d, foo = %f, num = %d\n", argc, foo, num); return 0;
int main(int argc, char **argv){ double foo = 10; int num = 10; if (argc > 1) if (argc > 2) foo = atof(argv[1]); num = atoi(argv[2]); printf("ac = %d, foo = %f, num = %d\n", argc, foo, num); return 0;
int main(int argc, char **argv){ *argv[ ] double foo = 10; int num = 10; argv 1 if (argc > 1) foo = atof(argv[1]); if (argc > 2) num = atoi(argv[2]); printf("ac = %d, foo = %f, num = %d\n", argc, foo, num); return 0;
int main(int argc, char **argv){ *argv[ ] double foo = 10; int num = 10; argv 1 if (argc > 1) foo = atof(argv[1]); if (argc > 2) num = atoi(argv[2]); printf("ac = %d, foo = %f, num = %d\n", argc, foo, num); return 0; $ /execname 1290 1000
int main(int argc, char **argv){ *argv[ ] double foo = 10; int num = 10; argv 1 if (argc > 1) foo = atof(argv[1]); if (argc > 2) num = atoi(argv[2]); printf("ac = %d, foo = %f, num = %d\n", argc, foo, num); return 0; $ /execname 1290 1000 argv[0] argv[1] argv[2]
char *fname[] = {"cos", "sinh", "exp"; double (*fa[])() = { cos, sinh, exp ; double (*Ifa[])() = { sin, cosh, exp ; fname[i] fa[i],ifa[i]
1 f cos, sinh, exp 2,3 a, b b a f(x) dx f = cos, a = 0, b = 1
2 b 50 [matuda@yuuko Slides]$ /ex2018-2 Int( cos, 0000, 1000) = 0841, 0841 $ /ex2018-2 cos 0 264 Int( cos, 0000, 2640) = 0481, 0481 $ /ex2018-2 sinh 0 264 Int(sinh, 0000, 2640) = 6041, 6042 $ /ex2018-2 exp 1 264 Int( exp, 1000, 2640) = 11295, 11295
wasedajp wasedaacjp matuda-namio@aoniwasedajp 1y13b999 2 7 5 10:30