![]() |
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; |
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!) |
Re: IntervallSchachtelung
Zitat:
Und bitte veröffentliche den dann hier, dass jeder etwas davon hat, danke. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz