Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi IntervallSchachtelung (https://www.delphipraxis.net/36388-intervallschachtelung.html)

glkgereon 19. Dez 2004 13:47


IntervallSchachtelung
 
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;

Maximus 19. Dez 2004 14:18

Re: IntervallSchachtelung
 
Ich hab auch mal so ein Programm geschrieben, aber es ist nie ganz fertig geworden (das WUrzel Berechnen hat aber funktioniert :) .

Wenn du den Quellcode willst kann ich ihn dir per PM schicken (ist aber nicht wirklich so auf die feine, saubere Art geschrieben!)

Matze 19. Dez 2004 14:23

Re: IntervallSchachtelung
 
Zitat:

Zitat von Maximus
Wenn du den Quellcode willst kann ich ihn dir per PM schicken (ist aber nicht wirklich so auf die feine, saubere Art geschrieben!)

Er hätte doch gerne den Quelltext, hat er doch oben geschrieben.

Und bitte veröffentliche den dann hier, dass jeder etwas davon hat, danke.


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:28 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