codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#coding: utf-8 def f(x): return ( x / ( x*x + 1) ) #return 4 * (( (x ** 2) - 4 ) / ( x - 2 )) def poslimit(f, a): v = [] for x in range((a)*1000+20,a*1000,-1): a = float(a) x = float(x) v.append(f(x/1000)) #print "a:%s , x:%s, l:%s" % (a,x,f(x/1000)) return min( [ round(y*100)/100.0 for y in v ] ) def neglimit(f, a): v = [] for x in range((a)*1000-20,a*1000,1): a = float(a) x = float(x) v.append(f(x/1000)) #print "a:%s , x:%s, l:%s" % (a,x,f(x/1000)) return max( [ round(y*100)/100.0 for y in v ] ) def limitcalc(f, a): neg = neglimit(f,a) pos = poslimit(f,a) if pos == neg: print "Limite é %s" %neg else: print "O limite não existe. LimPos %s LimNeg %s" % ( pos, neg) limitcalc(f, 2)
Private
[
?
]
Run code
Submit