Skip to main content

Questions tagged [trigonometry]

For challenges where trigonometry plays an important role.

Filter by
Sorted by
Tagged with
8 votes
6 answers
1k views

Inverse trigonometric functions

There are 3 (commonly used) trigonometric functions sin cos and tan each of these functions ...
bsoelch's user avatar
  • 6,035
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 ...
Yousername's user avatar
  • 4,080
15 votes
9 answers
1k views

Ptolemy's table of chords

Ptolemy's Almagest contains a table of chords that effectively served as the world's only comprehensive trigonometric table for over a millennium. In modern form it looks like this: \begin{array}{|l|...
Parcly Taxel's user avatar
  • 3,945
2 votes
0 answers
278 views

Compute the Three Dimensional Discrete Cosine Transform

Challenge I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine ...
JimmyHu's user avatar
  • 403
12 votes
10 answers
2k views

Integers in cosine

Integers in cosine From trigonometry we know that \$\sin(a) =-\cos(a + \frac{(4*m + 1)\pi}{2})\$ where \$a\$ is an angle and \$m\in\mathbb{Z}\$ (integer). The task For an input of a positive integer \$...
Gábor Fekete's user avatar
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 ...
Bubbler's user avatar
  • 78.4k
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 ...
Adám's user avatar
  • 31.1k
33 votes
15 answers
4k views

Black Box Trigonometry

Write a program or function that can distinguish the following 12 trigonometric functions: sin, cos, ...
Laikoni's user avatar
  • 26.3k
14 votes
21 answers
3k views

Distance between two points on the Moon

Given latitude/longitude of two points on the Moon (lat1, lon1) and (lat2, lon2), compute the distance between the two points in ...
mdahmoune's user avatar
  • 3,002
22 votes
2 answers
790 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, ...
Nissa's user avatar
  • 3,634
24 votes
24 answers
2k 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 ...
Wheat Wizard's user avatar
  • 100k
6 votes
7 answers
693 views

Solve sin(θ) = x in the range a ≤ θ ≤ b

Challenge Given a number, x where -1 ≤ x ≤ 1, and the integers a and ...
Beta Decay's user avatar
  • 23.4k
4 votes
6 answers
532 views

Compute the Discrete Cosine Transform

Implement the Discrete Cosine Transform (DCT). This may implemented as either a function or a program and the sequence can be given as either an argument or using standard input. Your program must be ...
user avatar
2 votes
18 answers
1k views

Find the coterminal angle on [0, 2π)

This challenge is very simple: Given an angle measure in degrees or radians (your choice), output the angle between 0 and 2π non-inclusive [0º, 360º) that is coterminal with it. Input A positive ...
Daniel's user avatar
  • 6,719
33 votes
43 answers
5k 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!} - \...
Silvio Mayolo's user avatar
36 votes
21 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 ...
Beta Decay's user avatar
  • 23.4k
11 votes
14 answers
2k views

Help me I'm lost in the ocean!

Introduction Today I went fishing alone with my canoe, unfortunately I fell asleep and the stream brought me away, I lost my oars, now it's night and I am lost in the ocean! I can't see the coast so ...
Mario's user avatar
  • 3,091
23 votes
7 answers
885 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 ...
Ando Bando's user avatar
5 votes
16 answers
966 views

Write a Sine-Deriving Machine

The Challenge Your challenge is to write a program that evaluates the following function: f(x, t) = d^x / dt^x (sin t) That is, the x-th derivative of sin t. In case you aren't familiar with ...
Meow Mix's user avatar
  • 923
17 votes
15 answers
1k views

g​o​l​f​ ​a​t​a​n​2

Sometimes it really is a struggle to convert Cartesian coordinates (x,y) to Polar coordinates (r,phi). While you can calculate <...
flawr's user avatar
  • 43.9k
15 votes
9 answers
4k views

Matrix Trigonometry

Introduction The two most common trigonometric functions, sine and cosine (or sin and ...
user avatar
6 votes
12 answers
1k views

Print cos(2π/17) exactly

One way to construct a regular heptadecagon starts with drawing a horizontal line of length 1 from the center to a vertex. Then the distance along that line from ...
anatolyg's user avatar
  • 13.9k
9 votes
1 answer
8k views

Print sin, cos, and tan of special angles

In trigonometry, there are certain angles known as "special angles". This is because when you take sin, cos or tan of one of these angles, you get a result that is easy to remember because it is a ...
DJMcMayhem's user avatar
  • 59.6k
6 votes
2 answers
659 views

Make a Surfin' Word

Your goal is to map a piece of text to a sine curve of the form: a sin ( mx - b ) Where a and m are non-zero rational numbers, b is a rational number, and the calculations are in radians. It doesn't ...
geokavel's user avatar
  • 6,676
23 votes
3 answers
850 views

Finding Exclusive Area in Circle Intersections

Here's a deceptively challenging geometry puzzle for you! Given a circle A, and n other circles ...
BrainSteel's user avatar
  • 5,490
16 votes
2 answers
3k views

Spherical excess of a triangle

Spherical excess of a triangle As we all know, the sum of angles of any planar triangle is equal to 180 degrees. However, for a spherical triangle, the sum of angles is always greater than 180 degrees....
pawel.boczarski's user avatar
44 votes
47 answers
9k 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 ...
user avatar
13 votes
18 answers
2k views

Find the angle between two points

Given two points A and B, find the angle from line AO to line ...
Alien G's user avatar
  • 437
17 votes
3 answers
612 views

Regular Polygrams

Given the number of vertices n ≥ 3 and the "step size" 1 ≤ m < n/2 (indicating the distance between two connected vertices), ...
Martin Ender's user avatar
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 ...
Zach Gates's user avatar
  • 6,690
10 votes
3 answers
2k views

Help me with trigonometry!

Thank you guys so much for your help with calculus. Now I need some help with my upcoming trigonometry test. On the test, I'll need to simplify expressions. I’ll be given input like ...
Ypnypn's user avatar
  • 10.9k
6 votes
2 answers
754 views

Output an Animated Trigonometry Circle

I want you to write a program that outputs a trigonometry circle like the one below. I also want you to animate this circle, having the sine line move along the circumference with the other lines move ...
Beta Decay's user avatar
  • 23.4k
18 votes
5 answers
4k views

Fast Trig Calculation

Fast Trigonometry Calculations Your task is to create a program which can calculate the sine, cosine and tangent of an angle in degrees. Rules No built-in trigonometry functions (not even secant, ...
user avatar
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 ...
Gaurang Tandon's user avatar
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 ...
Taconut's user avatar
  • 903
13 votes
3 answers
2k views

Solving triangles with trigonometry

Time to dig up your old trigonometry notes from high school! The challenge is to solve the unknown sides and angles of different triangles. And as is customary in code golf, the smallest working code ...
user avatar