Результати розрахунків за допомогою системи Math Cad. 


Мы поможем в написании ваших работ!



ЗНАЕТЕ ЛИ ВЫ?

Результати розрахунків за допомогою системи Math Cad.



Головна функція, її розбиття та графік.

Графіки функцій k(x) та g(x), точки перетину та результати функції root().

Обчислення інтегралу, графік функції та площа інтегралу.

 

Розрахункова частина за допомогою табличного процесору Excel.

Відокремлення коренів графічним методом.

Уточнення коренів методом половинного ділення із точністю 0.00001.

 

 

Чисельне інтегрування.

Розрахунок за методом середніх прямокутників.

Розрахунок за методом трапецій.

Результати алгоритмічної частини.

Лістинг програми 1.

uses crt;

var h,s,a,x,b,e,suma:real;

i,n:integer;

function fun(var x:real):real;

begin

fun:=x/exp(1/2*ln(2+cos(pi*2)));

end;

begin

clrscr;

a:=0;

b:=1.1;

write('n=');

readln(n);

e:=0.0000001;

suma:=0;

repeat

s:=suma;

suma:=0;

h:=(b-a)/n;

x:=a+h/2;

for i:=1 to n do

begin

suma:=suma+h*fun(x);

x:=x+h;

end;

writeln('suma=',suma:14:12, ' n=', n:2, ' pogreshnost=', abs(s-suma):14:12);

n:=n*2;

until e>=abs(s-suma);

writeln('suma=',suma:14:12, ' pogreshnost=', abs(s-suma):14:12, '<', e:10:7);

readkey;

end.

Результат виконання.

 

 

Лістинг програми 2.

uses crt;

var h,s,sk,a,x,b,e:real;

i,n:longint;

begin

clrscr;

a:=0;

b:=1.1;

write('vvedit n=');

readln(n);

e:=0.0000001;

sk:=0;

repeat

s:=sk;

sk:=0;

h:=(b-a)/n;

x:=a;

for i:=1 to n do

begin

sk:=sk+(ln(1+h)/ln(1+h))*h/2;

x:=x+h;

end;

writeln('suma=',sk:16:12, ' n=', n:2, ' pogreshnost=', abs(s-sk):14:12);

n:=n*2;

until e>=abs(s-sk);

writeln('s=',sk:16:12, ' pogreshnost=', abs(s-sk):14:12, '<', e:14:12);

readkey;

end.

 

Результат виконання.

 

Лістинг програми 3.

PROGRAM kyr;

 

USES

CRT, Graph,VGL_Small;

TYPE

BaseType = real;

Point = Record

x, y: BaseType

end;

Index = 1..65520 div SizeOf (Point);

PArrayPoint = ^ArrayPoint;

ArrayPoint = array [Index] of Point;

Clip = record

Xmin:Integer;

Ymin:Integer;

Xmax:Integer;

Ymax:integer;

end;

VAR

nxmin, nxmax, nymin, nymax,a: Integer;

ymin, ymax,xmin,xmax, pixx, pixy, tmin, tmax: real;

ArrP,ArrTemp: PArrayPoint;

ColPoint: Integer;

gd,gm:integer;

P:Clip;

FUNCTION F1 (x: real): real;

Begin

F1:= x*cos(x);

End;

 

FUNCTION F2 (t: real): real;

Begin

F2:= 2*arctan(t);

End;

 

FUNCTION F3 (t: real): real;

Begin

F3:= 2*a*sqr(sin(t));

End;

Function Gx(x:real):real;

begin

Gx:=x+(nxmax-nxmin) div 2+nxmin;

end;

Function Gy(y:real):real;

Var Xasp,Yasp:word;

begin

GetAspectRatio(Xasp, Yasp);

Gy:=(nymax-nymin) div 2 -(Xasp/Yasp)*y + nymin;

end;

Procedure LineClip(x1,y1,x2,y2:Integer);

Const

CodeBottom = 1;

CodeTop = 2;

CodeLeft = 4;

CodeRight = 8;

PROCEDURE Razm (var m, n, cp: Integer; pix: real);

Begin

m:= 1;

n:= 0;

If Round (m * Exp(n*Ln(10)) / pix) < 30 then

While Round (m * Exp(n*Ln(10)) / pix) < 30 do

begin

Case m of

1: m:= 2;

2: m:= 5;

5: begin

m:= 1;

Inc (n)

end

end

end

Else

begin

While Round (m * Exp(n*Ln(10)) / pix) > 30 do

begin

Case m of

1: begin

m:= 5;

Dec (n)

end;

2: m:= 1;

5: m:= 2;

end

end;

Case m of

1: m:= 2;

2: m:= 5;

5: begin

m:= 1;

Inc (n)

end

end

end;

cp:= Round (m * Exp(n*Ln(10)) / pix)

End;

 

PROCEDURE Out_CoordAxle;

Var

x, y, m, n, cp, ost, y1, x1, ch, i: Integer;

mn: real;

f: Boolean;

Begin

SetColor (GREEN);

f:= true;

if ymin >= 0 then y:= nymax

else

if ymax <= 0 then

begin

y:= nymin;

f:= false;

end

else y:= nymax + Round (ymin/pixy);

Line (nxmin, y, nxmax, y);

Line (nxmax, y, nxmax-10, y+3);

Line (nxmax, y, nxmax-10, y-3);

if xmin >= 0 then x:= nxmin

else if xmax <= 0 then x:= nxmax

else x:= nxmin - Round (xmin/pixx);

Line (x, nymin, x, nymax);

if f

then

begin

Line (x, nymin, x-3, nymin+10);

Line (x, nymin, x+3, nymin+10);

end;

Razm (m, n, cp, pixx);

ost:= abs (nxmin - x) mod cp;

ch:= m * ((nxmin - x) div cp);

SetTextJustify (centertext, toptext);

if (nxmin - x) > 0 then

begin

ost:= cp - ost;

Inc (ch, m)

end;

x1:= ost + nxmin;

While x1 <= nxmax - 10 do

begin

Line (x1, y-3, x1, y+3);

if ch <> 0 then OutTextXY (x1, y+10, MakeStr (ch))

else OutTextXY (x1 - 5, y+10, MakeStr (ch));

Inc (x1, cp);

Inc (ch, m)

end;

if xmin > 0 then

begin

mn:= 1;

for i:= 1 to Abs (n) do

begin

if n < 0 then mn:= mn * 10

else mn:= mn / 10

end;

OutTextXY (nxmax-20, y+20, '(x+'+MakeStrR(xmin*mn, 2, 0)+')*10^'+MakeStr(n))

end

else OutTextXY (nxmax, y+20, 'x*10^'+MakeStr(n));

Razm (m, n, cp, pixy);

ost:= abs (-nymax + y) mod cp;

ch:= m * ((-nymax + y) div cp);

if (-nymax + y) > 0 then

begin

ost:= cp - ost;

Inc (ch, m)

end;

y1:= nymax - ost;

While y1 >= nymin+10 do

begin

Line (x-3, y1, x+3, y1);

if ch <> 0 then OutTextXY (x-17, y1-3, MakeStr (ch));

Dec (y1, cp);

Inc (ch, m);

end;

if ymin > 0 then OutTextXY (x, nymin-10, '(y+'+MakeStr(round(xmin))+')*10^'+MakeStr(n))

else OutTextXY (x, nymin-10, 'y*10^'+MakeStr(n));

SetColor (White)

End;

 

var ch,ch1:char;

k,h,d,t1,t2:real;

i,j:integer;

BEGIN

ch:=#0;

gd:=detect;

{ gm:=VgaHi;}

initGraph(gd,gm,'c:\bp\bgi');

SetColor(Yellow);

InitVgl;

repeat

ClearDevice;

nxmin:= 50;

nxmax:= 590;

nymin:= 50;

nymax:= 430;

SetTextJustify (LeftText, TopText);

SetColor(Yellow);

OutTextXY(0,0,'1: Function given Obviously');

OutTextXY(0,20,'2: Function given in parameter');

OutTextXY(0,40,'3: Transformation of the diagrams');

OutTextXY(0,60,'Esc: Exit');

Ch:=readkey;

case ch of

'1': begin

ClearDevice;

SetColor(Yellow);

Rectangle(nxmin-40, nymin-40, nxmax+40, nymax+40);

xmin:= -pi;

xmax:= 2*pi;

MinMax1;

SetColor (Red);

Out_Wind;

Out_CoordAxle;

FreeMem (ArrP, Round ((nxmax-nxmin)) * Sizeof (Point));

OutTextXY(320,460,'Press any key');

ch:=readkey;

ClearDevice;

ch:=#0;

end;

'2': begin

ClearDevice;

SetColor(Yellow);

Rectangle(nxmin-40, nymin-40, nxmax+40, nymax+40);

tmin:= 0.01;

tmax:= 10;

a:=1;

MinMax2;

SetColor (Red);

Out_Wind;

Out_CoordAxle;

FreeMem (ArrP, Round((nxmax-nxmin)) * Sizeof (Point));

OutTextXY(320,460,'Press any key');

ch:=readkey;

ClearDevice;

ch:=#0;

end;

'3': begin

repeat

nxmin:= 50;

nxmax:= 450;

nymin:= 50;

nymax:= 430;

P.xmin:= 50;

P.xmax:= 450;

P.ymin:= 50;

P.ymax:= 430;

ClearDevice;

Rectangle(nxmin-40, nymin-40, nxmax+40, nymax+40);

xmin:= -10;

xmax:= 10;

MinMax1;

SetColor (Red);

Out_Wind;

Out_CoordAxle;

SetTextJustify (LeftText, TopText);

SetColor(Yellow);

OutTextXY(500,0,'1: y=kx(x+h)+d');

OutTextXY(500,20,'2: y=F(|x|)');

OutTextXY(500,40,'3: y=|F(x)|');

OutTextXY(500,60,'4: y=|F(|x|)|');

ch1:=readkey;

case ch1 of

'1':begin

OutTextXy(500,100,'k=');

GotoXY(66,7);Read(k);

SetFillStyle(0,0);

Bar(500,90,600,110);

OutTextXy(500,100,'h=');

GotoXY(66,7);Read(h);

Bar(500,90,600,110);

OutTextXy(500,100,'d=');

GotoXY(66,7);Read(d);

Bar(500,90,600,110);

vgl_pushmatrix;

vgl_scale(1,k);

vgl_translated(d,h);

for i:=1 to (nxmax - nxmin) do

begin

arrp^[i].x:=XG(arrp^[i].x);arrp^[i].y:=YG(arrp^[i].y);

Vgl_GetPoint(arrp^[i].x,arrp^[i].y);

arrp^[i].x:=GX(arrp^[i].x);arrp^[i].y:=GY(arrp^[i].y);

end;

vgl_popmatrix;

setcolor(green);

Out_Wind1;

ch1:=readkey;

end;

'2':begin

vgl_pushmatrix;

vgl_reflectionY;

j:=0;

for i:=(nxmax-nxmin) downto (nxmax-nxmin) div 2 do

begin

t1:=XG(arrp^[i].x);t2:=YG(arrp^[i].y);

vgl_getPoint(t1,t2);

t1:=Gx(t1);t2:=Gy(t2);

arrp^[j+1].x:=t1;

arrp^[j+1].y:=t2;

j:=j+1;

end;

vgl_popmatrix;

setcolor(green);

Out_Wind;

ch1:=readkey;

end;

'3':begin

vgl_pushmatrix;

vgl_reflectionX;

for i:=1 to (nxmax - nxmin) do

begin

arrp^[i].x:=XG(arrp^[i].x);arrp^[i].y:=YG(arrp^[i].y);

if arrp^[i].y<0 then VGL_GetPoint(arrp^[i].x,arrp^[i].y);

arrp^[i].x:=GX(arrp^[i].x);arrp^[i].y:=GY(arrp^[i].y);

end;

vgl_popmatrix;

setcolor(green);

Out_Wind;

ch1:=readkey;

end;

'4':begin

vgl_pushmatrix;

vgl_reflectionY;

j:=0;

for i:=(nxmax-nxmin) downto (nxmax-nxmin) div 2 do

begin

t1:=XG(arrp^[i].x);t2:=YG(arrp^[i].y);

vgl_getPoint(t1,t2);

t1:=Gx(t1);t2:=Gy(t2);

arrp^[j+1].x:=t1;

arrp^[j+1].y:=t2;

j:=j+1;

end;

vgl_popmatrix;

vgl_pushmatrix;

vgl_reflectionX;

for i:=1 to (nxmax - nxmin) do

begin

arrp^[i].x:=XG(arrp^[i].x);arrp^[i].y:=YG(arrp^[i].y);

if arrp^[i].y<0 then VGL_GetPoint(arrp^[i].x,arrp^[i].y);

arrp^[i].x:=GX(arrp^[i].x);arrp^[i].y:=GY(arrp^[i].y);

end;

vgl_popmatrix;

setcolor(green);

Out_Wind;

ch1:=readkey;

end;

end;

FreeMem (ArrP, Round ((nxmax-nxmin)) * Sizeof (Point));

until ch1=#27;

end;

end;

Until ch=#27;

CloseGraph;

 

END.

 

Результат виконання.



Поделиться:


Последнее изменение этой страницы: 2016-07-15; просмотров: 266; Нарушение авторского права страницы; Мы поможем в написании вашей работы!

infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 18.188.61.223 (0.037 с.)