//------------------- // Solve a linear BVP // // -x''(t)-(1+t^2)x(t)=1, -1 #include #include #include #include //---------------------------------------------------------- int i; // Timeinterval [-L, L], L=1; double L = 1.0; // Amount of points on [-L, L] double M = 200.0; double h=0.01; double fun_q(int i){ double t = -L + i * h; return -(1.0+pow(t,2)); } //------------------------------------------------------------- main () { // Calculate the step size double h=(2.0*L)/M; // define the system A*y=b, where A is tridiagonal gsl_vector * x = gsl_vector_alloc (M+1); // allocate vector x gsl_vector * y = gsl_vector_alloc (M-1); // allocate vector x gsl_vector * b = gsl_vector_alloc (M-1); // allocate vector b gsl_vector * d = gsl_vector_alloc (M-1); // main diagonal of the matrix A gsl_vector * d1 = gsl_vector_alloc (M-2); // off-diagonal vector of the matrix A gsl_vector_set (x, 0, 2.0); // boundary condition on the left gsl_vector_set (x, M, 1.0); // boundary condition on the right /*for(i=0; i