Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program lab1_5;
- Uses
- System.SysUtils;
- Var
- I: Integer;
- IsCorrect: Boolean;
- PrevSum, Sum , Temp, Diff, X, Eps : Double;
- Begin;
- Writeln('Данная программа позволяет вычислить значение функции y=sin(x) с точностью eps с помощью разложения функции в ряд Маклорена' );
- Writeln('Введите X ');
- Repeat
- IsCorrect := True;
- Try
- Readln(X);
- Except
- Writeln('Введите число! ');
- IsCorrect := False;
- End;
- Until (IsCorrect);
- Writeln('Введите точность');
- Repeat
- IsCorrect := True;
- Try
- Readln(Eps);
- Except
- Writeln('Введите число!');
- IsCorrect := False;
- End;
- Until (IsCorrect);
- Sum := X;
- Temp := -X * X * X / 6;
- Diff := X;
- while Diff > Eps do
- Begin
- PrevSum := Sum;
- Sum := Sum + Temp;
- Diff := abs(Sum - PrevSum);
- Temp := Temp * (-1) * X * X / (I + 3) / (I + 4);
- I := I + 1;
- End;
- Writeln('Значение функции Sin(X) равно : ' , Sum:7:5);
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement