Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inverse Trig

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
Its been a while...
How do you find the Inverse Sine of a value in Qbasic?
 
Found this


' define an inverse sine function
'
DEF FNasin (x)
c = SQR(1 - x * x)
FNasin = ATN(x / c)
END DEF
David Paulson

 
You should catch the error conditions otr the function will break:
pi=4*ATN(1)
Function asin (x)
    select case abs(x)
case is >1: asin=1e30 '<it indicates an erroneous input!
case 1: if x>0 then asin =pi/2 else asin=-pi/2
case else: c= SQR(1 - x * x)
     asin = ATN(x / c)
end select
END Function Antoni
 
Inverse Sine
Arcsin(X) = Atn(X / Sqr(-X * X + 1))


From VB Documentation:
(...this should take care of most of your trig stuff...)

Function
Derived equivalents


Secant
Sec(X) = 1 / Cos(X)

Cosecant
Cosec(X) = 1 / Sin(X)

Cotangent
Cotan(X) = 1 / Tan(X)

Inverse Sine
Arcsin(X) = Atn(X / Sqr(-X * X + 1))

Inverse Cosine
Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

Inverse Secant
Arcsec(X) = Atn(X / Sqr(X * X – 1)) + Sgn((X) – 1) * (2 * Atn(1))

Inverse Cosecant
Arccosec(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) – 1) * (2 * Atn(1))

Inverse Cotangent
Arccotan(X) = Atn(X) + 2 * Atn(1)

Hyperbolic Sine
HSin(X) = (Exp(X) – Exp(-X)) / 2

Hyperbolic Cosine
HCos(X) = (Exp(X) + Exp(-X)) / 2

Hyperbolic Tangent
HTan(X) = (Exp(X) – Exp(-X)) / (Exp(X) + Exp(-X))

Hyperbolic Secant
HSec(X) = 2 / (Exp(X) + Exp(-X))

Hyperbolic Cosecant
HCosec(X) = 2 / (Exp(X) – Exp(-X))

Hyperbolic Cotangent
HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) – Exp(-X))

Inverse Hyperbolic Sine
HArcsin(X) = Log(X + Sqr(X * X + 1))

Inverse Hyperbolic Cosine
HArccos(X) = Log(X + Sqr(X * X – 1))

Inverse Hyperbolic Tangent
HArctan(X) = Log((1 + X) / (1 – X)) / 2

Inverse Hyperbolic Secant
HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X)

Inverse Hyperbolic Cosecant
HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X)

Inverse Hyperbolic Cotangent
HArccotan(X) = Log((X + 1) / (X – 1)) / 2

Logarithm to base N
LogN(X) = Log(X) / Log(N)

Good Luck -Josh Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
Note: The above are in algebraic notation...

to use in a program...

This:

Inverse Sine
Arcsin(X) = Atn(X / Sqr(-X * X + 1))


Should look like this:

Code:
Function Arcsin(X as double)
  Arcsin = Atn(X / Sqr(-X * X +1))
End Function

(Just 4 Tha Record ;-)) Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top