3

I'm making an infinite mathematical art graph and it requires calling all values in specific increments. Is there some way to call for, say, all odd integers or all multiples of π? Optimally, I would like to easily customise the increment and it MUST be in the form of an equation.

Ethan Chapman
  • 123
  • 10
  • What do you mean call? All of the odd integers are of the form 2n + 1 for n in R. You can make this a function easily but I think I'm missing something, – Zaros Sep 28 '16 at 22:19
  • @lordoftheshadows I need some equation which contains only the points (0,0), (x,0), (2x,0), (-x,0), etc. – Ethan Chapman Sep 28 '16 at 22:44
  • Come to think of it, the y-value of the points doesn't matter as long as it's consistent. – Ethan Chapman Sep 28 '16 at 22:45

2 Answers2

1

If you want to enumerate all integers in order of their absolute values, you can enumerate the function $$x_n = (-1)^n\lfloor n/2\rfloor$$ for indices $n\geq 1$, where $\lfloor\cdot\rfloor$ is the floor function. (In many computer languages, dividing a positive integer by $2$ will automatically apply the floor function, so you don't have to worry about it.) Here's how $x_n$ works: $$x_1 = (-1)^1\lfloor 1/2\rfloor=-1\times0 = 0$$ $$x_2 = (-1)^2\lfloor 2/2\rfloor=1\times1 = 1$$ $$x_3 = (-1)^3\lfloor 3/2\rfloor=-1\times1 = -1$$ $$x_4 = (-1)^4\lfloor 4/2\rfloor=1\times2 = 2$$ and so on: $(x_n)=(0,1,-1,2,-2,3,-3,4,-4,\ldots)$.

Then you can use this function to generate the related functions you're interested in. In particular, to enumerate odd integers, $$y_n=2x_n+1$$ or to enumerate multiples of $\pi$, $$z_n=x_n\pi$$ or more generally, for all values starting from $b$ with spacing $m$, $$w_n=mx_n+b$$

I do have some experience writing such code! In the illustration for this answer, I needed to enumerate integers in absolute-value order in a few places. It's not too unwieldy to work with.

That said, for your particular application, if you know the bounds for the values in advance, you can write simpler code. For example, let's say you need all multiples of $\pi$ in the range $[-400,400]$. Then you can just enumerate $\pi n$ for all integers $n$ in the range $\big[\lceil -400/\pi\rceil, \lfloor 400/\pi\rfloor\big]$, where $\lceil\cdot\rceil$ is the ceiling function. That's a simpler equation, and the bounds become a simple for-loop in many computer languages.

Chris Culter
  • 27,415
0

Well, I figured out an answer eventually. I took the equation $y=sin(x)$ and added the range $\{y=0\}$ to get $y=sin(x)\;\,\{y=0\}$, which contains the points $(\pi k,0)$ where $k$ is any integer. Therefore, to get the points $(kn,0)$ where $n$ is the desired interval and $k$ is any integer, one simply has to do $y=sin(\frac{nx}{\pi}) \;\, \{y=0\}$.

Ethan Chapman
  • 123
  • 10