Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-10

MATH.PP

8 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Медведев Слава

Hello, developers,

It seems to be a bug in MATH.PP 1.1.2.2 in arcsin function. I think, this is incorrect:
if abs(x) > 1 then InvalidArgument
I added these strings:
const Epsilon = 1.0e-9;
....
if (x-1)<=Epsilon then x:=1;
if (x+1)<=Epsilon then x:=-1;

I made these changes because of InvalidArgument exception when arcsin parameter (displayed by GDB) is 1 (but, I think, it was near 1, but not 1).

Best regards,
Medvedev

Reply by email

Michael Van Canneyt
to Медведев Слава
[koi8-r] �������� ����� wrote 14 lines
Hello, developers, It seems to be a bug in MATH.PP 1.1.2.2 in arcsin function. I think, this is incorrect: if abs(x) > 1 then InvalidArgument I added these strings: const Epsilon = 1.0e-9; .... if (x-1)<=Epsilon then x:=1; if (x+1)<=Epsilon then x:=-1; I made these changes because of InvalidArgument exception when arcsin parameter (displayed by GDB) is 1 (but, I think, it was near 1, but not 1).

But if it is larger than 1, arcsin is not defined ? You deliberately introduce an error in the calculation in this way ?

It may be better to change the code to

if abs(x)>1.0 then

Because then reals are used for the comparision, since in the case of abs(X) > 1 the '1' will probably be interpreted as an integer.

Michael.

Reply by email

Marco van de Voort
to Michael Van Canneyt

[ Charset X-UNKNOWN unsupported, converting... ]

Show quoted text 28 lines
On Sat, 13 Oct 2001, [koi8-r] ________ _____ wrote: > Hello, developers, > > It seems to be a bug in MATH.PP 1.1.2.2 in arcsin function. > I think, this is incorrect: > if abs(x) > 1 then InvalidArgument > I added these strings: > const Epsilon = 1.0e-9; > .... > if (x-1)<=Epsilon then x:=1; > if (x+1)<=Epsilon then x:=-1; > > I made these changes because of InvalidArgument exception when arcsin > parameter (displayed by GDB) is 1 (but, I think, it was near 1, but > not 1). But if it is larger than 1, arcsin is not defined ? You deliberately introduce an error in the calculation in this way ? It may be better to change the code to if abs(x)>1.0 then Because then reals are used for the comparision, since in the case of abs(X) > 1 the '1' will probably be interpreted as an integer.

or abs(x+epsilon) >=1

Reply by email

Jonas Maebe
to Michael Van Canneyt: But if it is larger than 1, arcsin is not defined ? You deliberately introduce an error…
Michael Van Canneyt wrote 11 lines
> const Epsilon = 1.0e-9; > .... > if (x-1)<=Epsilon then x:=1; > if (x+1)<=Epsilon then x:=-1; > > I made these changes because of InvalidArgument exception when arcsin > parameter (displayed by GDB) is 1 (but, I think, it was near 1, but > not 1). But if it is larger than 1, arcsin is not defined ? You deliberately introduce an error in the calculation in this way ?

The problem is that floats on computers are inherently inexact and if you perform a number of calculations the results becomes more inexact after every operation (I had a lot of trouble with this while implementing the str_real() routine). You should indeed work with a small epsilon to compensate for this, but the size of this epsilon depends on the size of the best real type available (for extended = 10 bytes, it could be 1.0e-9, but for extended = 8 bytes, it will be bigger).

Because then reals are used for the comparision, since in the case of abs(X) > 1 the '1' will probably be interpreted as an integer.

No, if one operand in an expression is a float, everything will be converted to a float.

Jonas

Reply by email

Marco van de Voort
to Jonas Maebe
Show quoted text 10 lines
small epsilon to compensate for this, but the size of this epsilon depends on the size of the best real type available (for extended = 10 bytes, it could be 1.0e-9, but for extended = 8 bytes, it will be bigger). > Because then reals are used for the comparision, since in the case > of abs(X) > 1 the '1' will probably be interpreted as an integer. No, if one operand in an expression is a float, everything will be converted to a float.

See also the numlib sources. They have a lot of those constructs to prevent such problems. They use epsilon constructs everywhere.

Reply by email

Peter Vreman
Show quoted text 6 lines
i have latest TV and i get this error C:\zbyna\tv>fpc buildfv views.pas(908,7) Error: Identifier not found "GetLockScreenCount" views.pas(5579) Fatal: There were 1 errors compiling module, stopping

You need the latest RTL also

Reply by email

Lee, John

Latest fv.zip that I have (24/09/01) works ok here for Mon's sources making win32 & go32 compiler && IDEs both for v10 & v11...hth J

Earlier message 17 lines
-----Original Message----- From: Zbynek Grygar Sent: Monday, October 15, 2001 04:18 To: Subject: [fpc-devel]TV error i have latest TV and i get this error C:\zbyna\tv>fpc buildfv views.pas(908,7) Error: Identifier not found "GetLockScreenCount" views.pas(5579) Fatal: There were 1 errors compiling module, stopping Zbynek

Reply by email