Julia 0.6 with Plots.jl, 46 bytes
using Plots
~n=plot(real((0im-n).^(-3:.05:3)))
This needed a Julia representation!
Not much to golf here though, except (ab)using operator overloading to save bytes on function defintion, and using 0im-n
to make the input number complex where I might usually have used Complex(n)
. That's necessary because in Julia, for type stability reasons, the ^
operator returns Complex results only when the input is Complex itself. So here we make it a complex number by adding 0im
ie. 0i.
One cool thing about the Plots.jl package is that it automatically chooses the backend to use based on what plotting packages you have installed and where you're running the plot
command from. The above plot was created with the GR backend, but if I didn't have that installed (or if I explicitly ran a plotly()
command like I did for this), it would have used the more interactive Plotly backend and output this (which looks a tiny bit nicer IMO):
There's even a UnicodePlots backend, to print a plot in the terminal (or save to a text file) using Unicode characters and color codes. SE keeps messing up the plot alignment if I try to directly paste it though, so here's a terminal screenshot:
PS: The alternate formula, Re((−n)x)=nxcos(πx), comes out to the same length:
using Plots
~n=plot(n.^(x=-3:.05:3).*cospi(x))
ASCII art is disallowed.
(ಥ﹏ಥ)