fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. a = 9
  5. b = 10
  6.  
  7. # f(x) = log_a(x-b)
  8. x = np.linspace(10.1, 50, 400)
  9. y = np.log(x - b) / np.log(a)
  10.  
  11. # f^-1(x) = b + a^x
  12. x_inv = np.linspace(-2, 3, 400)
  13. y_inv = b + a**x_inv
  14.  
  15. # линия y=x
  16. line = np.linspace(0, 50, 400)
  17.  
  18. plt.figure(figsize=(8,6))
  19. plt.plot(x, y, label=r'$f(x)=\log_{9}(x-10)$', color="blue")
  20. plt.plot(y_inv, x_inv, label=r'$f^{-1}(x)=10+9^x$', color="red")
  21. plt.plot(line, line, '--', color="gray", label="y=x")
  22.  
  23. plt.xlim(0, 50)
  24. plt.ylim(-2, 5)
  25. plt.xlabel("x")
  26. plt.ylabel("y")
  27. plt.title("Функция и её обратная при a=9, b=10")
  28. plt.legend()
  29. plt.grid(True)
  30. plt.show()
Success #stdin #stdout #stderr 3.53s 68920KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Fontconfig error: No writable cache directories