65

Operation Flashpoint scripting language, 165 157 bytes F={x=_this select 0;n=_this select 1;i=0;r=0;while{i<n*2}do{r=r+x^i/(i call{c=_this;j=c-1;while{j>0}do{c=c*j;j=j-1};if(c<1)then{c=1};c})*(-1)^(i/2);i=i+2};r} Call with: hint format["%1\n%2\n%3\n%4\n%5\n%6\n%7", [0.0, 1] call f, [0.5, 1] call f, [0.5, 2] call f, [0.5, 4] call f,...


23

Processing, 101 97 96 bytes 4 bytes thanks to Flambino. 1 byte thanks to Kritixi Lithos. float d;void draw(){background(-1);stroke(#800080);d+=PI/1800;point(50+cos(d)*38,50+sin(d)*38);} This creates a default 100 by 100 pixel window with the required animation. Disclaimer: that image is not a GIF. Don't stare at it for a minute.


22

TI-Basic, 26 21 bytes ~3→Xmin 3→Xmax Prompt N DrawF N^Xcos(πX Output for N=2:


22

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] Requires the trigonometric functions to be one out of the built-in cmath module for complex in/output.


21

LOGO 37 - 25% = 27.75 (with variables) REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S] LOGO 49 - 25% = 36.75 (as a function) TO P:R:S REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S]END Triangle Called with variables Make "R 100 Make "S 3 REPEAT:S[FD:R*2*sin(180/:S)RT 360/:S] Used as a function P 100 3 Square Called with variables Make "R 100 Make "S 4 REPEAT:S[FD:R*...


21

TI-BASIC, 13 bytes For TI-83+/84+ series calculators. Degree Input Y min(ΔList(R►Pθ(Ans,∟Y To use this program, enter the list {x1,x2} through the Ans variable, and {y1,y2} at the prompt.


18

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 it online! A recursive function, takes in 3 sides of the triangle as input. Recursion is used to repeats the function 3 times, each time with the positions of a,b,c swapped in order to calculate ...


17

Mathematica, 40 - 25% = 30 ListPolarPlot[r&~Array~n]/.PointPolygon


16

Mathematica, 142 bytes Graphics[{Circle[],Line/@{{{c=Cos@t,0},{c,s=Sin@t},{0,s}},{{0,0},{1/c,0},{0,1/s},{0,0},{c,s}}},},PlotRange->{r={-2,2},r}]~Animate~{t,0.01,2Pi} I'm plotting for angles between 0.01 and 2π which conveniently skips any angles where one of the lines would become actually infinite. You can make a GIF from it by replacing Animate with ...


16

QB64, 79 bytes QB64 is a QBasic emulator that adds some nice features. This program uses one (CLS,15) that isn't supported by vanilla QBasic. SCREEN 7 DO T=TIMER/9.55 PSET(COS(T)*75+99,SIN(T)*75+99),5 PLAY"c8" CLS,15 LOOP This is very loud. It uses the PLAY command to halt execution for a short while before clearing the screen; otherwise the pixel will ...


15

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 png image named A in the current working directory. Example Outputs For n = 1: For n = 2:


14

HTML, 235 290 295 354 347 bytes <a><style>*{position:absolute;margin:0;box-sizing:border-box}body{height:100vh;width:100vh}a{left:12.5%;top:50%;width:75%;height:1px;border-left:1px solid purple;animation:r 60s infinite linear}@keyframes r{100%{transform:rotate(360deg Save as a .html file and open in a browser, that doesn't need vendor prefixes, ...


14

Java, 449 443 439 bytes Because I've always had stupid ideas. Like golfing in Java ;) . import java.awt.*;import javax.swing.*;class F extends JFrame{F()throws Exception{setContentPane(new P());setSize(400,400);setVisible(0<1);for(;;Thread.sleep(100))repaint();}class P extends JPanel{double c;public void paintComponent(Graphics g){g.setColor(new Color(...


14

TI-BASIC, 44 bytes For the TI-84+ CSE/CE calculators, which support some limited BASIC color graphics. AxesOff ZSquare While rand Pt-Off(imag(Ans),real(Ans 7.5e^(-i6startTmr° Pt-On(imag(Ans),real(Ans),13 End The color here is magenta, or color 13 (one can also use the MAGENTA token). I use rand instead of 1 for the infinite loop condition to provide a tiny ...


14

Python 2, 631 bytes from cmath import* C=input() O,R=C[0] def I(p,r,q,s): try:q-=p;d=abs(q*q);x=(r*r-s*s+d)/d/2;return[p+q*(x+z*(r*r/d-x*x)**.5)for z in-1j,1j] except:return[] S=sorted V=S(i.real for p,r in C for c in C for i in[p-r,p+r]+I(p,r,*c)if-R<=(i-O).real<=R) A=pi*R*R for l,r in zip(V,V[1:]): H=[] for p,t in C: try: for s in-1,1:a,...


14

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): (--(--(-1+sqrt(1*1-4*-4))/2+sqrt(-(-1+sqrt(1*1-4*-4))/2*-(-1+sqrt(1*1-4*-4))/2-4*-1) )/2+sqrt(-(--(-1+sqrt(1*1-4*-4))/2+sqrt(-(-1+sqrt(1*1-4*-4))/2*-(-1+sqrt(1*1-4*-4))/ 2-4*-1))/2*-(--(-1+sqrt(1*1-4*-4))/2+sqrt(-(-1+...


14

Python 3 with matplotlib, 103 72 bytes -12 bytes thanks to DSM (a module is installed alongside matplotlib called pylab with the necessary functionality "making Python in a repl more like Matlab" - odd, but true!) -18 more as a result (pylab has many numpy functions too!) -1 byte thanks to Ajasja (replacing arange(-60,61)/20+0j with arange(121)/20-3+0j) ...


13

Mathematica, 102 101 94 bytes Animate[Graphics[{White,Disk[],{Purple,Point[{0,1}]}}~Rotate~-t],{t,0,2π},DefaultDuration->60] Creates a white circle that is hidden and places a point that follows its edge from 0 to 2π. Mathematica's DefaultDuration option let's me set it to complete a loop every 60 seconds. Here's a sped up version of the output: EDIT: ...


13

Java, 339 308 289 287 bytes import java.awt.*;class F extends Frame{{setSize(200,200);show();}int c;public void paint(Graphics g){g.setColor(new Color(8388736));g.fillRect((int)(99+Math.sin(--c*.01)*75),(int)(99+Math.cos(c*.01)*75),1,1);for(int i=0;++i<62864;)paint();}public static void main(String[] x){new F();}} Thanks to @Peter Lenkefi, whose great ...


13

05AB1E, 14 11 bytes FIn(NmN·!/O Try it online! Explanation F # for N in [0 ... n] do In # push (x^2) ( # negate Nm # raise to the Nth power N·! # push (2*N)! / # divide O # sum


12

Java 8 : 533 322 - 25% = 241.5 Well, it's Java :/ Just draws lines, point to point. Should work for any arbitrarily sized polygon. Cut it down quite a bit from original size. Huge credit to Vulcan (in comments) for the golf lesson. import java.awt.*;class D{public static void main(String[]v){new Frame(){public void paint(Graphics g){int i=0,r=Short.valueOf(...


12

Pyth, 11 bytes .t-FPM.jMQ6 Demonstration Input is given in the format: [[Bx, By], [Ax, Ay]] If it is desired that A comes first, this can be changed for 1 byte. Explanation: .t-FPM.jMQ6 Implicit: Q = eval(input()) .jMQ Convert input pairs to complex numbers. PM Take their phases (angles in the complex plane). -F ...


12

MATL, 22 18 16 bytes Thanks @LuisMendo for additional -2 bytes! I_.01I3$:i_y^&XG I_ push 3 and negate .01 push 0.01 I push 3 3$: generate the list [-3,-2.99,-2.98,...,3] i_y^ calculate (-input)^(list) ...


12

R, 29 bytes curve(Re((0i-scan())^x),-3,3) n is provided through stdin. Result for n=1: And for n=2:


11

TeX/TikZ (60 – 80.25) File polygon.tex: \input tikz \tikz\draw(0:\r)\foreach\!in{1,...,\n}{--(\!*360/\n:\r)}--cycle;\bye (80 bytes) The radius and number of sides are provided as variables/macros \r and \n. Any TeX unit can be given for the radius. Without unit, the default unit cm is used. Examples: \def\r{1}\def\n{5} % pentagon with radius ...


11

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 left.


11

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. MATLAB's plot automatically ignores the imaginary part of the y-coordinates as long as your provide corresponding x-coordinates.The following output is for n=3.


11

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 suspect was created with Wolfram Alpha).


11

MATL, 15 12 bytes ,i4:)d|S]/da The program inputs two 3×1 vectors of complex numbers representing the coordinates; and outputs 0 for similar, 1 for not similar. Try it online! Or verify all test cases. Explanation The code checks if the side lengths, sorted for each triangle, are proportional between the two triangles. , % Do twice i % Take ...


11

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 so that the variables a,b,c repeat in a cycle when the formula is read left to right. +((-(a-b)**2+c**2)/a/b)**.5+((-(c-a)**2+b**2)/c/a)**.5+((-(b-c)**2+a**2)/b/c)**.5 This lets us insert the ...


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