7

I am trying to do mathematical limits in python.

I have defined a function for smoke

import turtle
t = turtle.Pen()

def drawsmoke(y):
    i = 0
    while i < ((2 * y) - 1):
        t.seth(i * 5)
        t.circle((10 + i), 160)
        i = i + 2

this draws one side of the smoke, the other side yet to be done.

now the problem arises when i try to draw about 4 smoke circles(y=4) that the smoke starts turning the wrong way. to fix this, i considered doing a mathematical limit. I would make a variable

   smkang=(i*5)

and then do a limit on this variable:

      lim
    smkang->20    

how may i do this? or is there another way not involving limits? btw this is in turtle (python language but turtle imported) thanks

unor
  • 92,415
  • 26
  • 211
  • 360
user2095044
  • 223
  • 3
  • 6
  • 12
  • What is `t`? Please have a look at http://sscce.org/, where 'sc' is sef contained and 'c' "correct"/"compilable"(/"working") – glglgl Mar 12 '13 at 09:30
  • i have imported turtle at the start import turtle t = turtle.Pen() well yeah, t is turtle.Pen() – user2095044 Mar 12 '13 at 09:30
  • ok, I edited your question in order to make it complete. – glglgl Mar 12 '13 at 09:32
  • ok thanks i should have probably done that at the start – user2095044 Mar 12 '13 at 09:36
  • It seems to me that the problem is the constant angle of 160 degrees at the circle. As the starting angle is a `f(i)`, the ending one should be as well... I'll think about it, but maybe someone finds another solution. – glglgl Mar 12 '13 at 09:39
  • yes this seems to help a bit i tried 160-i, it doesnt work very well, but ill be able to find a better one. – user2095044 Mar 13 '13 at 14:32

1 Answers1

10

use sympy. SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries. Ex:

>>> from sympy import limit, Symbol, sin, oo
>>> x = Symbol("x")
>>> limit(sin(x)/x, x, 0)
1
DSM
  • 342,061
  • 65
  • 592
  • 494
Chathuranga
  • 1,008
  • 1
  • 15
  • 26