Có thư viện nào có sẵn để có nghịch đảo của một chức năng không? Để cụ thể hơn, được đưa ra một hàm y=f(x) và tên miền, có thư viện nào có thể xuất x=f(y) không? Đáng buồn thay, tôi không thể sử dụng MATLAB/Toán học trong ứng dụng của mình, tìm kiếm thư viện C/Python ..
Tôi hơi muộn, nhưng đối với những độc giả trong tương lai của bài đăng, tôi vừa xuất bản một gói Python làm điều này một cách chính xác. https://pypi.python.org/pypi/pynverse Có một mô tả chi tiết về cách sử dụng nó và cách nó thực hiện trong mô tả!
Như đã được đề cập, không phải tất cả các chức năng đều không thể đảo ngược. Trong một số trường hợp áp đặt các ràng buộc bổ sung giúp: suy nghĩ về nghịch đảo của sin(x).
Một khi bạn chắc chắn rằng chức năng của bạn có nghịch đảo duy nhất, hãy giải phương trình f(x) = y. Giải pháp cung cấp cho bạn nghịch đảo, y(x).
Tìm nghịch đảo của một chức năng.
Đầu tiên, thay thế f (x) bằng y. ....
Thay thế mọi x bằng y và thay thế mọi y bằng x ..
- Giải phương trình từ bước 2 cho y. ....
- Thay thế y bằng f - 1 (x) f - 1 (x). ....
Tìm nghịch đảo của một chức năng.
Đầu tiên, thay thế f (x) bằng y. ....
Thay thế mọi x bằng y và thay thế mọi y bằng x ..
Giải phương trình từ bước 2 cho y. ....function is used to Compute the bit-wise Inversion of an array element-wise. It computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays.
Thay thế y bằng f - 1 (x) f - 1 (x). ....
Xác minh công việc của bạn bằng cách kiểm tra rằng (f∘f 1) (x) = x (f ∘ f - 1) (x) = x và (f 1∘f) (x) = x (f - 1 ∘ f) (x) = x đều đúng .. numpy.invert(x, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, ufunc ‘invert’)
Làm thế nào để bạn nghịch đảo một chức năng?
x : [array_like] Input array.
out : [ndarray, optional] A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.
**kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function.
where : [array_like, optional] True value means to calculate the universal functions(ufunc) at that position, False value means to leave the value in the output alone.
Trả về: [ndarray hoặc vô hướng] kết quả. Đây là vô hướng nếu X là vô hướng. [ndarray or scalar] Result. This is a scalar if x is scalar.
Mã số 1: Làm việc
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
1
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
2
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
3
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
4
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
5
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
6
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
7
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
8
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
9
Input number : 10
inversion of 10 : -11
0
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
4
Input number : 10
inversion of 10 : -11
2
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
6
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
7
Input number : 10
inversion of 10 : -11
5
Input number : 10
inversion of 10 : -11
6
Đầu ra:
Input number : 10
inversion of 10 : -11
& nbsp; mã số 2:
Code #2 :
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
1
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
2
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
3
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
4
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
5
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
6
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
7
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
8
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
9
Input number : 10
inversion of 10 : -11
0
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
4
Input number : 10
inversion of 10 : -11
2
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
6
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
7
Input number : 10
inversion of 10 : -11
5
Input number : 10
inversion of 10 : -11
6
Đầu ra:
Input array : [2, 0, 25]
Output array after inversion: [ -3 -1 -26]
& nbsp; mã số 2:
Code #3 :
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
1
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
2
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
3
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
4
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
5
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
6
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
7
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
8
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
9
Input number : 10
inversion of 10 : -11
0
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
4
Input number : 10
inversion of 10 : -11
2
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
6
from scipy.optimize import minimize
x = np.arange(np.min(y),np.max(y),0.1)
y = np.zeros(x.shape)
def diff(x,a):
yt = function(x)
return (yt - a )**2
for idx,x_value in enumerate(x):
res = minimize(diff, 1.0, args=(x_value), method='Nelder-Mead', tol=1e-6)
y[idx] = res.x[0]
fig = figure(num=None, figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
plt.plot(x,y)
plt.title(r'$f^{-1}(x)$')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("function_inverse.png", bbox_inches='tight')
plt.show()
7
Input number : 10
inversion of 10 : -11
5
Input number : 10
inversion of 10 : -11
6
Đầu ra:
Input array : [True, False]
Output array after inversion: [False True]
Python cung cấp một phương pháp rất dễ dàng để tính toán nghịch đảo của ma trận. Hàm numpy.linalg.inv () có sẵn trong mô -đun Python Numpy được sử dụng để tính toán nghịch đảo của ma trận.numpy. linalg. inv() which is available in the python NumPy module is used to compute the inverse of a matrix.
Đảo ngược () trong Python.Numpy.Hàm đảo ngược () được sử dụng để tính toán đảo ngược bit khôn ngoan của phần tử mảng.Nó tính toán bit khôn ngoan không phải của biểu diễn nhị phân cơ bản của các số nguyên trong các mảng đầu vào.used to Compute the bit-wise Inversion of an array element-wise. It computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays.
Làm thế nào để bạn tìm thấy nghịch đảo của một hàm?Để tìm nghịch đảo của một hàm, hãy viết hàm y làm hàm của x i.e. y = f (x) và sau đó giải x là hàm của y.write the function y as a function of x i.e. y = f(x) and then solve for x as a function of y.