Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

Way to replace ASIN trigonometrical function

Hello guys'

I have a big proble. This is my application uses Math.asin() function. But BB hasn't 

functions that named asin(), acon(), atan(). I found function that calculate asin() approximately :

 

    public double arcSine(double a) {
       
        double x;
        double epsilon = 1.0E-7;
       
        x = a;
        do {
            x = x - (Math.sin(x)-a)/Math.cos(x);
        } while(Math.abs(Math.sin(x)-a) <= epsilon);
        return x;
    }

 

But its difference is too a lot of. For example 0.02693011603811.

I need difference at least :  0.000000001

 

Have u any best solution ?

 

Plz help me guys.

Tnx again.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Way to replace ASIN trigonometrical function

Haven't tried it myself, but have you seen the code in this thread?

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=142

(you can also find it by searching for ASIN)

Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: Way to replace ASIN trigonometrical function

Yeap' I've seen this thread. I found a new function. Its difference : 0.000001

It's enough to calculate.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Way to replace ASIN trigonometrical function

Any chance of publishing your new function for other people who might want a more accurate value?

Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: Way to replace ASIN trigonometrical function

It's workin :

 

public double asinCalculation(double x) {
       
        double result = x + 0.16666666666666666666666666666667 * x * x * x
        + 0.075 * x * x * x * x * x
        + 0.044642857142857142857142857142857 * x * x * x * x * x * x
        * x + 0.030381944444444444444444444444444 * x * x * x * x * x
        * x * x * x * x + 0.022372159090909090909090909090909 * x * x
        * x * x * x * x * x * x * x * x * x
        + 0.017352764423076923076923076923077 * x * x * x * x * x * x
        * x * x * x * x * x * x * x + 0.01396484375 * x * x * x * x * x
        * x * x * x * x * x * x * x * x * x * x
        + 0.011551800896139705882352941176471 * x * x * x * x * x * x
        * x * x * x * x * x * x * x * x * x * x * x
        + 0.0097616095291940789473684210526316 * x * x * x * x * x * x
        * x * x * x * x * x * x * x * x * x * x * x * x * x
        + 0.0083903358096168154761904761904762 * x * x * x * x * x * x
        * x * x * x * x * x * x * x * x * x * x * x * x * x * x * x
        + 0.007312525873598845108695652173913 * x * x * x * x * x * x
        * x * x * x * x * x * x * x * x * x * x * x * x * x * x * x * x
        * x;
        return result;
    }