AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

IntervallSchachtelung

Ein Thema von glkgereon · begonnen am 19. Dez 2004 · letzter Beitrag vom 19. Dez 2004
 
Benutzerbild von glkgereon
glkgereon

Registriert seit: 16. Mär 2004
2.287 Beiträge
 
#1

IntervallSchachtelung

  Alt 19. Dez 2004, 13:47
moin

ich hab (versucht) ein programm zu schreiben welches eine wurzel mit hilfe einer intervallschachtelung berechnet...

aber irgendwie klappt das nicht so richtig...
hat einer von euch da Quelltexte wies geht?

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var Zahl, i:Integer;
    RootMin, RootMax, RealRoot, Genauigkeit, AktGenau, Stelle:Extended;

begin
  ListBox1.Clear;
  Zahl:=JvIntegerEdit1.Value;
  RealRoot:=sqrt(Zahl);
  for i:=0 to Zahl do if sqr(i+1)>zahl then break;
  RootMin:=i;
  ListBox1.Items.Add('Minimum: '+FormatFloat('000.0000000000',RootMin));
  for i:=zahl downto 0 do if sqr(i-1)<zahl then break;
  RootMax:=i;
  ListBox1.Items.Add('Maximum: '+FormatFloat('000.0000000000',RootMax));
  AktGenau:=1;
  Stelle:=1;
  Genauigkeit:=0.0001;
  ListBox1.Items.Add(FormatFloat('000.0000000000',RootMin / Stelle)+' <= '+FormatFloat('000.0000000000',RealRoot)+' <= '+FormatFloat('000.0000000000',RootMax / Stelle));
  while (AktGenau>Genauigkeit) and (RootMax-RootMin>Genauigkeit) do
    begin
    while RootMax-RootMin>AktGenau do
      begin
      if sqr((RootMax+RootMin) / 2)>zahl
      then RootMax:=RootMax - 1
      else RootMin:=RootMin + 1;
      ListBox1.Items.Add(FormatFloat('000.0000000000',RootMin / Stelle)+' <= '+FormatFloat('000.0000000000',RealRoot)+' <= '+FormatFloat('000.0000000000',RootMax / Stelle));
      Application.ProcessMessages;
      end;
    if (RootMin=RealRoot) or (RootMax=RealRoot) then break;
    Stelle:=Stelle * 10;
    RootMax:=RootMax * 10;
    RootMin:=RootMin * 10;
    end;
end;
»Unlösbare Probleme sind in der Regel schwierig...«
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz