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!

## Comments

Sort by:

TopNewestNice problem! Here's my solution:

Language used:

PythonCore formula used:

sin((A+B)/2) = sin(A/2)cos(B/2) + cos(A/2)sin(B/2)Log in to reply

– Lokesh Sharma · 2 years, 5 months ago

Note: I have just included the implementation of sin(theta) as other 5 trigonometric functions can be evaluated given we have sin(theta).Log in to reply

I'm definitely doing this! Just kidding, I don't even know what a computer is. :D – Finn Hulse · 2 years, 5 months ago

Log in to reply

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. – Mardokay Mosazghi · 2 years, 5 months ago

Log in to reply

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. – Trevor B. · 2 years, 5 months ago

Log in to reply

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... – Vishal Sharma · 2 years, 5 months ago

Log in to reply

– Mardokay Mosazghi · 2 years, 5 months ago

Thanks didn't know about codeacademy really helpfulLog in to reply

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. – Amar Nath · 2 years, 5 months ago

Log in to reply

You can easily achieve a logarithmic number of operations and constant memory: Consider the binary representation of \(\frac{\theta}{30}\). This uses the half angle formula, \(\tan\frac\theta2=\frac{\sin\theta}{\cos\theta+1}\), though. (Which is easily derivable from the basics). Only using addition and substraction in the code will

neverbe useful enough, since we could ony represent linear intger combinations of the angles we are given, that is: Angles multiples of \(30^{\circ}\) . – Luis Rivera · 2 years, 5 months agoLog in to reply

python languagei have not learn. but the formula used is notcosine formula.i am sure. o. k – Amar Nath · 2 years, 5 months ago

Log in to reply