01-基石题-test

This commit is contained in:
严浩
2026-01-09 17:15:50 +08:00
parent 97154d4b5b
commit f5c6f1d20f
26 changed files with 0 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@@ -0,0 +1,66 @@
# /// script
# requires-python = ">=3.11"
# dependencies = ["numpy", "matplotlib"]
# ///
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = [
"WenQuanYi Micro Hei",
"Noto Sans CJK SC",
"Microsoft YaHei",
"DejaVu Sans",
]
plt.rcParams["axes.unicode_minus"] = False
fig, ax = plt.subplots(figsize=(10, 7), dpi=150)
x = np.linspace(-1, 5, 500)
y = -2 * x**2 + 8 * x - 3
ax.plot(x, y, "b-", linewidth=2, label="$y = -2x^2 + 8x - 3$")
vertex_x, vertex_y = 2, 5
ax.scatter(
[vertex_x],
[vertex_y],
color="red",
s=150,
zorder=5,
label=f"顶点 ({vertex_x}, {vertex_y})",
)
ax.annotate(
f"顶点 ({vertex_x}, {vertex_y})\n最大值: y = {vertex_y}",
xy=(vertex_x, vertex_y),
xytext=(vertex_x + 0.8, vertex_y + 1.5),
fontsize=11,
ha="left",
arrowprops=dict(arrowstyle="->", color="red", lw=1.5),
bbox=dict(boxstyle="round,pad=0.3", facecolor="yellow", alpha=0.7),
)
ax.axhline(y=0, color="gray", linestyle="--", linewidth=1, alpha=0.7)
ax.axvline(x=0, color="gray", linestyle="--", linewidth=1, alpha=0.7)
ax.axvline(
x=vertex_x,
color="green",
linestyle=":",
linewidth=1.5,
alpha=0.7,
label=f"对称轴 x = {vertex_x}",
)
ax.set_xlabel("x", fontsize=12)
ax.set_ylabel("y", fontsize=12)
ax.set_title("二次函数 $y = -2x^2 + 8x - 3$ 的图像", fontsize=14, fontweight="bold")
ax.legend(loc="upper right", fontsize=10)
ax.grid(True, alpha=0.3)
ax.set_xlim(-0.5, 5.5)
ax.set_ylim(-6, 8)
plt.tight_layout()
plt.savefig("figure.png", bbox_inches="tight", dpi=150)
plt.close()
print("图像已保存: figure.png")

View File

@@ -0,0 +1,80 @@
# 二次函数 $y=-2x^2+8x-3$ 求解报告
## 1. 🎯 问题描述
已知二次函数 $y = -2x^2 + 8x - 3$,求:
1. 函数的顶点坐标
2. 函数的最大值
## 2. ✅ 最终结论
二次函数 $y = -2x^2 + 8x - 3$ 的顶点坐标为 $(2, 5)$,由于抛物线开口向下,该顶点即为函数的最大值点,因此函数的最大值为 $y = 5$。
## 3. 📈 可视化
![函数图像](figure.png)
**图表说明**
- 蓝色曲线:函数 $y = -2x^2 + 8x - 3$ 的图像
- 红色圆点:顶点位置 $(2, 5)$,也是函数的最大值点
- 绿色虚线:对称轴 $x = 2$
- 灰色虚线:坐标轴参考线
## 4. 🧠 数学建模与解题过程
<details>
<summary><strong>点击展开</strong></summary>
**问题分析**:这是一个标准的一元二次函数 $y = ax^2 + bx + c$ 的求极值问题。
**方法选择**:使用顶点公式法。对于二次函数 $y = ax^2 + bx + c$,其顶点横坐标为 $x = -\frac{b}{2a}$,顶点纵坐标为函数在该点的函数值。
**推导过程**
已知函数:
$$y = -2x^2 + 8x - 3$$
其中 $a = -2$$b = 8$$c = -3$。
**步骤 1求顶点横坐标**
$$x_{vertex} = -\frac{b}{2a} = -\frac{8}{2 \times (-2)} = -\frac{8}{-4} = 2$$
**步骤 2求顶点纵坐标**
将 $x = 2$ 代入原函数:
$$y_{vertex} = -2(2)^2 + 8(2) - 3 = -2 \times 4 + 16 - 3 = -8 + 16 - 3 = 5$$
**步骤 3判断极值类型**
由于二次项系数 $a = -2 < 0$,抛物线开口向下,因此顶点为最高点,即函数的最大值点。
**结论**
- 顶点坐标:$(2, 5)$
- 函数最大值:$y = 5$
</details>
## 5. 📊 运行结果
<details>
<summary><strong>点击展开</strong></summary>
```
==================================================
二次函数 y = -2x² + 8x - 3 求解结果
==================================================
1. 顶点坐标: (2, 5)
即: x = 2.0, y = 5.0
2. 函数最大值: y = 5.0
由于 a = -2 < 0抛物线开口向下
顶点为最高点,即为最大值点。
3. 对称轴: x = 2.0
==================================================
```
</details>

View File

@@ -0,0 +1,26 @@
# /// script
# requires-python = ">=3.11"
# dependencies = ["sympy"]
# ///
import sympy as sp
x = sp.symbols("x", real=True)
a, b, c = -2, 8, -3
y = a * x**2 + b * x + c
vertex_x = -b / (2 * a)
vertex_y = a * vertex_x**2 + b * vertex_x + c
print("=" * 50)
print("二次函数 y = -2x² + 8x - 3 求解结果")
print("=" * 50)
print(f"\n1. 顶点坐标: ({sp.nsimplify(vertex_x)}, {sp.nsimplify(vertex_y)})")
print(f" 即: x = {vertex_x}, y = {vertex_y}")
print(f"\n2. 函数最大值: y = {vertex_y}")
print(f" 由于 a = -2 < 0抛物线开口向下")
print(f" 顶点为最高点,即为最大值点。")
print(f"\n3. 对称轴: x = {vertex_x}")
print("=" * 50)