Hi! I have a challenge for the programmers out there. Using only sine, cosine, their addition and subtraction formulas, and the values \(\sin\left(0^\circ\right),\) \(\sin\left(30^\circ\right),\) \(\sin\left(90^\circ\right),\) \(\cos\left(0^\circ\right),\) \(\cos\left(60^\circ\right),\) and \(\cos\left(90^\circ\right),\) write a program that will find the value of all six of the trigonometric functions (where defined) to three decimal places for all \(\theta\in[0^\circ,360^\circ).\) Use any language you want, and post your code below. Good luck!
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Nice problem! Here's my solution:
Language used: Python
Core formula used: sin((A+B)/2) = sin(A/2)cos(B/2) + cos(A/2)sin(B/2)
Log in to reply
Note: I have just included the implementation of sin(theta) as other 5 trigonometric functions can be evaluated given we have sin(theta).
I'm definitely doing this! Just kidding, I don't even know what a computer is. :D
Did you already create one , it seems that you already know it it. Can you post your code after some replies of codes from problems.May I ask you how are good at computer science while you said you started recently, what resources do you use.@Trevor B.
Log in to reply
I might be able to do this if I tried, but I haven't yet. I'm way too busy nowadays, and this would take me a couple hours to do.
Codecademy and lots of Google searches is how I learned programming.
This is actually an area programming I haven't had experience with before, generating a bunch of data instead of finding one concrete answer. Additionally, I didn't learn how to make the box come up to input values and have the program pick a specific value stored.
Log in to reply
Thanks didn't know about codeacademy really helpful
Hi,
Although I actually don't know anything about programming till date. But I have become all the way curious about learning. Could you pls suggest me where to start from. ( literally from the basics) Thanks....! Anyways I have signed up for Codeacademy...
python languagei have not learn. but the formula used is notcosine formula.i am sure. o. k
You can easily achieve a logarithmic number of operations and constant memory: Consider the binary representation of 30θ. This uses the half angle formula, tan2θ=cosθ+1sinθ, though. (Which is easily derivable from the basics). Only using addition and substraction in the code will never be useful enough, since we could ony represent linear intger combinations of the angles we are given, that is: Angles multiples of 30∘ .
It is not the matter of challenging. once i am calculating some value of trigonometry function oo calculator but suddenly i find this that sum of two angle that is sin or cos whose sum is 90 and diference is 90.are equal to 1 ( one). I want your comments can it be prove by right triangle method. All the best good night.
I think there is a numerical algorithm that calculators use to do what you just said.