You are on page 1of 6

INSTITUTO TECNOLÓGICO DE CHIHUAHUA II

Chihuahua, Chih. Noviembre 2010

DISEÑO DE UN
CIRCUITO
ELECTRICO

Laura Antonia Ortega Chávez

Ing. Sistemas Computacionales


Alfonso Orrantia Vega
07550470
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, math;

type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
biseccion: TButton;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
resultado1: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
GroupBox2: TGroupBox;
Label6: TLabel;
Button1: TButton;
x0: TEdit;
Label7: TLabel;
x1: TEdit;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure biseccionClick(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;

implementation

{$R *.dfm}

Function Potencia(Base:extended; Exponent: integer): extended;


Begin
if Exponent = 0 then
result := 1
else
result := Base * Potencia(Base, Exponent - 1);
End;

function Redondear(Valor: Real; Redondeo: Integer):Real;


begin
Redondear := Trunc(Valor * Power(10, Redondeo)) /
Power(10,Redondeo);
end;

Function f(R: extended): Extended;


var e, raiz, coseno,pot:extended;
Begin
pot:=potencia(R,2);
e:=exp((-0.005*R)) ;
raiz:= sqrt((2000-(0.01*pot)));
coseno:=cos(raiz*0.05);
result :=(e*coseno)-0.01;
End;

Function XR_FP(xl_fp, xu_fp: extended): Extended;


var a,b,c:extended;
Begin
a:= (f(xu_fp)*(xl_fp-xu_fp)) ;
b:= f(xl_fp) -f(xu_fp);
c:= a/b;
result:=xu_fp - c ;
End;

Function X11(xii,xi: extended): Extended;


var a,b,c:extended;
Begin
a:= (f(xii)*(xii-xi)) ;
b:= f(xii) -f(xi);
c:= a/b;
result:=xii - c ;

End;

procedure TForm1.biseccionClick(Sender: TObject);


var
xl,xu,xr,aux,xr_ant,ea: extended;
it:integer;
begin
xl:=strtoint(edit1.text) ;
xu:=strtoint(edit2.text);
xr_ant:=0;
it:=0;

REPEAT
label3.caption:='numero de iteracion ';

xr:=XR_FP(xl,xu);
aux:=f(xl)* f(xu) ;

If aux< 0 then begin


xu:=xr; end
else begin
xl:=xr ; end;

ea:=abs(((xr-xr_ant)/xr)*100);
xr_ant:=xr;
it:=it+1;

UNTIL (ea<0.0001);
resultado1.Caption:='Raíz= '+floattostr(xr);
label4.Caption:='Error: '+ floattostr(ea);
label3.Caption:='Iteración: '+inttostr(it);

end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);


begin
if (key <#48) or (key >#57) then
if key<>#8 then
begin
beep;
showmessage('Solo puedes introducir números');
key:=#0;
edit1.SetFocus;
end;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);


begin
if (key <#48) or (key >#57) then
if key<>#8 then
begin
beep;
showmessage('Solo puedes introducir números');
key:=#0;
edit1.SetFocus;
end;
end;

Function error(a,n:extended): Extended;


var
d,b:double;
Begin
d:=n-a;
b:=d/n;
result:=b*100;
End;
procedure TForm1.Button1Click(Sender: TObject);
var
fi, fii, xi, xii, aux: double;
iter:integer;

begin
xi:= strtofloat(x0.Text);
xii:= strtofloat(x1.Text);
fi:=f(xi);
fii:=f(xii);
aux:=xii;
xii:=x11(xii,xi);
xi:=aux;
iter:=1;
while error(xii,xi)*(-1)>=0.0001 do
begin
aux:=xii;
xii:=x11(xii,xi);
xi:=aux;
iter:=iter+1;
end;
label8.Caption:='Raíz= '+floattostr(xii);
label9.Caption:='Iteración: '+inttostr(iter);
label10.Caption:='Error: ' + floattostr(redondear((error(xii,xi)*(-
1)),9));

end;

end.

You might also like