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

**URL:** https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039
**Category:** New to Julia
**Created:** [June 7, 2019, 10:09am UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039 "2019-06-07T10:09:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)
#### Post date: [June 7, 2019, 10:09am UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/1 "2019-06-07T10:09:33Z")

</div>

If I want to find the value of sin(60 degrees), I can calculate from the exact value  
 ![19%20PM](https://global.discourse-cdn.com/julialang/original/3X/1/d/1dca1c648722f5b5c7b166920d2db0c12662c4d2.png)

and calculate 100 decimal places using

```julia
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

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/0/e/0e505bf9707bc21b4d264e3ba17e4316f1f2ebd1.png)

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [June 7, 2019, 10:17am UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/2 "2019-06-07T10:17:20Z")

</div>

Something like

```julia
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?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [June 7, 2019, 12:01pm UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/3 "2019-06-07T12:01:51Z")

</div>

> [@StevenSiew](#):
>
> No cheating by calling the sin function.

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

---

<div class="post-metadata">

### Author: ![dkarrasch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkarrasch/32/7410_2.png) [@dkarrasch](https://discourse.julialang.org/u/dkarrasch)
#### Post date: [June 7, 2019, 12:11pm UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/4 "2019-06-07T12:11:45Z")

</div>

Yes, the purpose is unclear. Why not simply

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

```

?

---

<div class="post-metadata">

### Author: ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)
#### Post date: [June 7, 2019, 2:31pm UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/5 "2019-06-07T14:31:57Z")

</div>

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

> **[sin(50) - Wolfram|Alpha](https://www.wolframalpha.com/input/?i=sin%2850%29)**
>
> Wolfram|Alpha brings expert-level knowledge and capabilities to the broadest possible range of people—spanning all professions and education levels.

```julia
0.7660444431189780352023926505554166739358324570803952458540452846421553888568747235282292766805484934499624883998700455341954248316333490711841864889023860281082594782010899261924361273893782904078770273006354688599137325083942815336330350954685107618325549288375883429890386354276785479071197343786221265745844798601091903854036409358705798621426631952466977531043261972745910816640595291004784330497183410104807025160539738339882790832858732629391480897657539603952497173690488784768527075866522481047541645808795123966392345773943563388083848396701961681348379456980904427582362573317984311518696512834851104919855096784185294162424820133028323621286860806014406303017834545192236924816164399454116865865343693163091111786595547334133957510051373483198345016130092476664617072759979544411418825323224370590915697195648516145831336019005572620396906869462462153536867484966465346283413886306432238648089602001616782454076738446234936149618504927414257528123025355272619970273797965168688313968628259350041085177572293906508974040852910529230930337444518498374084440612562375609620798789469552249214217724827181867789326600291202986926609100110402544166517891369887594891650270286604640009655281994959398671707335024850936759841809545428347519797179468939976779803956309448510333557653386389690007527399363474193623333813052883037883114530932337820629075265970256835517551206853286462908442062747124547659855819120412402635907474928733402990202473132352200631818732050877170316228352452375668060154443573442409170239780537038365773940581346779787945266342041494432025486697008463950027835023675365349541006050505314465623344532967370397989428087025615972392793652087528541719950567575887579412118934757757840836944030778788635286906166475280769021161944831568917358334382281464401862484864551283763324615953384823733680487532793077104432682990945290063088889819054987220305409514381226755893477023371910831602165326726614226796275846255323364745641837629791503447193570326001315714435037387646117687115307494800697881153538243414451517563865320603699324156154032783047667022025895806955230713443494530949503766402404968731370676476736695560468960885296784972940796806197559179541575992487561597252217789459506574210649661092184323948753212511360100448284393155493947571471934550881124592160233397485015531273639384425248541156247997969163538012218780687204431683783546704821380001688719446193149145436976760147575829451472282131986353434842246351449850191904650566435804635955199055406483735117318978738562692938812290977480543409946315652699885206520846229736560256693691950479466731361445503661449956257961856105789670920737242933585758465288261079590228755894985853517069719458076363394906303314050145427661034014864585853131913795406966702675200534452755932245095924892323348421305270750574234840385973059640108939111291694318557771781370598136051366709054910495023400590972514763217178279037556917208098650295525510235861769723340600125780948712450716994004305781460105805855621204657518988493096221068336632836451804883450187236655445142444663394257439975186603276261439803265780303235941582524987700009819386823123493733152496638336512941165588060479094024854435438556251500524761667338269044469420365903050710914210313848636595637131817603648365177634558670362989846688940637092927116001407422333726462398711266783222095795832627255112547446881988803942435759986615725217224399269338150831159722176954884914844821365543730180216822872665944116559610010963833111368981871308515998380128800478572127941216845008151379807852290746586696122972142992810694929162749725498720253631200540404736457518305630453571411714059374192893220904697270516

```

---

<div class="post-metadata">

### Author: ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)
#### Post date: [June 7, 2019, 10:34pm UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/6 "2019-06-07T22:34:29Z")

</div>

> [@kristoffer.carlsson](#):
>
> (a + b)^c + (a - b)^c

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 [Complex and Rational Numbers · The Julia Language](https://docs.julialang.org/en/v1/manual/complex-and-rational-numbers/#Complex-Numbers-1)

```julia
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 )

```

```julia
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

```

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [June 7, 2019, 10:37pm UTC](https://discourse.julialang.org/t/how-do-i-find-the-value-of-sin-50-degrees/25039/7 "2019-06-07T22:37:13Z")

</div>

> [@StevenSiew](#):
>
> 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.

No, Julia’s `Complex` type is [documented to work with any `Real` type](https://docs.julialang.org/en/v1/base/numbers/#Base.Complex).
