Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# arcSin and arcCos without using library functions

Posted on 2009-05-03
Medium Priority
678 Views
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,

its urgent,

Thanks,
0
Question by:montu_12
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 84

Accepted Solution

ozo earned 1000 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

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

ID: 24297091
0

LVL 22

Assisted Solution

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article seeks to propel the full implementation of geothermal power plants in Mexico as a renewable energy source.
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month9 days, 12 hours left to enroll