Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mathematical limits in python?

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

like image 426
user2095044 Avatar asked Mar 12 '13 09:03

user2095044


1 Answers

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
like image 69
Chathuranga Avatar answered Oct 27 '22 05:10

Chathuranga