• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Jan 15th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # -*- coding: utf-8 -*-
2. """
3. Created on Wed Jan 15 12:09:55 2020
4.
5. @author: ZUISA
6. """
7.
8.
9. import matplotlib.pyplot as plt
10. import math
11. import numpy as np
12.
13.
14. def f(x):
15.     return -x**2+5*x+2.2
16.
17.
18.
19. def lewy_prostokat(a,b):
20.     return(b-a)*f(a)
21.
22. def srodkowy_prostokat(a,b):
23.     x0=(a+b)/2
24.     return(b-a)*f(x0)
25.
26. def prawy_prostokat(a,b):
27.     return(b-a)*f(b)
28.
29. def trapez(a,b):
30.     return ((b-a)/2)*(f(a)+f(b))
31.
32.
33. a=1
34. b=2
35. x=np.arange(-100,100,0.1)
36.
37.
38. lew=lewy_prostokat(a,b)
39.
40. srod=srodkowy_prostokat(a,b)
41.
42. praw=prawy_prostokat(a,b)
43.
44.
45.
46. print(lew, srod , praw)
47. plt.plot(x,f(x),"--",lew,"o",srod,"o",praw,"o")
48. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top