Can we plot Tupper's self-referential formula?

207 views
Skip to first unread message

Sumith 1896

unread,
May 12, 2015, 12:00:35 PM5/12/15
to sy...@googlegroups.com

Hi there,
I just happened to come across this very interesting formula known as
Tupper’s self-referential formula.
The wiki article says that is a formula defined by Jeff Tupper that,
when graphed in two dimensions at a very specific location in the plane, can be “programmed” to visually reproduce the formula itself.
Matlab is capable to plot this. It was very interesting to see the plot.
Is our plotting module capable to plot this?
If yes, could you say how?
Cheers
Sumith

Ondřej Čertík

unread,
May 12, 2015, 1:22:14 PM5/12/15
to sympy
Good question, we should be able to do it. I found more info about this:

http://www.quora.com/How-did-Jeff-Tupper-come-up-with-his-%E2%80%9Cself-referential%E2%80%9D-formula

With some other examples.

Ondrej

Peter Brady

unread,
May 12, 2015, 1:29:33 PM5/12/15
to sy...@googlegroups.com
Just tried:

In [1]: from sympy import *

In [3]: x,y = symbols("x y")

In [11]: rhs = floor(Mod(floor(y/17)*2**(-17*floor(x)-Mod(floor(y),17)),2))

In [14]: s = "960 939 379 918 958 884 971 672 962 127 852 754 715 004 339 660 129 306 651 505 519 271 702 802 395 266 424 689 642 842 174 350 718 121 267 153 782 770 623 355 993 237 280 874 144 307 891 325 963 941 337 723 487 857 735 749 823 926 629 715 517 173 716 995 165 232 890 538 221 612 403 238 855 866 184 013 235 585 136 048 828 693 337 902 491 454 229 288 667 081 096 184 496 091 705 183 454 067 827 731 551 705 405 381 627 380 967 602 565 625 016 981 482 083 418 783 163 849 115 590 225 610 003 652 351 370 343 874 461 848 378 737 238 198 224 849 863 465 033 159 410 054 974 700 593 138 339 226 497 249 461 751 545 728 366 702 369 745 461 014 655 997 933 798 537 483 143 786 841 806 593 422 227 898 388 722 980 000 748 404 719".replace(" ", "")

In [16]: k = S(s)

In [17]: plot_
plot_backends  plot_implicit  

In [17]: plot_implicit(S(1/2) < rhs, (x, 0, 106), (y, k, k+17))
/home/ptb/gitrepos/sympy/sympy/plotting/plot_implicit.py:84: UserWarning: Adaptive meshing could not be applied to the expression. Using uniform meshing.
  warnings.warn("Adaptive meshing could not be applied to the"

I then got a lot of errors that started with:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/ptb/gitrepos/sympy/sympy/plotting/experimental_lambdify.py in __call__(self, *args)
    118             temp_args = (np.array(a, dtype=np.complex) for a in args)
--> 119             results = self.vector_func(*temp_args)
    120             results = np.ma.masked_where(

<string> in <lambda>(x0, x1)

and ended with

/home/ptb/gitrepos/sympy/sympy/sets/sets.py in __new__(cls, *args, **kwargs)
   1684         evaluate = kwargs.get('evaluate', global_evaluate[0])
   1685         if evaluate:
-> 1686             args = list(map(sympify, args))
   1687 
   1688             if len(args) == 0:

RuntimeError: maximum recursion depth exceeded

Sumith 1896

unread,
May 12, 2015, 1:45:57 PM5/12/15
to sy...@googlegroups.com
Is there a need for an issue to be opened?


--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/e6b490d0-5d76-4f83-ac41-3c05cccb3a2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
May 12, 2015, 3:40:24 PM5/12/15
to sy...@googlegroups.com
Ideally implitic_plot should be able to do it. The plot comes from a
paper whose algorithm was implemented in a GSoC project
https://github.com/sympy/sympy/wiki/GSoC-2012-Report-Bharath-M-R:-Implicit-plotting.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/CAFeyqwM_GfnfbOLLjX1E2rYCuEqUmKLHo3R1a2eHTFKL%2BOzRSQ%40mail.gmail.com.

Peter Brady

unread,
May 12, 2015, 3:54:44 PM5/12/15
to sy...@googlegroups.com
From the post:

 Initially the idea was to implement it in mpmath, but due to speed concerns, the interval arithmetic module was completely implemented in numpy. The interval arithmetic is not completely accurate as it uses floating points, but it was sufficient for plotting.

Perhaps since the y-bounds are [k:k+17] where k is 524 digit number, double precision arithmetic simply won't cut it.  Note that I haven't looked at the actually plotting routines to check, I'm just going off the above quote. 

Aaron Meurer

unread,
May 12, 2015, 8:00:13 PM5/12/15
to sy...@googlegroups.com
I think you may be right. So we will need to implement mpmath as a
backend for this to work.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/5c8031ef-887c-402d-b8db-01a30de68812%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages