返回课程主页 🎯 开始互动测验

Maple 微积分实验考试2

MATH1131 核心命令复习

针对实验考试的 Maple 核心命令复习,涵盖函数定义、求解、绘图与极值问题

💡 复习提示: 本笔记涵盖10个核心Maple知识点,建议先完整阅读理解概念,再进行互动测验巩固学习成果。

1. 变量赋值 := (冒号等于号)

这是 Maple 中最基本也最重要的命令之一。它用来给一个变量赋值

核心要点

  • 用途:将一个数字、一个表达式、一个函数或者一个计算结果存到一个你命名的变量里。
  • 语法:变量名 := 值或表达式;
  • 注意:它和数学里的单个等号 = 不同。= 在 Maple 里只用于表示一个方程,比如 fsolve 里的 df(x) = 0。

示例代码

df := D(f); // 将 f 的导函数结果赋值给变量 df x0 := 0.12345; // 将数值 0.12345 赋值给变量 x0 result := x^2 + 3*x; // 将表达式赋值给变量 result

2. 定义函数 -> (箭头)

这用于创建一个可以重复使用的函数。

核心要点

  • 用途:定义一个数学函数,之后可以方便地代入不同的值进行计算。
  • 语法:函数名 := 自变量 -> 表达式;
  • 调用:定义之后,你就可以像 f(0.1) 或 f(x0) 这样来调用它了。

示例代码

f := x -> 7^x + 7*cos(7*x/2); // 定义函数 f g := (x, y) -> x^2 + y^2; // 定义二元函数 g h := t -> sin(t) * exp(-t); // 定义函数 h // 函数调用 f(0.1); // 计算 f 在 x=0.1 处的值 g(2, 3); // 计算 g(2,3) 的值

3. 求导 D() (大写D)

这是 Maple 的求导算子。

核心要点

  • 用途:计算一个函数或表达式的导数。
  • 语法:
    • 求一阶导数: D(函数名)
    • 求二阶导数: D(一阶导函数名) 或者 (D@@2)(原函数名)

示例代码

f := x -> x^3 + 2*x^2 - 5*x + 1; // 定义函数 df := D(f); // 计算 f 的一阶导数,并存入 df ddf := D(df); // 计算 df 的导数,即 f 的二阶导数 ddf := (D@@2)(f); // 直接计算 f 的二阶导数,效果同上 // 求导数在特定点的值 df(2); // 计算导数在 x=2 处的值

4. 数值求解 fsolve()

当方程无法直接解出精确的符号解时,用它来找数值解(近似解)。

核心要点

  • 用途:求解单个或多个方程的数值解。
  • 语法:
    • 基本形式: fsolve(方程, 变量);
    • 在指定区间内求解: fsolve(方程, 变量 = 起点..终点);

示例代码

// 基本求解 f := x -> x^3 - 2*x - 5; fsolve(f(x) = 0, x); // 在整个实数范围寻找解 // 指定区间求解 fsolve(df(x) = 0, x = 0..0.3); // 在 x 位于 0 和 0.3 之间寻找解 fsolve(sin(x) = 0.5, x = 0..Pi); // 在指定区间内求解三角方程

5. 控制精度 Digits (首字母大写)

这是一个全局变量,用来控制所有浮点数计算的有效数字位数。

核心要点

  • 用途:设定计算结果的精度。
  • 语法:Digits := 你想要的数字;
  • 注意:Maple 严格区分大小写,Digits 不能写成 digits。

示例代码

Digits := 10; // 设置10位有效数字 evalf(Pi); // 计算 π 的近似值 Digits := 20; // 提高精度到20位 evalf(sqrt(2)); // 计算 √2 的高精度近似值

6. 符号积分 int() 与数值计算 evalf()

这是解决数值定积分问题的核心组合。

核心要点

  • int() 的用途:用来表示一个数学上的积分(定积分或不定积分)。它本身只是建立一个积分的符号表达式。
  • evalf() 的用途:用来将一个符号表达式(包括 int 创建的积分表达式)计算出其具体的浮点数值(小数)。
  • 组合用途:evalf(int(...)) 是解决数值定积分问题的标准"黄金组合"。

示例代码

// 数值定积分 integrand := (exp(-x) * cos(x^2 / 3)) / (5 + x); evalf(int(integrand, x = 0..infinity)); // 有限区间积分 evalf(int(x^2 * sin(x), x = 0..Pi)); // 不定积分(符号积分) int(x^2 * exp(x), x); // 返回符号结果

特殊常数

  • 无穷大 ∞ → infinity
  • 圆周率 π → Pi (P大写)
  • 虚数单位 i → I (I大写)
  • 自然对数的底 e → 通过 exp(1) 表示

7. 极坐标绘图 polarplot()

这是解决"根据函数选择图像"这类问题的核心命令。

核心要点

  • 用途:用于绘制极坐标系下的函数图像 r = f(θ)。这对于从多个选项中选择正确图像的题目至关重要。
  • 重要前提:绘图功能通常在一个叫 plots 的程序包里,因此需要先用 with(plots); 命令加载这个包。
  • 语法:polarplot(r的表达式, 角度变量 = 下限..上限);

示例代码

with(plots); // 加载绘图包 polarplot(3*sin(theta) - cos(4*theta), theta = 0..2*Pi); // 玫瑰曲线 polarplot(sin(3*theta), theta = 0..Pi); // 心形线 polarplot(1 + cos(theta), theta = 0..2*Pi); // 螺旋线 polarplot(theta, theta = 0..4*Pi);

注意事项

  • 加载程序包:with(plots); 只需要在每个 Maple 会话的开头执行一次。
  • 变量名:Maple 能够直接识别 theta 作为希腊字母 θ。
  • 常数:圆周率 π 必须写作 Pi (P大写),例如 2*Pi。
  • 输出类型:这个命令的输出是一个图像,而不是一个数值。

8. 精确求解 solve()

用于求解方程,并给出精确的符号解(例如整数、分数、根式等)。

核心要点

  • 用途:求解方程,给出精确的符号解。这在题目要求 "exact values" 时至关重要。
  • 与 fsolve() 的区别:solve() 追求精确解;fsolve() 给出数值近似解(小数)。
  • 语法:solve(方程, 变量);

示例代码

// 二次方程的精确解 solve(x^2 + 2*x - 24 = 0, x); // 输出精确的整数解 -6, 4 solve(x^2 - 2 = 0, x); // 输出带根号的精确解 sqrt(2), -sqrt(2) // 三角方程的精确解 solve(sin(x) = 1/2, x); // 输出精确的角度解 // 系统方程 solve({x + y = 5, x - y = 1}, {x, y}); // 解方程组

选择指南

  • 使用 solve():当题目要求精确值、分数、根式等符号形式的答案时。
  • 使用 fsolve():当需要数值近似解,或者方程过于复杂无法得到符号解时。

9. 寻找临界点与闭区间极值 (The Closed Interval Method)

这是解决"求函数在闭区间 [a,b] 上的绝对最大/最小值"这类问题的标准方法。

核心理论 (极值定理)

任何一个在闭区间 [a,b] 上的连续函数,都必然存在一个绝对最大值和一个绝对最小值。

候选点 (Candidate Points)

这些最大/最小值只会出现在以下三类"候选点"上:

  1. 驻点 (Stationary Points):在区间内部 (a, b),使得导数 f'(x) = 0 的点。
  2. 奇点 (Singular Points):在区间内部 (a, b),使得导数 f'(x) 不存在的点。
  3. 区间端点 (Endpoints):即 x = a 和 x = b。

完整解题流程

  1. 找出所有候选点:驻点、奇点、端点。
  2. 筛选:只保留所有在闭区间 [a,b] 内的、不重复的候选点。
  3. 求值:将筛选后的所有候选点逐个代入原始函数 f(x) 中计算函数值。
  4. 比较:所有计算出的函数值中,最大的就是绝对最大值,最小的就是绝对最小值。

针对绝对值函数 f(x) = |g(x)| 的特殊策略

f := x -> abs(x^3 - 2*x^2 - 7*x - 4); g := x -> x^3 - 2*x^2 - 7*x - 4; // 找驻点:求解 g'(x) = 0 solve(D(g)(x) = 0, x); // 找奇点:求解 g(x) = 0(绝对值函数的尖角点) solve(g(x) = 0, x); // 然后手动筛选在指定区间内的点,代入原函数求值并比较

10. 求极限与洛必达法则的验证 (limit)

limit 命令是 Maple 中计算函数极限的核心工具,尤其在处理洛必达法则问题时,它是你最可靠的验证助手

核心理论 (洛必达法则)

只有当极限是 0/0∞/∞不定式时,才可以尝试使用洛必达法则。

Maple 的策略性用途

  1. 验证前提:分别计算分子和分母的极限,以确定极限的类型。这是判断能否使用洛必达法则的关键一步。
  2. 验证答案:直接计算整个分式的极限,以核对你的最终答案(无论是否使用了洛必达法则)。

语法

  • 双边极限:limit(表达式, 变量=趋近的值);
  • 单边极限:limit(表达式, 变量=趋近的值, left); 或 limit(表达式, 变量=趋近的值, right);

示例代码

// 基本极限计算 limit(sin(x)/x, x=0); // 输出 1 // 单边极限 limit(ln(x), x=0, right); // 输出 -infinity // 验证洛必达法则条件的例子 // 问题: lim(x->0) cos(x)/ln(x) 是否可用洛必达? // 1. 验证分子极限 limit(cos(x), x=0); // 输出: 1 // 2. 验证分母极限 limit(ln(x), x=0, right); // 输出: -infinity // 3. 结论: 极限类型是 1/(-∞),不是不定式,不能使用洛必达法则

验证流程总结

  1. 分别计算分子和分母的极限
  2. 判断是否为 0/0 或 ∞/∞ 不定式
  3. 如果是不定式,可以使用洛必达法则
  4. 如果不是,直接计算原极限或使用其他方法
  5. 最后用 limit 命令验证最终答案

综合示例

例1:求转折点 (fsolve)

Digits := 10; f := x -> 3*sin(x^2/2) - (sin(x/2))^2; df := D(f); x0 := fsolve(df(x) = 0, x = 1..2); ddf := D(df); ddf(x0);

例2:求数值定积分 (evalf & int)

Digits := 10; integrand := (exp(-x) * cos(x^2 / 3)) / (5 + x); evalf(int(integrand, x = 0..infinity));

例3:绘制极坐标图像 (polarplot)

with(plots); polarplot(3*sin(theta) - cos(4*theta), theta = 0..2*Pi);

🎯 准备好测试您的掌握程度了吗?

开始70道互动测验

1. Variable Assignment := (colon equals)

This is one of the most basic and important commands in Maple. It is used to assign values to variables.

Key Points

  • Purpose: Store a number, expression, function, or calculation result into a variable you name.
  • Syntax: variable_name := value_or_expression;
  • Note: It differs from the single equals sign = in mathematics. In Maple, = is only used to represent an equation, such as df(x) = 0 in fsolve.

Example Code

df := D(f); // Assign the derivative of f to variable df x0 := 0.12345; // Assign the value 0.12345 to variable x0 result := x^2 + 3*x; // Assign the expression to variable result

2. Define Function -> (arrow)

This is used to create a reusable function.

Key Points

  • Purpose: Define a mathematical function that can be easily evaluated at different values.
  • Syntax: function_name := variable -> expression;
  • Usage: After definition, you can call it like f(0.1) or f(x0).

Example Code

f := x -> 7^x + 7*cos(7*x/2); // Define function f g := (x, y) -> x^2 + y^2; // Define two-variable function g h := t -> sin(t) * exp(-t); // Define function h // Function calls f(0.1); // Calculate f at x=0.1 g(2, 3); // Calculate g(2,3)

3. Derivative D() (capital D)

This is Maple's differentiation operator.

Key Points

  • Purpose: Calculate the derivative of a function or expression.
  • Syntax:
    • First derivative: D(function_name)
    • Second derivative: D(first_derivative_name) or (D@@2)(original_function_name)

Example Code

f := x -> x^3 + 2*x^2 - 5*x + 1; // Define function df := D(f); // Calculate first derivative of f, store in df ddf := D(df); // Calculate derivative of df, i.e., second derivative of f ddf := (D@@2)(f); // Directly calculate second derivative of f, same result // Evaluate derivative at a specific point df(2); // Calculate derivative value at x=2

4. Numerical Solving fsolve()

When an equation cannot be solved exactly, use this to find numerical solutions (approximate solutions).

Key Points

  • Purpose: Find numerical solutions to single or multiple equations.
  • Syntax:
    • Basic form: fsolve(equation, variable);
    • Solve in a specified interval: fsolve(equation, variable = start..end);

Example Code

// Basic solving f := x -> x^3 - 2*x - 5; fsolve(f(x) = 0, x); // Find solution in entire real range // Solve in specified interval fsolve(df(x) = 0, x = 0..0.3); // Find solution where x is between 0 and 0.3 fsolve(sin(x) = 0.5, x = 0..Pi); // Solve trigonometric equation in specified interval

5. Precision Control Digits (capitalized)

This is a global variable that controls the number of significant digits in all floating-point calculations.

Key Points

  • Purpose: Set the precision of calculation results.
  • Syntax: Digits := desired_number;
  • Note: Maple is case-sensitive, so Digits cannot be written as digits.

Example Code

Digits := 10; // Set 10 significant digits evalf(Pi); // Calculate approximation of π Digits := 20; // Increase precision to 20 digits evalf(sqrt(2)); // Calculate high-precision approximation of √2

6. Symbolic Integration int() and Numerical evalf()

This is the core combination for solving numerical definite integral problems.

Key Points

  • int() purpose: Represents a mathematical integral (definite or indefinite). It only creates a symbolic integral expression.
  • evalf() purpose: Calculates the floating-point value (decimal) of a symbolic expression (including integral expressions created by int).
  • Combined use: evalf(int(...)) is the standard "golden combination" for solving numerical definite integrals.

Example Code

// Numerical definite integral integrand := (exp(-x) * cos(x^2 / 3)) / (5 + x); evalf(int(integrand, x = 0..infinity)); // Finite interval integral evalf(int(x^2 * sin(x), x = 0..Pi)); // Indefinite integral (symbolic integration) int(x^2 * exp(x), x); // Returns symbolic result

Special Constants

  • Infinity ∞ → infinity
  • Pi π → Pi (capital P)
  • Imaginary unit i → I (capital I)
  • Natural logarithm base e → represented as exp(1)

7. Polar Plot polarplot()

This is the core command for solving "choose the correct graph from function" type problems.

Key Points

  • Purpose: Plot functions in polar coordinates r = f(θ). This is crucial for questions where you need to select the correct graph from multiple options.
  • Important prerequisite: Plotting functions are usually in a package called plots, so you need to load it first with the with(plots); command.
  • Syntax: polarplot(r_expression, angle_variable = lower..upper);

Example Code

with(plots); // Load plotting package polarplot(3*sin(theta) - cos(4*theta), theta = 0..2*Pi); // Rose curve polarplot(sin(3*theta), theta = 0..Pi); // Cardioid polarplot(1 + cos(theta), theta = 0..2*Pi); // Spiral polarplot(theta, theta = 0..4*Pi);

Notes

  • Loading package: with(plots); only needs to be executed once at the beginning of each Maple session.
  • Variable name: Maple can directly recognize theta as the Greek letter θ.
  • Constants: Pi must be written with capital P, e.g., 2*Pi.
  • Output type: The output of this command is a graph, not a numerical value.

8. Exact Solving solve()

Used to solve equations and give exact symbolic solutions (e.g., integers, fractions, radicals).

Key Points

  • Purpose: Solve equations with exact symbolic solutions. This is crucial when questions require "exact values".
  • Difference from fsolve(): solve() seeks exact solutions; fsolve() gives numerical approximate solutions (decimals).
  • Syntax: solve(equation, variable);

Example Code

// Exact solutions to quadratic equations solve(x^2 + 2*x - 24 = 0, x); // Outputs exact integer solutions -6, 4 solve(x^2 - 2 = 0, x); // Outputs exact solutions with radicals sqrt(2), -sqrt(2) // Exact solutions to trigonometric equations solve(sin(x) = 1/2, x); // Outputs exact angle solutions // System of equations solve({x + y = 5, x - y = 1}, {x, y}); // Solve system of equations

Selection Guide

  • Use solve(): When questions require exact values, fractions, radicals, or other symbolic form answers.
  • Use fsolve(): When you need numerical approximate solutions, or the equation is too complex for symbolic solutions.

9. Finding Critical Points and Closed Interval Extrema (The Closed Interval Method)

This is the standard method for solving "find the absolute maximum/minimum of a function on a closed interval [a,b]" type problems.

Core Theory (Extreme Value Theorem)

Any continuous function on a closed interval [a,b] must have an absolute maximum and an absolute minimum.

Candidate Points

These maximum/minimum values can only occur at the following three types of "candidate points":

  1. Stationary Points: Points inside the interval (a, b) where the derivative f'(x) = 0.
  2. Singular Points: Points inside the interval (a, b) where the derivative f'(x) does not exist.
  3. Endpoints: Namely x = a and x = b.

Complete Solution Process

  1. Find all candidate points: Stationary points, singular points, endpoints.
  2. Filter: Keep only the unique candidate points within the closed interval [a,b].
  3. Evaluate: Substitute each filtered candidate point into the original function f(x) to calculate function values.
  4. Compare: Among all calculated function values, the largest is the absolute maximum, the smallest is the absolute minimum.

Special Strategy for Absolute Value Functions f(x) = |g(x)|

f := x -> abs(x^3 - 2*x^2 - 7*x - 4); g := x -> x^3 - 2*x^2 - 7*x - 4; // Find stationary points: solve g'(x) = 0 solve(D(g)(x) = 0, x); // Find singular points: solve g(x) = 0 (corner points of absolute value function) solve(g(x) = 0, x); // Then manually filter points within the specified interval, substitute into original function and compare

10. Finding Limits and Verifying L'Hopital's Rule (limit)

The limit command is Maple's core tool for calculating function limits. It is your most reliable verification assistant when dealing with L'Hopital's rule problems.

Core Theory (L'Hopital's Rule)

L'Hopital's rule can only be attempted when the limit is an indeterminate form of 0/0 or ∞/∞.

Strategic Uses of Maple

  1. Verify conditions: Calculate limits of numerator and denominator separately to determine the type of limit. This is a crucial step in deciding whether L'Hopital's rule can be applied.
  2. Verify answers: Directly calculate the limit of the entire fraction to check your final answer (whether or not L'Hopital's rule was used).

Syntax

  • Two-sided limit: limit(expression, variable=approaching_value);
  • One-sided limit: limit(expression, variable=approaching_value, left); or limit(expression, variable=approaching_value, right);

Example Code

// Basic limit calculation limit(sin(x)/x, x=0); // Outputs 1 // One-sided limit limit(ln(x), x=0, right); // Outputs -infinity // Example of verifying L'Hopital's rule conditions // Question: Can lim(x->0) cos(x)/ln(x) use L'Hopital's rule? // 1. Verify numerator limit limit(cos(x), x=0); // Output: 1 // 2. Verify denominator limit limit(ln(x), x=0, right); // Output: -infinity // 3. Conclusion: The limit type is 1/(-∞), not an indeterminate form, cannot use L'Hopital's rule

Verification Process Summary

  1. Calculate limits of numerator and denominator separately
  2. Determine if it's a 0/0 or ∞/∞ indeterminate form
  3. If it's an indeterminate form, L'Hopital's rule can be used
  4. If not, calculate the original limit directly or use other methods
  5. Finally use the limit command to verify the final answer

Comprehensive Examples

Example 1: Find Turning Point (fsolve)

Digits := 10; f := x -> 3*sin(x^2/2) - (sin(x/2))^2; df := D(f); x0 := fsolve(df(x) = 0, x = 1..2); ddf := D(df); ddf(x0);

Example 2: Numerical Definite Integral (evalf & int)

Digits := 10; integrand := (exp(-x) * cos(x^2 / 3)) / (5 + x); evalf(int(integrand, x = 0..infinity));

Example 3: Plot Polar Graph (polarplot)

with(plots); polarplot(3*sin(theta) - cos(4*theta), theta = 0..2*Pi);

🎯 Ready to Test Your Knowledge?

Start 70 Interactive Quiz Questions