Ejercicio 2 Analisis.docx

  • Uploaded by: ValeriaAguirreCastro
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ejercicio 2 Analisis.docx as PDF for free.

More details

  • Words: 236
  • Pages: 2
EJERCICIO 2 unit Programa; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls, Math; type TForm3 = class(TForm) label1: TLabel; Label2: TLabel; Label3: TLabel; areaTexto: TMemo; tablaResultado: TStringGrid; cajaH: TEdit; cajaIteraciones: TEdit; Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form3: TForm3; implementation {$R *.dfm} procedure TForm3.FormCreate(Sender: TObject); begin TablaResultado.Cells[0,0] := 'Item'; TablaResultado.Cells[1,0] := 'Descripcion'; TablaResultado.Cells[2,0] := 'h = 0.0'; TablaResultado.Cells[0,1] := '1'; TablaResultado.Cells[0,2] := '2'; TablaResultado.Cells[0,3] := '3'; TablaResultado.Cells[0,4] := '4'; TablaResultado.Cells[0,5] := '5'; TablaResultado.Cells[1,2] := 'M. de Euler'; TablaResultado.Cells[1,3] := 'Error actual'; TablaResultado.Cells[1,4] := 'E. de M. Matematico'; TablaResultado.Cells[1,5] := 'Error absoluto.';

areaTexto.Text := ''; end; procedure TForm3.Button1Click(Sender: TObject); VAR y0, yi, deltaY, funcion, h: Double; valorE, errorActual, errorAbs: Double; i, iter: Integer; begin y0 := 1; yi := y0; h := StrToFloat(cajaH.Text); areaTexto.Text := ''; TablaResultado.Cells[2,0] := 'h = ' + cajaH.Text; iter := StrToInt(cajaIteraciones.Text); FOR i := 1 TO iter DO begin funcion := -2*i; IF i = 1 THEN yi := yi + h*funcion ELSE yi := yi*(1 - 2*h); IF i = 1 THEN areaTexto.Lines.Add('['+IntToStr(i)+'] '+FloatToStr(yi)); IF i MOD 1000 = 0 THEN areaTexto.Lines.Add('['+IntToStr(i)+'] '+FloatToStr(yi)); end; deltaY := (h/2)*y0*power(2.71828, -2); valorE := power(2.718281, -2); errorActual := valorE - yi; errorAbs := errorActual - deltaY; TablaResultado.Cells[1,1] := 'e^-2';//FloatToStr(valorE); TablaResultado.Cells[2,1] := FloatToStr(valorE); TablaResultado.Cells[2,2] := FloatToStr(yi); TablaResultado.Cells[2,3] := FloatToStr(errorActual); TablaResultado.Cells[2,4] := FloatToStr(deltaY); TablaResultado.Cells[2,5] := FloatToStr(errorAbs); end; end.

Related Documents

Ejercicio 2
November 2019 17
Ejercicio 2
April 2020 11
Ejercicio 2
August 2019 27
Ejercicio 2
December 2019 23
Ejercicio 2
May 2020 13
Ejercicio 2
April 2020 9

More Documents from ""