{"id":429,"date":"2017-06-23T15:50:05","date_gmt":"2017-06-23T15:50:05","guid":{"rendered":"http:\/\/konrad.burnik.org\/wordpress\/?p=429"},"modified":"2024-06-23T15:52:28","modified_gmt":"2024-06-23T15:52:28","slug":"computable-sets-in-the-euclidean-plane-using-python","status":"publish","type":"post","link":"https:\/\/konrad.burnik.org\/wordpress\/computable-sets-in-the-euclidean-plane-using-python\/","title":{"rendered":"Computable Sets in the Euclidean plane using Python"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#####################################################################\n#\n# Implementing the notion of Computable Set in the euclidean plane \n#\n# Every weakly computable set in the euclidean plane is a set \n# of zeroes of some a computable function.\n#\n# Konrad Burnik, June 2017.\n#\n#####################################################################\n\nfrom math import *\nfrom decimal import *\nimport matplotlib.pyplot as plt\n\nclass ComputableSet:\n    '''A computable subset of the euclidean plane is given by its computable function representing it.'''\n    def f(self, x, y):\n        '''A function whose zeroes represent this computable set. \n           For example: def f(x, y): return x**2 + y**2 - 1 has zeroes which represents a unit circle.\n        '''\n        raise Exception(\"Not implemented!\")\n    \n    def points(self, k):\n        return [(x\/2**k, y\/2**k) \n                        for y in range(-2**k, 2**k + 1) \n                        for x in range(-2**k, 2**k + 1) \n                        if Decimal(-1) \/ Decimal(2**k) &lt; self.f(Decimal(x)\/Decimal(2**k), Decimal(y)\/Decimal(2**k)) &lt; Decimal(1) \/ Decimal(2**k)]  class Circle(ComputableSet):\n    def f(self, x, y):\n        return x**2 + y**2 - Decimal(1\/2)\nclass EllipticCurve(ComputableSet):\n    def f(self, x, y):\n        return x**2 + y**3 - Decimal(1\/2)<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def plot_set(s, k):\n    points = s.points(k)\n    x = list(map(lambda x : x[0], points))\n    y = list(map(lambda x : x[1], points))\n\n    plt.plot(x, y, 'ro')\n    plt.show()<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">class Circle(ComputableSet):\n    def f(self, x, y):\n        return x**2 + y**2 - Decimal(1\/2)<\/pre>\n<p><a href=\"http:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/circle.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-431\" src=\"http:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/circle-300x197.png\" alt=\"\" width=\"300\" height=\"197\" srcset=\"https:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/circle-300x197.png 300w, https:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/circle.png 384w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class EllipticCurve(ComputableSet):\n    def f(self, x, y):\n        return x**2 + y**3 - Decimal(1\/2)<\/pre>\n<p><a href=\"http:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/elliptic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-432\" src=\"http:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/elliptic-300x197.png\" alt=\"\" width=\"300\" height=\"197\" srcset=\"https:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/elliptic-300x197.png 300w, https:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/elliptic.png 384w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">class ComputableSetUnion(ComputableSet):\n    def __init__(self):\n        self.A = ComputableSet()\n        self.B = ComputableSet()\n        \n    def f(self, x, y):\n        return self.A.f(x, y) * self.B.f(x, y)\n<\/pre>\n<p><a href=\"http:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/union.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-433\" src=\"http:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/union-300x194.png\" alt=\"\" width=\"300\" height=\"194\" srcset=\"https:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/union-300x194.png 300w, https:\/\/konrad.burnik.org\/wordpress\/wp-content\/uploads\/2017\/09\/union.png 390w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style3 like-429 jlk' href='javascript:void(0)' data-task='like' data-post_id='429' data-nonce='b932f7ab63' rel='nofollow'><img class='wti-pixel' src='https:\/\/konrad.burnik.org\/wordpress\/wp-content\/plugins\/wti-like-post\/images\/pixel.gif' title='Like' \/><span class='lc-429 lc'>+1<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style3 unlike-429 jlk' href='javascript:void(0)' data-task='unlike' data-post_id='429' data-nonce='b932f7ab63' rel='nofollow'><img class='wti-pixel' src='https:\/\/konrad.burnik.org\/wordpress\/wp-content\/plugins\/wti-like-post\/images\/pixel.gif' title='Unlike' \/><span class='unlc-429 unlc'>0<\/span><\/a><\/div> <\/div> <div class='status-429 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>##################################################################### # # Implementing the notion of Computable Set in the euclidean plane # # Every weakly computable set in the euclidean plane is a set # of zeroes of some a computable function. # # Konrad Burnik, June 2017. # ##################################################################### from math import * from decimal import * import matplotlib.pyplot as plt class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_s2mail":"yes","footnotes":""},"categories":[4],"tags":[],"class_list":["post-429","post","type-post","status-publish","format-standard","hentry","category-computable-analysis"],"_links":{"self":[{"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":3,"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":443,"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/posts\/429\/revisions\/443"}],"wp:attachment":[{"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/konrad.burnik.org\/wordpress\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}