Question #1: #include #include #include #include #include using std::setprecision; //sub function to calculate f double f (double x, void * params) { double f = ((exp(x)-exp(-x))/(exp(x)+exp(-x)))*pow(x,x); return f; } int main (void) { gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000); double result, error; double alpha = 1.0; gsl_function F; F.function = &f; F.params = α gsl_integration_qags (&F, 2, 3, 0, 1e-8, 1000, w, &result, &error); std::cout<size< set xrange [2:3] gnuplot> plot ((exp(x)-exp(-x))/(exp(x)+exp(-x)))*x**x gnuplot> set terminal postscript eps enhanced gnuplot> set output "myplot.eps" gnuplot> replot Question #3: #include #include #include int main (void) { const gsl_rng_type * T; gsl_rng * r; int i, n = 10; /* create a generator chosen by the environment variable GSL_RNG_TYPE */ T = gsl_rng_default; r = gsl_rng_alloc (T); unsigned long int s = time(0); gsl_rng_set(r, s); /* print n random variates chosen from the poisson distribution with mean parameter mu */ for (i = 0; i < n; i++) { double k = gsl_rng_uniform (r); double j = 25+12*k; std::cout< #include #include #include int main (void) { const gsl_rng_type * T; gsl_rng * r; int i, j, n = 10000, drunks=100; double a=0,b=2, direction[n], distance=0,abs=0, Average=0; T = gsl_rng_default; r = gsl_rng_alloc (T); srand((time(0))); long int seed = random(); gsl_rng_env_setup(); gsl_rng_set(r,seed); for( i=0; i < drunks; i++){ for (j = 0; j < n; j++) { unsigned int k = gsl_ran_flat (r, a, b); if(k==0){ direction[i] =-1; } else direction[i] = 1; distance+=direction[i]; } abs=fabs(distance); Average+=abs; } Average /= drunks; std::cout << " the average distance D a drunk is from his/her starting position at the end of the journey of 10, 000 steps is: \t" << Average << "l"< #include #include #include #include using std::setprecision; double f (double x, void * params) { double f = 1/sqrt(3.14159)*exp(-pow(x,2))*pow(x,2); return f; } int main (void) { gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000); double result, error, total; double alpha = 1.0; gsl_function F; F.function = &f; F.params = α gsl_integration_qags (&F, 0.995, 1.005, 0, 1e-8, 1000, w, &result, &error); gsl_integration_qags (&F, 0, 100, 0, 1e-8, 1000, w, &total, &error); std::cout<