# 交互增强演示：割线逼近 + 重置/换点按钮（真机导出 + 脚本注入版）
f(x) = x^3 - 3x + 1
a = Slider(-2, 2, 0.1)
h = Slider(0.1, 2, 0.05)
SetValue(a, 1)
SetValue(h, 0.8)
A = (a, f(a))
B = (a + h, f(a + h))
secant = Line(A, B)
tangentLn = Tangent(a, f)
mSec = Slope(secant)
txt = Text("割线斜率 = " + mSec, (3, 2), true, true)
SetColor(secant, 0, 0, 1)
SetColor(tangentLn, 1, 0, 0)
ShowLabel(secant, false)
ShowLabel(tangentLn, false)
btnReset = Button("重置")
btnRand = Button("换一个点")
SetCoords(btnReset, 40, 80)
SetCoords(btnRand, 40, 140)
