# [PD] Prime limit sliders

Mathieu Bouchard matju at artengine.ca
Mon Apr 4 10:09:54 CEST 2005

```On Sun, 3 Apr 2005, Chuckk Hubbard wrote:

> Hi, Mathieu.  This sounds pretty intense, but maybe because I haven't
> gotten that far into Pd.  That is dead on, though, to just have the
> slider go smoothly decimal and use the closest value in the table. That
> would work perfectly.

Now that I think of it, it's also possible to use a radiobutton or a
slider or a numbox, that indexes into the table of all possible values, so
that you access the ratios by their order in the table.

In the example you gave, the slider would have 9*3*3*3=243 positions.

> Might it be less involved to have the possible values of the sliders
> determined by a prime to the power of -1 to 1

In Number Theory one would say that you are working with ratios of
squarefree number. A squarefree number is one that is not divisible by a
square number: in other words it's not divisible by a prime power beyond
an exponent of just one.

> (maybe throwing 9 in as a "prime"),

This would cause duplicates because 3 is already there.

I don't think this would make things any easier unless I'm missing
something not too obvious.

One can use an extension of the Euclidean GCD algorithm to find a sequence
of rational approximations to a given float, and those approximations are
really consider it in my last email because I'm not aware of any way to
make it not use a prime more than a certain number of times, be it three
times or even just one time.

BTW I just wrote a Ruby program that prepares a sorted list of ratios. It
generates output like this:

[...]
7/495 = 0.0141414141414141
1/63 = 0.0158730158730159
5/297 = 0.0168350168350168
7/405 = 0.0172839506172839
1/55 = 0.0181818181818182
11/567 = 0.0194003527336861
5/231 = 0.0216450216450216
1/45 = 0.0222222222222222
[...]

You will need the Ruby interpreter.
It's cross-platform Linux/Win32/OSX/etc).
Here's the full source code:

------------------8<--------cut-here--------8<------------------
require "rational"
module Enumerable
def mult(p,n)
(-n..+n).map {|i| map{|x| x*Rational(p,1)**i }}.flatten
end
end
[Rational(1,1)].mult(3,4).mult(5,1).mult(7,1).mult(11,1).sort.map {|x|
puts "#{x} = #{x.to_f}"
}
------------------8<--------cut-here--------8<------------------

.-----------------------------------------------------------------.
/  The Diagram is the Program (TM) ,--------------------------------}
{----------------------------------"     http://artengine.ca/matju  /
`-----------------------------------------------------------------'

```
{"ft_lang_label":"__label__en","ft_lang_prob":0.81915367,"math_prob":0.8358406,"size":2680,"snap":"2020-24-2020-29","text_gpt3_token_len":724,"char_repetition_ratio":0.17825112,"word_repetition_ratio":0.0,"special_character_ratio":0.40932837,"punctuation_ratio":0.14229248,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9898531,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-27T15:40:03Z\",\"WARC-Record-ID\":\"<urn:uuid:a37d4365-f915-4d90-beeb-9abb586f9338>\",\"Content-Length\":\"5212\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8dbf70f2-be95-4afc-86fb-8bf64e00a5e5>\",\"WARC-Concurrent-To\":\"<urn:uuid:037b8da4-acb3-4306-b42d-4bc7c89f7613>\",\"WARC-IP-Address\":\"193.170.191.182\",\"WARC-Target-URI\":\"https://lists.puredata.info/pipermail/pd-list/2005-04/027257.html\",\"WARC-Payload-Digest\":\"sha1:QTENAV4DVXU6TD3JDDYDANP3J5AUYAGE\",\"WARC-Block-Digest\":\"sha1:2ZSI6HKLQZWHQXDSHTWUHWBAU77NRT4Q\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347394756.31_warc_CC-MAIN-20200527141855-20200527171855-00303.warc.gz\"}"}