Solved

arcSin and arcCos without using library functions

Posted on 2009-05-03
4
658 Views
Last Modified: 2012-05-06
Hi guys i want to find arcSin and arcCos without using library functions,

Can you please provide me the algorithm or equation which gives accurate reading,

Please help,

its urgent,

Thanks,
0
Comment
Question by:montu_12
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 250 total points
ID: 24292794
float arctan(float x){
    if( x < 0 ){ return -arctan(-x); }
    if( x > 1 ){ return pi/2 - arctan(1/x); }
    if( x <= 1/8.0 ){ return  0.9974133042 * x; }
    if( x <= 2/8.0 ){ return  0.004072621 + 0.964989344 * x; }
    if( x <= 3/8.0 ){ return .017899968 + 0.910336056 * x; }
    if( x <= 4/8.0 ){ return .044740546 + 0.839015512 * x; }
    if( x <= 5/8.0 ){ return .084473784 + 0.759613648 * x; }
    if( x <= 6/8.0 ){ return .134708924 + 0.679214352 * x; }
    if( x <= 7/8.0 ){ return .192103293 + 0.602631128 * x; }
    if( x <= 8/8.0 ){ return .253371504 + 0.532545304 * x; }
}

float arcsin(float x){
  return arctan(x/sqrt(1-x*x));
}
float arccos(float x){
    return pi/2 - arcsin(x);
}
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 24293128
Arcsin(x) Calculator
http://www.analyzemath.com/Calculators_2/arcsin_calculator.html

Inverse trigonometric functions
http://en.wikipedia.org/wiki/Inverse_trigonometric_functions
You can write a loop to calculate the definite integrals. Divide the area let's say by 1000 and calculate the areas of the smaller 1000s rectangles.

Calculating ArcSin and ArcCos
http://cuinl.tripod.com/Tips/math9.htm
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 24297091
0
 
LVL 22

Assisted Solution

by:NovaDenizen
NovaDenizen earned 250 total points
ID: 24306215
I like ozo's code, except for the piecewise linear approximation (all the "if (x <=" lines).  I would instead recommend the Maclaurin series, see (17) at http://mathworld.wolfram.com/InverseSine.html.

Alternatively, you will get quicker convergence and better numerical accuracy if you also use the Maclaurin series for arccos(1 - y), for situations when y is close to 1 and convergence will be slow.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I gu…
This article seeks to propel the full implementation of geothermal power plants in Mexico as a renewable energy source.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now