https://github.com/n1ghtf1re/lab1
Lab №1. Simple cycles
https://github.com/n1ghtf1re/lab1
Last synced: 6 months ago
JSON representation
Lab №1. Simple cycles
- Host: GitHub
- URL: https://github.com/n1ghtf1re/lab1
- Owner: N1ghtF1re
- Created: 2017-10-09T05:30:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-30T16:07:21.000Z (almost 8 years ago)
- Last Synced: 2025-02-19T05:51:29.998Z (8 months ago)
- Language: Pascal
- Homepage:
- Size: 284 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Lab №1. Simple cycles
--------------------
***
#### Task:
>The program calculates the value of the function from the initial value x **(xn)** to the final value **(xk)** with step **dx**
**Language**: Delphi
**Code:**
``` pascal
program lab1;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows, math;var xn, xk, dx, e, x, y: real;
procedure getY(x: real);
begin
if((x <= 0) or (pi*pi - x*x + 1/x = 0)) then
writeln('For x = ', x:0:4, ' the value of the function is not defined')
else
begin
y:=pi*pi - x*x + 1/x;if(y<0) then
begin
y:=(-1)*Power(abs(y), 1/3);
endelse
begin
y:=Power(y, 1/3);
end;y:= Log10(x)/y;
y:= y + Power(abs(1.5 - x*x), 1/2)*Tan((x-1)/x);
writeln('x = ', x:0:4, '; y = ', y:0:4);
end;
end;begin
repeat
writeln('Enter the initial value of x');
readln(xn);
writeln('Enter the final value of x');
readln(xk);
writeln('Enter a step');
readln(dx);
if ((xn>xk) and (dx >= 0))
or
((xn 0))
or
((xn>=xk) and (dx < 0));e:=dx/1000; // Accuracy of machine
x:=xn;
while(((x < xk + e) and (dx > 0))
or
((x > xk + e) and (dx < 0))) do
begin
getY(x);
x:= x + dx;
end;// Checking whether the value of the function for xk
if(((x - dx + e - xk < 0) and (dx > 0))
or
((xk - (x - dx + e) < 0) and (dx < 0))) then
begin
getY(xk);
end;readln;
end.```