您的位置:首页 > 房产 > 家装 > 企业解决方案_长春网页制作_网站推广推广_1688网站

企业解决方案_长春网页制作_网站推广推广_1688网站

2024/10/5 20:28:22 来源:https://blog.csdn.net/naozibuok/article/details/142706833  浏览:    关键词:企业解决方案_长春网页制作_网站推广推广_1688网站
企业解决方案_长春网页制作_网站推广推广_1688网站


import numpy as np
import matplotlib.pyplot as plt# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']  # 用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False  # 正常显示负号# 创建图形和子图
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6))# 反函数示例
x = np.linspace(0, 5, 1000)
f = 2**x  # 原函数 f(x) = 2^x
f_inv = np.log2(x)  # 反函数 f^(-1)(x) = log_2(x)ax1.plot(x, f, label='f(x) = 2^x')
ax1.plot(f, x, label='f^(-1)(x) = log_2(x)')
ax1.plot(x, x, 'k--', label='y = x')
ax1.set_title('反函数示例')
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax1.legend()
ax1.grid(True)# 复合函数示例
x = np.linspace(-2, 2, 1000)
f = x**2  # f(x) = x^2
g = np.sin(x)  # g(x) = sin(x)
g_of_f = np.sin(x**2)  # (g ∘ f)(x) = sin(x^2)ax2.plot(x, f, label='f(x) = x^2')
ax2.plot(x, g, label='g(x) = sin(x)')
ax2.plot(x, g_of_f, label='g[f(x)] = sin(x^2)')
ax2.set_title('复合函数示例')
ax2.set_xlabel('x')
ax2.set_ylabel('y')
ax2.legend()
ax2.grid(True)plt.tight_layout()
plt.show()

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com