530 lines
26 KiB
Python
530 lines
26 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
错题锻炼8.31 - PDF生成脚本 v3
|
||
使用matplotlib生成PDF,简化公式格式
|
||
"""
|
||
|
||
import matplotlib
|
||
matplotlib.use('Agg')
|
||
import matplotlib.pyplot as plt
|
||
from matplotlib.backends.backend_pdf import PdfPages
|
||
import matplotlib.patches as patches
|
||
import numpy as np
|
||
import os
|
||
|
||
# 设置中文字体
|
||
plt.rcParams['font.sans-serif'] = ['SimHei', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'DejaVu Sans', 'Arial']
|
||
plt.rcParams['axes.unicode_minus'] = False
|
||
|
||
# 页面尺寸 (A4, inches)
|
||
PAGE_W = 8.27
|
||
PAGE_H = 11.69
|
||
MARGIN = 0.6
|
||
|
||
def clean_formula(s):
|
||
"""清理公式,移除不支持的LaTeX命令"""
|
||
s = s.replace(r'\displaystyle', '')
|
||
s = s.replace(r'\quad', ' ')
|
||
s = s.replace(r'\text{', '')
|
||
# 移除花括号但保留内容
|
||
import re
|
||
s = re.sub(r'\{([^{}]*)\}', r'\1', s)
|
||
s = s.replace('\\', '')
|
||
return s
|
||
|
||
def make_question_page(fig_num, chapter_title, chapter_note, question_num, level, question_text, signal_text):
|
||
"""创建题目页面"""
|
||
fig = plt.figure(figsize=(PAGE_W, PAGE_H))
|
||
ax = fig.add_axes([0, 0, 1, 1])
|
||
ax.set_xlim(0, 1)
|
||
ax.set_ylim(0, 1)
|
||
ax.axis('off')
|
||
|
||
y = 0.95
|
||
|
||
# 章节标题
|
||
ax.text(0.5, y, chapter_title, fontsize=18, ha='center', va='top',
|
||
fontweight='bold', color='#1e3a8a', family='sans-serif')
|
||
y -= 0.03
|
||
|
||
if chapter_note:
|
||
ax.text(0.5, y, chapter_note, fontsize=10, ha='center', va='top',
|
||
color='#166534', family='sans-serif')
|
||
y -= 0.05
|
||
|
||
# 题目
|
||
ax.text(0.08, y, question_num, fontsize=16, ha='left', va='top',
|
||
fontweight='bold', color='#1e40af', family='sans-serif')
|
||
ax.text(0.15, y, level, fontsize=12, ha='left', va='top', color='#b45309', family='sans-serif')
|
||
y -= 0.05
|
||
|
||
# 题目内容 - 分行显示
|
||
lines = question_text.split('\n')
|
||
for line in lines:
|
||
# 检测是否是公式(包含$或\)
|
||
if '$' in line or '\\' in line:
|
||
line = clean_formula(line.replace('$', ''))
|
||
ax.text(0.08, y, line, fontsize=10, ha='left', va='top',
|
||
color='black', family='monospace')
|
||
else:
|
||
ax.text(0.08, y, line, fontsize=11, ha='left', va='top',
|
||
color='black', family='sans-serif')
|
||
y -= 0.04
|
||
|
||
y -= 0.02
|
||
|
||
# 识别信号
|
||
if signal_text:
|
||
signal_text = clean_formula(signal_text)
|
||
# 绿色背景框
|
||
rect = patches.FancyBboxPatch((0.06, y - 0.06), 0.88, 0.08,
|
||
boxstyle='round,pad=0.01',
|
||
facecolor='#f0fdf4', edgecolor='#22c55e', linewidth=1)
|
||
ax.add_patch(rect)
|
||
ax.text(0.08, y, signal_text, fontsize=9, ha='left', va='top',
|
||
color='#166534', family='sans-serif')
|
||
y -= 0.12
|
||
|
||
y -= 0.03
|
||
|
||
# 留空区域
|
||
blank_h = max(y - 0.08, 0.15)
|
||
rect = patches.FancyBboxPatch((0.06, 0.05), 0.88, blank_h,
|
||
boxstyle='round,pad=0.005',
|
||
facecolor='white', edgecolor='#d1d5db',
|
||
linewidth=1, linestyle='--')
|
||
ax.add_patch(rect)
|
||
ax.text(0.5, 0.05 + blank_h/2, '--- Write Your Answer Here ---', fontsize=12,
|
||
ha='center', va='center', color='#9ca3af', style='italic', family='sans-serif')
|
||
|
||
# 页脚
|
||
ax.text(0.5, 0.02, f'-- Page {fig_num} --', fontsize=9, ha='center', va='bottom',
|
||
color='#9ca3af', family='sans-serif')
|
||
|
||
return fig
|
||
|
||
def make_answer_page(fig_num, chapter_title, answer_num, answer_text, analysis_text):
|
||
"""创建答案页面"""
|
||
fig = plt.figure(figsize=(PAGE_W, PAGE_H))
|
||
ax = fig.add_axes([0, 0, 1, 1])
|
||
ax.set_xlim(0, 1)
|
||
ax.set_ylim(0, 1)
|
||
ax.axis('off')
|
||
|
||
y = 0.95
|
||
|
||
# 章节标题
|
||
ax.text(0.5, y, chapter_title, fontsize=16, ha='center', va='top',
|
||
fontweight='bold', color='#991b1b', family='sans-serif')
|
||
y -= 0.04
|
||
|
||
# 答案
|
||
ax.text(0.08, y, f'{answer_num} Answer:', fontsize=14, ha='left', va='top',
|
||
fontweight='bold', color='#166534', family='sans-serif')
|
||
y -= 0.05
|
||
|
||
# 答案内容
|
||
answer_text = clean_formula(answer_text)
|
||
ax.text(0.08, y, answer_text, fontsize=12, ha='left', va='top',
|
||
color='#1e40af', family='monospace')
|
||
y -= 0.06
|
||
|
||
# 解析
|
||
if analysis_text:
|
||
analysis_text = clean_formula(analysis_text)
|
||
ax.text(0.08, y, '-> ' + analysis_text, fontsize=10, ha='left', va='top',
|
||
color='#6b7280', family='sans-serif')
|
||
|
||
# 页脚
|
||
ax.text(0.5, 0.02, f'-- Answer Page {fig_num} --', fontsize=9, ha='center', va='bottom',
|
||
color='#9ca3af', family='sans-serif')
|
||
|
||
return fig
|
||
|
||
def main():
|
||
output_path = os.path.join(os.path.dirname(__file__), '错题锻炼8.31_打印版v3.pdf')
|
||
|
||
with PdfPages(output_path) as pdf:
|
||
page_num = 0
|
||
|
||
# 封面
|
||
page_num += 1
|
||
fig = plt.figure(figsize=(PAGE_W, PAGE_H))
|
||
ax = fig.add_axes([0, 0, 1, 1])
|
||
ax.set_xlim(0, 1)
|
||
ax.set_ylim(0, 1)
|
||
ax.axis('off')
|
||
|
||
ax.text(0.5, 0.7, '错题锻炼 8.31', fontsize=32, ha='center', va='center',
|
||
fontweight='bold', color='#1a1a1a', family='sans-serif')
|
||
ax.text(0.5, 0.6, '-- 题目打印版 --', fontsize=18, ha='center', va='center',
|
||
color='#666666', family='sans-serif')
|
||
ax.text(0.5, 0.48, '[x] Each question on one page', fontsize=12,
|
||
ha='center', va='center', color='#888888', family='sans-serif')
|
||
ax.text(0.5, 0.43, '[x] Answers at the end', fontsize=12,
|
||
ha='center', va='center', color='#888888', family='sans-serif')
|
||
ax.text(0.5, 0.38, '[x] 53 questions + 8 comprehensive', fontsize=12,
|
||
ha='center', va='center', color='#888888', family='sans-serif')
|
||
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 训练场1 ==========
|
||
questions_1 = [
|
||
("1.1", "【★★】",
|
||
r"lim_{x->0} [integral_0^x |t| sin(t) dt] / x^3",
|
||
"Integral contains |t| -> hidden piecewise; x at limit -> type 1"),
|
||
("1.2", "【★★】",
|
||
r"lim_{x->0} [integral_0^1 sin(xt)/|t| dt] / x",
|
||
"Be careful at t=0; integrand contains x -> type 2"),
|
||
("1.3", "【★★★】",
|
||
r"lim_{x->0} [integral_0^{x^2} (e^{(t-x)^2} - 1 - (t-x)^2) sin(t) dt] / x^7",
|
||
"Hybrid type 1/2; e^u - 1 - u is classic 'first non-zero term' form"),
|
||
("1.4", "【★★】",
|
||
r"lim_{n->infty} [(n + n^{1/n}) / n]^n",
|
||
"Base is fraction -> rewrite as 1 + small; 1^infty type"),
|
||
("1.5", "【★★★】",
|
||
r"x_n = (1 + sin(n)/n)^n, find lim_{n->infty} x_n",
|
||
"1^infty type; sin(n) oscillates without converging at integers"),
|
||
("1.6", "【★★★】",
|
||
r"lim_{x->0} [ln(1+x)/x]^{1/x}",
|
||
"Base -> 1, exponent -> infinity; not (1+1/n)^n form"),
|
||
("1.7", "【★★★】",
|
||
r"f(x) = (e^{1/x} - 1)/(e^{1/x} + 1) * sgn(x), does lim_{x->0} f(x) exist?",
|
||
"Contains e^{1/x} (must consider both sides) and sgn(x) (hidden piecewise)"),
|
||
("1.8", "【★★★】",
|
||
r"f strictly increasing on R, lim_{x->-inf} f=0, lim_{x->+inf} f=1. Does lim_{x->1} f^{-1}(x) exist?",
|
||
"Strictly increasing -> inverse exists; lim f(x)=1 never reached -> range is open interval"),
|
||
]
|
||
|
||
for num, level, q, sig in questions_1:
|
||
page_num += 1
|
||
fig = make_question_page(page_num, "Training 1: Limit Calculation Compound Traps",
|
||
"Focus: Limit with integral + Hidden piecewise + e definition",
|
||
f"Q {num}", level, q, sig)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 训练场2 ==========
|
||
questions_2 = [
|
||
("2.1", "【★★】",
|
||
r"Find equivalent infinitesimal of sqrt(1+2x) - sqrt(1-3x) as x->0",
|
||
"Subtraction form, both terms approach 1; must check 'main term cancellation'"),
|
||
("2.2", "【★★★】",
|
||
r"lim_{x->0} [ln(1+x) - x + x^2/2 - x^3/3] / x^4",
|
||
"First three terms of ln(1+x) cancel; denominator x^4 -> expand to x^4"),
|
||
("2.3", "【★★★】",
|
||
r"lim_{x->0} [arctan(x) - sin(x)] / x^5",
|
||
"Difference of two odd functions; denominator x^5 -> expand to x^5"),
|
||
("2.4", "【★★★】",
|
||
r"lim_{x->0} [cuberoot(1+x) - 1 - x/3 + x^2/9] / x^3",
|
||
"First two terms of cube root cancel -> must expand to x^3"),
|
||
("2.5", "【★★★】",
|
||
r"lim_{n->infty} n [ln(n+1) - ln(n) - 1/n]",
|
||
"Sequence limit, n->infty; main term cancellation"),
|
||
("2.6", "【★★★】",
|
||
r"lim_{n->infty} n^2 [(1+1/n)^{n+1} - e]",
|
||
"(1+1/n)^{n+1} -> e (decreasing); careful: exponent is n+1, not n!"),
|
||
("2.7", "【★★★】",
|
||
r"lim_{n->infty} n [e^2 - (1+2/n)^n]",
|
||
"(1+2/n)^n -> e^2 (standard form)"),
|
||
("2.8", "【★★★★】",
|
||
r"a_n = n^{1/n} - 1, find lim_{n->infty} n*a_n / ln(n)",
|
||
"n^{1/n} = e^{ln(n)/n}; first order expansion is ln(n)/n"),
|
||
("2.9", "【★★★】",
|
||
r"f(x) = x^2/(1+x^2), find f^{(10)}(0)",
|
||
"Use Taylor expansion to find high-order derivative"),
|
||
("2.10", "【★★★★】",
|
||
r"cos(x) approx 1 - x^2/2, error <= 10^{-4}, find max delta. Then find lim 1/delta^4 * integral_0^delta [cos(x) - (1-x^2/2)] dx",
|
||
"Lagrange remainder; integral then limit -> type 1 variable limit integral"),
|
||
]
|
||
|
||
for num, level, q, sig in questions_2:
|
||
page_num += 1
|
||
fig = make_question_page(page_num, "Training 2: Taylor Expansion Precision Strike",
|
||
"Focus: Asymptotic expansion + Precision loss trap",
|
||
f"Q {num}", level, q, sig)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 训练场3 ==========
|
||
questions_3 = [
|
||
("3.1", "【★★★】",
|
||
r"f(x) = {x+1, x<0; x^2, x>=0} (1) Is f strictly monotonic? (2) Find discontinuity of f^{-1}",
|
||
"Piecewise function + find inverse -> inverse function topic"),
|
||
("3.2", "【★★★】",
|
||
r"f(x) = {2x+1, x<=1; x+2, x>1} (1) Prove f strictly increasing (2) Find f^{-1} (3) Find discontinuity of f^{-1}",
|
||
"Check left and right limits at switching point x=1"),
|
||
("3.3", "【★★★★】",
|
||
r"f(x) = {x^2, x in [-2,-1]; x, x in (-1,1); sqrt(x), x in [1,4]} Find range and discontinuity of f^{-1}",
|
||
"Three segments, each strictly monotonic; must compute limits at switching points"),
|
||
("3.4", "【★★★】",
|
||
r"f strictly increasing, lim_{x->2-} f=5, lim_{x->2+} f=8, f(2)=5. Find discontinuity of f^{-1}",
|
||
"Need to determine removable vs jump at x=2"),
|
||
("3.5", "【★★★】",
|
||
r"f(x) = {sin(2x)/x, x!=0; a, x=0} (1) Find a for continuity (2) First class discontinuity (3) Second class discontinuity",
|
||
"Parameter + discontinuity classification -> must discuss a"),
|
||
("3.6", "【★★★★】",
|
||
r"f(x) = {ln(1+x)/x, x>0; a, x=0; sin(x)/x, x<0} (1) Find limits (2) Find a for continuity (3) Jump discontinuity?",
|
||
"Two-sided limits need separate computation (different expressions)"),
|
||
("3.7", "【★★★】",
|
||
r"f(x) = {1/x * sin(1/x), x!=0; a, x=0} Find a for continuity at x=0",
|
||
"1/x * sin(1/x) oscillates and diverges as x->0"),
|
||
("3.8", "【★★★】",
|
||
r"g continuous at x=0, f(u) = {u, u!=0; 1, u=0}. Is f(g(x)) continuous at x=0?",
|
||
"Composite function continuity; key is whether f is continuous at g(0)"),
|
||
("3.9", "【★★★★】",
|
||
r"f(x) = {x+1, x>=0; -x, x<0}, g(x)=x^2. Find discontinuity of f(g(x))",
|
||
"g(x)=x^2 >= 0, always in x>=0 region of f"),
|
||
("3.10", "【★★★★★】",
|
||
r"f(x+y)=f(x)+f(y) (Cauchy), f continuous at x=0. Prove: (1) f continuous on R (2) f(x)=f(1)*x",
|
||
"Cauchy + continuity -> linear; abstract function discontinuity"),
|
||
]
|
||
|
||
for num, level, q, sig in questions_3:
|
||
page_num += 1
|
||
fig = make_question_page(page_num, "Training 3: Multi-dimensional Discontinuity Identification",
|
||
"Focus: Hidden piecewise + Inverse function discontinuity",
|
||
f"Q {num}", level, q, sig)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 训练场4 ==========
|
||
questions_4 = [
|
||
("4.1", "【★★★】",
|
||
r"f(u)=u^2, g(x)=|x|, F(x)=f(g(x)). (1) Is F continuous/differentiable at x=0? (2) Find F'(0)",
|
||
"Inner |x| not differentiable at 0; outer u^2 smooth; can't use chain rule!"),
|
||
("4.2", "【★★★】",
|
||
r"f(u)=|u|, g(x)=x, F(x)=f(g(x)). Is F differentiable at x=0?",
|
||
"Outer |u| not differentiable, inner g(x)=x smooth"),
|
||
("4.3", "【★★★】",
|
||
r"f(u)=u^3, g(x)=|x|, F(x)=|x|^3. (1) Is F differentiable at x=0? (2) Find F'(0)",
|
||
"|x|^3 is odd power (power function smooths out corner)"),
|
||
("4.4", "【★★★★】",
|
||
r"f(u)=|u|, g(x)=|x|, F(x)=f(g(x)). (1) Simplify F(x) (2) Discuss continuity and differentiability at x=0",
|
||
"Double corner"),
|
||
("4.5", "【★★★】",
|
||
r"f(u)=u^2, g(x)={x+1,x>=0; -x,x<0}, F(x)=f(g(x)). (1) Simplify F(x) (2) Discuss differentiability at x=0",
|
||
"Outer smooth u^2; inner piecewise g, g not differentiable at 0"),
|
||
("4.6", "【★★★】",
|
||
r"f(u)={u+1,u>=0; -u,u<0}, g(x)=x^2, F(x)=f(g(x)). Discuss continuity and differentiability at x=0",
|
||
"g(x)=x^2 >= 0, avoids u<0 region of f"),
|
||
("4.7", "【★★★★】",
|
||
r"f has second derivative at 0, f(0)=1, f'(0)=2, f''(0)=3; g(x)=x^2. Find d^2/dx^2 f(g(x)) at x=0",
|
||
"Second-order chain rule"),
|
||
("4.8", "【★★★★】",
|
||
r"Find dy/dx at x=0, where y = e^{sin^2(x^3)}",
|
||
"4-layer nesting; missing any layer derivative = wrong"),
|
||
("4.9", "【★★★】",
|
||
r"f continuous at u=1, g continuous at x=0, g(0)=1. Is F(x)=f(g(x)) continuous at x=0?",
|
||
"Chain rule for continuity theorem"),
|
||
("4.10", "【★★★★】",
|
||
r"F(x)=f(g(x)) continuous at x=0. Can we conclude f is continuous at g(0)?",
|
||
"Continuity reverse inference trap; reverse doesn't hold"),
|
||
("4.11", "【★★★★】",
|
||
r"f differentiable at 0, g differentiable at 0, g(0)=0. F(x)=f(g(x)) differentiable at 0, find F'(0)",
|
||
"Standard chain rule application"),
|
||
("4.12", "【★★★★★】",
|
||
r"f differentiable at 0, f(0)=0, f'(0)=2; g(x)=x^2*sin(1/x) (x!=0), g(0)=0. Discuss F(x)=f(g(x)) at x=0",
|
||
"Is g(x) continuous but not differentiable at 0?"),
|
||
]
|
||
|
||
for num, level, q, sig in questions_4:
|
||
page_num += 1
|
||
fig = make_question_page(page_num, "Training 4: Chain Rule Counter-Intuition",
|
||
"Focus: Composite function continuity/differentiability",
|
||
f"Q {num}", level, q, sig)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 训练场5 ==========
|
||
questions_5 = [
|
||
("5.1", "【★★★★】",
|
||
r"x_{n+1} = ln(1+x_n), x_1 in (0,1). (1) Prove lim x_n exists and find it (2) Find lim n*x_n",
|
||
"Explicit recursion x_{n+1}=f(x_n); f(0)=0 is fixed point"),
|
||
("5.2", "【★★★★】",
|
||
r"sin(x_{n+1}) + x_{n+1} = sin(x_n), x_n in (0,pi). (1) Prove lim x_n exists (2) Find lim x_{n+1}/x_n",
|
||
"Implicit recursion; must construct auxiliary function"),
|
||
("5.3", "【★★★★】",
|
||
r"x_{n+1} = (1/2)(x_n + a/x_n), a>0 (Newton iteration). (1) Prove lim x_n = sqrt(a) (2) Find convergence order",
|
||
"Newton iteration; error is quadratic -> quadratic convergence"),
|
||
("5.4", "【★★★★】",
|
||
r"x_1=1, x_{n+1}=sin(x_n). (1) Prove lim x_n=0 (2) Find lim sqrt(n)*x_n",
|
||
"sin(x) approx x - x^3/6; use Stolz-Cesaro for slow convergence"),
|
||
("5.5", "【★★★★】",
|
||
r"x_1=1, x_{n+1}=sqrt(n+x_n). (1) Prove x_n -> +inf (2) Find lim x_n/sqrt(n)",
|
||
"Recursion contains n, need to analyze growth rate"),
|
||
]
|
||
|
||
for num, level, q, sig in questions_5:
|
||
page_num += 1
|
||
fig = make_question_page(page_num, "Training 5: Recursion Finals",
|
||
"Focus: Implicit recursion + Asymptotic order",
|
||
f"Q {num}", level, q, sig)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 终极综合卷 ==========
|
||
questions_final = [
|
||
("1", "【★★★】MC",
|
||
r"f(x)={ln(1+x^2)/x, x!=0; a, x=0}. Find a for f differentiable at x=0.\nA. a=0 B. a=1 C. a=2 D. Never differentiable",
|
||
""),
|
||
("2", "【★★★】MC",
|
||
r"lim_{x->0} [integral_0^{x^2} (e^t - 1 - t) sin(xt) dt] / x^7\nA. 0 B. 1/60 C. 1/30 D. 1/12",
|
||
""),
|
||
("3", "【★★★】MC",
|
||
r"f(x)=|x|sin(x). Is f differentiable at x=0? If so, f'(0)=?\nA. No B. f'(0)=1 C. f'(0)=0 D. f'(0)=-1",
|
||
""),
|
||
("4", "【★★★】MC",
|
||
r"lim_{n->infty} n^2 [n^{1/n} - 1 - ln(n)/n]\nA. 0 B. 1/2 C. (ln(n))^2/(2n) D. DNE",
|
||
""),
|
||
("5", "【★★★ 20pts】",
|
||
r"lim_{x->0} [1 - cos(x)*sqrt(cos(2x))*cuberoot(cos(3x))] / x^2",
|
||
"Multiple function product -> Taylor expand to x^2"),
|
||
("6", "【★★★★ 20pts】",
|
||
r"f(x)={1/|x|^{1/2}, 0<|x|<1; 0, x=0}. Find discontinuity type at x=0",
|
||
"|x|^{-1/2} at x=0 -> check if diverges"),
|
||
("7", "【★★★★ 20pts】",
|
||
r"lim_{n->infty} sum_{k=1}^n (k/n^2) * sqrt(1+k/n)",
|
||
"Sum + n->infty -> definite integral definition"),
|
||
("8", "【★★★★★ 20pts】",
|
||
r"x_{n+1} = cos(x_n) + ln(1+x_n), x_1 in (0,1). (1) Prove lim x_n exists (2) Find lim x_n (3) Find lim x_n/sqrt(1-cos(x_n))",
|
||
"Explicit recursion; fixed point analysis; asymptotic order"),
|
||
]
|
||
|
||
for num, level, q, sig in questions_final:
|
||
page_num += 1
|
||
fig = make_question_page(page_num, "Ultimate Comprehensive Exam",
|
||
"Difficulty: ★★★★ | 8 Questions | 100 Points",
|
||
f"Q {num}", level, q, sig)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# ========== 答案部分 ==========
|
||
# 答案封面
|
||
fig = plt.figure(figsize=(PAGE_W, PAGE_H))
|
||
ax = fig.add_axes([0, 0, 1, 1])
|
||
ax.set_xlim(0, 1)
|
||
ax.set_ylim(0, 1)
|
||
ax.axis('off')
|
||
ax.text(0.5, 0.6, '!!! ANSWER SECTION !!!', fontsize=28, ha='center', va='center',
|
||
fontweight='bold', color='#dc2626', family='sans-serif')
|
||
ax.text(0.5, 0.45, 'Complete all questions before viewing', fontsize=14,
|
||
ha='center', va='center', color='#991b1b', family='sans-serif')
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# 训练场1答案
|
||
answers_1 = [
|
||
("1.1", "1/3", "Absolute value -> integration by parts -> Taylor expand -> numerator x^3/3"),
|
||
("1.2", "1", "Substitute u=xt -> integral_0^x sin(u)/u du ~ x"),
|
||
("1.3", "0", "Estimate order: integrand O(x^6), interval length x^2 -> overall O(x^8) > denominator x^7"),
|
||
("1.4", "e", "Rewrite as (1+n^{1/n}-1)^n, n*(n^{1/n}-1)=n^{1/n}->1 -> e^1=e"),
|
||
("1.5", "DNE", "ln(x_n) ~ sin(n) oscillates, does not converge"),
|
||
("1.6", "1/sqrt(e)", "Take ln -> expand -> ln L = -1/2"),
|
||
("1.7", "1", "Both left and right limits = 1"),
|
||
("1.8", "+inf", "f range (0,1) -> f^{-1} domain (0,1), as x->1-, f^{-1}(x)->+inf"),
|
||
]
|
||
|
||
for num, ans, ana in answers_1:
|
||
fig = make_answer_page(1, "Training 1 Answers", f"Q {num}", ans, ana)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# 训练场2答案
|
||
answers_2 = [
|
||
("2.1", "~ 5x/2", "Binomial expand -> subtract -> main term 5x/2"),
|
||
("2.2", "-1/4", "Expand ln(1+x) to x^4 -> -x^4/4 -> -1/4"),
|
||
("2.3", "DNE", "Lowest order x^3, denominator x^5 -> orders don't match"),
|
||
("2.4", "5/81", "Trinomial expand -> first two terms cancel -> remaining 5x^3/81"),
|
||
("2.5", "0", "ln(1+1/n)=1/n-1/(2n^2) -> n*(-1/(2n^2))->0"),
|
||
("2.6", "+inf", "(1+1/n)^{n+1}-e ~ e/(2n) -> n^2*e/(2n)=en/2->+inf"),
|
||
("2.7", "2e^2", "Expand (1+2/n)^n = e^2(1-2/n+2/n^2) -> n*(2e^2/n)->2e^2"),
|
||
("2.8", "1", "n^{1/n}=e^{ln(n)/n}=1+ln(n)/n -> n*a_n ~ ln(n) -> ratio 1"),
|
||
("2.9", "3628800", "f(x)=sum(-1)^n x^{2n+2} -> x^10 coefficient 1 -> 10!=3628800"),
|
||
("2.10", "delta<=0.084, limit=0", "Lagrange remainder <= delta^3/6; integral gives delta/120 -> 0"),
|
||
]
|
||
|
||
for num, ans, ana in answers_2:
|
||
fig = make_answer_page(2, "Training 2 Answers", f"Q {num}", ans, ana)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# 训练场3答案
|
||
answers_3 = [
|
||
("3.1", "Inverse does not exist", "f(0-)=1, f(0+)=0 jump -> not strictly monotonic"),
|
||
("3.2", "No discontinuity", "f(1-)=f(1+)=f(1)=3 continuous -> f^{-1} continuous"),
|
||
("3.3", "Inverse does not exist", "Three segments ranges overlap: [1,4],[-1,1],[1,2]"),
|
||
("3.4", "x=5 and x=8 jump", "f has jump at x=2 (5,8) -> f^{-1} has jumps at x=5,8"),
|
||
("3.5", "a=2 cont; a!=2 removable; no 2nd class", "lim sin(2x)/x=2 exists"),
|
||
("3.6", "Both =1; a=1 cont; jump impossible", "Left and right limits equal"),
|
||
("3.7", "Never continuous", "Subsequence limits differ -> oscillatory (2nd class)"),
|
||
("3.8", "g(0)!=0: continuous; g(0)=0: removable", "Key is whether f is continuous at u=g(0)"),
|
||
("3.9", "No discontinuity", "g(x)=x^2>=0 -> f(g(x))=x^2+1"),
|
||
("3.10", "f(x)=f(1)*x", "Cauchy+continuity -> f(0)=0 -> continuous -> rationals -> reals -> f(x)=cx"),
|
||
]
|
||
|
||
for num, ans, ana in answers_3:
|
||
fig = make_answer_page(3, "Training 3 Answers", f"Q {num}", ans, ana)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# 训练场4答案
|
||
answers_4 = [
|
||
("4.1", "Continuous, diff, F'(0)=0", "F(x)=(|x|)^2=x^2, corner smoothed by u^2"),
|
||
("4.2", "Not differentiable", "F(x)=|x|, left/right derivatives +/-1 unequal"),
|
||
("4.3", "Differentiable, F'(0)=0", "|dx|^3/dx = |dx|^2 -> 0"),
|
||
("4.4", "Continuous but not diff", "F(x)=||x||=|x|, double abs doesn't smooth corner"),
|
||
("4.5", "Not differentiable", "F'(0+)=2, F'(0-)->+-inf"),
|
||
("4.6", "Continuous, diff, F'(0)=0", "g(x)=x^2>=0 -> F(x)=x^2+1"),
|
||
("4.7", "4", "2nd chain: =4x^2 f''(g(x))+2f'(g(x)) -> 2f'(0)=4"),
|
||
("4.8", "0", "4-layer chain: =6x^2 sin(x^3)cos(x^3)e^{sin^2(x^3)} -> 0"),
|
||
("4.9", "Continuous at x=0", "Chain continuity: g cont -> lim g(x)=1, f cont at u=1"),
|
||
("4.10", "Cannot conclude", "Counterexample: f discontinuous but f o g continuous"),
|
||
("4.11", "f'(0)*g'(0)", "Chain rule: F'(0)=f'(g(0))*g'(0)=f'(0)*g'(0)"),
|
||
("4.12", "Continuous, diff, F'(0)=0", "g'(0)=lim x*sin(1/x)=0 -> F'(0)=f'(0)*0=0"),
|
||
]
|
||
|
||
for num, ans, ana in answers_4:
|
||
fig = make_answer_page(4, "Training 4 Answers", f"Q {num}", ans, ana)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# 训练场5答案
|
||
answers_5 = [
|
||
("5.1", "(1)0 (2)2", "f'(x)<1 decreasing bounded -> 1/x_{n+1}-1/x_n->1/2 -> nx_n->2"),
|
||
("5.2", "(1)0 (2)1/2", "Construct f(x)=sin(x)+x -> 2x_{n+1}=x_n+O(x_n^3)"),
|
||
("5.3", "(1)sqrt(a) (2)1/(2sqrt(a))", "AM-GM -> e_{n+1}=e_n^2/(2x_n) -> 1/(2sqrt(a))"),
|
||
("5.4", "(1)0 (2)sqrt(3)", "1/x_{n+1}^2-1/x_n^2->1/3 -> nx_n^2->3 -> sqrt(n)*x_n->sqrt(3)"),
|
||
("5.5", "(1)+inf (2)1", "y_n=x_n^2/n -> y_{n+1}=(n+x_n)/(n+1)->1"),
|
||
]
|
||
|
||
for num, ans, ana in answers_5:
|
||
fig = make_answer_page(5, "Training 5 Answers", f"Q {num}", ans, ana)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
# 综合卷答案
|
||
answers_final = [
|
||
("1", "A", "a=0: f'(0)=1 exists; a!=0: a/x diverges"),
|
||
("2", "A", "Numerator O(x^9), denominator x^7 -> limit 0"),
|
||
("3", "C", "|x|sin(x)/x = |x|*sin(x)/x -> 0"),
|
||
("4", "D", "(ln(n))^2/2 -> +inf"),
|
||
("5", "3", "(1-x^2/2)(1-x^2)(1-3x^2/2)=1-3x^2"),
|
||
("6", "2nd class infinite", "lim 1/|x|^{1/2}=+inf"),
|
||
("7", "4(sqrt(2)+1)/15", "Riemann sum -> integral_0^1 x*sqrt(1+x) dx"),
|
||
("8", "(1)exists (2)a~1.164 (3)sqrt(2)", "|f'(a)|<1 contraction mapping; 1-cos(x_n)~x_n^2/2"),
|
||
]
|
||
|
||
for num, ans, ana in answers_final:
|
||
fig = make_answer_page(6, "Ultimate Comprehensive Answers", f"Q {num}", ans, ana)
|
||
pdf.savefig(fig, bbox_inches='tight')
|
||
plt.close(fig)
|
||
|
||
print(f"PDF generated: {output_path}")
|
||
return output_path
|
||
|
||
if __name__ == '__main__':
|
||
main()
|