Files
ai-math-test/01-基石题-test/工具openode模型MiniMax21/solve.py
2026-01-09 17:15:50 +08:00

27 lines
681 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# /// 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)