Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 sine arc function?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
midnite13




PostPosted: Fri Jan 06, 2006 12:04 am   Post subject: sine arc function?

Hello...

I was wondering if turing has a predefined sine arc function (I need it in degrees)

the sind function only returns the ratio, but it's the angle that I want. I'm not sure my wording is the best, so I'll provide an example

sind (30) would return a value of 0.5, however, I"m wondering if there's an arcsind that woudl allow for

arcsind (0.5) which would return 30.

Thanks for all your help
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Fri Jan 06, 2006 1:04 am   Post subject: Re: sine arc function?

midnite13 wrote:
Hello...

I was wondering if turing has a predefined sine arc function (I need it in degrees)

the sind function only returns the ratio, but it's the angle that I want. I'm not sure my wording is the best, so I'll provide an example

sind (30) would return a value of 0.5, however, I"m wondering if there's an arcsind that woudl allow for

arcsind (0.5) which would return 30.

Thanks for all your help


you know arcsind does work.
Saad85




PostPosted: Fri Jan 06, 2006 1:17 am   Post subject: (No subject)

if not that then you could go arcsin*(180/pi) to turn radians into degrees
MysticVegeta




PostPosted: Sun Jan 08, 2006 1:45 pm   Post subject: (No subject)

What I forgot to mention is that,

arcsind

works for Turing 4.05 only.
Phonon




PostPosted: Mon Apr 03, 2006 10:22 pm   Post subject: older versions

I have an older version of Turing. I plan on getting the newest one but I need to get this done. The version I have does include an arctan function. Is there any way to manipulate trigonometric functions so that I can use a combination of arctan and other functions to get arcsin? I can't see a way of doing this with Taylor series expansions. Maybe I should be thinking about using exponentials and complex variables (but leaving 'i' out of it)?
Delos




PostPosted: Tue Apr 04, 2006 9:53 am   Post subject: (No subject)

Disclaimer: I am not a Math major. The furthest math I took was 1st year intro calculus. I don't really like math all that much - but I am quite capable of it. Take this proof with a bit of salt, and perhaps oregano for taste.

I'll going to work in radians, because I want to and because all the cool people do so anyway. You've already seen a way to convert from radians to degrees above.
Conversions from arctan to arcsin are possible, but you'll just have to limit yourself to (-1<= x <= 1). That's not too difficult. You can always manipulate your answer later on to suit your needs.

Either way:
math:

let x be inputted value
let a be (x / sqrt (x^2 + 1))

arcsin (x)  = arctan (x) - arctan (sqrt (1 - x^2) / x) + arctan (sqrt (1 - a^2)/a)


Try it. It should work.
NikG




PostPosted: Tue Apr 04, 2006 10:40 am   Post subject: (No subject)

I'm just wondering... what exactly is arcsin even necessary for anyways?
I mean if you're just looking for the angle in between 2 lines, arctand is more than sufficient.
Andy




PostPosted: Tue Apr 04, 2006 11:02 am   Post subject: (No subject)

wow delos.. you're trying wayyyyyyyyyyy too hard....

consider the following:

what is sine? draw a unit circle with the centre as the origin, and start from (1,0) then walk B units counter clock wise, now let's call that point (a,b)

Posted Image, might have been reduced in size. Click Image to view fullscreen.

sin(B) in this case would be b. insimpler terms, sin(theta) yeilds the y co ordinate on a unit circle

to find arcsin(A):

let arcsin(A) = B => sin(B) = A

this means that A is the y co ordinate of the arc length B from the (1,0) along the unit circle.

so let's find both co ordinates of this point.

take the equation of the circle: x^2 + y^2 = 1 and the equation of the line y = A. turns out, the co ordinate is (A, sqrt(1-A^2))

now to find how long is that arc between (A, sqrt(1-A^2)) and (1,0) along the unit circle:

simply take the arctan(A/sqrt(1-A^2))) and you're done.

note, this method only works for the first quadrant, but making the rest work shouldnt be too hard.


Turing:

function arcsind (r : real) : real
    result arctand (r / sqrt (1 - r ** 2))
end arcsind
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Apr 04, 2006 11:34 am   Post subject: (No subject)

Yes dodge, yes I am. Laughing. Ah well, I enjoyed the proof anyway, so it was worth it. But yes, do what dodge says, he knows more maths than I do.
Phonon




PostPosted: Tue Apr 04, 2006 6:20 pm   Post subject: (No subject)

NikG wrote:
I'm just wondering... what exactly is arcsin even necessary for anyways?
I mean if you're just looking for the angle in between 2 lines, arctand is more than sufficient.


I am writing a program for x-ray crystallography. In order to find theta from bragg's law, I need to use arcsin. There's simply no other way I can do it, as far as I see, because:

sin (theta) = (n * radiation wavelength)/2*d(hkl).

Thus, knowing n, the radiation wavelength and d(hkl), I am using that information to find theta.
Phonon




PostPosted: Wed Apr 05, 2006 12:09 am   Post subject: works

Anyway, I got it to work. Thanks very much for the help!
Andy




PostPosted: Wed Apr 05, 2006 12:56 pm   Post subject: (No subject)

of course you got it to work.. i gave you the exact code
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: