In [2]:
import numpy as np
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [4]:
import numpy as np
x = np.linspace(0,10,23)
f = np.sin(x)
In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
In [8]:
plt.plot(x,f,'o-')
plt.plot(4,0,'ro')
Out[8]:
In [25]:
# f1 = f[1:-1] * f[:]
print(np.shape(f[:-1]))
print(np.shape(f[1:]))
ff = f[:-1] * f[1:]
print(ff.shape)
In [43]:
x_zero = x[np.where(ff < 0)]
x_zero2 = x[np.where(ff < 0)[0] + 1]
f_zero = f[np.where(ff < 0)]
f_zero2 = f[np.where(ff < 0)[0] + 1]
print(x_zero)
print(f_zero)
In [50]:
Dx = x_zero2 - x_zero
df = np.abs(f_zero)
Df = np.abs(f_zero - f_zero2)
print(Dx)
print(df)
print(Df)
In [51]:
xz = x_zero + (df * Dx) / Df
xz
Out[51]:
In [ ]:
In [54]:
plt.plot(x,f,'o-')
plt.plot(x_zero,f_zero,'ro')
plt.plot(x_zero2,f_zero2,'go')
plt.plot(xz,np.zeros_like(xz),'yo-')
Out[54]:
In [40]:
np.where(ff < 0)[0] + 1
Out[40]:
In [ ]:
In [ ]:
In [51]:
Z = np.random.random(30)
In [65]:
x = np.linspace(0,3,64)
y = np.linspace(0,3,64)
In [67]:
X,Y = np.meshgrid(x,y)
In [60]:
X
Out[60]:
In [61]:
Y
Out[61]:
In [62]:
np.sin(X**2+Y**2)
Out[62]:
In [69]:
plt.contourf(X,Y,np.sin(X**2+Y**2))
Out[69]:
In [ ]:
In [ ]:
In [ ]: