函数与反函数

import numpy as np
import matplotlib.pyplot as plt

def h(x):
    return np.exp(x)
def g(x):
    return np.log(x)
g_start, g_end = 0.1, 4
h_start, h_end = g(g_start), g(g_end)
numbers = 100
h_x = np.linspace(h_start, h_end, numbers)
g_x = np.linspace(g_start,g_end, numbers)
h_y = h(x1)
g_y = g(x2)
plt.figure(figsize=(6,6))
plt.plot(h_x, h_y)
plt.plot(g_x, g_y)
plt.plot([-2,2],[-2,2], '--')
x0 = 2
plt.text(x0+0.5, g(x0), r'$g(x0)=y$', fontsize=10)  
plt.text(x0-1.3, g(x0)-1.5, r'$g(x)
函数与反函数_第1张图片

你可能感兴趣的:(函数与反函数)