How do I find the value of sin(50 degrees)

If I want to find the value of sin(60 degrees), I can calculate from the exact value
19%20PM

and calculate 100 decimal places using

const decimalplaces = 100
const numofbits = Int(ceil(log(2,10) * decimalplaces))
setprecision(numofbits)

result = sqrt(big(3))/big(2)
println("sin(60 deg) = $result")

with output

sin(60 deg) = 0.86602540378443864676372317075293618347140262690519031402790348972596650845440001854057309337862437

But how do I find the value of sin(50 degrees) to 100 decimal places using the exact value where I is the sqrt(-1.0)? No cheating by calling the sin function.
06%20PM

Something like

julia> a = -1/16;

julia> b = 1/16 * im * sqrt(big(3));

julia> c = 1 / big(3);

julia> real((a + b)^c + (a - b)^c)
0.7660444431189780352023926505554166739358324570803952458540452846421553888568742

maybe? But maybe I am missing the point?

What’s the purpose of the exercise? Is this homework?

Yes, the purpose is unclear. Why not simply

const decimalplaces = 100
const numofbits = Int(ceil(log(2,10) * decimalplaces))
setprecision(numofbits)
sind(big(50))

?

1 Like

Assuming you are interested in the result (and do not necessarily need Julia for it):

Wolfram alpha is quite good at this too.
click on ‘more digits’ and then ‘plaintext’ in the link below

0.7660444431189780352023926505554166739358324570803952458540452846421553888568747235282292766805484934499624883998700455341954248316333490711841864889023860281082594782010899261924361273893782904078770273006354688599137325083942815336330350954685107618325549288375883429890386354276785479071197343786221265745844798601091903854036409358705798621426631952466977531043261972745910816640595291004784330497183410104807025160539738339882790832858732629391480897657539603952497173690488784768527075866522481047541645808795123966392345773943563388083848396701961681348379456980904427582362573317984311518696512834851104919855096784185294162424820133028323621286860806014406303017834545192236924816164399454116865865343693163091111786595547334133957510051373483198345016130092476664617072759979544411418825323224370590915697195648516145831336019005572620396906869462462153536867484966465346283413886306432238648089602001616782454076738446234936149618504927414257528123025355272619970273797965168688313968628259350041085177572293906508974040852910529230930337444518498374084440612562375609620798789469552249214217724827181867789326600291202986926609100110402544166517891369887594891650270286604640009655281994959398671707335024850936759841809545428347519797179468939976779803956309448510333557653386389690007527399363474193623333813052883037883114530932337820629075265970256835517551206853286462908442062747124547659855819120412402635907474928733402990202473132352200631818732050877170316228352452375668060154443573442409170239780537038365773940581346779787945266342041494432025486697008463950027835023675365349541006050505314465623344532967370397989428087025615972392793652087528541719950567575887579412118934757757840836944030778788635286906166475280769021161944831568917358334382281464401862484864551283763324615953384823733680487532793077104432682990945290063088889819054987220305409514381226755893477023371910831602165326726614226796275846255323364745641837629791503447193570326001315714435037387646117687115307494800697881153538243414451517563865320603699324156154032783047667022025895806955230713443494530949503766402404968731370676476736695560468960885296784972940796806197559179541575992487561597252217789459506574210649661092184323948753212511360100448284393155493947571471934550881124592160233397485015531273639384425248541156247997969163538012218780687204431683783546704821380001688719446193149145436976760147575829451472282131986353434842246351449850191904650566435804635955199055406483735117318978738562692938812290977480543409946315652699885206520846229736560256693691950479466731361445503661449956257961856105789670920737242933585758465288261079590228755894985853517069719458076363394906303314050145427661034014864585853131913795406966702675200534452755932245095924892323348421305270750574234840385973059640108939111291694318557771781370598136051366709054910495023400590972514763217178279037556917208098650295525510235861769723340600125780948712450716994004305781460105805855621204657518988493096221068336632836451804883450187236655445142444663394257439975186603276261439803265780303235941582524987700009819386823123493733152496638336512941165588060479094024854435438556251500524761667338269044469420365903050710914210313848636595637131817603648365177634558670362989846688940637092927116001407422333726462398711266783222095795832627255112547446881988803942435759986615725217224399269338150831159722176954884914844821365543730180216822872665944116559610010963833111368981871308515998380128800478572127941216845008151379807852290746586696122972142992810694929162749725498720253631200540404736457518305630453571411714059374192893220904697270516

It actually does work. I am surprised that you can use bigfloat with complex numbers. The documentation on complex numbers for Julia seems to say that only Float64 and Int64 can be used for complex numbers. see https://docs.julialang.org/en/v1/manual/complex-and-rational-numbers/#Complex-Numbers-1

const decimalplaces = 100
const numofbits = Int(ceil(log(2,10) * decimalplaces))
setprecision(numofbits)

result = sqrt(big(3))/big(2)
println("sin(60 deg) = $result")

a = big(-1)/big(16);
b = big(1)/big(16) * im * sqrt(big(3));
c = big(1)/big(3);

println("sin(50 deg) = ",(a + b)^c + (a - b)^c |> real )
Starting Julia...
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _  |  |
  | | |_| | | | (_| |  |  Version 1.1.1 (2019-05-16)
 _/ |\__ _|_|_|\__ _|  |  Official https://julialang.org/ release
|__/                   |

sin(60 deg) = 0.866025403784438646763723170752936183471402626905190314027903489725966508454400018540573093378624287827
sin(50 deg) = 0.7660444431189780352023926505554166739358324570803952458540452846421553888568747235282292766805484935
1 Like

No, Julia’s Complex type is documented to work with any Real type.

1 Like