OU blog

Personal Blogs

Valentin Fadeev

Return of the recurrencies

Visible to anyone in the world
Edited by Valentin Fadeev, Thursday, 15 Apr 2010, 00:21

I have always been amazed by the power of recurrent formulas. Although they are likely to cause stack overflow (this was the first occasion when i learned what it actually meanssmile), used carefully they deliver beautiful results.

I once amused myself drawing stellar polygons of arbitrary number of vertices. That required a simple parametrized procedure that produced a sequence of vertices to be connected with line segments.

Starting with the formula of the n-th root of complex number (of unitary modulus):

MathJax failure: TeX parse error: Extra open brace or missing close brace

to get the coordinates of the n vertices, i found the following way to produce the path sequence:

equation left hand side v sub k equals right hand side open v sub k minus one plus d close mod n

where v sub k is the number of the vertex and d ( one less than or equals d less than or equals open n divided by two close ) is the number of vertices "skipped" in one step.

So the procedure looks roughly like this:

 

x0=cos(phi/n)

y0=sin(phi/n)

do

vn=(v+d) mod n

x1=cos((phi+2*pi*vn)/n)

y1=sin((phi+2*pi*vn)/n)

line(x0,y0)-(x1,y1)

v=vn

x0=x1

y0=y1

loop until vn=0

I even considered the idea of enumerating the possible outcomes for different pairs of (n,d), but put it on the shelf then..

Permalink
Share post

This blog might contain posts that are only visible to logged-in users, or where only logged-in users can comment. If you have an account on the system, please log in for full access.

Total visits to this blog: 77439