помогите пожалуйста сделать задание... Вычисление значений тригонометрических функций на основе разложения в ряд Маклорена 1. Вычислить с заданной точностью значения тригонометрических функций arctg(x); 2. Построить графики функций arctg(x), где x - ограниченно; 3. Оценить погрешности вычислений;
type TForm1 = class(TForm) Chart1: TChart; Button1: TButton; Series1: TLineSeries; Edit1: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
function _arctan(x: double): double; const eps = 0.0001; var next: double; i: integer; begin result := 0; next := x; i := 1; repeat result := result + next / i; next := - next * sqr(x); inc(i, 2); until abs(next) < eps; end;
procedure TForm1.Button1Click(Sender: TObject); var x, delta: double; n: integer; begin Series1.Clear; x := -0.99; n := 0; while x < 1 do begin Series1.AddXY(x, _arctan(x)); delta := delta + abs(_arctan(x) - ArcTan(x)); x := x + 0.01; inc(n); end; Edit1.Text := 'Average delta = ' + FloatToStr(delta / n); end;
end.
, на Chart-е одна Серия, типа TLineSeries... После нажатия на кнопку получаешь в Чарте график арктангенса, а в Edit-е - среднюю погрешность вычисления. Вот так это выглядит: