Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numpy import *
- from pylab import *
- from scipy import integrate
- def f(x):
- return x**2-x+1
- a=1.0
- b=3.0
- c=(a+b)/2.
- x1=array([a,b])
- x2=array([a,b,c])
- y1=f(x1)
- y2=f(x2)
- iTrap=trapz(y1,x1)
- print ('Rjesenje pomocu trapezne:'), iTrap
- iSimp=integrate.simps(y2,x2)
- print ('Rjesenje pomocu Simps.:'), iSimp
- from numpy import *
- from pylab import *
- from scipy import *
- from scipy import interpolate
- def f(x):
- return x**2-x+1
- a=1.0
- b=3.0
- c=(a+b)/2.
- x1=array([a,b])
- x2=array([a,b,c])
- y1=f(x1)
- y2=f(x2)
- iTrap=trapz(y1,x1)
- print ('Rjesenje pomocu trapezne:'), iTrap
- iSimp=integrate.simps(y2,x2)
- print ('Rjesenje pomocu Simps.:'), iSimp
- integral=3**3/3.+3**2/2.
- print ('Tocno rjesenje:'), integral
- print ('Prava greska trap:'), (abs(integral-iTrap))
- print ('Prava greska Simp:'), (abs(integral-iSimp))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement