An inverse sine function 
Author Message
 An inverse sine function

Does anyone know how to write a inverse sine (symbol sin-1) function or
of a .tpu wich contains the like? If so please mail me  with the info at



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function
Does anyone know how to write a inverse sine (symbol sin-1) function or
of a .tpu wich contains the like? If so please mail me  with the info at



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function

Quote:

> Does anyone know how to write a inverse sine (symbol sin-1) function or
> of a .tpu wich contains the like? If so please mail me  with the info at


Not tested (or guaranteed to be the best) -

function ArcSin(x : real) : real;
  begin
    ArcSin := Arctan( x / sqrt(1 - sqr(x) ));
  end;

For values of x between -1 and 1, this should return values of ArcSin
between -Pi/2 and Pi/2.

Good luck.
Bob.



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function


Quote:
> Does anyone know how to write a inverse sine (symbol sin-1) function or
> of a .tpu wich contains the like? If so please mail me  with the info at


A quick stroll through the on-line help would find this immediately.

Take a look at the page for ArcTan.

Note that it doesn't work for x=1, x=-1.

.splitbung
--
* TQ 1.0 * The 'Just So Quotes'.
"Your superior intellect is no match for our puny weapons!"
        -- THE SIMPSONS



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function

Quote:

> Does anyone know how to write a inverse sine (symbol sin-1) function or
> of a .tpu wich contains the like? If so please mail me  with the info at


I have been using the following:  

unit MiscMath;

{ Catch all unit for Math functions not already provided in the language.}

{$N+} { use '87 instructions }

interface

function ArcSin( x : extended) : extended;
function ArcCos( x : extended) : extended;
function ArcTan2(y : extended; x : extended): extended;

implementation

function ArcSin( x : extended) : extended;
begin
  ArcSin :=  ArcTan2( x , sqrt(1-sqr(x)) );
  { ArcTan2 is used instead of ArcTan to avoid exception when x = 1 or -1}
end;

function ArcCos( x : extended) : extended;
begin
 ArcCos := ArcTan2 (sqrt (1-sqr (x)) , x);
 { ArcTan2 is used instead of ArcTan to avoid exception when x = 0}
end;

function ArcTan2(y : extended; x : extended) : extended;

{ The '87, '287, '387, i486, and i586 have an op code to do ATAN2!  It is
 advertised to be well behaved and execute in 290 cycles on a i486.  This
 would be about 3 uSec on a 100MHz i486 machine!  It is also supposed to be
 very accurate.  More information can be found in the "i486 Microprocessor -
 Programmers Reference Manual" }

assembler;
asm
  fld [y]
  fld [x]
  fpatan
end;

end.

The above compiles in Delphi.  I'd appreciate a note if you find a bug.

Paul Z.



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function

Quote:
>Does anyone know how to write a inverse sine (symbol sin-1) function or
>of a .tpu wich contains the like? If so please mail me  with the info at


You can use the mathematic serie:

                       1*x**3      1*3*x**5      1*3*5*x**7
arcsin(x) = x + ----------- + --------------- + ------------------ + .
                       2*3          2*4*5           2*4*6*7

for abs(x) < 1

where ** stand fo power of

and remembering that arcsin(-x) = -arcsin(x)

                                 or

You can use this code:

Unit Trigo; { en degrs / in degree }

{ de Programmes en Pascal pour Scientifiques et Ingnieurs
  par Alan R. Miller, chap. 1
  tap par Roger Garipy }

Interface

Function arctg (x, y : real) : real;
Function arcsin (x : real) : real;
Function arccos (x : real) : real;

Implementation

Function arctg (x, y : real) : real;
{ x, y : coordonnes
  parce que arctan de Pascal ne spcifie pas le quadrant
  de la rponse }
const pi180 = 180.0 / pi;
var a : real;
begin
if x = 0.0
   then begin
        if y = 0.0
           then arctg:=0.0
           else arctg:=90.0
        end
   else if y = 0.0
           then arctg:=0.0
           else begin
                a:=arctan(abs(y/x)) * pi180;
                if x > 0.0
                   then begin
                        if y > 0.0
                           then arctg:=a
                           else arctg:=-a
                        end
                   else if y > 0.0
                           then arctg:=180.0 - a
                           else arctg:=180.0 + a
                end
end { arctg };

Function arcsin (x : real) : real;
begin
if x = 0.0
   then arcsin:=0.0
   else if x = 1.0
           then arcsin:=90.0
           else if x = -1.0
                   then arcsin:=-90.0
                   else arcsin:=arctg(1.0,x/sqrt(1.0-sqr(x)))
end { arcsin };

Function arccos (x : real) : real;
begin
if x = 0.0
   then arccos:=90.0
   else if x = 1.0
           then arccos:=0.0
           else if x =  -1.0
                   then arccos:=180.0
                   else arccos:=arctg(x/sqrt(1.0-sqr(x)),1.0)
end { arccos };

End.

---
Roger Gariepy                            Be :-) even if you feel :-(



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function



Quote:

>> Does anyone know how to write a inverse sine (symbol sin-1) function or
>> of a .tpu wich contains the like? If so please mail me  with the info at

>I have been using the following:  

>unit MiscMath;

>{ Catch all unit for Math functions not already provided in the language.}

>{$N+} { use '87 instructions }

>interface

>function ArcSin( x : extended) : extended;
>function ArcCos( x : extended) : extended;
>function ArcTan2(y : extended; x : extended): extended;

Looks very good to me, for anyone with an '87.  No errors found.  A
better solution to the "incorrect on-line help" question than any I've
seen before.  My test program now includes it.
--



Wed, 18 Jun 1902 08:00:00 GMT  
 An inverse sine function

Quote:


>>Does anyone know how to write a inverse sine (symbol sin-1) function or
>>of a .tpu wich contains the like? If so please mail me  with the info at


ftp://webworldinc.com/pmapi002.zip

contains math387.obj and math387.pas.  I'm assuming sin-1 to be
equivilent to arcsin, in which case, they exist optimized for the 387,
and in general work 5 times faster than borland equivilents.  In
addition, the FPU automatically determines infinity for you, or a
rough approximation for it.  A comparible math unit is available from
another person for $7.00, and claims to be fast because of inline
code.  Inline code will not make it faster, simply because you just
wait sooner for the FPU to finish its job.  More often than not, the
Borland pascal side will be waiting for the FPU to finish, simply
because of the number of math cycles exceed the number of cycles in
the call and return.  Borland, under the {$n+ e-} condition does in
its usual undocumented fashion does this for floating point accesses:

        wait
        fstp    somevar

Essentially, this means that all math processes can start while you
return from your procedure, and will continue to run independent of
the CPU until you need the data, in which case you wait until it's
ready.  This kind of program is typical in parallel processing
systems.  The only exception I know of personally is where the FPU
needs to access common memory, ie fld qword ptr [bx], in which case
the CPU sets up the address, and the FPU reads and writes as needed.
{terms may be inaccurate, but hopefully the thought process is
understood}

http://www.webworldinc.com/joejared/index.htm
ftp://webworldinc.com/joejared/
--- Fidoknot v1.0



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Sine function / Sweep

2. Sine-Function / Sweeping

3. Inverse Trig Functions in BP & TP

4. inverse trig functions

5. Sine and cosine problem

6. Sine waves

7. Sine+Cosine in assembler...

8. inverse matrix

9. Inverse frequency counter via parallel port

10. Inverse Printing problem

11. Dynamic multidimentianal arrays and inverse of a complex matrix

12. Help ASAP!!! inverse trig functions?!?!?!

 

 
Powered by phpBB® Forum Software