67 votes

The Pedant's Cosine

Operation Flashpoint scripting language, 165 157 bytes ...
Steadybox's user avatar
  • 16.5k
24 votes

Draw a graph of \$y=(-n)^x\$

TI-Basic, 26 21 bytes ~3→Xmin 3→Xmax Prompt N DrawF N^Xcos(πX Output for N=2:
Timtech's user avatar
  • 12.6k
22 votes

Black Box Trigonometry

Python 3.6.4 on Linux, 99 bytes Bit of a silly answer, but: lambda f:"asinh acos cos cosh atan atanh tan sin asin tanh sinh acosh".split()[hash(f(.029))%19%12] ...
orlp's user avatar
  • 39.1k
18 votes

Perimeter of Conway hexagon

Python 3, 89 87 69 68 bytes Thanks @xnor for finding a shorter expression, saving 1 byte! f=lambda a,b,c,n=3:n and(a+b+c)*(c*c/a/b-a/b-b/a+2)**.5+f(b,c,a,n-1) Try ...
Surculose Sputum's user avatar
15 votes

Draw a graph of \$y=(-n)^x\$

Bash + Gnuplot, 56 45 bytes (-11 bytes thanks to Noiralef!) gnuplot -e "se t png;p[-3:3]real((-$1)**x)">A Saves the resulting graph as a ...
R. Kap's user avatar
  • 4,908
14 votes

Print cos(2π/17) exactly

CJam (60 bytes) 1-4{"(- +sqrt( * -4* ))/2"S/@a*N/\a*}:F~'-\+WF'-\+W-4FWFF'/2 Online demo Output (with added newlines to avoid wrapping): ...
Peter Taylor's user avatar
  • 43.1k
14 votes

Draw a graph of \$y=(-n)^x\$

Python 3 with matplotlib, 103 72 bytes -12 bytes thanks to DSM (a module is installed alongside matplotlib called pylab with ...
Jonathan Allan's user avatar
13 votes

The Pedant's Cosine

05AB1E, 14 11 bytes FIn(NmN·!/O Try it online! Explanation ...
Emigna's user avatar
  • 53k
12 votes

Draw a graph of \$y=(-n)^x\$

Mathematica, 41 bytes Plot[Re[(-#)^x],{x,-3,3},PlotRange->All]& Output looks exactly as shown in the challenge except for the font of the numbers (which I ...
Martin Ender's user avatar
12 votes
Accepted

Draw a graph of \$y=(-n)^x\$

MATL, 22 18 16 bytes Thanks @LuisMendo for additional -2 bytes! ...
flawr's user avatar
  • 43.8k
12 votes

Draw a graph of \$y=(-n)^x\$

R, 29 bytes curve(Re((0i-scan())^x),-3,3) n is provided through stdin. Result for n=1: And for n=2:
plannapus's user avatar
  • 8,919
12 votes

Perimeter of Conway hexagon

Python 3, 64 bytes lambda*t:eval("+((-(%s-%s)**2+%s**2)/%s/%s)**.5"*3%(t*5))*sum(t) Try it online! Uses an adaptation of a formula by Surculose Sputum, written ...
xnor's user avatar
  • 145k
11 votes

Draw a graph of \$y=(-n)^x\$

MATLAB, 35 30 bytes x=-3:.01:3;@(n)plot(x,(-n).^x) This defines an anyonmous function. The output is via a new window with a resizable vector graphic output. ...
flawr's user avatar
  • 43.8k
11 votes

Are my triangles similar?

MATL, 15 12 bytes ,i4:)d|S]/da The program inputs two 3×1 vectors of complex numbers representing the coordinates; and outputs ...
Luis Mendo's user avatar
  • 104k
11 votes

Integers in cosine

Wolfram Language (Mathematica), 25 bytes This uses a trick: Mathematica doesn't expand Sin[51819] into a proper number even when ...
the default.'s user avatar
  • 8,415
10 votes

Write a Sine-Deriving Machine

Python, 42 bytes from math import* lambda x,n:sin(x+pi/2*n) Uses the fact that differentiating shifts the function by pi/2 ...
xnor's user avatar
  • 145k
10 votes

Draw a graph of \$y=(-n)^x\$

R, 30 bytes plot(Re((0i-n)^seq(-3,3,.05))) n = 1 n = 2
Konrad Rudolph's user avatar
10 votes

Draw a graph of \$y=(-n)^x\$

Excel VBA, 168 160 147 138 Bytes (cells as pixels at 100x scale) Saved 8 bytes thanks to KyleKanos Saved 22 bytes thanks to Taylor Scott ...
Engineer Toast's user avatar
10 votes

The Pedant's Cosine

Mathematica, 49 41 39 31 bytes Sum[(-#^2)^k/(2k)!,{k,0,#2-1}]& Old, more "fun" version: (39 bytes) ...
GamrCorps's user avatar
  • 7,582
10 votes

The Pedant's Cosine

MATL, 14 bytes U_iqE:2ep/YpsQ Try it online! Or verify all test cases. Explanation with example All numbers have double precision (this is the default). Consider ...
Luis Mendo's user avatar
  • 104k
10 votes

Approximate the Dottie number to arbitrary precision

MATL, 34 30 19 bytes 11 bytes off thanks to Sanchises! 48i:"'cos('wh41hGY$ The last decimal figures in the output may be off. However, the number of correct ...
Luis Mendo's user avatar
  • 104k
9 votes

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

MATL, 12 bytes yYy/X;0G0<?_ The result is in radians. Try it online! Or verify all test cases. Explanation MATL doesn't have an ...
Luis Mendo's user avatar
  • 104k
9 votes

The Pedant's Cosine

Jelly, 12 11 bytes ḶḤµ⁹*÷!_2/S Try it online! How? ...
Jonathan Allan's user avatar
9 votes

Integers in cosine

Ruby, 37 bytes ->n{(1..10**n).max_by{|k|Math.sin k}} Try it online! Minimising the difference between \$\sin(a)\$ and \$-\cos(a+k)\$ amounts to minimising \$|...
Dingus's user avatar
  • 11.2k
8 votes

The Pedant's Cosine

Jelly, 22 bytes -*ð×ø⁹*⁸²ð÷ø⁸Ḥ! ⁸R’Ç€S This is a full program which takes n as the first argument and x as the second. Explanation: ...
fireflame241's user avatar
  • 16.3k
8 votes

Approximate the Dottie number to arbitrary precision

dzaima/APL, 55 bytes ⎕←⊃{⍵,⍨-/P,((P÷⍨×)/¨(2×⍳N)⍴¨⊃⍵)÷!2L×⍳N}⍣{⍵≢∪⍵}P←10L*N←⎕ Using big integer (no big decimals!) arithmetic (where \$10^N\$ is the equivalent of ...
dzaima's user avatar
  • 20.2k
8 votes

Inverse trigonometric functions

Built-in solutions APL(Dyalog Unicode), 1 bytes SBCS Try it on APLgolf! Left argument chooses function: ...
8 votes

Inverse trigonometric functions

R, 45 bytes \(x,f,y=0:4e8/1e8)y[match(T,(f(y)-x)^2<1e-7)] Attempt This Online! with slightly reduced precision to enable it to run with ATO's reduced memory ...
Dominic van Essen's user avatar
8 votes

Inverse trigonometric functions

JavaScript (ES7), 94 bytes Probably not the golfiest way, especially for edge cases. Returns [atan(x), acos(x), asin(x)]. ...
Arnauld's user avatar
  • 192k
7 votes
Accepted

Matrix Trigonometry

Julia, 33 19 bytes A->reim(expm(A*im)) This is a function that accepts a 2-dimensional array of floats and returns a tuple of such arrays correponding to the ...
Alex A.'s user avatar
  • 24.6k

Only top scored, non community-wiki answers of a minimum length are eligible