metoda_punktu_kolokacji.sci
clc clear // d2y/dx2 + 1000x^2 = 0 // y(0) = 0, y(1) = 0, function r = res(a,x) // n1 = x*(1-x); // n2 = x*(1-x^2); // yp = a1*n1 + a2*n2 ddn1 = -2; ddn2 = -6*x; r = a(1)*ddn1 + a(2)*ddn2 + 1000*x.^2; endfunction function r = integr(a) x1 = 1/3; x2 = 2/3; r(1,1) = res(a, x1); r(1,2) = res(a, x2); endfunction a = fsolve([0 0], integr); disp(a) x = linspace(0,1); yp = a(1)*x.*(1-x) + a(2)*x.*(1-x.^2); plot(x,yp,'b') // rozw analit. y = 1000/12*x.*(1-x.^3); plot(x,y,'r')