sin(x) + cos(x) 的极大值和极小值

sinx + cosx 的极大值和极小值

今天遇到了一个问题,就是如何求解 sin ⁡ x + cos ⁡ x \sin{x} + \cos{x} sinx+cosx 的极大值和极小值。这里特来记录一下。

理论推导

首先,我们假设:
sin ⁡ x + cos ⁡ x = R sin ⁡ ( x + α ) (1) \sin{x} + \cos{x} = R\sin{\left ( x+\alpha \right ) } \tag{1} sinx+cosx=Rsin(x+α)(1)
展开(1)式后我们可以得到:
sin ⁡ x + cos ⁡ x = R cos ⁡ α sin ⁡ x + R sin ⁡ α cos ⁡ x (2) \sin{x} + \cos{x} = R\cos{\alpha}\sin{x} + R\sin{\alpha}\cos{x} \tag{2} sinx+cosx=Rcosαsinx+Rsinαcosx(2)
从(2)式我们可以得到:
R cos ⁡ α = 1 R sin ⁡ α = 1 \begin{align} R\cos{\alpha} &= 1 \tag{3} \\ R\sin{\alpha} &= 1 \tag{4} \end{align} RcosαRsinα=1=1(3)(4)
对(3)和(4)式进行平方并加和可得:
R 2 cos ⁡ 2 α + R 2 sin ⁡ 2 α = 1 2 + 1 2 R 2 ( sin ⁡ 2 α + cos ⁡ 2 α ) = 2 \begin{align} R^2\cos^2{\alpha} + R^2\sin^2{\alpha}&= 1^2 + 1^2 \nonumber \\ R^2 \left ( \sin^2{\alpha} + \cos^2{\alpha} \right ) &= 2 \tag{5} \end{align} R2cos2α+R2sin2αR2(sin2α+cos2α)=12+12=2(5)
从(5)式可得:
R = 2 (6) R = \sqrt{2} \tag{6} R=2 (6)
将(6)式代入(3)和(4)式可得:
cos ⁡ α = 2 2 sin ⁡ α = 2 2 \begin{align} \cos{\alpha} &= \frac{\sqrt{2}}{2} \tag{7} \\ \sin{\alpha} &= \frac{\sqrt{2}}{2} \tag{8} \end{align} cosαsinα=22 =22 (7)(8)
结合(7)式和(8)式最终可得:
α = π 4 (9) \alpha = \frac{\pi}{4} \tag{9} α=4π(9)
将(9)式和(6)式代入(1)中可得:
sin ⁡ x + cos ⁡ x = 2 sin ⁡ ( x + π 4 ) (10) \sin{x} + \cos{x} = \sqrt{2}\sin{\left ( x+\frac{\pi}{4} \right ) } \tag{10} sinx+cosx=2 sin(x+4π)(10)
通过(10)式可以看出, sin ⁡ x + cos ⁡ x \sin{x} + \cos{x} sinx+cosx 的最大值为 2 \sqrt{2} 2 ,最小值为 − 2 -\sqrt{2} 2

图像

如果我们做一下它的图像,我们可以得到:
在这里插入图片描述
图像也验证了我们的理论推导。

如果大家觉得有用,就点个赞让更多的人看到吧~

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: import matplotlib.pyplot as plt import numpy as np x = np.linspace(-6, 6, 100) y = np.sin(x) + np.cos(2*x)# 求点 x1 = np.array([-3.14, -1.57, 0, 1.57, 3.14]) y1 = np.sin(x1) + np.cos(2*x1)# 绘制曲线 plt.plot(x, y)# 标记点 plt.scatter(x1, y1) plt.show() ### 回答2: 绘制具有3个极大值和4个的曲线,并标记点,可以使用Python中的matplotlib库来实现。 以下是一段简单的代码示例: ```python import numpy as np import matplotlib.pyplot as plt # 生成x轴的数据 x = np.linspace(-10, 10, 100) # 为曲线设置三个极大值和四个的y轴数据 y = np.sin(x) + np.cos(2*x) + np.sin(3*x) - np.cos(4*x) - np.sin(5*x) + np.cos(6*x) # 绘制曲线 plt.plot(x, y) # 找到点的索引位置 maxima_index = np.where((y[1:-1] > y[:-2]) & (y[1:-1] > y[2:]))[0] minima_index = np.where((y[1:-1] < y[:-2]) & (y[1:-1] < y[2:]))[0] # 在图中标记点 plt.scatter(x[maxima_index+1], y[maxima_index+1], color='red', label='Maxima') plt.scatter(x[minima_index+1], y[minima_index+1], color='blue', label='Minima') # 添加图例 plt.legend() # 显示图形 plt.show() ``` 上述代码将生成一个具有三个极大值和四个的曲线,并在图中用红色和蓝色标记了极大值点和点。可以根据需要修改生成曲线的函数和标记点的条件。 ### 回答3: 要绘制一个具有3个极大值和4个的曲线,并标记点,可以使用Python中的Matplotlib库来实现。下面是一段代码示例: ```python import matplotlib.pyplot as plt import numpy as np # 定义x轴的取范围 x = np.linspace(-np.pi, np.pi, 100) # 定义曲线方程 y = np.sin(x) + 0.5 * np.sin(2 * x) + 0.3 * np.sin(3 * x) + 0.2 * np.sin(4 * x) # 绘制曲线 plt.plot(x, y) # 计算点 max_points = [(x[i], y[i]) for i in range(1, len(x)-1) if y[i-1] < y[i] and y[i+1] < y[i]] min_points = [(x[i], y[i]) for i in range(1, len(x)-1) if y[i-1] > y[i] and y[i+1] > y[i]] # 标记点 for point in max_points: plt.plot(point[0], point[1], 'ro') for point in min_points: plt.plot(point[0], point[1], 'bo') # 设置坐标轴标签 plt.xlabel('x') plt.ylabel('y') # 设置标题 plt.title('Curve with 3 maxima and 4 minima') # 显示图形 plt.show() ``` 运行以上代码,将会得到一个具有3个极大值和4个的曲线,并且在图形上标记了点。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

勤奋的大熊猫

你的鼓励将是我写作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值