import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,11)
y = x+2
plt.figure(figsize=(8,5))
plt.plot(x,y,linestyle=(12, (10, 10)),alpha=0.4,c='green')
plt.scatter(x=2,y=4,s=80,facecolors='none', edgecolors='black')
plt.show()
pip install numpy matplotlib
Requirement already satisfied: numpy in /shared-libs/python3.9/py/lib/python3.9/site-packages (1.23.4)
Requirement already satisfied: matplotlib in /shared-libs/python3.9/py/lib/python3.9/site-packages (3.6.0)
Requirement already satisfied: pyparsing>=2.2.1 in /shared-libs/python3.9/py-core/lib/python3.9/site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: kiwisolver>=1.0.1 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from matplotlib) (1.4.4)
Requirement already satisfied: fonttools>=4.22.0 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from matplotlib) (4.37.4)
Requirement already satisfied: python-dateutil>=2.7 in /shared-libs/python3.9/py-core/lib/python3.9/site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: pillow>=6.2.0 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from matplotlib) (9.2.0)
Requirement already satisfied: packaging>=20.0 in /shared-libs/python3.9/py-core/lib/python3.9/site-packages (from matplotlib) (21.3)
Requirement already satisfied: cycler>=0.10 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: contourpy>=1.0.1 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from matplotlib) (1.0.5)
Requirement already satisfied: six>=1.5 in /shared-libs/python3.9/py-core/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Note: you may need to restart the kernel to use updated packages.
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return x**2
x = np.linspace(-10,10,100)
y = f(x)
plt.plot(x,y, 'b')
plt.grid()
def df(f):
h= 0.0000001
return (f(x+h) - f(x))/h
plt.plot(x,y,'b')
plt.plot(x,df(f),'r')
plt.grid()
def f(x):
return np.sin(x)
x = np.linspace(-10,10,100)
y = f(x)
def df(f):
h= 0.0000001
return (f(x+h) - f(x))/h
plt.plot(x,y,'b')
plt.plot(x,df(f),'r')
plt.grid()
def df(f):
h=0.000001
return (f(x+h)-f(x))/h
"""Sea
f(x) = mx+b
f'(x) = m
"""
def f(x):
return x
plt.plot(x, f(x), 'b')
plt.plot(x,df(f), 'r')
plt.grid()
def H(x):
Y = np.zeros(len(x))
for idx,x in enumerate(x):
if x>=0:
Y[idx]=1
return Y
N=1000
y = H(x)
plt.plot(x, H(x), 'b')
plt.plot(x,df(H), 'r')
plt.grid()
def f(x):
return 1/(1 + np.exp(-x))
plt.plot(x, f(x), 'b')
plt.plot(x,df(f), 'r')
plt.grid()
def f(x):
return np.tanh(x)
N=1000
y = f(x)
plt.plot(x, f(x), 'b')
plt.plot(x,df(f), 'r')
plt.grid()
def f(x):
return np.maximum(x,0)
N=1000
y = f(x)
plt.plot(x, f(x), 'b')
plt.plot(x,df(f), 'r')
plt.grid()