Лаба1.1

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
program lab1;
var
x: real;
n: integer;
Function Comp_N (x,eps:real; n:integer): boolean;
Var
prov: boolean;
comp: real;
one_s: real;
step: real;
Begin
prov := true;
{
WriteLN ('n ',n);
If (n mod 2 = 0)
then one_s := 1
else one_s := -1;
If (x<1)
then x := -x;
n := n + 1;
step := exp(n*ln(x-1));
comp := (one_s*step)/n;
If (comp>eps)
then prov := false;
WriteLN ('one_s ',one_s);
WriteLN ('step ',step);
WriteLN ('comp ',comp);
WriteLN ('n ',n);
}
If (n mod 2 = 0)
then one_s := 1
else one_s := -1;
n := n + 1;
step := Power((x-1),n);
comp := (one_s*step)/n;
comp := Abs(comp);
If (comp>eps)
then prov := false;
//WriteLN ('one_s ',one_s);
//WriteLN ('step ',step);
//WriteLN ('comp ',comp);
//WriteLN ('n ',n);
Comp_N := prov;
End;
Function Summ_ln (x:real; n:integer): real;
var
summ,one_s,step:real;
Begin
If (n mod 2 = 0)
then one_s := 1
else one_s := -1;
n := n + 1;
step := Power((x-1),n);
summ := (one_s*step)/n;
Summ_ln := summ;
End;
Function my_ln(x:real): real;
Var
eps,lnx:real;
n: integer;
Begin
WriteLN ('Vvedite Epsilon');
Read (eps);
n := 0;
lnx :=0;
While Comp_N(x,eps,n) do
begin
lnx := lnx + Summ_ln(x,n);
n := n+1;
WriteLN ('lnx = ',lnx);
end;
WriteLN ('lnx = ',lnx);
End;
BEGIN
WriteLN ('Vvedite X');
Read (x);
If ((x>0) and (x<=2))
then
Begin
WriteLN('X vvedeno verno');
my_ln(x);
End
else WriteLN('X vvedeno ne verno');
{
WriteLN ('Vvedite Epsilon');
Read (eps);
//WriteLN ('Otv',Comp_N(x,eps,0));
n := 0;
lnx :=0;
While (Comp_N(x,eps,n) = true) do
Begin
lnx := lnx + Summ_ln(x,n);
n := n+1;
WriteLN ('lnx = ',lnx);
End;
}
END.