170 likes | 306 Views
S kaitliskā integrēšana. y. f(x ). a. b. x. Kreisu taisnstūru metode. = *. Labēju taisnstūru metode. Vidēju taisnstūru metode. = *. Trapeču metode. = *. Simpsona metode. = *. Kreisu taisnstūru metodes realizācija Delphi vidē. function pram_lev(x:vector):Real ; begin
E N D
y f(x) a b x
Kreisu taisnstūru metodes realizācija Delphi vidē functionpram_lev(x:vector):Real; begin Result := 0; for i := 0 to n-1 do Result:= Result + (x[i+1]-x[i])*ffx(x[i]); end;
Kreisu taisnstūru metodes realizācija Delphi vidē function pram_lev_1(a,b:Real;n:integer):Real; var rrr:Real; begin rrr := 0; h:= (b-a)/n; z := a - h; while z <= b - h do begin z := z + h; rrr := rrr + h*ffx(z); end; pram_lev_1 := rrr; end;
Labēju taisnstūru metodes realizācija Delphi vidē functionpram_prav(x:vector):Real; begin Result := 0; fori := 1 to n do Result := Result + (x[i]-x[i-1])*ffx(x[i]); end;
Vidēju taisnstūru metodes realizācija Delphi vidē functionpram_sred(x:vector):Real; begin Result := 0; fori := 0 to n-1 do Result := Result + (x[i+1]-x[i])*ffx((x[i+1]+x[i])/2); end;
Trapeču metodes realizācija Delphi vidē functiontrapec (x:vector):Real; begin Result := 0; for i := 0 to n-1 do Result := Result + (x[i+1]-x[i])*(ffx(x[i+1])+ffx(x[i]))/2; end;
Simpsona metodes realizācija Delphi vidē function simpson1(a,b:Real;n:integer):real; begin Result := 0; h:=(b-a)/n; for i := 1 to n-1 do begin if i mod 2 = 0 thenResult := Result + 2*ffx(x[i]) elseResult := Result + 4*ffx(x[i]) end; Result := h*(Result + ffx(a) + ffx(b))/3; end;
Skaitliskā integrēšana Matlab vidē function y = fx(x) y = x.*x.*sin(x)/10; i1=quad(@fx,4,9) i1=quad(‘fx’,4,9) i1 = 7.6301
Skaitliskā integrēšana Matlab vidē n = 500; i = 0:n; a = 4; b = 9; h = (b-a)/n; x = a+h*i; y = fx(x); z = trapz(x,y) z = 7.6300
Skaitliskā integrēšana Matlab vidē x = 4:0.0001:9; y = x.*x.*sin(x)/10; z = trapz(x,y) z = 7.6300 x = 4:0.0001:9; y = fx(x); z = trapz(x,y)