Questions tagged [trigonometry]
For challenges where trigonometry plays an important role.
37 questions
47
votes
52
answers
10k
views
A single pixel moving in a circular path
This is a graphical output challenge where the task is to give the shortest code per language.
Task
Your code should plot a single purple pixel (hex value #800080 or
rgb(128, 0, 128)), moving ...
36
votes
45
answers
6k
views
The Pedant's Cosine
My boss just told me to write a cosine function. Being a good math geek, my mind immediately conjured the appropriate Taylor Series.
$$\cos(x) = \frac 1 {0!} - \frac {x^2} {2!} + \frac {x^4} {4!} - \...
36
votes
22
answers
6k
views
Draw a graph of \$y=(-n)^x\$
Challenge
Given an input of an integer, \$n\$ (where \$0<n<50\$), output the graph of \$y=\mathrm{Re}((-n)^x)\$ from \$x = -3\$ to \$x = 3\$ inclusive.
Where \$\mathrm{Re}(p)\$ is the real part ...
33
votes
15
answers
4k
views
Black Box Trigonometry
Write a program or function that can distinguish the following 12 trigonometric functions: sin,
cos,
...
26
votes
25
answers
3k
views
Approximate the Dottie number to arbitrary precision
The Dottie number is the fixed point of the cosine function, or the solution to the equation cos(x)=x.1
Your task will be to make code that approximates this constant. Your code should represent a ...
25
votes
11
answers
2k
views
Perimeter of Conway hexagon
Background
Given a triangle \$ABC\$, extend its three sides by the opposite side length, as shown in the figure below. Then the six points surprisingly lie on a circle called the Conway circle, whose ...
25
votes
12
answers
2k
views
A Sine of Greatness
Introduction
Everyone's heard of sine (sin), cosine (cos), tangent (tan), cotangent (cot), secant (sec), and cosecant (csc). Nearly every angle has them.
Far less known, or remembered, are the ...
25
votes
14
answers
3k
views
Are my triangles similar?
Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ...
24
votes
29
answers
10k
views
Draw a regular polygon
The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex).
The number of sides and the radius can be ...
23
votes
3
answers
932
views
Finding Exclusive Area in Circle Intersections
Here's a deceptively challenging geometry puzzle for you!
Given a circle A, and n other circles ...
23
votes
7
answers
975
views
Distance Between Two Points Travelling on a Polar Graph Chart
Brief Problem Explanation
Write a program to find the minimum distance between two points traveling only on rays emanating from the origin and circles centered on the origin.
Explanation of Premise
...
22
votes
2
answers
851
views
Expand Sine and Cosine
Trigonometry has LOTS of identities. So many that you can expand most functions into sines and cosines of a few values. The task here is to do that in the fewest bytes possible.
Identity list
Well, ...
21
votes
18
answers
5k
views
Let the trigonometry begin!
Introduction:
The sine of \$x\$ is given by the formula:
$$\sin(x) = x - \frac {x^3}{3!} + \frac {x^5}{5!} - \frac {x^7}{7!} + \frac {x^9}{9!} - \frac {x^{11}}{11!} + \cdots$$
The cosine of \$x\$ is ...
20
votes
9
answers
2k
views
Cutting a Circular Pizza Vertically
Most people would cut circular pizzas into circular sectors to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same ...
18
votes
15
answers
2k
views
golf atan2
Sometimes it really is a struggle to convert Cartesian coordinates (x,y) to Polar coordinates (r,phi). While you can calculate <...