csc() sec() cot()

Please help me ,how i can to program these functions 1-csc()2-sec()3-cot()all thanks for all
[141 byte] By [balanceda] at [2007-10-2 7:22:51]
# 1

.

. .

..

C..

.. A

. .

.T.

......................

B

sin(T) = A / C

csc(T) = C / A (= 1 / sin(T))

cos(T) = B / C

sec(T) = C / B (= 1 / cos(T))

tan(T) = A / B (= sin(T) / cos(T))

cot(T) = B / A (= 1 / tan(T))

Checkout this class: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html

prometheuzza at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 2
Thanks prometheuzz ::but , i programed this functions (1/(sin x)) as followpublic void Csc(){String csc="";csc=""+(1/(Math.sin ( z )))}but the result was incorrectplease try that and give me your opinionsthanks for all
balanceda at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 3

> but the result was incorrect

> please try that and give me your opinions

> thanks for all

I can't: your code won't compile.

The argument of the Math.sin(...) function must be an angle in radians.

So if my example would be A=3, B=4 and C=5 then T ~= 36.9 degrees and in radians T ~= (Pi / (180.0 / 36.9)).

prometheuzza at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 4
Where I come from we do trig with numbers, not java.lang.Strings.
YAT_Archivista at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 5

> Where I come from we do trig with numbers, not java.lang.Strings.

LOL!

WTF? You've got the example of java.lang.Math right in front of you. Isn't emulation the sincerest form of flattery? Write your functions to look like the java.lang.Math ones:

public class MyMathFunctions

{

public static final double csc(double angleInRadians)

{

return 1.0/Math.sin(angleInRadians);

}

public static final double sec(double angleInRadians)

{

return 1.0/Math.cos(angleInRadians);

}

public static final double cot(double angleInRadians)

{

return 1.0/Math.tan(angleInRadians);

}

}

%

duffymoa at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 6

Thanks for all members ::

but i want to point that i prgramed this functions , see the code

of that , but the result is incorrect

example:

the correct answers must be

csc 0.5=30

sec 0.5=60

cot 1.0=45

but in this code the results don't give this answers

The results that displayed as follow

csc 0.5=2.08.........

sec 0.5=1.13.........

cot 1.0=0.64.........

import javax.swing.*;

public class MyMathFunctions

{

public static void main(String [] args)

{

MyMathFunctions F=new MyMathFunctions();

String output;

output="Csc : "+F.csc(0.5)+"\nSec : "+F.sec(0.5)+"\n Cot : "+F.cot(1);

JOptionPane.showMessageDialog(null,output);

}

public static final double csc(double angleInRadians)

{

return 1.0/Math.sin(angleInRadians);

}

public static final double sec(double angleInRadians)

{

return 1.0/Math.cos(angleInRadians);

}

public static final double cot(double angleInRadians)

{

return 1.0/Math.tan(angleInRadians);

}

}

balanceda at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 7

> example:

> the correct answers must be

> csc 0.5=30

> sec 0.5=60

> cot 1.0=45

Wrong. Again: the argument of these functions are radians. You obviously don't know what a radian is. You really need to brush up your trigonometry.

> but in this code the results don't give this answers

> The results that displayed as follow

>

> csc 0.5=2.08.........

> sec 0.5=1.13.........

> cot 1.0=0.64.........

That is correct.

Tip: Google also has a nice calculator function:

[url=http://www.google.com/search?hl=en&q=csc%280.5%29&btnG=Google+Search]csc(0.5) according to Google[/url]

prometheuzza at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 8
> So if my example would be A=3, B=4 and C=5 then T> ~= 36.9 degrees and in radians T ~= (Pi /> (180.0 / 36.9)).Of course, Math.toRadians(double) works just as well.~Cheers
Adeodatusa at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 9
> Of course, Math.toRadians(double) works just as> well.> > ~CheersDidn't even know that one (like so many other things). But I think it won't hurt to let the OP know how to do it manually.; )
prometheuzza at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...
# 10

> example:

> the correct answers must be

> csc 0.5=30

> sec 0.5=60

> cot 1.0=45

No, but

arcsin 0.5 = 30?br>arccos 0.5 = 60?br>arctan 1.0 = 45?br>

1-1

cosec(x) = - = (sin(x))

sin(x)

-1

arcsin(x) = sin (x)

Which function do you want?

Pete

pm_kirkhama at 2007-7-16 20:59:18 > top of Java-index,Other Topics,Algorithms...