Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi W.Erhardt aMath (https://www.delphipraxis.net/200420-w-erhardt-amath.html)

wendelin 18. Apr 2019 10:09

W.Erhardt aMath
 
Hallo,

kennt sich jemand mit der Unit aMath von W.Erhardt aus ?
Ich brauche eine Instruktion wie ich die 'exp - funktion aus aMath' nutze und in mein Programm einbinde.
Am besten ein ordentliches Manual (englisch oder deutsch) mit Beispielen.

W. Erhardt schreibt, das die exp-function aus der Delphi-Unit 'math' recht ungenau sei und bis zu 13 bits (extended Argument) verloren gehen
würden.http://wolfgang-ehrhardt.de/misc_de.html#mparith

Wendelin

DeddyH 18. Apr 2019 10:38

AW: W.Erhardt aMath
 
Ganz naiv würde ich die Unit einbinden und die Funktion Exp aufrufen. Hat man auch noch Math eingebunden, dann entweder sicherstellen, dass AMath in der Uses-Liste nach Math kommt oder die Funktion voll qualifiziert aufrufen (AMath.Exp).

Rollo62 18. Apr 2019 12:13

AW: W.Erhardt aMath
 
Wie man die nutzt, ich denke 1:1, wie DeddyH schon geschrieben hat.

Zitat:

{---------------------------------------------------------------------------}
function exp(x: extended): extended; assembler; {&Frame-} {&Uses none}
{-Accurate exp, result good to extended precision}
asm
{This version of Norbert Juffa's exp is from the VirtualPascal RTL source,}
{discussed and explained in the VP Bugtracker system. Quote: }
{ }
{ ... "since the 387, F2XM1 can accecpt arguments in [-1, 1]. }
{ }
{ So, we can split the argument into an integer and a fraction part using }
{ FRNDINT and the fraction part will always be -1 <= f <= 1 no matter what}
{ rounding control. This means we don't have to load/restore the FPU }
{ control word (CW) which is slow on modern OOO FPUs (since FLDCW is a }
{ serializing instruction). }
{ }
{ Note that precision is lost in doing exponentation when the fraction is }
{ subtracted from the integer part of the argument. The "naive" code can }
{ loose up to 11 (or 15) bits of the extended precision format for large }
{ DP or EP arguments, yielding a result good to double precision. To get a}
{ function accurate to full extended precision, we need to simulate higher}
{ precision intermediate arithmetic." }
{ Ref: [Virtual Pascal 0000056]: More accurate Exp() function. URL (Oct.2009):}
{ https://admin.topica.com/lists/virtualpascal@topica.com/read/message.html?sort=a&mid=908867704&start=7}
Die exp() Funktion in Delphi und AMath machen beide stark von Assembler Gebrauch,
ist nicht so mein Spezialgebiet, dehalb würde ich dem Wolfgang Erhardt da blind vertrauen.
Der kannte jedes seiner Bits einzeln.

Allerdings gebe ich zu Bedenken das sein Code nur für Windows kompatibel war,
also müsste man bei iOS/Android/Linux nach Alternativen suchen, oder mit Delphi-Code leben.

DeddyH 18. Apr 2019 12:15

AW: W.Erhardt aMath
 
Wenn die Angabe im Profil stimmt (Delphi 7), spielen mobile Plattformen wohl keine Rolle ;)

Rudy Velthuis 25. Apr 2019 00:03

AW: W.Erhardt aMath
 
Zitat:

Zitat von wendelin (Beitrag 1430552)
Hallo,

kennt sich jemand mit der Unit aMath von W.Erhardt aus ?
Ich brauche eine Instruktion wie ich die 'exp - funktion aus aMath' nutze und in mein Programm einbinde.
Am besten ein ordentliches Manual (englisch oder deutsch) mit Beispielen.

W. Erhardt schreibt, das die exp-function aus der Delphi-Unit 'math' recht ungenau sei und bis zu 13 bits (extended Argument) verloren gehen
würden.http://wolfgang-ehrhardt.de/misc_de.html#mparith

Wendelin

Er schreibt auch, das arccsch(2) 0.27980789397 liefert. Aber bei mir gibt es, ziemlich nah am korrekten Wert, 4.81211811304092E-0001 (oder 0.481211811304092) zurück (Delphi 10.3.1 Rio).


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