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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you write functions acs(arc cos) and asn(arc sin)

Status
Not open for further replies.

akb

Technical User
Mar 10, 2001
5
IN
Could anyone please tell me how to write qbasic functions acs(arc cos) and asn(arc sin), and to input arguments for the functions via the keyboard. Th results should be in
radians.
 
You can create piecewise-defined functions (which can be represented in QB with a simple IF statement) for these using ATN (the arc of tangent function), which is the only inverse trig function built into QB. Just remember that cos^2(x) + sin^2(x) = 1. With this, you can take a cosine value and get one of the two possible sine values back, or a sine value and get one of the possible cosine values, either of which will give you a ratio that you can put into ATN() and get an angle back (in radians). Then, it's up to you to determine what quadrant that angle is in and transform in accordingly. Arcsin and arctan are always in the 1st or 4th quadrant, and Arccos is always in the 1st or 2nd quadrant. Here are sketches of the functions:
[tt]
Arctan:
^y **********
| *******
|**
-------------------*------------------>x
**|
******* |
********** |

Arccos:

(-1, 2pi)
* ^y
* |
* |
** |
***
(0, pi)| **
| *
| *(1, 0)
---------+----*------>x

Arcsin:
(-1, pi)
^y *
| *
| *
(0,0)| **
--------***--------->x
** |
* |
* |
* |
(1,-pi) |
[/tt]
The latter two graphs show the ENTIRE function. The range of the functions is as implied by the endpoints. As for the graph of arctan, it has the same range as arcsin, but its domain is the reals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top