![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Регистрация: 11.04.2011
Сообщений: 1
|
![]()
Есть код программы на паскале. Как задать функцию f:=x; после процедуры? Простой переносом не получается. В книгах не нашел.
P.S. хочу использовать процедуру в методе Галеркина, поэтому возник вопрос. program SimpsDoubleProsch; uses crt; type funct = function (x:real):real; var a,z,e,i,g,b :real; function f(x:real):real;far; begin f:=x; end; procedure Simps(f:funct; a,z,e:real; var I:real); var x,h,f1,f2,f3,f4,f5,i1,i2:real; num:word; begin i:=0; x:=a; h:=(z-a)/2000; { pervyi raschet shaga} {proschet koeff po metodu simpsona} f1:=f(x); f2:=f(x+h/2); f3:=f(x+h); f4:=f(x+h/4); f5:=f(x+3*h/4); writeln(' x h di i i2'); num:=0; while (x<=z) do begin {proverka na shodimost} if num>200 then begin writeln('Oshibka shodimosti'); break; end; inc(num); i1:=h/6*(f1+4*f2+f3); {raschet integrala s shagom} i2:=h/12*(f1+4*f4+2*f2+4*f5+f3);{raschet integrala s dvoinim shagom} if abs(i1-i2)/h*2<=e then begin i:=i+i2; writeln(x:10:4,' | ',h:10:4,' | ',i2:10:4,' | ',i:10:4,' | ',i1:10:4, #13#10); x:=x+h; h:=h*2; if x+h>=z then h:=z-x; {esli x+shag vishodit za verhni predel,to perechitat shag} if h=0 then break; f1 := f(x); f2 := f(x+h/2); f3 := f(x+h); f4 := f(x+h/4); f5 := f(x+3*h/4); end else if abs(i1-i2)/h<=e then begin i:=i+i2; writeln(x:10:4,' ',h:10:4,' ',i2:10:4,' ',i:10:4); x:=x+h; if x+h>=z then h:=z-x; if h=0 then break; f1 := f(x); f2 := f(x+h/2); f3 := f(x+h); f4 := f(x+h/4); f5 := f(x+3*h/4); end else begin h:=h/2; {shag umenshaem v 2} f1 := f(x); f2 := f(x+h/2); f3 := f(x+h); f4 := f(x+h/4); f5 := f(x+3*h/4); end; end; end; begin clrscr; writeln('Vvedite nigni i verhni predeli integrirovania'); readln(a,z); e:=0.001; {nachalnaya tochnost} simps(f,a,z,e,i); writeln(' I =',i:10:4); readln; end. |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Метод Симпсона С++ | sabaton | Помощь студентам | 2 | 03.04.2011 01:08 |
Численное интегрирование(метод Симпсона) | (=Hello=) | Помощь студентам | 1 | 18.03.2011 23:05 |
Turbo Pascal[програмыки : текстовая\метод симпсона\метод половинного деления | qsccsq | Помощь студентам | 7 | 24.12.2010 05:23 |
Метод Симпсона(си) | towelie | Помощь студентам | 0 | 23.12.2010 19:36 |
метод симпсона | 13xXx13 | Помощь студентам | 1 | 16.12.2010 09:57 |